documentation.d.ts 3.0 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * A class serves as a medium between the observable and its observers
  52. */
  53. export class EventState {
  54. /**
  55. * Create a new EventState
  56. * @param mask defines the mask associated with this state
  57. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  58. * @param target defines the original target of the state
  59. * @param currentTarget defines the current target of the state
  60. */
  61. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62. /**
  63. * Initialize the current event state
  64. * @param mask defines the mask associated with this state
  65. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66. * @param target defines the original target of the state
  67. * @param currentTarget defines the current target of the state
  68. * @returns the current event state
  69. */
  70. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71. /**
  72. * An Observer can set this property to true to prevent subsequent observers of being notified
  73. */
  74. skipNextObservers: boolean;
  75. /**
  76. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77. */
  78. mask: number;
  79. /**
  80. * The object that originally notified the event
  81. */
  82. target?: any;
  83. /**
  84. * The current object in the bubbling phase
  85. */
  86. currentTarget?: any;
  87. /**
  88. * This will be populated with the return value of the last function that was executed.
  89. * If it is the first function in the callback chain it will be the event data.
  90. */
  91. lastReturnValue?: any;
  92. }
  93. /**
  94. * Represent an Observer registered to a given Observable object.
  95. */
  96. export class Observer<T> {
  97. /**
  98. * Defines the callback to call when the observer is notified
  99. */
  100. callback: (eventData: T, eventState: EventState) => void;
  101. /**
  102. * Defines the mask of the observer (used to filter notifications)
  103. */
  104. mask: number;
  105. /**
  106. * Defines the current scope used to restore the JS context
  107. */
  108. scope: any;
  109. /** @hidden */
  110. _willBeUnregistered: boolean;
  111. /**
  112. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  113. */
  114. unregisterOnNextCall: boolean;
  115. /**
  116. * Creates a new observer
  117. * @param callback defines the callback to call when the observer is notified
  118. * @param mask defines the mask of the observer (used to filter notifications)
  119. * @param scope defines the current scope used to restore the JS context
  120. */
  121. constructor(
  122. /**
  123. * Defines the callback to call when the observer is notified
  124. */
  125. callback: (eventData: T, eventState: EventState) => void,
  126. /**
  127. * Defines the mask of the observer (used to filter notifications)
  128. */
  129. mask: number,
  130. /**
  131. * Defines the current scope used to restore the JS context
  132. */
  133. scope?: any);
  134. }
  135. /**
  136. * Represent a list of observers registered to multiple Observables object.
  137. */
  138. export class MultiObserver<T> {
  139. private _observers;
  140. private _observables;
  141. /**
  142. * Release associated resources
  143. */
  144. dispose(): void;
  145. /**
  146. * Raise a callback when one of the observable will notify
  147. * @param observables defines a list of observables to watch
  148. * @param callback defines the callback to call on notification
  149. * @param mask defines the mask used to filter notifications
  150. * @param scope defines the current scope used to restore the JS context
  151. * @returns the new MultiObserver
  152. */
  153. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  154. }
  155. /**
  156. * The Observable class is a simple implementation of the Observable pattern.
  157. *
  158. * 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.
  159. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  160. * 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).
  161. * 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.
  162. */
  163. export class Observable<T> {
  164. private _observers;
  165. private _eventState;
  166. private _onObserverAdded;
  167. /**
  168. * Gets the list of observers
  169. */
  170. readonly observers: Array<Observer<T>>;
  171. /**
  172. * Creates a new observable
  173. * @param onObserverAdded defines a callback to call when a new observer is added
  174. */
  175. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  176. /**
  177. * Create a new Observer with the specified callback
  178. * @param callback the callback that will be executed for that Observer
  179. * @param mask the mask used to filter observers
  180. * @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.
  181. * @param scope optional scope for the callback to be called from
  182. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  183. * @returns the new observer created for the callback
  184. */
  185. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  186. /**
  187. * Create a new Observer with the specified callback and unregisters after the next notification
  188. * @param callback the callback that will be executed for that Observer
  189. * @returns the new observer created for the callback
  190. */
  191. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  192. /**
  193. * Remove an Observer from the Observable object
  194. * @param observer the instance of the Observer to remove
  195. * @returns false if it doesn't belong to this Observable
  196. */
  197. remove(observer: Nullable<Observer<T>>): boolean;
  198. /**
  199. * Remove a callback from the Observable object
  200. * @param callback the callback to remove
  201. * @param scope optional scope. If used only the callbacks with this scope will be removed
  202. * @returns false if it doesn't belong to this Observable
  203. */
  204. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  205. private _deferUnregister;
  206. private _remove;
  207. /**
  208. * Moves the observable to the top of the observer list making it get called first when notified
  209. * @param observer the observer to move
  210. */
  211. makeObserverTopPriority(observer: Observer<T>): void;
  212. /**
  213. * Moves the observable to the bottom of the observer list making it get called last when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverBottomPriority(observer: Observer<T>): void;
  217. /**
  218. * Notify all Observers by calling their respective callback with the given data
  219. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  220. * @param eventData defines the data to send to all observers
  221. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  222. * @param target defines the original target of the state
  223. * @param currentTarget defines the current target of the state
  224. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  225. */
  226. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  227. /**
  228. * Calling this will execute each callback, expecting it to be a promise or return a value.
  229. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  230. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  231. * and it is crucial that all callbacks will be executed.
  232. * The order of the callbacks is kept, callbacks are not executed parallel.
  233. *
  234. * @param eventData The data to be sent to each callback
  235. * @param mask is used to filter observers defaults to -1
  236. * @param target defines the callback target (see EventState)
  237. * @param currentTarget defines he current object in the bubbling phase
  238. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  239. */
  240. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  241. /**
  242. * Notify a specific observer
  243. * @param observer defines the observer to notify
  244. * @param eventData defines the data to be sent to each callback
  245. * @param mask is used to filter observers defaults to -1
  246. */
  247. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  248. /**
  249. * Gets a boolean indicating if the observable has at least one observer
  250. * @returns true is the Observable has at least one Observer registered
  251. */
  252. hasObservers(): boolean;
  253. /**
  254. * Clear the list of observers
  255. */
  256. clear(): void;
  257. /**
  258. * Clone the current observable
  259. * @returns a new observable
  260. */
  261. clone(): Observable<T>;
  262. /**
  263. * Does this observable handles observer registered with a given mask
  264. * @param mask defines the mask to be tested
  265. * @return whether or not one observer registered with the given mask is handeled
  266. **/
  267. hasSpecificMask(mask?: number): boolean;
  268. }
  269. }
  270. declare module BABYLON {
  271. /**
  272. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  273. * Babylon.js
  274. */
  275. export class DomManagement {
  276. /**
  277. * Checks if the window object exists
  278. * @returns true if the window object exists
  279. */
  280. static IsWindowObjectExist(): boolean;
  281. /**
  282. * Checks if the navigator object exists
  283. * @returns true if the navigator object exists
  284. */
  285. static IsNavigatorAvailable(): boolean;
  286. /**
  287. * Extracts text content from a DOM element hierarchy
  288. * @param element defines the root element
  289. * @returns a string
  290. */
  291. static GetDOMTextContent(element: HTMLElement): string;
  292. }
  293. }
  294. declare module BABYLON {
  295. /**
  296. * Logger used througouht the application to allow configuration of
  297. * the log level required for the messages.
  298. */
  299. export class Logger {
  300. /**
  301. * No log
  302. */
  303. static readonly NoneLogLevel: number;
  304. /**
  305. * Only message logs
  306. */
  307. static readonly MessageLogLevel: number;
  308. /**
  309. * Only warning logs
  310. */
  311. static readonly WarningLogLevel: number;
  312. /**
  313. * Only error logs
  314. */
  315. static readonly ErrorLogLevel: number;
  316. /**
  317. * All logs
  318. */
  319. static readonly AllLogLevel: number;
  320. private static _LogCache;
  321. /**
  322. * Gets a value indicating the number of loading errors
  323. * @ignorenaming
  324. */
  325. static errorsCount: number;
  326. /**
  327. * Callback called when a new log is added
  328. */
  329. static OnNewCacheEntry: (entry: string) => void;
  330. private static _AddLogEntry;
  331. private static _FormatMessage;
  332. private static _LogDisabled;
  333. private static _LogEnabled;
  334. private static _WarnDisabled;
  335. private static _WarnEnabled;
  336. private static _ErrorDisabled;
  337. private static _ErrorEnabled;
  338. /**
  339. * Log a message to the console
  340. */
  341. static Log: (message: string) => void;
  342. /**
  343. * Write a warning message to the console
  344. */
  345. static Warn: (message: string) => void;
  346. /**
  347. * Write an error message to the console
  348. */
  349. static Error: (message: string) => void;
  350. /**
  351. * Gets current log cache (list of logs)
  352. */
  353. static readonly LogCache: string;
  354. /**
  355. * Clears the log cache
  356. */
  357. static ClearLogCache(): void;
  358. /**
  359. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  360. */
  361. static LogLevels: number;
  362. }
  363. }
  364. declare module BABYLON {
  365. /** @hidden */
  366. export class _TypeStore {
  367. /** @hidden */
  368. static RegisteredTypes: {
  369. [key: string]: Object;
  370. };
  371. /** @hidden */
  372. static GetClass(fqdn: string): any;
  373. }
  374. }
  375. declare module BABYLON {
  376. /**
  377. * Class containing a set of static utilities functions for deep copy.
  378. */
  379. export class DeepCopier {
  380. /**
  381. * Tries to copy an object by duplicating every property
  382. * @param source defines the source object
  383. * @param destination defines the target object
  384. * @param doNotCopyList defines a list of properties to avoid
  385. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  386. */
  387. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  388. }
  389. }
  390. declare module BABYLON {
  391. /**
  392. * Class containing a set of static utilities functions for precision date
  393. */
  394. export class PrecisionDate {
  395. /**
  396. * Gets either window.performance.now() if supported or Date.now() else
  397. */
  398. static readonly Now: number;
  399. }
  400. }
  401. declare module BABYLON {
  402. /** @hidden */
  403. export class _DevTools {
  404. static WarnImport(name: string): string;
  405. }
  406. }
  407. declare module BABYLON {
  408. /**
  409. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  410. */
  411. export class WebRequest {
  412. private _xhr;
  413. /**
  414. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  415. * i.e. when loading files, where the server/service expects an Authorization header
  416. */
  417. static CustomRequestHeaders: {
  418. [key: string]: string;
  419. };
  420. /**
  421. * Add callback functions in this array to update all the requests before they get sent to the network
  422. */
  423. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  424. private _injectCustomRequestHeaders;
  425. /**
  426. * Gets or sets a function to be called when loading progress changes
  427. */
  428. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  429. /**
  430. * Returns client's state
  431. */
  432. readonly readyState: number;
  433. /**
  434. * Returns client's status
  435. */
  436. readonly status: number;
  437. /**
  438. * Returns client's status as a text
  439. */
  440. readonly statusText: string;
  441. /**
  442. * Returns client's response
  443. */
  444. readonly response: any;
  445. /**
  446. * Returns client's response url
  447. */
  448. readonly responseURL: string;
  449. /**
  450. * Returns client's response as text
  451. */
  452. readonly responseText: string;
  453. /**
  454. * Gets or sets the expected response type
  455. */
  456. responseType: XMLHttpRequestResponseType;
  457. /** @hidden */
  458. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  459. /** @hidden */
  460. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  461. /**
  462. * Cancels any network activity
  463. */
  464. abort(): void;
  465. /**
  466. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  467. * @param body defines an optional request body
  468. */
  469. send(body?: Document | BodyInit | null): void;
  470. /**
  471. * Sets the request method, request URL
  472. * @param method defines the method to use (GET, POST, etc..)
  473. * @param url defines the url to connect with
  474. */
  475. open(method: string, url: string): void;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * File request interface
  481. */
  482. export interface IFileRequest {
  483. /**
  484. * Raised when the request is complete (success or error).
  485. */
  486. onCompleteObservable: Observable<IFileRequest>;
  487. /**
  488. * Aborts the request for a file.
  489. */
  490. abort: () => void;
  491. }
  492. }
  493. declare module BABYLON {
  494. /**
  495. * Class used to store gfx data (like WebGLBuffer)
  496. */
  497. export class DataBuffer {
  498. /**
  499. * Gets or sets the number of objects referencing this buffer
  500. */
  501. references: number;
  502. /** Gets or sets the size of the underlying buffer */
  503. capacity: number;
  504. /**
  505. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  506. */
  507. is32Bits: boolean;
  508. /**
  509. * Gets the underlying buffer
  510. */
  511. readonly underlyingResource: any;
  512. }
  513. }
  514. declare module BABYLON {
  515. /**
  516. * Class used to store data that will be store in GPU memory
  517. */
  518. export class Buffer {
  519. private _engine;
  520. private _buffer;
  521. /** @hidden */
  522. _data: Nullable<DataArray>;
  523. private _updatable;
  524. private _instanced;
  525. /**
  526. * Gets the byte stride.
  527. */
  528. readonly byteStride: number;
  529. /**
  530. * Constructor
  531. * @param engine the engine
  532. * @param data the data to use for this buffer
  533. * @param updatable whether the data is updatable
  534. * @param stride the stride (optional)
  535. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  536. * @param instanced whether the buffer is instanced (optional)
  537. * @param useBytes set to true if the stride in in bytes (optional)
  538. */
  539. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  540. /**
  541. * Create a new VertexBuffer based on the current buffer
  542. * @param kind defines the vertex buffer kind (position, normal, etc.)
  543. * @param offset defines offset in the buffer (0 by default)
  544. * @param size defines the size in floats of attributes (position is 3 for instance)
  545. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  546. * @param instanced defines if the vertex buffer contains indexed data
  547. * @param useBytes defines if the offset and stride are in bytes
  548. * @returns the new vertex buffer
  549. */
  550. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  551. /**
  552. * Gets a boolean indicating if the Buffer is updatable?
  553. * @returns true if the buffer is updatable
  554. */
  555. isUpdatable(): boolean;
  556. /**
  557. * Gets current buffer's data
  558. * @returns a DataArray or null
  559. */
  560. getData(): Nullable<DataArray>;
  561. /**
  562. * Gets underlying native buffer
  563. * @returns underlying native buffer
  564. */
  565. getBuffer(): Nullable<DataBuffer>;
  566. /**
  567. * Gets the stride in float32 units (i.e. byte stride / 4).
  568. * May not be an integer if the byte stride is not divisible by 4.
  569. * DEPRECATED. Use byteStride instead.
  570. * @returns the stride in float32 units
  571. */
  572. getStrideSize(): number;
  573. /**
  574. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  575. * @param data defines the data to store
  576. */
  577. create(data?: Nullable<DataArray>): void;
  578. /** @hidden */
  579. _rebuild(): void;
  580. /**
  581. * Update current buffer data
  582. * @param data defines the data to store
  583. */
  584. update(data: DataArray): void;
  585. /**
  586. * Updates the data directly.
  587. * @param data the new data
  588. * @param offset the new offset
  589. * @param vertexCount the vertex count (optional)
  590. * @param useBytes set to true if the offset is in bytes
  591. */
  592. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  593. /**
  594. * Release all resources
  595. */
  596. dispose(): void;
  597. }
  598. /**
  599. * Specialized buffer used to store vertex data
  600. */
  601. export class VertexBuffer {
  602. /** @hidden */
  603. _buffer: Buffer;
  604. private _kind;
  605. private _size;
  606. private _ownsBuffer;
  607. private _instanced;
  608. private _instanceDivisor;
  609. /**
  610. * The byte type.
  611. */
  612. static readonly BYTE: number;
  613. /**
  614. * The unsigned byte type.
  615. */
  616. static readonly UNSIGNED_BYTE: number;
  617. /**
  618. * The short type.
  619. */
  620. static readonly SHORT: number;
  621. /**
  622. * The unsigned short type.
  623. */
  624. static readonly UNSIGNED_SHORT: number;
  625. /**
  626. * The integer type.
  627. */
  628. static readonly INT: number;
  629. /**
  630. * The unsigned integer type.
  631. */
  632. static readonly UNSIGNED_INT: number;
  633. /**
  634. * The float type.
  635. */
  636. static readonly FLOAT: number;
  637. /**
  638. * Gets or sets the instance divisor when in instanced mode
  639. */
  640. instanceDivisor: number;
  641. /**
  642. * Gets the byte stride.
  643. */
  644. readonly byteStride: number;
  645. /**
  646. * Gets the byte offset.
  647. */
  648. readonly byteOffset: number;
  649. /**
  650. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  651. */
  652. readonly normalized: boolean;
  653. /**
  654. * Gets the data type of each component in the array.
  655. */
  656. readonly type: number;
  657. /**
  658. * Constructor
  659. * @param engine the engine
  660. * @param data the data to use for this vertex buffer
  661. * @param kind the vertex buffer kind
  662. * @param updatable whether the data is updatable
  663. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  664. * @param stride the stride (optional)
  665. * @param instanced whether the buffer is instanced (optional)
  666. * @param offset the offset of the data (optional)
  667. * @param size the number of components (optional)
  668. * @param type the type of the component (optional)
  669. * @param normalized whether the data contains normalized data (optional)
  670. * @param useBytes set to true if stride and offset are in bytes (optional)
  671. */
  672. 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);
  673. /** @hidden */
  674. _rebuild(): void;
  675. /**
  676. * Returns the kind of the VertexBuffer (string)
  677. * @returns a string
  678. */
  679. getKind(): string;
  680. /**
  681. * Gets a boolean indicating if the VertexBuffer is updatable?
  682. * @returns true if the buffer is updatable
  683. */
  684. isUpdatable(): boolean;
  685. /**
  686. * Gets current buffer's data
  687. * @returns a DataArray or null
  688. */
  689. getData(): Nullable<DataArray>;
  690. /**
  691. * Gets underlying native buffer
  692. * @returns underlying native buffer
  693. */
  694. getBuffer(): Nullable<DataBuffer>;
  695. /**
  696. * Gets the stride in float32 units (i.e. byte stride / 4).
  697. * May not be an integer if the byte stride is not divisible by 4.
  698. * DEPRECATED. Use byteStride instead.
  699. * @returns the stride in float32 units
  700. */
  701. getStrideSize(): number;
  702. /**
  703. * Returns the offset as a multiple of the type byte length.
  704. * DEPRECATED. Use byteOffset instead.
  705. * @returns the offset in bytes
  706. */
  707. getOffset(): number;
  708. /**
  709. * Returns the number of components per vertex attribute (integer)
  710. * @returns the size in float
  711. */
  712. getSize(): number;
  713. /**
  714. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  715. * @returns true if this buffer is instanced
  716. */
  717. getIsInstanced(): boolean;
  718. /**
  719. * Returns the instancing divisor, zero for non-instanced (integer).
  720. * @returns a number
  721. */
  722. getInstanceDivisor(): number;
  723. /**
  724. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  725. * @param data defines the data to store
  726. */
  727. create(data?: DataArray): void;
  728. /**
  729. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  730. * This function will create a new buffer if the current one is not updatable
  731. * @param data defines the data to store
  732. */
  733. update(data: DataArray): void;
  734. /**
  735. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  736. * Returns the directly updated WebGLBuffer.
  737. * @param data the new data
  738. * @param offset the new offset
  739. * @param useBytes set to true if the offset is in bytes
  740. */
  741. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  742. /**
  743. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  744. */
  745. dispose(): void;
  746. /**
  747. * Enumerates each value of this vertex buffer as numbers.
  748. * @param count the number of values to enumerate
  749. * @param callback the callback function called for each value
  750. */
  751. forEach(count: number, callback: (value: number, index: number) => void): void;
  752. /**
  753. * Positions
  754. */
  755. static readonly PositionKind: string;
  756. /**
  757. * Normals
  758. */
  759. static readonly NormalKind: string;
  760. /**
  761. * Tangents
  762. */
  763. static readonly TangentKind: string;
  764. /**
  765. * Texture coordinates
  766. */
  767. static readonly UVKind: string;
  768. /**
  769. * Texture coordinates 2
  770. */
  771. static readonly UV2Kind: string;
  772. /**
  773. * Texture coordinates 3
  774. */
  775. static readonly UV3Kind: string;
  776. /**
  777. * Texture coordinates 4
  778. */
  779. static readonly UV4Kind: string;
  780. /**
  781. * Texture coordinates 5
  782. */
  783. static readonly UV5Kind: string;
  784. /**
  785. * Texture coordinates 6
  786. */
  787. static readonly UV6Kind: string;
  788. /**
  789. * Colors
  790. */
  791. static readonly ColorKind: string;
  792. /**
  793. * Matrix indices (for bones)
  794. */
  795. static readonly MatricesIndicesKind: string;
  796. /**
  797. * Matrix weights (for bones)
  798. */
  799. static readonly MatricesWeightsKind: string;
  800. /**
  801. * Additional matrix indices (for bones)
  802. */
  803. static readonly MatricesIndicesExtraKind: string;
  804. /**
  805. * Additional matrix weights (for bones)
  806. */
  807. static readonly MatricesWeightsExtraKind: string;
  808. /**
  809. * Deduces the stride given a kind.
  810. * @param kind The kind string to deduce
  811. * @returns The deduced stride
  812. */
  813. static DeduceStride(kind: string): number;
  814. /**
  815. * Gets the byte length of the given type.
  816. * @param type the type
  817. * @returns the number of bytes
  818. */
  819. static GetTypeByteLength(type: number): number;
  820. /**
  821. * Enumerates each value of the given parameters as numbers.
  822. * @param data the data to enumerate
  823. * @param byteOffset the byte offset of the data
  824. * @param byteStride the byte stride of the data
  825. * @param componentCount the number of components per element
  826. * @param componentType the type of the component
  827. * @param count the number of values to enumerate
  828. * @param normalized whether the data is normalized
  829. * @param callback the callback function called for each value
  830. */
  831. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  832. private static _GetFloatValue;
  833. }
  834. }
  835. declare module BABYLON {
  836. /**
  837. * Scalar computation library
  838. */
  839. export class Scalar {
  840. /**
  841. * Two pi constants convenient for computation.
  842. */
  843. static TwoPi: number;
  844. /**
  845. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  846. * @param a number
  847. * @param b number
  848. * @param epsilon (default = 1.401298E-45)
  849. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  850. */
  851. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  852. /**
  853. * Returns a string : the upper case translation of the number i to hexadecimal.
  854. * @param i number
  855. * @returns the upper case translation of the number i to hexadecimal.
  856. */
  857. static ToHex(i: number): string;
  858. /**
  859. * Returns -1 if value is negative and +1 is value is positive.
  860. * @param value the value
  861. * @returns the value itself if it's equal to zero.
  862. */
  863. static Sign(value: number): number;
  864. /**
  865. * Returns the value itself if it's between min and max.
  866. * Returns min if the value is lower than min.
  867. * Returns max if the value is greater than max.
  868. * @param value the value to clmap
  869. * @param min the min value to clamp to (default: 0)
  870. * @param max the max value to clamp to (default: 1)
  871. * @returns the clamped value
  872. */
  873. static Clamp(value: number, min?: number, max?: number): number;
  874. /**
  875. * the log2 of value.
  876. * @param value the value to compute log2 of
  877. * @returns the log2 of value.
  878. */
  879. static Log2(value: number): number;
  880. /**
  881. * Loops the value, so that it is never larger than length and never smaller than 0.
  882. *
  883. * This is similar to the modulo operator but it works with floating point numbers.
  884. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  885. * With t = 5 and length = 2.5, the result would be 0.0.
  886. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  887. * @param value the value
  888. * @param length the length
  889. * @returns the looped value
  890. */
  891. static Repeat(value: number, length: number): number;
  892. /**
  893. * Normalize the value between 0.0 and 1.0 using min and max values
  894. * @param value value to normalize
  895. * @param min max to normalize between
  896. * @param max min to normalize between
  897. * @returns the normalized value
  898. */
  899. static Normalize(value: number, min: number, max: number): number;
  900. /**
  901. * Denormalize the value from 0.0 and 1.0 using min and max values
  902. * @param normalized value to denormalize
  903. * @param min max to denormalize between
  904. * @param max min to denormalize between
  905. * @returns the denormalized value
  906. */
  907. static Denormalize(normalized: number, min: number, max: number): number;
  908. /**
  909. * Calculates the shortest difference between two given angles given in degrees.
  910. * @param current current angle in degrees
  911. * @param target target angle in degrees
  912. * @returns the delta
  913. */
  914. static DeltaAngle(current: number, target: number): number;
  915. /**
  916. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  917. * @param tx value
  918. * @param length length
  919. * @returns The returned value will move back and forth between 0 and length
  920. */
  921. static PingPong(tx: number, length: number): number;
  922. /**
  923. * Interpolates between min and max with smoothing at the limits.
  924. *
  925. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  926. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  927. * @param from from
  928. * @param to to
  929. * @param tx value
  930. * @returns the smooth stepped value
  931. */
  932. static SmoothStep(from: number, to: number, tx: number): number;
  933. /**
  934. * Moves a value current towards target.
  935. *
  936. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  937. * Negative values of maxDelta pushes the value away from target.
  938. * @param current current value
  939. * @param target target value
  940. * @param maxDelta max distance to move
  941. * @returns resulting value
  942. */
  943. static MoveTowards(current: number, target: number, maxDelta: number): number;
  944. /**
  945. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  946. *
  947. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  948. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  949. * @param current current value
  950. * @param target target value
  951. * @param maxDelta max distance to move
  952. * @returns resulting angle
  953. */
  954. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  955. /**
  956. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  957. * @param start start value
  958. * @param end target value
  959. * @param amount amount to lerp between
  960. * @returns the lerped value
  961. */
  962. static Lerp(start: number, end: number, amount: number): number;
  963. /**
  964. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  965. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  966. * @param start start value
  967. * @param end target value
  968. * @param amount amount to lerp between
  969. * @returns the lerped value
  970. */
  971. static LerpAngle(start: number, end: number, amount: number): number;
  972. /**
  973. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  974. * @param a start value
  975. * @param b target value
  976. * @param value value between a and b
  977. * @returns the inverseLerp value
  978. */
  979. static InverseLerp(a: number, b: number, value: number): number;
  980. /**
  981. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  982. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  983. * @param value1 spline value
  984. * @param tangent1 spline value
  985. * @param value2 spline value
  986. * @param tangent2 spline value
  987. * @param amount input value
  988. * @returns hermite result
  989. */
  990. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  991. /**
  992. * Returns a random float number between and min and max values
  993. * @param min min value of random
  994. * @param max max value of random
  995. * @returns random value
  996. */
  997. static RandomRange(min: number, max: number): number;
  998. /**
  999. * This function returns percentage of a number in a given range.
  1000. *
  1001. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1002. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1003. * @param number to convert to percentage
  1004. * @param min min range
  1005. * @param max max range
  1006. * @returns the percentage
  1007. */
  1008. static RangeToPercent(number: number, min: number, max: number): number;
  1009. /**
  1010. * This function returns number that corresponds to the percentage in a given range.
  1011. *
  1012. * PercentToRange(0.34,0,100) will return 34.
  1013. * @param percent to convert to number
  1014. * @param min min range
  1015. * @param max max range
  1016. * @returns the number
  1017. */
  1018. static PercentToRange(percent: number, min: number, max: number): number;
  1019. /**
  1020. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1021. * @param angle The angle to normalize in radian.
  1022. * @return The converted angle.
  1023. */
  1024. static NormalizeRadians(angle: number): number;
  1025. }
  1026. }
  1027. declare module BABYLON {
  1028. /**
  1029. * Constant used to convert a value to gamma space
  1030. * @ignorenaming
  1031. */
  1032. export const ToGammaSpace: number;
  1033. /**
  1034. * Constant used to convert a value to linear space
  1035. * @ignorenaming
  1036. */
  1037. export const ToLinearSpace = 2.2;
  1038. /**
  1039. * Constant used to define the minimal number value in Babylon.js
  1040. * @ignorenaming
  1041. */
  1042. let Epsilon: number;
  1043. }
  1044. declare module BABYLON {
  1045. /**
  1046. * Class used to represent a viewport on screen
  1047. */
  1048. export class Viewport {
  1049. /** viewport left coordinate */
  1050. x: number;
  1051. /** viewport top coordinate */
  1052. y: number;
  1053. /**viewport width */
  1054. width: number;
  1055. /** viewport height */
  1056. height: number;
  1057. /**
  1058. * Creates a Viewport object located at (x, y) and sized (width, height)
  1059. * @param x defines viewport left coordinate
  1060. * @param y defines viewport top coordinate
  1061. * @param width defines the viewport width
  1062. * @param height defines the viewport height
  1063. */
  1064. constructor(
  1065. /** viewport left coordinate */
  1066. x: number,
  1067. /** viewport top coordinate */
  1068. y: number,
  1069. /**viewport width */
  1070. width: number,
  1071. /** viewport height */
  1072. height: number);
  1073. /**
  1074. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1075. * @param renderWidth defines the rendering width
  1076. * @param renderHeight defines the rendering height
  1077. * @returns a new Viewport
  1078. */
  1079. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1080. /**
  1081. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1082. * @param renderWidth defines the rendering width
  1083. * @param renderHeight defines the rendering height
  1084. * @param ref defines the target viewport
  1085. * @returns the current viewport
  1086. */
  1087. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1088. /**
  1089. * Returns a new Viewport copied from the current one
  1090. * @returns a new Viewport
  1091. */
  1092. clone(): Viewport;
  1093. }
  1094. }
  1095. declare module BABYLON {
  1096. /**
  1097. * Class containing a set of static utilities functions for arrays.
  1098. */
  1099. export class ArrayTools {
  1100. /**
  1101. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1102. * @param size the number of element to construct and put in the array
  1103. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1104. * @returns a new array filled with new objects
  1105. */
  1106. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1107. }
  1108. }
  1109. declare module BABYLON {
  1110. /**
  1111. * @hidden
  1112. */
  1113. export interface IColor4Like {
  1114. r: float;
  1115. g: float;
  1116. b: float;
  1117. a: float;
  1118. }
  1119. /**
  1120. * @hidden
  1121. */
  1122. export interface IColor3Like {
  1123. r: float;
  1124. g: float;
  1125. b: float;
  1126. }
  1127. /**
  1128. * @hidden
  1129. */
  1130. export interface IVector4Like {
  1131. x: float;
  1132. y: float;
  1133. z: float;
  1134. w: float;
  1135. }
  1136. /**
  1137. * @hidden
  1138. */
  1139. export interface IVector3Like {
  1140. x: float;
  1141. y: float;
  1142. z: float;
  1143. }
  1144. /**
  1145. * @hidden
  1146. */
  1147. export interface IVector2Like {
  1148. x: float;
  1149. y: float;
  1150. }
  1151. /**
  1152. * @hidden
  1153. */
  1154. export interface IMatrixLike {
  1155. toArray(): DeepImmutable<Float32Array>;
  1156. updateFlag: int;
  1157. }
  1158. /**
  1159. * @hidden
  1160. */
  1161. export interface IViewportLike {
  1162. x: float;
  1163. y: float;
  1164. width: float;
  1165. height: float;
  1166. }
  1167. /**
  1168. * @hidden
  1169. */
  1170. export interface IPlaneLike {
  1171. normal: IVector3Like;
  1172. d: float;
  1173. normalize(): void;
  1174. }
  1175. }
  1176. declare module BABYLON {
  1177. /**
  1178. * Class representing a vector containing 2 coordinates
  1179. */
  1180. export class Vector2 {
  1181. /** defines the first coordinate */
  1182. x: number;
  1183. /** defines the second coordinate */
  1184. y: number;
  1185. /**
  1186. * Creates a new Vector2 from the given x and y coordinates
  1187. * @param x defines the first coordinate
  1188. * @param y defines the second coordinate
  1189. */
  1190. constructor(
  1191. /** defines the first coordinate */
  1192. x?: number,
  1193. /** defines the second coordinate */
  1194. y?: number);
  1195. /**
  1196. * Gets a string with the Vector2 coordinates
  1197. * @returns a string with the Vector2 coordinates
  1198. */
  1199. toString(): string;
  1200. /**
  1201. * Gets class name
  1202. * @returns the string "Vector2"
  1203. */
  1204. getClassName(): string;
  1205. /**
  1206. * Gets current vector hash code
  1207. * @returns the Vector2 hash code as a number
  1208. */
  1209. getHashCode(): number;
  1210. /**
  1211. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1212. * @param array defines the source array
  1213. * @param index defines the offset in source array
  1214. * @returns the current Vector2
  1215. */
  1216. toArray(array: FloatArray, index?: number): Vector2;
  1217. /**
  1218. * Copy the current vector to an array
  1219. * @returns a new array with 2 elements: the Vector2 coordinates.
  1220. */
  1221. asArray(): number[];
  1222. /**
  1223. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1224. * @param source defines the source Vector2
  1225. * @returns the current updated Vector2
  1226. */
  1227. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1228. /**
  1229. * Sets the Vector2 coordinates with the given floats
  1230. * @param x defines the first coordinate
  1231. * @param y defines the second coordinate
  1232. * @returns the current updated Vector2
  1233. */
  1234. copyFromFloats(x: number, y: number): Vector2;
  1235. /**
  1236. * Sets the Vector2 coordinates with the given floats
  1237. * @param x defines the first coordinate
  1238. * @param y defines the second coordinate
  1239. * @returns the current updated Vector2
  1240. */
  1241. set(x: number, y: number): Vector2;
  1242. /**
  1243. * Add another vector with the current one
  1244. * @param otherVector defines the other vector
  1245. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1246. */
  1247. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1248. /**
  1249. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1250. * @param otherVector defines the other vector
  1251. * @param result defines the target vector
  1252. * @returns the unmodified current Vector2
  1253. */
  1254. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1255. /**
  1256. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1257. * @param otherVector defines the other vector
  1258. * @returns the current updated Vector2
  1259. */
  1260. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1261. /**
  1262. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1263. * @param otherVector defines the other vector
  1264. * @returns a new Vector2
  1265. */
  1266. addVector3(otherVector: Vector3): Vector2;
  1267. /**
  1268. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1269. * @param otherVector defines the other vector
  1270. * @returns a new Vector2
  1271. */
  1272. subtract(otherVector: Vector2): Vector2;
  1273. /**
  1274. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1275. * @param otherVector defines the other vector
  1276. * @param result defines the target vector
  1277. * @returns the unmodified current Vector2
  1278. */
  1279. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1280. /**
  1281. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1282. * @param otherVector defines the other vector
  1283. * @returns the current updated Vector2
  1284. */
  1285. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1286. /**
  1287. * Multiplies in place the current Vector2 coordinates by the given ones
  1288. * @param otherVector defines the other vector
  1289. * @returns the current updated Vector2
  1290. */
  1291. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1292. /**
  1293. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1294. * @param otherVector defines the other vector
  1295. * @returns a new Vector2
  1296. */
  1297. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1298. /**
  1299. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1300. * @param otherVector defines the other vector
  1301. * @param result defines the target vector
  1302. * @returns the unmodified current Vector2
  1303. */
  1304. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1305. /**
  1306. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1307. * @param x defines the first coordinate
  1308. * @param y defines the second coordinate
  1309. * @returns a new Vector2
  1310. */
  1311. multiplyByFloats(x: number, y: number): Vector2;
  1312. /**
  1313. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1314. * @param otherVector defines the other vector
  1315. * @returns a new Vector2
  1316. */
  1317. divide(otherVector: Vector2): Vector2;
  1318. /**
  1319. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1320. * @param otherVector defines the other vector
  1321. * @param result defines the target vector
  1322. * @returns the unmodified current Vector2
  1323. */
  1324. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1325. /**
  1326. * Divides the current Vector2 coordinates by the given ones
  1327. * @param otherVector defines the other vector
  1328. * @returns the current updated Vector2
  1329. */
  1330. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1331. /**
  1332. * Gets a new Vector2 with current Vector2 negated coordinates
  1333. * @returns a new Vector2
  1334. */
  1335. negate(): Vector2;
  1336. /**
  1337. * Multiply the Vector2 coordinates by scale
  1338. * @param scale defines the scaling factor
  1339. * @returns the current updated Vector2
  1340. */
  1341. scaleInPlace(scale: number): Vector2;
  1342. /**
  1343. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1344. * @param scale defines the scaling factor
  1345. * @returns a new Vector2
  1346. */
  1347. scale(scale: number): Vector2;
  1348. /**
  1349. * Scale the current Vector2 values by a factor to a given Vector2
  1350. * @param scale defines the scale factor
  1351. * @param result defines the Vector2 object where to store the result
  1352. * @returns the unmodified current Vector2
  1353. */
  1354. scaleToRef(scale: number, result: Vector2): Vector2;
  1355. /**
  1356. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1357. * @param scale defines the scale factor
  1358. * @param result defines the Vector2 object where to store the result
  1359. * @returns the unmodified current Vector2
  1360. */
  1361. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1362. /**
  1363. * Gets a boolean if two vectors are equals
  1364. * @param otherVector defines the other vector
  1365. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1366. */
  1367. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1368. /**
  1369. * Gets a boolean if two vectors are equals (using an epsilon value)
  1370. * @param otherVector defines the other vector
  1371. * @param epsilon defines the minimal distance to consider equality
  1372. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1373. */
  1374. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1375. /**
  1376. * Gets a new Vector2 from current Vector2 floored values
  1377. * @returns a new Vector2
  1378. */
  1379. floor(): Vector2;
  1380. /**
  1381. * Gets a new Vector2 from current Vector2 floored values
  1382. * @returns a new Vector2
  1383. */
  1384. fract(): Vector2;
  1385. /**
  1386. * Gets the length of the vector
  1387. * @returns the vector length (float)
  1388. */
  1389. length(): number;
  1390. /**
  1391. * Gets the vector squared length
  1392. * @returns the vector squared length (float)
  1393. */
  1394. lengthSquared(): number;
  1395. /**
  1396. * Normalize the vector
  1397. * @returns the current updated Vector2
  1398. */
  1399. normalize(): Vector2;
  1400. /**
  1401. * Gets a new Vector2 copied from the Vector2
  1402. * @returns a new Vector2
  1403. */
  1404. clone(): Vector2;
  1405. /**
  1406. * Gets a new Vector2(0, 0)
  1407. * @returns a new Vector2
  1408. */
  1409. static Zero(): Vector2;
  1410. /**
  1411. * Gets a new Vector2(1, 1)
  1412. * @returns a new Vector2
  1413. */
  1414. static One(): Vector2;
  1415. /**
  1416. * Gets a new Vector2 set from the given index element of the given array
  1417. * @param array defines the data source
  1418. * @param offset defines the offset in the data source
  1419. * @returns a new Vector2
  1420. */
  1421. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1422. /**
  1423. * Sets "result" from the given index element of the given array
  1424. * @param array defines the data source
  1425. * @param offset defines the offset in the data source
  1426. * @param result defines the target vector
  1427. */
  1428. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1429. /**
  1430. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1431. * @param value1 defines 1st point of control
  1432. * @param value2 defines 2nd point of control
  1433. * @param value3 defines 3rd point of control
  1434. * @param value4 defines 4th point of control
  1435. * @param amount defines the interpolation factor
  1436. * @returns a new Vector2
  1437. */
  1438. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1439. /**
  1440. * 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".
  1441. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1442. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1443. * @param value defines the value to clamp
  1444. * @param min defines the lower limit
  1445. * @param max defines the upper limit
  1446. * @returns a new Vector2
  1447. */
  1448. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1449. /**
  1450. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1451. * @param value1 defines the 1st control point
  1452. * @param tangent1 defines the outgoing tangent
  1453. * @param value2 defines the 2nd control point
  1454. * @param tangent2 defines the incoming tangent
  1455. * @param amount defines the interpolation factor
  1456. * @returns a new Vector2
  1457. */
  1458. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1459. /**
  1460. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1461. * @param start defines the start vector
  1462. * @param end defines the end vector
  1463. * @param amount defines the interpolation factor
  1464. * @returns a new Vector2
  1465. */
  1466. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1467. /**
  1468. * Gets the dot product of the vector "left" and the vector "right"
  1469. * @param left defines first vector
  1470. * @param right defines second vector
  1471. * @returns the dot product (float)
  1472. */
  1473. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1474. /**
  1475. * Returns a new Vector2 equal to the normalized given vector
  1476. * @param vector defines the vector to normalize
  1477. * @returns a new Vector2
  1478. */
  1479. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1480. /**
  1481. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1482. * @param left defines 1st vector
  1483. * @param right defines 2nd vector
  1484. * @returns a new Vector2
  1485. */
  1486. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1487. /**
  1488. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1489. * @param left defines 1st vector
  1490. * @param right defines 2nd vector
  1491. * @returns a new Vector2
  1492. */
  1493. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1494. /**
  1495. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1496. * @param vector defines the vector to transform
  1497. * @param transformation defines the matrix to apply
  1498. * @returns a new Vector2
  1499. */
  1500. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1501. /**
  1502. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1503. * @param vector defines the vector to transform
  1504. * @param transformation defines the matrix to apply
  1505. * @param result defines the target vector
  1506. */
  1507. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1508. /**
  1509. * Determines if a given vector is included in a triangle
  1510. * @param p defines the vector to test
  1511. * @param p0 defines 1st triangle point
  1512. * @param p1 defines 2nd triangle point
  1513. * @param p2 defines 3rd triangle point
  1514. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1515. */
  1516. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1517. /**
  1518. * Gets the distance between the vectors "value1" and "value2"
  1519. * @param value1 defines first vector
  1520. * @param value2 defines second vector
  1521. * @returns the distance between vectors
  1522. */
  1523. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1524. /**
  1525. * Returns the squared distance between the vectors "value1" and "value2"
  1526. * @param value1 defines first vector
  1527. * @param value2 defines second vector
  1528. * @returns the squared distance between vectors
  1529. */
  1530. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1531. /**
  1532. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1533. * @param value1 defines first vector
  1534. * @param value2 defines second vector
  1535. * @returns a new Vector2
  1536. */
  1537. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1538. /**
  1539. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1540. * @param p defines the middle point
  1541. * @param segA defines one point of the segment
  1542. * @param segB defines the other point of the segment
  1543. * @returns the shortest distance
  1544. */
  1545. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1546. }
  1547. /**
  1548. * Classed used to store (x,y,z) vector representation
  1549. * A Vector3 is the main object used in 3D geometry
  1550. * It can represent etiher the coordinates of a point the space, either a direction
  1551. * Reminder: js uses a left handed forward facing system
  1552. */
  1553. export class Vector3 {
  1554. /**
  1555. * Defines the first coordinates (on X axis)
  1556. */
  1557. x: number;
  1558. /**
  1559. * Defines the second coordinates (on Y axis)
  1560. */
  1561. y: number;
  1562. /**
  1563. * Defines the third coordinates (on Z axis)
  1564. */
  1565. z: number;
  1566. private static _UpReadOnly;
  1567. private static _ZeroReadOnly;
  1568. /**
  1569. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1570. * @param x defines the first coordinates (on X axis)
  1571. * @param y defines the second coordinates (on Y axis)
  1572. * @param z defines the third coordinates (on Z axis)
  1573. */
  1574. constructor(
  1575. /**
  1576. * Defines the first coordinates (on X axis)
  1577. */
  1578. x?: number,
  1579. /**
  1580. * Defines the second coordinates (on Y axis)
  1581. */
  1582. y?: number,
  1583. /**
  1584. * Defines the third coordinates (on Z axis)
  1585. */
  1586. z?: number);
  1587. /**
  1588. * Creates a string representation of the Vector3
  1589. * @returns a string with the Vector3 coordinates.
  1590. */
  1591. toString(): string;
  1592. /**
  1593. * Gets the class name
  1594. * @returns the string "Vector3"
  1595. */
  1596. getClassName(): string;
  1597. /**
  1598. * Creates the Vector3 hash code
  1599. * @returns a number which tends to be unique between Vector3 instances
  1600. */
  1601. getHashCode(): number;
  1602. /**
  1603. * Creates an array containing three elements : the coordinates of the Vector3
  1604. * @returns a new array of numbers
  1605. */
  1606. asArray(): number[];
  1607. /**
  1608. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1609. * @param array defines the destination array
  1610. * @param index defines the offset in the destination array
  1611. * @returns the current Vector3
  1612. */
  1613. toArray(array: FloatArray, index?: number): Vector3;
  1614. /**
  1615. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1616. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1617. */
  1618. toQuaternion(): Quaternion;
  1619. /**
  1620. * Adds the given vector to the current Vector3
  1621. * @param otherVector defines the second operand
  1622. * @returns the current updated Vector3
  1623. */
  1624. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1625. /**
  1626. * Adds the given coordinates to the current Vector3
  1627. * @param x defines the x coordinate of the operand
  1628. * @param y defines the y coordinate of the operand
  1629. * @param z defines the z coordinate of the operand
  1630. * @returns the current updated Vector3
  1631. */
  1632. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1633. /**
  1634. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1635. * @param otherVector defines the second operand
  1636. * @returns the resulting Vector3
  1637. */
  1638. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1639. /**
  1640. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1641. * @param otherVector defines the second operand
  1642. * @param result defines the Vector3 object where to store the result
  1643. * @returns the current Vector3
  1644. */
  1645. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1646. /**
  1647. * Subtract the given vector from the current Vector3
  1648. * @param otherVector defines the second operand
  1649. * @returns the current updated Vector3
  1650. */
  1651. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1652. /**
  1653. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1654. * @param otherVector defines the second operand
  1655. * @returns the resulting Vector3
  1656. */
  1657. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1658. /**
  1659. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1660. * @param otherVector defines the second operand
  1661. * @param result defines the Vector3 object where to store the result
  1662. * @returns the current Vector3
  1663. */
  1664. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1665. /**
  1666. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1667. * @param x defines the x coordinate of the operand
  1668. * @param y defines the y coordinate of the operand
  1669. * @param z defines the z coordinate of the operand
  1670. * @returns the resulting Vector3
  1671. */
  1672. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1673. /**
  1674. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1675. * @param x defines the x coordinate of the operand
  1676. * @param y defines the y coordinate of the operand
  1677. * @param z defines the z coordinate of the operand
  1678. * @param result defines the Vector3 object where to store the result
  1679. * @returns the current Vector3
  1680. */
  1681. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1682. /**
  1683. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1684. * @returns a new Vector3
  1685. */
  1686. negate(): Vector3;
  1687. /**
  1688. * Multiplies the Vector3 coordinates by the float "scale"
  1689. * @param scale defines the multiplier factor
  1690. * @returns the current updated Vector3
  1691. */
  1692. scaleInPlace(scale: number): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1695. * @param scale defines the multiplier factor
  1696. * @returns a new Vector3
  1697. */
  1698. scale(scale: number): Vector3;
  1699. /**
  1700. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1701. * @param scale defines the multiplier factor
  1702. * @param result defines the Vector3 object where to store the result
  1703. * @returns the current Vector3
  1704. */
  1705. scaleToRef(scale: number, result: Vector3): Vector3;
  1706. /**
  1707. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1708. * @param scale defines the scale factor
  1709. * @param result defines the Vector3 object where to store the result
  1710. * @returns the unmodified current Vector3
  1711. */
  1712. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1713. /**
  1714. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1715. * @param otherVector defines the second operand
  1716. * @returns true if both vectors are equals
  1717. */
  1718. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1719. /**
  1720. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1721. * @param otherVector defines the second operand
  1722. * @param epsilon defines the minimal distance to define values as equals
  1723. * @returns true if both vectors are distant less than epsilon
  1724. */
  1725. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1726. /**
  1727. * Returns true if the current Vector3 coordinates equals the given floats
  1728. * @param x defines the x coordinate of the operand
  1729. * @param y defines the y coordinate of the operand
  1730. * @param z defines the z coordinate of the operand
  1731. * @returns true if both vectors are equals
  1732. */
  1733. equalsToFloats(x: number, y: number, z: number): boolean;
  1734. /**
  1735. * Multiplies the current Vector3 coordinates by the given ones
  1736. * @param otherVector defines the second operand
  1737. * @returns the current updated Vector3
  1738. */
  1739. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1740. /**
  1741. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1742. * @param otherVector defines the second operand
  1743. * @returns the new Vector3
  1744. */
  1745. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1746. /**
  1747. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1748. * @param otherVector defines the second operand
  1749. * @param result defines the Vector3 object where to store the result
  1750. * @returns the current Vector3
  1751. */
  1752. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1753. /**
  1754. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1755. * @param x defines the x coordinate of the operand
  1756. * @param y defines the y coordinate of the operand
  1757. * @param z defines the z coordinate of the operand
  1758. * @returns the new Vector3
  1759. */
  1760. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1761. /**
  1762. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1763. * @param otherVector defines the second operand
  1764. * @returns the new Vector3
  1765. */
  1766. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1767. /**
  1768. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1769. * @param otherVector defines the second operand
  1770. * @param result defines the Vector3 object where to store the result
  1771. * @returns the current Vector3
  1772. */
  1773. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1774. /**
  1775. * Divides the current Vector3 coordinates by the given ones.
  1776. * @param otherVector defines the second operand
  1777. * @returns the current updated Vector3
  1778. */
  1779. divideInPlace(otherVector: Vector3): Vector3;
  1780. /**
  1781. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1782. * @param other defines the second operand
  1783. * @returns the current updated Vector3
  1784. */
  1785. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1786. /**
  1787. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1788. * @param other defines the second operand
  1789. * @returns the current updated Vector3
  1790. */
  1791. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1792. /**
  1793. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1794. * @param x defines the x coordinate of the operand
  1795. * @param y defines the y coordinate of the operand
  1796. * @param z defines the z coordinate of the operand
  1797. * @returns the current updated Vector3
  1798. */
  1799. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1800. /**
  1801. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1802. * @param x defines the x coordinate of the operand
  1803. * @param y defines the y coordinate of the operand
  1804. * @param z defines the z coordinate of the operand
  1805. * @returns the current updated Vector3
  1806. */
  1807. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1808. /**
  1809. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1810. * Check if is non uniform within a certain amount of decimal places to account for this
  1811. * @param epsilon the amount the values can differ
  1812. * @returns if the the vector is non uniform to a certain number of decimal places
  1813. */
  1814. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1815. /**
  1816. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1817. */
  1818. readonly isNonUniform: boolean;
  1819. /**
  1820. * Gets a new Vector3 from current Vector3 floored values
  1821. * @returns a new Vector3
  1822. */
  1823. floor(): Vector3;
  1824. /**
  1825. * Gets a new Vector3 from current Vector3 floored values
  1826. * @returns a new Vector3
  1827. */
  1828. fract(): Vector3;
  1829. /**
  1830. * Gets the length of the Vector3
  1831. * @returns the length of the Vector3
  1832. */
  1833. length(): number;
  1834. /**
  1835. * Gets the squared length of the Vector3
  1836. * @returns squared length of the Vector3
  1837. */
  1838. lengthSquared(): number;
  1839. /**
  1840. * Normalize the current Vector3.
  1841. * Please note that this is an in place operation.
  1842. * @returns the current updated Vector3
  1843. */
  1844. normalize(): Vector3;
  1845. /**
  1846. * Reorders the x y z properties of the vector in place
  1847. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1848. * @returns the current updated vector
  1849. */
  1850. reorderInPlace(order: string): this;
  1851. /**
  1852. * Rotates the vector around 0,0,0 by a quaternion
  1853. * @param quaternion the rotation quaternion
  1854. * @param result vector to store the result
  1855. * @returns the resulting vector
  1856. */
  1857. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1858. /**
  1859. * Rotates a vector around a given point
  1860. * @param quaternion the rotation quaternion
  1861. * @param point the point to rotate around
  1862. * @param result vector to store the result
  1863. * @returns the resulting vector
  1864. */
  1865. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1866. /**
  1867. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  1868. * The cross product is then orthogonal to both current and "other"
  1869. * @param other defines the right operand
  1870. * @returns the cross product
  1871. */
  1872. cross(other: Vector3): Vector3;
  1873. /**
  1874. * Normalize the current Vector3 with the given input length.
  1875. * Please note that this is an in place operation.
  1876. * @param len the length of the vector
  1877. * @returns the current updated Vector3
  1878. */
  1879. normalizeFromLength(len: number): Vector3;
  1880. /**
  1881. * Normalize the current Vector3 to a new vector
  1882. * @returns the new Vector3
  1883. */
  1884. normalizeToNew(): Vector3;
  1885. /**
  1886. * Normalize the current Vector3 to the reference
  1887. * @param reference define the Vector3 to update
  1888. * @returns the updated Vector3
  1889. */
  1890. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1891. /**
  1892. * Creates a new Vector3 copied from the current Vector3
  1893. * @returns the new Vector3
  1894. */
  1895. clone(): Vector3;
  1896. /**
  1897. * Copies the given vector coordinates to the current Vector3 ones
  1898. * @param source defines the source Vector3
  1899. * @returns the current updated Vector3
  1900. */
  1901. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1902. /**
  1903. * Copies the given floats to the current Vector3 coordinates
  1904. * @param x defines the x coordinate of the operand
  1905. * @param y defines the y coordinate of the operand
  1906. * @param z defines the z coordinate of the operand
  1907. * @returns the current updated Vector3
  1908. */
  1909. copyFromFloats(x: number, y: number, z: number): Vector3;
  1910. /**
  1911. * Copies the given floats to the current Vector3 coordinates
  1912. * @param x defines the x coordinate of the operand
  1913. * @param y defines the y coordinate of the operand
  1914. * @param z defines the z coordinate of the operand
  1915. * @returns the current updated Vector3
  1916. */
  1917. set(x: number, y: number, z: number): Vector3;
  1918. /**
  1919. * Copies the given float to the current Vector3 coordinates
  1920. * @param v defines the x, y and z coordinates of the operand
  1921. * @returns the current updated Vector3
  1922. */
  1923. setAll(v: number): Vector3;
  1924. /**
  1925. * Get the clip factor between two vectors
  1926. * @param vector0 defines the first operand
  1927. * @param vector1 defines the second operand
  1928. * @param axis defines the axis to use
  1929. * @param size defines the size along the axis
  1930. * @returns the clip factor
  1931. */
  1932. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1933. /**
  1934. * Get angle between two vectors
  1935. * @param vector0 angle between vector0 and vector1
  1936. * @param vector1 angle between vector0 and vector1
  1937. * @param normal direction of the normal
  1938. * @return the angle between vector0 and vector1
  1939. */
  1940. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1941. /**
  1942. * Returns a new Vector3 set from the index "offset" of the given array
  1943. * @param array defines the source array
  1944. * @param offset defines the offset in the source array
  1945. * @returns the new Vector3
  1946. */
  1947. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1948. /**
  1949. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1950. * This function is deprecated. Use FromArray instead
  1951. * @param array defines the source array
  1952. * @param offset defines the offset in the source array
  1953. * @returns the new Vector3
  1954. */
  1955. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1956. /**
  1957. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1958. * @param array defines the source array
  1959. * @param offset defines the offset in the source array
  1960. * @param result defines the Vector3 where to store the result
  1961. */
  1962. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1963. /**
  1964. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1965. * This function is deprecated. Use FromArrayToRef instead.
  1966. * @param array defines the source array
  1967. * @param offset defines the offset in the source array
  1968. * @param result defines the Vector3 where to store the result
  1969. */
  1970. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1971. /**
  1972. * Sets the given vector "result" with the given floats.
  1973. * @param x defines the x coordinate of the source
  1974. * @param y defines the y coordinate of the source
  1975. * @param z defines the z coordinate of the source
  1976. * @param result defines the Vector3 where to store the result
  1977. */
  1978. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1979. /**
  1980. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1981. * @returns a new empty Vector3
  1982. */
  1983. static Zero(): Vector3;
  1984. /**
  1985. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1986. * @returns a new unit Vector3
  1987. */
  1988. static One(): Vector3;
  1989. /**
  1990. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1991. * @returns a new up Vector3
  1992. */
  1993. static Up(): Vector3;
  1994. /**
  1995. * Gets a up Vector3 that must not be updated
  1996. */
  1997. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1998. /**
  1999. * Gets a zero Vector3 that must not be updated
  2000. */
  2001. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2002. /**
  2003. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2004. * @returns a new down Vector3
  2005. */
  2006. static Down(): Vector3;
  2007. /**
  2008. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2009. * @returns a new forward Vector3
  2010. */
  2011. static Forward(): Vector3;
  2012. /**
  2013. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2014. * @returns a new forward Vector3
  2015. */
  2016. static Backward(): Vector3;
  2017. /**
  2018. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2019. * @returns a new right Vector3
  2020. */
  2021. static Right(): Vector3;
  2022. /**
  2023. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2024. * @returns a new left Vector3
  2025. */
  2026. static Left(): Vector3;
  2027. /**
  2028. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2029. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2030. * @param vector defines the Vector3 to transform
  2031. * @param transformation defines the transformation matrix
  2032. * @returns the transformed Vector3
  2033. */
  2034. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2035. /**
  2036. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2037. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2038. * @param vector defines the Vector3 to transform
  2039. * @param transformation defines the transformation matrix
  2040. * @param result defines the Vector3 where to store the result
  2041. */
  2042. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2043. /**
  2044. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2045. * This method computes tranformed coordinates only, not transformed direction vectors
  2046. * @param x define the x coordinate of the source vector
  2047. * @param y define the y coordinate of the source vector
  2048. * @param z define the z coordinate of the source vector
  2049. * @param transformation defines the transformation matrix
  2050. * @param result defines the Vector3 where to store the result
  2051. */
  2052. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2053. /**
  2054. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2055. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2056. * @param vector defines the Vector3 to transform
  2057. * @param transformation defines the transformation matrix
  2058. * @returns the new Vector3
  2059. */
  2060. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2061. /**
  2062. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2063. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2064. * @param vector defines the Vector3 to transform
  2065. * @param transformation defines the transformation matrix
  2066. * @param result defines the Vector3 where to store the result
  2067. */
  2068. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2069. /**
  2070. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2071. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2072. * @param x define the x coordinate of the source vector
  2073. * @param y define the y coordinate of the source vector
  2074. * @param z define the z coordinate of the source vector
  2075. * @param transformation defines the transformation matrix
  2076. * @param result defines the Vector3 where to store the result
  2077. */
  2078. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2079. /**
  2080. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2081. * @param value1 defines the first control point
  2082. * @param value2 defines the second control point
  2083. * @param value3 defines the third control point
  2084. * @param value4 defines the fourth control point
  2085. * @param amount defines the amount on the spline to use
  2086. * @returns the new Vector3
  2087. */
  2088. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2089. /**
  2090. * 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"
  2091. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2092. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2093. * @param value defines the current value
  2094. * @param min defines the lower range value
  2095. * @param max defines the upper range value
  2096. * @returns the new Vector3
  2097. */
  2098. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2099. /**
  2100. * 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"
  2101. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2102. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2103. * @param value defines the current value
  2104. * @param min defines the lower range value
  2105. * @param max defines the upper range value
  2106. * @param result defines the Vector3 where to store the result
  2107. */
  2108. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2109. /**
  2110. * Checks if a given vector is inside a specific range
  2111. * @param v defines the vector to test
  2112. * @param min defines the minimum range
  2113. * @param max defines the maximum range
  2114. */
  2115. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2116. /**
  2117. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2118. * @param value1 defines the first control point
  2119. * @param tangent1 defines the first tangent vector
  2120. * @param value2 defines the second control point
  2121. * @param tangent2 defines the second tangent vector
  2122. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2123. * @returns the new Vector3
  2124. */
  2125. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2126. /**
  2127. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2128. * @param start defines the start value
  2129. * @param end defines the end value
  2130. * @param amount max defines amount between both (between 0 and 1)
  2131. * @returns the new Vector3
  2132. */
  2133. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2134. /**
  2135. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2136. * @param start defines the start value
  2137. * @param end defines the end value
  2138. * @param amount max defines amount between both (between 0 and 1)
  2139. * @param result defines the Vector3 where to store the result
  2140. */
  2141. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2142. /**
  2143. * Returns the dot product (float) between the vectors "left" and "right"
  2144. * @param left defines the left operand
  2145. * @param right defines the right operand
  2146. * @returns the dot product
  2147. */
  2148. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2149. /**
  2150. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2151. * The cross product is then orthogonal to both "left" and "right"
  2152. * @param left defines the left operand
  2153. * @param right defines the right operand
  2154. * @returns the cross product
  2155. */
  2156. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2157. /**
  2158. * Sets the given vector "result" with the cross product of "left" and "right"
  2159. * The cross product is then orthogonal to both "left" and "right"
  2160. * @param left defines the left operand
  2161. * @param right defines the right operand
  2162. * @param result defines the Vector3 where to store the result
  2163. */
  2164. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2165. /**
  2166. * Returns a new Vector3 as the normalization of the given vector
  2167. * @param vector defines the Vector3 to normalize
  2168. * @returns the new Vector3
  2169. */
  2170. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2171. /**
  2172. * Sets the given vector "result" with the normalization of the given first vector
  2173. * @param vector defines the Vector3 to normalize
  2174. * @param result defines the Vector3 where to store the result
  2175. */
  2176. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2177. /**
  2178. * Project a Vector3 onto screen space
  2179. * @param vector defines the Vector3 to project
  2180. * @param world defines the world matrix to use
  2181. * @param transform defines the transform (view x projection) matrix to use
  2182. * @param viewport defines the screen viewport to use
  2183. * @returns the new Vector3
  2184. */
  2185. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2186. /** @hidden */
  2187. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2188. /**
  2189. * Unproject from screen space to object space
  2190. * @param source defines the screen space Vector3 to use
  2191. * @param viewportWidth defines the current width of the viewport
  2192. * @param viewportHeight defines the current height of the viewport
  2193. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2194. * @param transform defines the transform (view x projection) matrix to use
  2195. * @returns the new Vector3
  2196. */
  2197. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2198. /**
  2199. * Unproject from screen space to object space
  2200. * @param source defines the screen space Vector3 to use
  2201. * @param viewportWidth defines the current width of the viewport
  2202. * @param viewportHeight defines the current height of the viewport
  2203. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2204. * @param view defines the view matrix to use
  2205. * @param projection defines the projection matrix to use
  2206. * @returns the new Vector3
  2207. */
  2208. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2209. /**
  2210. * Unproject from screen space to object space
  2211. * @param source defines the screen space Vector3 to use
  2212. * @param viewportWidth defines the current width of the viewport
  2213. * @param viewportHeight defines the current height of the viewport
  2214. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2215. * @param view defines the view matrix to use
  2216. * @param projection defines the projection matrix to use
  2217. * @param result defines the Vector3 where to store the result
  2218. */
  2219. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2220. /**
  2221. * Unproject from screen space to object space
  2222. * @param sourceX defines the screen space x coordinate to use
  2223. * @param sourceY defines the screen space y coordinate to use
  2224. * @param sourceZ defines the screen space z coordinate to use
  2225. * @param viewportWidth defines the current width of the viewport
  2226. * @param viewportHeight defines the current height of the viewport
  2227. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2228. * @param view defines the view matrix to use
  2229. * @param projection defines the projection matrix to use
  2230. * @param result defines the Vector3 where to store the result
  2231. */
  2232. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2233. /**
  2234. * Gets the minimal coordinate values between two Vector3
  2235. * @param left defines the first operand
  2236. * @param right defines the second operand
  2237. * @returns the new Vector3
  2238. */
  2239. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2240. /**
  2241. * Gets the maximal coordinate values between two Vector3
  2242. * @param left defines the first operand
  2243. * @param right defines the second operand
  2244. * @returns the new Vector3
  2245. */
  2246. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2247. /**
  2248. * Returns the distance between the vectors "value1" and "value2"
  2249. * @param value1 defines the first operand
  2250. * @param value2 defines the second operand
  2251. * @returns the distance
  2252. */
  2253. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2254. /**
  2255. * Returns the squared distance between the vectors "value1" and "value2"
  2256. * @param value1 defines the first operand
  2257. * @param value2 defines the second operand
  2258. * @returns the squared distance
  2259. */
  2260. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2261. /**
  2262. * Returns a new Vector3 located at the center between "value1" and "value2"
  2263. * @param value1 defines the first operand
  2264. * @param value2 defines the second operand
  2265. * @returns the new Vector3
  2266. */
  2267. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2268. /**
  2269. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2270. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2271. * to something in order to rotate it from its local system to the given target system
  2272. * Note: axis1, axis2 and axis3 are normalized during this operation
  2273. * @param axis1 defines the first axis
  2274. * @param axis2 defines the second axis
  2275. * @param axis3 defines the third axis
  2276. * @returns a new Vector3
  2277. */
  2278. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2279. /**
  2280. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2281. * @param axis1 defines the first axis
  2282. * @param axis2 defines the second axis
  2283. * @param axis3 defines the third axis
  2284. * @param ref defines the Vector3 where to store the result
  2285. */
  2286. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2287. }
  2288. /**
  2289. * Vector4 class created for EulerAngle class conversion to Quaternion
  2290. */
  2291. export class Vector4 {
  2292. /** x value of the vector */
  2293. x: number;
  2294. /** y value of the vector */
  2295. y: number;
  2296. /** z value of the vector */
  2297. z: number;
  2298. /** w value of the vector */
  2299. w: number;
  2300. /**
  2301. * Creates a Vector4 object from the given floats.
  2302. * @param x x value of the vector
  2303. * @param y y value of the vector
  2304. * @param z z value of the vector
  2305. * @param w w value of the vector
  2306. */
  2307. constructor(
  2308. /** x value of the vector */
  2309. x: number,
  2310. /** y value of the vector */
  2311. y: number,
  2312. /** z value of the vector */
  2313. z: number,
  2314. /** w value of the vector */
  2315. w: number);
  2316. /**
  2317. * Returns the string with the Vector4 coordinates.
  2318. * @returns a string containing all the vector values
  2319. */
  2320. toString(): string;
  2321. /**
  2322. * Returns the string "Vector4".
  2323. * @returns "Vector4"
  2324. */
  2325. getClassName(): string;
  2326. /**
  2327. * Returns the Vector4 hash code.
  2328. * @returns a unique hash code
  2329. */
  2330. getHashCode(): number;
  2331. /**
  2332. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2333. * @returns the resulting array
  2334. */
  2335. asArray(): number[];
  2336. /**
  2337. * Populates the given array from the given index with the Vector4 coordinates.
  2338. * @param array array to populate
  2339. * @param index index of the array to start at (default: 0)
  2340. * @returns the Vector4.
  2341. */
  2342. toArray(array: FloatArray, index?: number): Vector4;
  2343. /**
  2344. * Adds the given vector to the current Vector4.
  2345. * @param otherVector the vector to add
  2346. * @returns the updated Vector4.
  2347. */
  2348. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2349. /**
  2350. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2351. * @param otherVector the vector to add
  2352. * @returns the resulting vector
  2353. */
  2354. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2355. /**
  2356. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2357. * @param otherVector the vector to add
  2358. * @param result the vector to store the result
  2359. * @returns the current Vector4.
  2360. */
  2361. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2362. /**
  2363. * Subtract in place the given vector from the current Vector4.
  2364. * @param otherVector the vector to subtract
  2365. * @returns the updated Vector4.
  2366. */
  2367. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2368. /**
  2369. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2370. * @param otherVector the vector to add
  2371. * @returns the new vector with the result
  2372. */
  2373. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2374. /**
  2375. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2376. * @param otherVector the vector to subtract
  2377. * @param result the vector to store the result
  2378. * @returns the current Vector4.
  2379. */
  2380. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2381. /**
  2382. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2383. */
  2384. /**
  2385. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2386. * @param x value to subtract
  2387. * @param y value to subtract
  2388. * @param z value to subtract
  2389. * @param w value to subtract
  2390. * @returns new vector containing the result
  2391. */
  2392. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2393. /**
  2394. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2395. * @param x value to subtract
  2396. * @param y value to subtract
  2397. * @param z value to subtract
  2398. * @param w value to subtract
  2399. * @param result the vector to store the result in
  2400. * @returns the current Vector4.
  2401. */
  2402. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2403. /**
  2404. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2405. * @returns a new vector with the negated values
  2406. */
  2407. negate(): Vector4;
  2408. /**
  2409. * Multiplies the current Vector4 coordinates by scale (float).
  2410. * @param scale the number to scale with
  2411. * @returns the updated Vector4.
  2412. */
  2413. scaleInPlace(scale: number): Vector4;
  2414. /**
  2415. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2416. * @param scale the number to scale with
  2417. * @returns a new vector with the result
  2418. */
  2419. scale(scale: number): Vector4;
  2420. /**
  2421. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2422. * @param scale the number to scale with
  2423. * @param result a vector to store the result in
  2424. * @returns the current Vector4.
  2425. */
  2426. scaleToRef(scale: number, result: Vector4): Vector4;
  2427. /**
  2428. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2429. * @param scale defines the scale factor
  2430. * @param result defines the Vector4 object where to store the result
  2431. * @returns the unmodified current Vector4
  2432. */
  2433. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2434. /**
  2435. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2436. * @param otherVector the vector to compare against
  2437. * @returns true if they are equal
  2438. */
  2439. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2440. /**
  2441. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2442. * @param otherVector vector to compare against
  2443. * @param epsilon (Default: very small number)
  2444. * @returns true if they are equal
  2445. */
  2446. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2447. /**
  2448. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2449. * @param x x value to compare against
  2450. * @param y y value to compare against
  2451. * @param z z value to compare against
  2452. * @param w w value to compare against
  2453. * @returns true if equal
  2454. */
  2455. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2456. /**
  2457. * Multiplies in place the current Vector4 by the given one.
  2458. * @param otherVector vector to multiple with
  2459. * @returns the updated Vector4.
  2460. */
  2461. multiplyInPlace(otherVector: Vector4): Vector4;
  2462. /**
  2463. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2464. * @param otherVector vector to multiple with
  2465. * @returns resulting new vector
  2466. */
  2467. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2468. /**
  2469. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2470. * @param otherVector vector to multiple with
  2471. * @param result vector to store the result
  2472. * @returns the current Vector4.
  2473. */
  2474. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2475. /**
  2476. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2477. * @param x x value multiply with
  2478. * @param y y value multiply with
  2479. * @param z z value multiply with
  2480. * @param w w value multiply with
  2481. * @returns resulting new vector
  2482. */
  2483. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2484. /**
  2485. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2486. * @param otherVector vector to devide with
  2487. * @returns resulting new vector
  2488. */
  2489. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2490. /**
  2491. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2492. * @param otherVector vector to devide with
  2493. * @param result vector to store the result
  2494. * @returns the current Vector4.
  2495. */
  2496. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2497. /**
  2498. * Divides the current Vector3 coordinates by the given ones.
  2499. * @param otherVector vector to devide with
  2500. * @returns the updated Vector3.
  2501. */
  2502. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2503. /**
  2504. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2505. * @param other defines the second operand
  2506. * @returns the current updated Vector4
  2507. */
  2508. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2509. /**
  2510. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2511. * @param other defines the second operand
  2512. * @returns the current updated Vector4
  2513. */
  2514. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2515. /**
  2516. * Gets a new Vector4 from current Vector4 floored values
  2517. * @returns a new Vector4
  2518. */
  2519. floor(): Vector4;
  2520. /**
  2521. * Gets a new Vector4 from current Vector3 floored values
  2522. * @returns a new Vector4
  2523. */
  2524. fract(): Vector4;
  2525. /**
  2526. * Returns the Vector4 length (float).
  2527. * @returns the length
  2528. */
  2529. length(): number;
  2530. /**
  2531. * Returns the Vector4 squared length (float).
  2532. * @returns the length squared
  2533. */
  2534. lengthSquared(): number;
  2535. /**
  2536. * Normalizes in place the Vector4.
  2537. * @returns the updated Vector4.
  2538. */
  2539. normalize(): Vector4;
  2540. /**
  2541. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2542. * @returns this converted to a new vector3
  2543. */
  2544. toVector3(): Vector3;
  2545. /**
  2546. * Returns a new Vector4 copied from the current one.
  2547. * @returns the new cloned vector
  2548. */
  2549. clone(): Vector4;
  2550. /**
  2551. * Updates the current Vector4 with the given one coordinates.
  2552. * @param source the source vector to copy from
  2553. * @returns the updated Vector4.
  2554. */
  2555. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2556. /**
  2557. * Updates the current Vector4 coordinates with the given floats.
  2558. * @param x float to copy from
  2559. * @param y float to copy from
  2560. * @param z float to copy from
  2561. * @param w float to copy from
  2562. * @returns the updated Vector4.
  2563. */
  2564. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2565. /**
  2566. * Updates the current Vector4 coordinates with the given floats.
  2567. * @param x float to set from
  2568. * @param y float to set from
  2569. * @param z float to set from
  2570. * @param w float to set from
  2571. * @returns the updated Vector4.
  2572. */
  2573. set(x: number, y: number, z: number, w: number): Vector4;
  2574. /**
  2575. * Copies the given float to the current Vector3 coordinates
  2576. * @param v defines the x, y, z and w coordinates of the operand
  2577. * @returns the current updated Vector3
  2578. */
  2579. setAll(v: number): Vector4;
  2580. /**
  2581. * Returns a new Vector4 set from the starting index of the given array.
  2582. * @param array the array to pull values from
  2583. * @param offset the offset into the array to start at
  2584. * @returns the new vector
  2585. */
  2586. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2587. /**
  2588. * Updates the given vector "result" from the starting index of the given array.
  2589. * @param array the array to pull values from
  2590. * @param offset the offset into the array to start at
  2591. * @param result the vector to store the result in
  2592. */
  2593. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2594. /**
  2595. * Updates the given vector "result" from the starting index of the given Float32Array.
  2596. * @param array the array to pull values from
  2597. * @param offset the offset into the array to start at
  2598. * @param result the vector to store the result in
  2599. */
  2600. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2601. /**
  2602. * Updates the given vector "result" coordinates from the given floats.
  2603. * @param x float to set from
  2604. * @param y float to set from
  2605. * @param z float to set from
  2606. * @param w float to set from
  2607. * @param result the vector to the floats in
  2608. */
  2609. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2610. /**
  2611. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2612. * @returns the new vector
  2613. */
  2614. static Zero(): Vector4;
  2615. /**
  2616. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2617. * @returns the new vector
  2618. */
  2619. static One(): Vector4;
  2620. /**
  2621. * Returns a new normalized Vector4 from the given one.
  2622. * @param vector the vector to normalize
  2623. * @returns the vector
  2624. */
  2625. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2626. /**
  2627. * Updates the given vector "result" from the normalization of the given one.
  2628. * @param vector the vector to normalize
  2629. * @param result the vector to store the result in
  2630. */
  2631. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2632. /**
  2633. * Returns a vector with the minimum values from the left and right vectors
  2634. * @param left left vector to minimize
  2635. * @param right right vector to minimize
  2636. * @returns a new vector with the minimum of the left and right vector values
  2637. */
  2638. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2639. /**
  2640. * Returns a vector with the maximum values from the left and right vectors
  2641. * @param left left vector to maximize
  2642. * @param right right vector to maximize
  2643. * @returns a new vector with the maximum of the left and right vector values
  2644. */
  2645. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2646. /**
  2647. * Returns the distance (float) between the vectors "value1" and "value2".
  2648. * @param value1 value to calulate the distance between
  2649. * @param value2 value to calulate the distance between
  2650. * @return the distance between the two vectors
  2651. */
  2652. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2653. /**
  2654. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2655. * @param value1 value to calulate the distance between
  2656. * @param value2 value to calulate the distance between
  2657. * @return the distance between the two vectors squared
  2658. */
  2659. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2660. /**
  2661. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2662. * @param value1 value to calulate the center between
  2663. * @param value2 value to calulate the center between
  2664. * @return the center between the two vectors
  2665. */
  2666. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2667. /**
  2668. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2669. * This methods computes transformed normalized direction vectors only.
  2670. * @param vector the vector to transform
  2671. * @param transformation the transformation matrix to apply
  2672. * @returns the new vector
  2673. */
  2674. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2675. /**
  2676. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2677. * This methods computes transformed normalized direction vectors only.
  2678. * @param vector the vector to transform
  2679. * @param transformation the transformation matrix to apply
  2680. * @param result the vector to store the result in
  2681. */
  2682. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2683. /**
  2684. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2685. * This methods computes transformed normalized direction vectors only.
  2686. * @param x value to transform
  2687. * @param y value to transform
  2688. * @param z value to transform
  2689. * @param w value to transform
  2690. * @param transformation the transformation matrix to apply
  2691. * @param result the vector to store the results in
  2692. */
  2693. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2694. /**
  2695. * Creates a new Vector4 from a Vector3
  2696. * @param source defines the source data
  2697. * @param w defines the 4th component (default is 0)
  2698. * @returns a new Vector4
  2699. */
  2700. static FromVector3(source: Vector3, w?: number): Vector4;
  2701. }
  2702. /**
  2703. * Class used to store quaternion data
  2704. * @see https://en.wikipedia.org/wiki/Quaternion
  2705. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2706. */
  2707. export class Quaternion {
  2708. /** defines the first component (0 by default) */
  2709. x: number;
  2710. /** defines the second component (0 by default) */
  2711. y: number;
  2712. /** defines the third component (0 by default) */
  2713. z: number;
  2714. /** defines the fourth component (1.0 by default) */
  2715. w: number;
  2716. /**
  2717. * Creates a new Quaternion from the given floats
  2718. * @param x defines the first component (0 by default)
  2719. * @param y defines the second component (0 by default)
  2720. * @param z defines the third component (0 by default)
  2721. * @param w defines the fourth component (1.0 by default)
  2722. */
  2723. constructor(
  2724. /** defines the first component (0 by default) */
  2725. x?: number,
  2726. /** defines the second component (0 by default) */
  2727. y?: number,
  2728. /** defines the third component (0 by default) */
  2729. z?: number,
  2730. /** defines the fourth component (1.0 by default) */
  2731. w?: number);
  2732. /**
  2733. * Gets a string representation for the current quaternion
  2734. * @returns a string with the Quaternion coordinates
  2735. */
  2736. toString(): string;
  2737. /**
  2738. * Gets the class name of the quaternion
  2739. * @returns the string "Quaternion"
  2740. */
  2741. getClassName(): string;
  2742. /**
  2743. * Gets a hash code for this quaternion
  2744. * @returns the quaternion hash code
  2745. */
  2746. getHashCode(): number;
  2747. /**
  2748. * Copy the quaternion to an array
  2749. * @returns a new array populated with 4 elements from the quaternion coordinates
  2750. */
  2751. asArray(): number[];
  2752. /**
  2753. * Check if two quaternions are equals
  2754. * @param otherQuaternion defines the second operand
  2755. * @return true if the current quaternion and the given one coordinates are strictly equals
  2756. */
  2757. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2758. /**
  2759. * Clone the current quaternion
  2760. * @returns a new quaternion copied from the current one
  2761. */
  2762. clone(): Quaternion;
  2763. /**
  2764. * Copy a quaternion to the current one
  2765. * @param other defines the other quaternion
  2766. * @returns the updated current quaternion
  2767. */
  2768. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2769. /**
  2770. * Updates the current quaternion with the given float coordinates
  2771. * @param x defines the x coordinate
  2772. * @param y defines the y coordinate
  2773. * @param z defines the z coordinate
  2774. * @param w defines the w coordinate
  2775. * @returns the updated current quaternion
  2776. */
  2777. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2778. /**
  2779. * Updates the current quaternion from the given float coordinates
  2780. * @param x defines the x coordinate
  2781. * @param y defines the y coordinate
  2782. * @param z defines the z coordinate
  2783. * @param w defines the w coordinate
  2784. * @returns the updated current quaternion
  2785. */
  2786. set(x: number, y: number, z: number, w: number): Quaternion;
  2787. /**
  2788. * Adds two quaternions
  2789. * @param other defines the second operand
  2790. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2791. */
  2792. add(other: DeepImmutable<Quaternion>): Quaternion;
  2793. /**
  2794. * Add a quaternion to the current one
  2795. * @param other defines the quaternion to add
  2796. * @returns the current quaternion
  2797. */
  2798. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2799. /**
  2800. * Subtract two quaternions
  2801. * @param other defines the second operand
  2802. * @returns a new quaternion as the subtraction result of the given one from the current one
  2803. */
  2804. subtract(other: Quaternion): Quaternion;
  2805. /**
  2806. * Multiplies the current quaternion by a scale factor
  2807. * @param value defines the scale factor
  2808. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2809. */
  2810. scale(value: number): Quaternion;
  2811. /**
  2812. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2813. * @param scale defines the scale factor
  2814. * @param result defines the Quaternion object where to store the result
  2815. * @returns the unmodified current quaternion
  2816. */
  2817. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2818. /**
  2819. * Multiplies in place the current quaternion by a scale factor
  2820. * @param value defines the scale factor
  2821. * @returns the current modified quaternion
  2822. */
  2823. scaleInPlace(value: number): Quaternion;
  2824. /**
  2825. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2826. * @param scale defines the scale factor
  2827. * @param result defines the Quaternion object where to store the result
  2828. * @returns the unmodified current quaternion
  2829. */
  2830. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2831. /**
  2832. * Multiplies two quaternions
  2833. * @param q1 defines the second operand
  2834. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2835. */
  2836. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2837. /**
  2838. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2839. * @param q1 defines the second operand
  2840. * @param result defines the target quaternion
  2841. * @returns the current quaternion
  2842. */
  2843. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2844. /**
  2845. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2846. * @param q1 defines the second operand
  2847. * @returns the currentupdated quaternion
  2848. */
  2849. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2850. /**
  2851. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2852. * @param ref defines the target quaternion
  2853. * @returns the current quaternion
  2854. */
  2855. conjugateToRef(ref: Quaternion): Quaternion;
  2856. /**
  2857. * Conjugates in place (1-q) the current quaternion
  2858. * @returns the current updated quaternion
  2859. */
  2860. conjugateInPlace(): Quaternion;
  2861. /**
  2862. * Conjugates in place (1-q) the current quaternion
  2863. * @returns a new quaternion
  2864. */
  2865. conjugate(): Quaternion;
  2866. /**
  2867. * Gets length of current quaternion
  2868. * @returns the quaternion length (float)
  2869. */
  2870. length(): number;
  2871. /**
  2872. * Normalize in place the current quaternion
  2873. * @returns the current updated quaternion
  2874. */
  2875. normalize(): Quaternion;
  2876. /**
  2877. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2878. * @param order is a reserved parameter and is ignore for now
  2879. * @returns a new Vector3 containing the Euler angles
  2880. */
  2881. toEulerAngles(order?: string): Vector3;
  2882. /**
  2883. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2884. * @param result defines the vector which will be filled with the Euler angles
  2885. * @param order is a reserved parameter and is ignore for now
  2886. * @returns the current unchanged quaternion
  2887. */
  2888. toEulerAnglesToRef(result: Vector3): Quaternion;
  2889. /**
  2890. * Updates the given rotation matrix with the current quaternion values
  2891. * @param result defines the target matrix
  2892. * @returns the current unchanged quaternion
  2893. */
  2894. toRotationMatrix(result: Matrix): Quaternion;
  2895. /**
  2896. * Updates the current quaternion from the given rotation matrix values
  2897. * @param matrix defines the source matrix
  2898. * @returns the current updated quaternion
  2899. */
  2900. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2901. /**
  2902. * Creates a new quaternion from a rotation matrix
  2903. * @param matrix defines the source matrix
  2904. * @returns a new quaternion created from the given rotation matrix values
  2905. */
  2906. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2907. /**
  2908. * Updates the given quaternion with the given rotation matrix values
  2909. * @param matrix defines the source matrix
  2910. * @param result defines the target quaternion
  2911. */
  2912. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2913. /**
  2914. * Returns the dot product (float) between the quaternions "left" and "right"
  2915. * @param left defines the left operand
  2916. * @param right defines the right operand
  2917. * @returns the dot product
  2918. */
  2919. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2920. /**
  2921. * Checks if the two quaternions are close to each other
  2922. * @param quat0 defines the first quaternion to check
  2923. * @param quat1 defines the second quaternion to check
  2924. * @returns true if the two quaternions are close to each other
  2925. */
  2926. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2927. /**
  2928. * Creates an empty quaternion
  2929. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2930. */
  2931. static Zero(): Quaternion;
  2932. /**
  2933. * Inverse a given quaternion
  2934. * @param q defines the source quaternion
  2935. * @returns a new quaternion as the inverted current quaternion
  2936. */
  2937. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2938. /**
  2939. * Inverse a given quaternion
  2940. * @param q defines the source quaternion
  2941. * @param result the quaternion the result will be stored in
  2942. * @returns the result quaternion
  2943. */
  2944. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2945. /**
  2946. * Creates an identity quaternion
  2947. * @returns the identity quaternion
  2948. */
  2949. static Identity(): Quaternion;
  2950. /**
  2951. * Gets a boolean indicating if the given quaternion is identity
  2952. * @param quaternion defines the quaternion to check
  2953. * @returns true if the quaternion is identity
  2954. */
  2955. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2956. /**
  2957. * Creates a quaternion from a rotation around an axis
  2958. * @param axis defines the axis to use
  2959. * @param angle defines the angle to use
  2960. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2961. */
  2962. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2963. /**
  2964. * Creates a rotation around an axis and stores it into the given quaternion
  2965. * @param axis defines the axis to use
  2966. * @param angle defines the angle to use
  2967. * @param result defines the target quaternion
  2968. * @returns the target quaternion
  2969. */
  2970. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2971. /**
  2972. * Creates a new quaternion from data stored into an array
  2973. * @param array defines the data source
  2974. * @param offset defines the offset in the source array where the data starts
  2975. * @returns a new quaternion
  2976. */
  2977. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2978. /**
  2979. * Create a quaternion from Euler rotation angles
  2980. * @param x Pitch
  2981. * @param y Yaw
  2982. * @param z Roll
  2983. * @returns the new Quaternion
  2984. */
  2985. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2986. /**
  2987. * Updates a quaternion from Euler rotation angles
  2988. * @param x Pitch
  2989. * @param y Yaw
  2990. * @param z Roll
  2991. * @param result the quaternion to store the result
  2992. * @returns the updated quaternion
  2993. */
  2994. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2995. /**
  2996. * Create a quaternion from Euler rotation vector
  2997. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2998. * @returns the new Quaternion
  2999. */
  3000. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3001. /**
  3002. * Updates a quaternion from Euler rotation vector
  3003. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3004. * @param result the quaternion to store the result
  3005. * @returns the updated quaternion
  3006. */
  3007. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3008. /**
  3009. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3010. * @param yaw defines the rotation around Y axis
  3011. * @param pitch defines the rotation around X axis
  3012. * @param roll defines the rotation around Z axis
  3013. * @returns the new quaternion
  3014. */
  3015. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3016. /**
  3017. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3018. * @param yaw defines the rotation around Y axis
  3019. * @param pitch defines the rotation around X axis
  3020. * @param roll defines the rotation around Z axis
  3021. * @param result defines the target quaternion
  3022. */
  3023. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3024. /**
  3025. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3026. * @param alpha defines the rotation around first axis
  3027. * @param beta defines the rotation around second axis
  3028. * @param gamma defines the rotation around third axis
  3029. * @returns the new quaternion
  3030. */
  3031. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3032. /**
  3033. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3034. * @param alpha defines the rotation around first axis
  3035. * @param beta defines the rotation around second axis
  3036. * @param gamma defines the rotation around third axis
  3037. * @param result defines the target quaternion
  3038. */
  3039. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3040. /**
  3041. * 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)
  3042. * @param axis1 defines the first axis
  3043. * @param axis2 defines the second axis
  3044. * @param axis3 defines the third axis
  3045. * @returns the new quaternion
  3046. */
  3047. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3048. /**
  3049. * 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
  3050. * @param axis1 defines the first axis
  3051. * @param axis2 defines the second axis
  3052. * @param axis3 defines the third axis
  3053. * @param ref defines the target quaternion
  3054. */
  3055. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3056. /**
  3057. * Interpolates between two quaternions
  3058. * @param left defines first quaternion
  3059. * @param right defines second quaternion
  3060. * @param amount defines the gradient to use
  3061. * @returns the new interpolated quaternion
  3062. */
  3063. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3064. /**
  3065. * Interpolates between two quaternions and stores it into a target quaternion
  3066. * @param left defines first quaternion
  3067. * @param right defines second quaternion
  3068. * @param amount defines the gradient to use
  3069. * @param result defines the target quaternion
  3070. */
  3071. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3072. /**
  3073. * Interpolate between two quaternions using Hermite interpolation
  3074. * @param value1 defines first quaternion
  3075. * @param tangent1 defines the incoming tangent
  3076. * @param value2 defines second quaternion
  3077. * @param tangent2 defines the outgoing tangent
  3078. * @param amount defines the target quaternion
  3079. * @returns the new interpolated quaternion
  3080. */
  3081. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3082. }
  3083. /**
  3084. * Class used to store matrix data (4x4)
  3085. */
  3086. export class Matrix {
  3087. private static _updateFlagSeed;
  3088. private static _identityReadOnly;
  3089. private _isIdentity;
  3090. private _isIdentityDirty;
  3091. private _isIdentity3x2;
  3092. private _isIdentity3x2Dirty;
  3093. /**
  3094. * Gets the update flag of the matrix which is an unique number for the matrix.
  3095. * It will be incremented every time the matrix data change.
  3096. * You can use it to speed the comparison between two versions of the same matrix.
  3097. */
  3098. updateFlag: number;
  3099. private readonly _m;
  3100. /**
  3101. * Gets the internal data of the matrix
  3102. */
  3103. readonly m: DeepImmutable<Float32Array>;
  3104. /** @hidden */
  3105. _markAsUpdated(): void;
  3106. /** @hidden */
  3107. private _updateIdentityStatus;
  3108. /**
  3109. * Creates an empty matrix (filled with zeros)
  3110. */
  3111. constructor();
  3112. /**
  3113. * Check if the current matrix is identity
  3114. * @returns true is the matrix is the identity matrix
  3115. */
  3116. isIdentity(): boolean;
  3117. /**
  3118. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3119. * @returns true is the matrix is the identity matrix
  3120. */
  3121. isIdentityAs3x2(): boolean;
  3122. /**
  3123. * Gets the determinant of the matrix
  3124. * @returns the matrix determinant
  3125. */
  3126. determinant(): number;
  3127. /**
  3128. * Returns the matrix as a Float32Array
  3129. * @returns the matrix underlying array
  3130. */
  3131. toArray(): DeepImmutable<Float32Array>;
  3132. /**
  3133. * Returns the matrix as a Float32Array
  3134. * @returns the matrix underlying array.
  3135. */
  3136. asArray(): DeepImmutable<Float32Array>;
  3137. /**
  3138. * Inverts the current matrix in place
  3139. * @returns the current inverted matrix
  3140. */
  3141. invert(): Matrix;
  3142. /**
  3143. * Sets all the matrix elements to zero
  3144. * @returns the current matrix
  3145. */
  3146. reset(): Matrix;
  3147. /**
  3148. * Adds the current matrix with a second one
  3149. * @param other defines the matrix to add
  3150. * @returns a new matrix as the addition of the current matrix and the given one
  3151. */
  3152. add(other: DeepImmutable<Matrix>): Matrix;
  3153. /**
  3154. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3155. * @param other defines the matrix to add
  3156. * @param result defines the target matrix
  3157. * @returns the current matrix
  3158. */
  3159. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3160. /**
  3161. * Adds in place the given matrix to the current matrix
  3162. * @param other defines the second operand
  3163. * @returns the current updated matrix
  3164. */
  3165. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3166. /**
  3167. * Sets the given matrix to the current inverted Matrix
  3168. * @param other defines the target matrix
  3169. * @returns the unmodified current matrix
  3170. */
  3171. invertToRef(other: Matrix): Matrix;
  3172. /**
  3173. * add a value at the specified position in the current Matrix
  3174. * @param index the index of the value within the matrix. between 0 and 15.
  3175. * @param value the value to be added
  3176. * @returns the current updated matrix
  3177. */
  3178. addAtIndex(index: number, value: number): Matrix;
  3179. /**
  3180. * mutiply the specified position in the current Matrix by a value
  3181. * @param index the index of the value within the matrix. between 0 and 15.
  3182. * @param value the value to be added
  3183. * @returns the current updated matrix
  3184. */
  3185. multiplyAtIndex(index: number, value: number): Matrix;
  3186. /**
  3187. * Inserts the translation vector (using 3 floats) in the current matrix
  3188. * @param x defines the 1st component of the translation
  3189. * @param y defines the 2nd component of the translation
  3190. * @param z defines the 3rd component of the translation
  3191. * @returns the current updated matrix
  3192. */
  3193. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3194. /**
  3195. * Adds the translation vector (using 3 floats) in the current matrix
  3196. * @param x defines the 1st component of the translation
  3197. * @param y defines the 2nd component of the translation
  3198. * @param z defines the 3rd component of the translation
  3199. * @returns the current updated matrix
  3200. */
  3201. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3202. /**
  3203. * Inserts the translation vector in the current matrix
  3204. * @param vector3 defines the translation to insert
  3205. * @returns the current updated matrix
  3206. */
  3207. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3208. /**
  3209. * Gets the translation value of the current matrix
  3210. * @returns a new Vector3 as the extracted translation from the matrix
  3211. */
  3212. getTranslation(): Vector3;
  3213. /**
  3214. * Fill a Vector3 with the extracted translation from the matrix
  3215. * @param result defines the Vector3 where to store the translation
  3216. * @returns the current matrix
  3217. */
  3218. getTranslationToRef(result: Vector3): Matrix;
  3219. /**
  3220. * Remove rotation and scaling part from the matrix
  3221. * @returns the updated matrix
  3222. */
  3223. removeRotationAndScaling(): Matrix;
  3224. /**
  3225. * Multiply two matrices
  3226. * @param other defines the second operand
  3227. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3228. */
  3229. multiply(other: DeepImmutable<Matrix>): Matrix;
  3230. /**
  3231. * Copy the current matrix from the given one
  3232. * @param other defines the source matrix
  3233. * @returns the current updated matrix
  3234. */
  3235. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3236. /**
  3237. * Populates the given array from the starting index with the current matrix values
  3238. * @param array defines the target array
  3239. * @param offset defines the offset in the target array where to start storing values
  3240. * @returns the current matrix
  3241. */
  3242. copyToArray(array: Float32Array, offset?: number): Matrix;
  3243. /**
  3244. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3245. * @param other defines the second operand
  3246. * @param result defines the matrix where to store the multiplication
  3247. * @returns the current matrix
  3248. */
  3249. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3250. /**
  3251. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3252. * @param other defines the second operand
  3253. * @param result defines the array where to store the multiplication
  3254. * @param offset defines the offset in the target array where to start storing values
  3255. * @returns the current matrix
  3256. */
  3257. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3258. /**
  3259. * Check equality between this matrix and a second one
  3260. * @param value defines the second matrix to compare
  3261. * @returns true is the current matrix and the given one values are strictly equal
  3262. */
  3263. equals(value: DeepImmutable<Matrix>): boolean;
  3264. /**
  3265. * Clone the current matrix
  3266. * @returns a new matrix from the current matrix
  3267. */
  3268. clone(): Matrix;
  3269. /**
  3270. * Returns the name of the current matrix class
  3271. * @returns the string "Matrix"
  3272. */
  3273. getClassName(): string;
  3274. /**
  3275. * Gets the hash code of the current matrix
  3276. * @returns the hash code
  3277. */
  3278. getHashCode(): number;
  3279. /**
  3280. * Decomposes the current Matrix into a translation, rotation and scaling components
  3281. * @param scale defines the scale vector3 given as a reference to update
  3282. * @param rotation defines the rotation quaternion given as a reference to update
  3283. * @param translation defines the translation vector3 given as a reference to update
  3284. * @returns true if operation was successful
  3285. */
  3286. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3287. /**
  3288. * Gets specific row of the matrix
  3289. * @param index defines the number of the row to get
  3290. * @returns the index-th row of the current matrix as a new Vector4
  3291. */
  3292. getRow(index: number): Nullable<Vector4>;
  3293. /**
  3294. * Sets the index-th row of the current matrix to the vector4 values
  3295. * @param index defines the number of the row to set
  3296. * @param row defines the target vector4
  3297. * @returns the updated current matrix
  3298. */
  3299. setRow(index: number, row: Vector4): Matrix;
  3300. /**
  3301. * Compute the transpose of the matrix
  3302. * @returns the new transposed matrix
  3303. */
  3304. transpose(): Matrix;
  3305. /**
  3306. * Compute the transpose of the matrix and store it in a given matrix
  3307. * @param result defines the target matrix
  3308. * @returns the current matrix
  3309. */
  3310. transposeToRef(result: Matrix): Matrix;
  3311. /**
  3312. * Sets the index-th row of the current matrix with the given 4 x float values
  3313. * @param index defines the row index
  3314. * @param x defines the x component to set
  3315. * @param y defines the y component to set
  3316. * @param z defines the z component to set
  3317. * @param w defines the w component to set
  3318. * @returns the updated current matrix
  3319. */
  3320. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3321. /**
  3322. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3323. * @param scale defines the scale factor
  3324. * @returns a new matrix
  3325. */
  3326. scale(scale: number): Matrix;
  3327. /**
  3328. * Scale the current matrix values by a factor to a given result matrix
  3329. * @param scale defines the scale factor
  3330. * @param result defines the matrix to store the result
  3331. * @returns the current matrix
  3332. */
  3333. scaleToRef(scale: number, result: Matrix): Matrix;
  3334. /**
  3335. * Scale the current matrix values by a factor and add the result to a given matrix
  3336. * @param scale defines the scale factor
  3337. * @param result defines the Matrix to store the result
  3338. * @returns the current matrix
  3339. */
  3340. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3341. /**
  3342. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3343. * @param ref matrix to store the result
  3344. */
  3345. toNormalMatrix(ref: Matrix): void;
  3346. /**
  3347. * Gets only rotation part of the current matrix
  3348. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3349. */
  3350. getRotationMatrix(): Matrix;
  3351. /**
  3352. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3353. * @param result defines the target matrix to store data to
  3354. * @returns the current matrix
  3355. */
  3356. getRotationMatrixToRef(result: Matrix): Matrix;
  3357. /**
  3358. * Toggles model matrix from being right handed to left handed in place and vice versa
  3359. */
  3360. toggleModelMatrixHandInPlace(): void;
  3361. /**
  3362. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3363. */
  3364. toggleProjectionMatrixHandInPlace(): void;
  3365. /**
  3366. * Creates a matrix from an array
  3367. * @param array defines the source array
  3368. * @param offset defines an offset in the source array
  3369. * @returns a new Matrix set from the starting index of the given array
  3370. */
  3371. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3372. /**
  3373. * Copy the content of an array into a given matrix
  3374. * @param array defines the source array
  3375. * @param offset defines an offset in the source array
  3376. * @param result defines the target matrix
  3377. */
  3378. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3379. /**
  3380. * Stores an array into a matrix after having multiplied each component by a given factor
  3381. * @param array defines the source array
  3382. * @param offset defines the offset in the source array
  3383. * @param scale defines the scaling factor
  3384. * @param result defines the target matrix
  3385. */
  3386. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3387. /**
  3388. * Gets an identity matrix that must not be updated
  3389. */
  3390. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3391. /**
  3392. * Stores a list of values (16) inside a given matrix
  3393. * @param initialM11 defines 1st value of 1st row
  3394. * @param initialM12 defines 2nd value of 1st row
  3395. * @param initialM13 defines 3rd value of 1st row
  3396. * @param initialM14 defines 4th value of 1st row
  3397. * @param initialM21 defines 1st value of 2nd row
  3398. * @param initialM22 defines 2nd value of 2nd row
  3399. * @param initialM23 defines 3rd value of 2nd row
  3400. * @param initialM24 defines 4th value of 2nd row
  3401. * @param initialM31 defines 1st value of 3rd row
  3402. * @param initialM32 defines 2nd value of 3rd row
  3403. * @param initialM33 defines 3rd value of 3rd row
  3404. * @param initialM34 defines 4th value of 3rd row
  3405. * @param initialM41 defines 1st value of 4th row
  3406. * @param initialM42 defines 2nd value of 4th row
  3407. * @param initialM43 defines 3rd value of 4th row
  3408. * @param initialM44 defines 4th value of 4th row
  3409. * @param result defines the target matrix
  3410. */
  3411. 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;
  3412. /**
  3413. * Creates new matrix from a list of values (16)
  3414. * @param initialM11 defines 1st value of 1st row
  3415. * @param initialM12 defines 2nd value of 1st row
  3416. * @param initialM13 defines 3rd value of 1st row
  3417. * @param initialM14 defines 4th value of 1st row
  3418. * @param initialM21 defines 1st value of 2nd row
  3419. * @param initialM22 defines 2nd value of 2nd row
  3420. * @param initialM23 defines 3rd value of 2nd row
  3421. * @param initialM24 defines 4th value of 2nd row
  3422. * @param initialM31 defines 1st value of 3rd row
  3423. * @param initialM32 defines 2nd value of 3rd row
  3424. * @param initialM33 defines 3rd value of 3rd row
  3425. * @param initialM34 defines 4th value of 3rd row
  3426. * @param initialM41 defines 1st value of 4th row
  3427. * @param initialM42 defines 2nd value of 4th row
  3428. * @param initialM43 defines 3rd value of 4th row
  3429. * @param initialM44 defines 4th value of 4th row
  3430. * @returns the new matrix
  3431. */
  3432. 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;
  3433. /**
  3434. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3435. * @param scale defines the scale vector3
  3436. * @param rotation defines the rotation quaternion
  3437. * @param translation defines the translation vector3
  3438. * @returns a new matrix
  3439. */
  3440. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3441. /**
  3442. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3443. * @param scale defines the scale vector3
  3444. * @param rotation defines the rotation quaternion
  3445. * @param translation defines the translation vector3
  3446. * @param result defines the target matrix
  3447. */
  3448. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3449. /**
  3450. * Creates a new identity matrix
  3451. * @returns a new identity matrix
  3452. */
  3453. static Identity(): Matrix;
  3454. /**
  3455. * Creates a new identity matrix and stores the result in a given matrix
  3456. * @param result defines the target matrix
  3457. */
  3458. static IdentityToRef(result: Matrix): void;
  3459. /**
  3460. * Creates a new zero matrix
  3461. * @returns a new zero matrix
  3462. */
  3463. static Zero(): Matrix;
  3464. /**
  3465. * Creates a new rotation matrix for "angle" radians around the X axis
  3466. * @param angle defines the angle (in radians) to use
  3467. * @return the new matrix
  3468. */
  3469. static RotationX(angle: number): Matrix;
  3470. /**
  3471. * Creates a new matrix as the invert of a given matrix
  3472. * @param source defines the source matrix
  3473. * @returns the new matrix
  3474. */
  3475. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3476. /**
  3477. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3478. * @param angle defines the angle (in radians) to use
  3479. * @param result defines the target matrix
  3480. */
  3481. static RotationXToRef(angle: number, result: Matrix): void;
  3482. /**
  3483. * Creates a new rotation matrix for "angle" radians around the Y axis
  3484. * @param angle defines the angle (in radians) to use
  3485. * @return the new matrix
  3486. */
  3487. static RotationY(angle: number): Matrix;
  3488. /**
  3489. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3490. * @param angle defines the angle (in radians) to use
  3491. * @param result defines the target matrix
  3492. */
  3493. static RotationYToRef(angle: number, result: Matrix): void;
  3494. /**
  3495. * Creates a new rotation matrix for "angle" radians around the Z axis
  3496. * @param angle defines the angle (in radians) to use
  3497. * @return the new matrix
  3498. */
  3499. static RotationZ(angle: number): Matrix;
  3500. /**
  3501. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3502. * @param angle defines the angle (in radians) to use
  3503. * @param result defines the target matrix
  3504. */
  3505. static RotationZToRef(angle: number, result: Matrix): void;
  3506. /**
  3507. * Creates a new rotation matrix for "angle" radians around the given axis
  3508. * @param axis defines the axis to use
  3509. * @param angle defines the angle (in radians) to use
  3510. * @return the new matrix
  3511. */
  3512. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3513. /**
  3514. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3515. * @param axis defines the axis to use
  3516. * @param angle defines the angle (in radians) to use
  3517. * @param result defines the target matrix
  3518. */
  3519. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3520. /**
  3521. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3522. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3523. * @param from defines the vector to align
  3524. * @param to defines the vector to align to
  3525. * @param result defines the target matrix
  3526. */
  3527. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3528. /**
  3529. * Creates a rotation matrix
  3530. * @param yaw defines the yaw angle in radians (Y axis)
  3531. * @param pitch defines the pitch angle in radians (X axis)
  3532. * @param roll defines the roll angle in radians (X axis)
  3533. * @returns the new rotation matrix
  3534. */
  3535. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3536. /**
  3537. * Creates a rotation matrix and stores it in a given matrix
  3538. * @param yaw defines the yaw angle in radians (Y axis)
  3539. * @param pitch defines the pitch angle in radians (X axis)
  3540. * @param roll defines the roll angle in radians (X axis)
  3541. * @param result defines the target matrix
  3542. */
  3543. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3544. /**
  3545. * Creates a scaling matrix
  3546. * @param x defines the scale factor on X axis
  3547. * @param y defines the scale factor on Y axis
  3548. * @param z defines the scale factor on Z axis
  3549. * @returns the new matrix
  3550. */
  3551. static Scaling(x: number, y: number, z: number): Matrix;
  3552. /**
  3553. * Creates a scaling matrix and stores it in a given matrix
  3554. * @param x defines the scale factor on X axis
  3555. * @param y defines the scale factor on Y axis
  3556. * @param z defines the scale factor on Z axis
  3557. * @param result defines the target matrix
  3558. */
  3559. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3560. /**
  3561. * Creates a translation matrix
  3562. * @param x defines the translation on X axis
  3563. * @param y defines the translation on Y axis
  3564. * @param z defines the translationon Z axis
  3565. * @returns the new matrix
  3566. */
  3567. static Translation(x: number, y: number, z: number): Matrix;
  3568. /**
  3569. * Creates a translation matrix and stores it in a given matrix
  3570. * @param x defines the translation on X axis
  3571. * @param y defines the translation on Y axis
  3572. * @param z defines the translationon Z axis
  3573. * @param result defines the target matrix
  3574. */
  3575. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3576. /**
  3577. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3578. * @param startValue defines the start value
  3579. * @param endValue defines the end value
  3580. * @param gradient defines the gradient factor
  3581. * @returns the new matrix
  3582. */
  3583. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3584. /**
  3585. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3586. * @param startValue defines the start value
  3587. * @param endValue defines the end value
  3588. * @param gradient defines the gradient factor
  3589. * @param result defines the Matrix object where to store data
  3590. */
  3591. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3592. /**
  3593. * Builds a new matrix whose values are computed by:
  3594. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3595. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3596. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3597. * @param startValue defines the first matrix
  3598. * @param endValue defines the second matrix
  3599. * @param gradient defines the gradient between the two matrices
  3600. * @returns the new matrix
  3601. */
  3602. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3603. /**
  3604. * Update a matrix to values which are computed by:
  3605. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3606. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3607. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3608. * @param startValue defines the first matrix
  3609. * @param endValue defines the second matrix
  3610. * @param gradient defines the gradient between the two matrices
  3611. * @param result defines the target matrix
  3612. */
  3613. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3614. /**
  3615. * 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"
  3616. * This function works in left handed mode
  3617. * @param eye defines the final position of the entity
  3618. * @param target defines where the entity should look at
  3619. * @param up defines the up vector for the entity
  3620. * @returns the new matrix
  3621. */
  3622. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3623. /**
  3624. * 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".
  3625. * This function works in left handed mode
  3626. * @param eye defines the final position of the entity
  3627. * @param target defines where the entity should look at
  3628. * @param up defines the up vector for the entity
  3629. * @param result defines the target matrix
  3630. */
  3631. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3632. /**
  3633. * 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"
  3634. * This function works in right handed mode
  3635. * @param eye defines the final position of the entity
  3636. * @param target defines where the entity should look at
  3637. * @param up defines the up vector for the entity
  3638. * @returns the new matrix
  3639. */
  3640. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3641. /**
  3642. * 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".
  3643. * This function works in right handed mode
  3644. * @param eye defines the final position of the entity
  3645. * @param target defines where the entity should look at
  3646. * @param up defines the up vector for the entity
  3647. * @param result defines the target matrix
  3648. */
  3649. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3650. /**
  3651. * Create a left-handed orthographic projection matrix
  3652. * @param width defines the viewport width
  3653. * @param height defines the viewport height
  3654. * @param znear defines the near clip plane
  3655. * @param zfar defines the far clip plane
  3656. * @returns a new matrix as a left-handed orthographic projection matrix
  3657. */
  3658. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3659. /**
  3660. * Store a left-handed orthographic projection to a given matrix
  3661. * @param width defines the viewport width
  3662. * @param height defines the viewport height
  3663. * @param znear defines the near clip plane
  3664. * @param zfar defines the far clip plane
  3665. * @param result defines the target matrix
  3666. */
  3667. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3668. /**
  3669. * Create a left-handed orthographic projection matrix
  3670. * @param left defines the viewport left coordinate
  3671. * @param right defines the viewport right coordinate
  3672. * @param bottom defines the viewport bottom coordinate
  3673. * @param top defines the viewport top coordinate
  3674. * @param znear defines the near clip plane
  3675. * @param zfar defines the far clip plane
  3676. * @returns a new matrix as a left-handed orthographic projection matrix
  3677. */
  3678. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3679. /**
  3680. * Stores a left-handed orthographic projection into a given matrix
  3681. * @param left defines the viewport left coordinate
  3682. * @param right defines the viewport right coordinate
  3683. * @param bottom defines the viewport bottom coordinate
  3684. * @param top defines the viewport top coordinate
  3685. * @param znear defines the near clip plane
  3686. * @param zfar defines the far clip plane
  3687. * @param result defines the target matrix
  3688. */
  3689. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3690. /**
  3691. * Creates a right-handed orthographic projection matrix
  3692. * @param left defines the viewport left coordinate
  3693. * @param right defines the viewport right coordinate
  3694. * @param bottom defines the viewport bottom coordinate
  3695. * @param top defines the viewport top coordinate
  3696. * @param znear defines the near clip plane
  3697. * @param zfar defines the far clip plane
  3698. * @returns a new matrix as a right-handed orthographic projection matrix
  3699. */
  3700. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3701. /**
  3702. * Stores a right-handed orthographic projection into a given matrix
  3703. * @param left defines the viewport left coordinate
  3704. * @param right defines the viewport right coordinate
  3705. * @param bottom defines the viewport bottom coordinate
  3706. * @param top defines the viewport top coordinate
  3707. * @param znear defines the near clip plane
  3708. * @param zfar defines the far clip plane
  3709. * @param result defines the target matrix
  3710. */
  3711. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3712. /**
  3713. * Creates a left-handed perspective projection matrix
  3714. * @param width defines the viewport width
  3715. * @param height defines the viewport height
  3716. * @param znear defines the near clip plane
  3717. * @param zfar defines the far clip plane
  3718. * @returns a new matrix as a left-handed perspective projection matrix
  3719. */
  3720. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3721. /**
  3722. * Creates a left-handed perspective projection matrix
  3723. * @param fov defines the horizontal field of view
  3724. * @param aspect defines the aspect ratio
  3725. * @param znear defines the near clip plane
  3726. * @param zfar defines the far clip plane
  3727. * @returns a new matrix as a left-handed perspective projection matrix
  3728. */
  3729. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3730. /**
  3731. * Stores a left-handed perspective projection into a given matrix
  3732. * @param fov defines the horizontal field of view
  3733. * @param aspect defines the aspect ratio
  3734. * @param znear defines the near clip plane
  3735. * @param zfar defines the far clip plane
  3736. * @param result defines the target matrix
  3737. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3738. */
  3739. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3740. /**
  3741. * Creates a right-handed perspective projection matrix
  3742. * @param fov defines the horizontal field of view
  3743. * @param aspect defines the aspect ratio
  3744. * @param znear defines the near clip plane
  3745. * @param zfar defines the far clip plane
  3746. * @returns a new matrix as a right-handed perspective projection matrix
  3747. */
  3748. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3749. /**
  3750. * Stores a right-handed perspective projection into a given matrix
  3751. * @param fov defines the horizontal field of view
  3752. * @param aspect defines the aspect ratio
  3753. * @param znear defines the near clip plane
  3754. * @param zfar defines the far clip plane
  3755. * @param result defines the target matrix
  3756. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3757. */
  3758. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3759. /**
  3760. * Stores a perspective projection for WebVR info a given matrix
  3761. * @param fov defines the field of view
  3762. * @param znear defines the near clip plane
  3763. * @param zfar defines the far clip plane
  3764. * @param result defines the target matrix
  3765. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3766. */
  3767. static PerspectiveFovWebVRToRef(fov: {
  3768. upDegrees: number;
  3769. downDegrees: number;
  3770. leftDegrees: number;
  3771. rightDegrees: number;
  3772. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3773. /**
  3774. * Computes a complete transformation matrix
  3775. * @param viewport defines the viewport to use
  3776. * @param world defines the world matrix
  3777. * @param view defines the view matrix
  3778. * @param projection defines the projection matrix
  3779. * @param zmin defines the near clip plane
  3780. * @param zmax defines the far clip plane
  3781. * @returns the transformation matrix
  3782. */
  3783. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3784. /**
  3785. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3786. * @param matrix defines the matrix to use
  3787. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3788. */
  3789. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3790. /**
  3791. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3792. * @param matrix defines the matrix to use
  3793. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3794. */
  3795. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3796. /**
  3797. * Compute the transpose of a given matrix
  3798. * @param matrix defines the matrix to transpose
  3799. * @returns the new matrix
  3800. */
  3801. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3802. /**
  3803. * Compute the transpose of a matrix and store it in a target matrix
  3804. * @param matrix defines the matrix to transpose
  3805. * @param result defines the target matrix
  3806. */
  3807. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3808. /**
  3809. * Computes a reflection matrix from a plane
  3810. * @param plane defines the reflection plane
  3811. * @returns a new matrix
  3812. */
  3813. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3814. /**
  3815. * Computes a reflection matrix from a plane
  3816. * @param plane defines the reflection plane
  3817. * @param result defines the target matrix
  3818. */
  3819. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  3820. /**
  3821. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3822. * @param xaxis defines the value of the 1st axis
  3823. * @param yaxis defines the value of the 2nd axis
  3824. * @param zaxis defines the value of the 3rd axis
  3825. * @param result defines the target matrix
  3826. */
  3827. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3828. /**
  3829. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3830. * @param quat defines the quaternion to use
  3831. * @param result defines the target matrix
  3832. */
  3833. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3834. }
  3835. /**
  3836. * @hidden
  3837. */
  3838. export class TmpVectors {
  3839. static Vector2: Vector2[];
  3840. static Vector3: Vector3[];
  3841. static Vector4: Vector4[];
  3842. static Quaternion: Quaternion[];
  3843. static Matrix: Matrix[];
  3844. }
  3845. }
  3846. declare module BABYLON {
  3847. /** Defines the cross module used constants to avoid circular dependncies */
  3848. export class Constants {
  3849. /** Defines that alpha blending is disabled */
  3850. static readonly ALPHA_DISABLE: number;
  3851. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  3852. static readonly ALPHA_ADD: number;
  3853. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  3854. static readonly ALPHA_COMBINE: number;
  3855. /** Defines that alpha blending to DEST - SRC * DEST */
  3856. static readonly ALPHA_SUBTRACT: number;
  3857. /** Defines that alpha blending to SRC * DEST */
  3858. static readonly ALPHA_MULTIPLY: number;
  3859. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  3860. static readonly ALPHA_MAXIMIZED: number;
  3861. /** Defines that alpha blending to SRC + DEST */
  3862. static readonly ALPHA_ONEONE: number;
  3863. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  3864. static readonly ALPHA_PREMULTIPLIED: number;
  3865. /**
  3866. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  3867. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  3868. */
  3869. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  3870. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  3871. static readonly ALPHA_INTERPOLATE: number;
  3872. /**
  3873. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  3874. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  3875. */
  3876. static readonly ALPHA_SCREENMODE: number;
  3877. /**
  3878. * Defines that alpha blending to SRC + DST
  3879. * Alpha will be set to SRC ALPHA + DST ALPHA
  3880. */
  3881. static readonly ALPHA_ONEONE_ONEONE: number;
  3882. /**
  3883. * Defines that alpha blending to SRC * DST ALPHA + DST
  3884. * Alpha will be set to 0
  3885. */
  3886. static readonly ALPHA_ALPHATOCOLOR: number;
  3887. /**
  3888. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  3889. */
  3890. static readonly ALPHA_REVERSEONEMINUS: number;
  3891. /**
  3892. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  3893. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  3894. */
  3895. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  3896. /**
  3897. * Defines that alpha blending to SRC + DST
  3898. * Alpha will be set to SRC ALPHA
  3899. */
  3900. static readonly ALPHA_ONEONE_ONEZERO: number;
  3901. /** Defines that alpha blending equation a SUM */
  3902. static readonly ALPHA_EQUATION_ADD: number;
  3903. /** Defines that alpha blending equation a SUBSTRACTION */
  3904. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  3905. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  3906. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  3907. /** Defines that alpha blending equation a MAX operation */
  3908. static readonly ALPHA_EQUATION_MAX: number;
  3909. /** Defines that alpha blending equation a MIN operation */
  3910. static readonly ALPHA_EQUATION_MIN: number;
  3911. /**
  3912. * Defines that alpha blending equation a DARKEN operation:
  3913. * It takes the min of the src and sums the alpha channels.
  3914. */
  3915. static readonly ALPHA_EQUATION_DARKEN: number;
  3916. /** Defines that the ressource is not delayed*/
  3917. static readonly DELAYLOADSTATE_NONE: number;
  3918. /** Defines that the ressource was successfully delay loaded */
  3919. static readonly DELAYLOADSTATE_LOADED: number;
  3920. /** Defines that the ressource is currently delay loading */
  3921. static readonly DELAYLOADSTATE_LOADING: number;
  3922. /** Defines that the ressource is delayed and has not started loading */
  3923. static readonly DELAYLOADSTATE_NOTLOADED: number;
  3924. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  3925. static readonly NEVER: number;
  3926. /** 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 */
  3927. static readonly ALWAYS: number;
  3928. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  3929. static readonly LESS: number;
  3930. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  3931. static readonly EQUAL: number;
  3932. /** 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 */
  3933. static readonly LEQUAL: number;
  3934. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  3935. static readonly GREATER: number;
  3936. /** 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 */
  3937. static readonly GEQUAL: number;
  3938. /** 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 */
  3939. static readonly NOTEQUAL: number;
  3940. /** Passed to stencilOperation to specify that stencil value must be kept */
  3941. static readonly KEEP: number;
  3942. /** Passed to stencilOperation to specify that stencil value must be replaced */
  3943. static readonly REPLACE: number;
  3944. /** Passed to stencilOperation to specify that stencil value must be incremented */
  3945. static readonly INCR: number;
  3946. /** Passed to stencilOperation to specify that stencil value must be decremented */
  3947. static readonly DECR: number;
  3948. /** Passed to stencilOperation to specify that stencil value must be inverted */
  3949. static readonly INVERT: number;
  3950. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  3951. static readonly INCR_WRAP: number;
  3952. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  3953. static readonly DECR_WRAP: number;
  3954. /** Texture is not repeating outside of 0..1 UVs */
  3955. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  3956. /** Texture is repeating outside of 0..1 UVs */
  3957. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  3958. /** Texture is repeating and mirrored */
  3959. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  3960. /** ALPHA */
  3961. static readonly TEXTUREFORMAT_ALPHA: number;
  3962. /** LUMINANCE */
  3963. static readonly TEXTUREFORMAT_LUMINANCE: number;
  3964. /** LUMINANCE_ALPHA */
  3965. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  3966. /** RGB */
  3967. static readonly TEXTUREFORMAT_RGB: number;
  3968. /** RGBA */
  3969. static readonly TEXTUREFORMAT_RGBA: number;
  3970. /** RED */
  3971. static readonly TEXTUREFORMAT_RED: number;
  3972. /** RED (2nd reference) */
  3973. static readonly TEXTUREFORMAT_R: number;
  3974. /** RG */
  3975. static readonly TEXTUREFORMAT_RG: number;
  3976. /** RED_INTEGER */
  3977. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  3978. /** RED_INTEGER (2nd reference) */
  3979. static readonly TEXTUREFORMAT_R_INTEGER: number;
  3980. /** RG_INTEGER */
  3981. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  3982. /** RGB_INTEGER */
  3983. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  3984. /** RGBA_INTEGER */
  3985. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  3986. /** UNSIGNED_BYTE */
  3987. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  3988. /** UNSIGNED_BYTE (2nd reference) */
  3989. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  3990. /** FLOAT */
  3991. static readonly TEXTURETYPE_FLOAT: number;
  3992. /** HALF_FLOAT */
  3993. static readonly TEXTURETYPE_HALF_FLOAT: number;
  3994. /** BYTE */
  3995. static readonly TEXTURETYPE_BYTE: number;
  3996. /** SHORT */
  3997. static readonly TEXTURETYPE_SHORT: number;
  3998. /** UNSIGNED_SHORT */
  3999. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4000. /** INT */
  4001. static readonly TEXTURETYPE_INT: number;
  4002. /** UNSIGNED_INT */
  4003. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4004. /** UNSIGNED_SHORT_4_4_4_4 */
  4005. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4006. /** UNSIGNED_SHORT_5_5_5_1 */
  4007. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4008. /** UNSIGNED_SHORT_5_6_5 */
  4009. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4010. /** UNSIGNED_INT_2_10_10_10_REV */
  4011. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4012. /** UNSIGNED_INT_24_8 */
  4013. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4014. /** UNSIGNED_INT_10F_11F_11F_REV */
  4015. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4016. /** UNSIGNED_INT_5_9_9_9_REV */
  4017. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4018. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4019. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4020. /** nearest is mag = nearest and min = nearest and mip = linear */
  4021. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4022. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4023. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4024. /** Trilinear is mag = linear and min = linear and mip = linear */
  4025. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4026. /** nearest is mag = nearest and min = nearest and mip = linear */
  4027. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4028. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4029. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4030. /** Trilinear is mag = linear and min = linear and mip = linear */
  4031. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4032. /** mag = nearest and min = nearest and mip = nearest */
  4033. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4034. /** mag = nearest and min = linear and mip = nearest */
  4035. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4036. /** mag = nearest and min = linear and mip = linear */
  4037. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4038. /** mag = nearest and min = linear and mip = none */
  4039. static readonly TEXTURE_NEAREST_LINEAR: number;
  4040. /** mag = nearest and min = nearest and mip = none */
  4041. static readonly TEXTURE_NEAREST_NEAREST: number;
  4042. /** mag = linear and min = nearest and mip = nearest */
  4043. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4044. /** mag = linear and min = nearest and mip = linear */
  4045. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4046. /** mag = linear and min = linear and mip = none */
  4047. static readonly TEXTURE_LINEAR_LINEAR: number;
  4048. /** mag = linear and min = nearest and mip = none */
  4049. static readonly TEXTURE_LINEAR_NEAREST: number;
  4050. /** Explicit coordinates mode */
  4051. static readonly TEXTURE_EXPLICIT_MODE: number;
  4052. /** Spherical coordinates mode */
  4053. static readonly TEXTURE_SPHERICAL_MODE: number;
  4054. /** Planar coordinates mode */
  4055. static readonly TEXTURE_PLANAR_MODE: number;
  4056. /** Cubic coordinates mode */
  4057. static readonly TEXTURE_CUBIC_MODE: number;
  4058. /** Projection coordinates mode */
  4059. static readonly TEXTURE_PROJECTION_MODE: number;
  4060. /** Skybox coordinates mode */
  4061. static readonly TEXTURE_SKYBOX_MODE: number;
  4062. /** Inverse Cubic coordinates mode */
  4063. static readonly TEXTURE_INVCUBIC_MODE: number;
  4064. /** Equirectangular coordinates mode */
  4065. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4066. /** Equirectangular Fixed coordinates mode */
  4067. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4068. /** Equirectangular Fixed Mirrored coordinates mode */
  4069. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4070. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4071. static readonly SCALEMODE_FLOOR: number;
  4072. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4073. static readonly SCALEMODE_NEAREST: number;
  4074. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4075. static readonly SCALEMODE_CEILING: number;
  4076. /**
  4077. * The dirty texture flag value
  4078. */
  4079. static readonly MATERIAL_TextureDirtyFlag: number;
  4080. /**
  4081. * The dirty light flag value
  4082. */
  4083. static readonly MATERIAL_LightDirtyFlag: number;
  4084. /**
  4085. * The dirty fresnel flag value
  4086. */
  4087. static readonly MATERIAL_FresnelDirtyFlag: number;
  4088. /**
  4089. * The dirty attribute flag value
  4090. */
  4091. static readonly MATERIAL_AttributesDirtyFlag: number;
  4092. /**
  4093. * The dirty misc flag value
  4094. */
  4095. static readonly MATERIAL_MiscDirtyFlag: number;
  4096. /**
  4097. * The all dirty flag value
  4098. */
  4099. static readonly MATERIAL_AllDirtyFlag: number;
  4100. /**
  4101. * Returns the triangle fill mode
  4102. */
  4103. static readonly MATERIAL_TriangleFillMode: number;
  4104. /**
  4105. * Returns the wireframe mode
  4106. */
  4107. static readonly MATERIAL_WireFrameFillMode: number;
  4108. /**
  4109. * Returns the point fill mode
  4110. */
  4111. static readonly MATERIAL_PointFillMode: number;
  4112. /**
  4113. * Returns the point list draw mode
  4114. */
  4115. static readonly MATERIAL_PointListDrawMode: number;
  4116. /**
  4117. * Returns the line list draw mode
  4118. */
  4119. static readonly MATERIAL_LineListDrawMode: number;
  4120. /**
  4121. * Returns the line loop draw mode
  4122. */
  4123. static readonly MATERIAL_LineLoopDrawMode: number;
  4124. /**
  4125. * Returns the line strip draw mode
  4126. */
  4127. static readonly MATERIAL_LineStripDrawMode: number;
  4128. /**
  4129. * Returns the triangle strip draw mode
  4130. */
  4131. static readonly MATERIAL_TriangleStripDrawMode: number;
  4132. /**
  4133. * Returns the triangle fan draw mode
  4134. */
  4135. static readonly MATERIAL_TriangleFanDrawMode: number;
  4136. /**
  4137. * Stores the clock-wise side orientation
  4138. */
  4139. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4140. /**
  4141. * Stores the counter clock-wise side orientation
  4142. */
  4143. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4144. /**
  4145. * Nothing
  4146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4147. */
  4148. static readonly ACTION_NothingTrigger: number;
  4149. /**
  4150. * On pick
  4151. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4152. */
  4153. static readonly ACTION_OnPickTrigger: number;
  4154. /**
  4155. * On left pick
  4156. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4157. */
  4158. static readonly ACTION_OnLeftPickTrigger: number;
  4159. /**
  4160. * On right pick
  4161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4162. */
  4163. static readonly ACTION_OnRightPickTrigger: number;
  4164. /**
  4165. * On center pick
  4166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4167. */
  4168. static readonly ACTION_OnCenterPickTrigger: number;
  4169. /**
  4170. * On pick down
  4171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4172. */
  4173. static readonly ACTION_OnPickDownTrigger: number;
  4174. /**
  4175. * On double pick
  4176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4177. */
  4178. static readonly ACTION_OnDoublePickTrigger: number;
  4179. /**
  4180. * On pick up
  4181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4182. */
  4183. static readonly ACTION_OnPickUpTrigger: number;
  4184. /**
  4185. * On pick out.
  4186. * This trigger will only be raised if you also declared a OnPickDown
  4187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4188. */
  4189. static readonly ACTION_OnPickOutTrigger: number;
  4190. /**
  4191. * On long press
  4192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4193. */
  4194. static readonly ACTION_OnLongPressTrigger: number;
  4195. /**
  4196. * On pointer over
  4197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4198. */
  4199. static readonly ACTION_OnPointerOverTrigger: number;
  4200. /**
  4201. * On pointer out
  4202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4203. */
  4204. static readonly ACTION_OnPointerOutTrigger: number;
  4205. /**
  4206. * On every frame
  4207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4208. */
  4209. static readonly ACTION_OnEveryFrameTrigger: number;
  4210. /**
  4211. * On intersection enter
  4212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4213. */
  4214. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4215. /**
  4216. * On intersection exit
  4217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4218. */
  4219. static readonly ACTION_OnIntersectionExitTrigger: number;
  4220. /**
  4221. * On key down
  4222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4223. */
  4224. static readonly ACTION_OnKeyDownTrigger: number;
  4225. /**
  4226. * On key up
  4227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4228. */
  4229. static readonly ACTION_OnKeyUpTrigger: number;
  4230. /**
  4231. * Billboard mode will only apply to Y axis
  4232. */
  4233. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4234. /**
  4235. * Billboard mode will apply to all axes
  4236. */
  4237. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4238. /**
  4239. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4240. */
  4241. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4242. /**
  4243. * Gets or sets base Assets URL
  4244. */
  4245. static PARTICLES_BaseAssetsUrl: string;
  4246. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4247. * Test order :
  4248. * Is the bounding sphere outside the frustum ?
  4249. * If not, are the bounding box vertices outside the frustum ?
  4250. * It not, then the cullable object is in the frustum.
  4251. */
  4252. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4253. /** Culling strategy : Bounding Sphere Only.
  4254. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4255. * It's also less accurate than the standard because some not visible objects can still be selected.
  4256. * Test : is the bounding sphere outside the frustum ?
  4257. * If not, then the cullable object is in the frustum.
  4258. */
  4259. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4260. /** Culling strategy : Optimistic Inclusion.
  4261. * This in an inclusion test first, then the standard exclusion test.
  4262. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4263. * 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.
  4264. * Anyway, it's as accurate as the standard strategy.
  4265. * Test :
  4266. * Is the cullable object bounding sphere center in the frustum ?
  4267. * If not, apply the default culling strategy.
  4268. */
  4269. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4270. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4271. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4272. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4273. * 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.
  4274. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4275. * Test :
  4276. * Is the cullable object bounding sphere center in the frustum ?
  4277. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4278. */
  4279. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4280. /**
  4281. * No logging while loading
  4282. */
  4283. static readonly SCENELOADER_NO_LOGGING: number;
  4284. /**
  4285. * Minimal logging while loading
  4286. */
  4287. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4288. /**
  4289. * Summary logging while loading
  4290. */
  4291. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4292. /**
  4293. * Detailled logging while loading
  4294. */
  4295. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4296. }
  4297. }
  4298. declare module BABYLON {
  4299. /**
  4300. * Class used to store and describe the pipeline context associated with an effect
  4301. */
  4302. export interface IPipelineContext {
  4303. /**
  4304. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4305. */
  4306. isAsync: boolean;
  4307. /**
  4308. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4309. */
  4310. isReady: boolean;
  4311. /** @hidden */
  4312. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4313. }
  4314. }
  4315. declare module BABYLON {
  4316. /** @hidden */
  4317. export interface IShaderProcessor {
  4318. attributeProcessor?: (attribute: string) => string;
  4319. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4320. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4321. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4322. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4323. lineProcessor?: (line: string, isFragment: boolean) => string;
  4324. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4325. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4326. }
  4327. }
  4328. declare module BABYLON {
  4329. /** @hidden */
  4330. export interface ProcessingOptions {
  4331. defines: string[];
  4332. indexParameters: any;
  4333. isFragment: boolean;
  4334. shouldUseHighPrecisionShader: boolean;
  4335. supportsUniformBuffers: boolean;
  4336. shadersRepository: string;
  4337. includesShadersStore: {
  4338. [key: string]: string;
  4339. };
  4340. processor?: IShaderProcessor;
  4341. version: string;
  4342. platformName: string;
  4343. lookForClosingBracketForUniformBuffer?: boolean;
  4344. }
  4345. }
  4346. declare module BABYLON {
  4347. /**
  4348. * Helper to manipulate strings
  4349. */
  4350. export class StringTools {
  4351. /**
  4352. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4353. * @param str Source string
  4354. * @param suffix Suffix to search for in the source string
  4355. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4356. */
  4357. static EndsWith(str: string, suffix: string): boolean;
  4358. /**
  4359. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4360. * @param str Source string
  4361. * @param suffix Suffix to search for in the source string
  4362. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4363. */
  4364. static StartsWith(str: string, suffix: string): boolean;
  4365. }
  4366. }
  4367. declare module BABYLON {
  4368. /** @hidden */
  4369. export class ShaderCodeNode {
  4370. line: string;
  4371. children: ShaderCodeNode[];
  4372. additionalDefineKey?: string;
  4373. additionalDefineValue?: string;
  4374. isValid(preprocessors: {
  4375. [key: string]: string;
  4376. }): boolean;
  4377. process(preprocessors: {
  4378. [key: string]: string;
  4379. }, options: ProcessingOptions): string;
  4380. }
  4381. }
  4382. declare module BABYLON {
  4383. /** @hidden */
  4384. export class ShaderCodeCursor {
  4385. private _lines;
  4386. lineIndex: number;
  4387. readonly currentLine: string;
  4388. readonly canRead: boolean;
  4389. lines: string[];
  4390. }
  4391. }
  4392. declare module BABYLON {
  4393. /** @hidden */
  4394. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4395. process(preprocessors: {
  4396. [key: string]: string;
  4397. }, options: ProcessingOptions): string;
  4398. }
  4399. }
  4400. declare module BABYLON {
  4401. /** @hidden */
  4402. export class ShaderDefineExpression {
  4403. isTrue(preprocessors: {
  4404. [key: string]: string;
  4405. }): boolean;
  4406. }
  4407. }
  4408. declare module BABYLON {
  4409. /** @hidden */
  4410. export class ShaderCodeTestNode extends ShaderCodeNode {
  4411. testExpression: ShaderDefineExpression;
  4412. isValid(preprocessors: {
  4413. [key: string]: string;
  4414. }): boolean;
  4415. }
  4416. }
  4417. declare module BABYLON {
  4418. /** @hidden */
  4419. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4420. define: string;
  4421. not: boolean;
  4422. constructor(define: string, not?: boolean);
  4423. isTrue(preprocessors: {
  4424. [key: string]: string;
  4425. }): boolean;
  4426. }
  4427. }
  4428. declare module BABYLON {
  4429. /** @hidden */
  4430. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4431. leftOperand: ShaderDefineExpression;
  4432. rightOperand: ShaderDefineExpression;
  4433. isTrue(preprocessors: {
  4434. [key: string]: string;
  4435. }): boolean;
  4436. }
  4437. }
  4438. declare module BABYLON {
  4439. /** @hidden */
  4440. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4441. leftOperand: ShaderDefineExpression;
  4442. rightOperand: ShaderDefineExpression;
  4443. isTrue(preprocessors: {
  4444. [key: string]: string;
  4445. }): boolean;
  4446. }
  4447. }
  4448. declare module BABYLON {
  4449. /** @hidden */
  4450. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4451. define: string;
  4452. operand: string;
  4453. testValue: string;
  4454. constructor(define: string, operand: string, testValue: string);
  4455. isTrue(preprocessors: {
  4456. [key: string]: string;
  4457. }): boolean;
  4458. }
  4459. }
  4460. declare module BABYLON {
  4461. /**
  4462. * @ignore
  4463. * Application error to support additional information when loading a file
  4464. */
  4465. export class LoadFileError extends Error {
  4466. /** defines the optional web request */
  4467. request?: WebRequest | undefined;
  4468. private static _setPrototypeOf;
  4469. /**
  4470. * Creates a new LoadFileError
  4471. * @param message defines the message of the error
  4472. * @param request defines the optional web request
  4473. */
  4474. constructor(message: string,
  4475. /** defines the optional web request */
  4476. request?: WebRequest | undefined);
  4477. }
  4478. }
  4479. declare module BABYLON {
  4480. /**
  4481. * Class used to enable access to offline support
  4482. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4483. */
  4484. export interface IOfflineProvider {
  4485. /**
  4486. * Gets a boolean indicating if scene must be saved in the database
  4487. */
  4488. enableSceneOffline: boolean;
  4489. /**
  4490. * Gets a boolean indicating if textures must be saved in the database
  4491. */
  4492. enableTexturesOffline: boolean;
  4493. /**
  4494. * Open the offline support and make it available
  4495. * @param successCallback defines the callback to call on success
  4496. * @param errorCallback defines the callback to call on error
  4497. */
  4498. open(successCallback: () => void, errorCallback: () => void): void;
  4499. /**
  4500. * Loads an image from the offline support
  4501. * @param url defines the url to load from
  4502. * @param image defines the target DOM image
  4503. */
  4504. loadImage(url: string, image: HTMLImageElement): void;
  4505. /**
  4506. * Loads a file from offline support
  4507. * @param url defines the URL to load from
  4508. * @param sceneLoaded defines a callback to call on success
  4509. * @param progressCallBack defines a callback to call when progress changed
  4510. * @param errorCallback defines a callback to call on error
  4511. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4512. */
  4513. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4514. }
  4515. }
  4516. declare module BABYLON {
  4517. /**
  4518. * Class used to help managing file picking and drag'n'drop
  4519. * File Storage
  4520. */
  4521. export class FilesInputStore {
  4522. /**
  4523. * List of files ready to be loaded
  4524. */
  4525. static FilesToLoad: {
  4526. [key: string]: File;
  4527. };
  4528. }
  4529. }
  4530. declare module BABYLON {
  4531. /**
  4532. * Class used to define a retry strategy when error happens while loading assets
  4533. */
  4534. export class RetryStrategy {
  4535. /**
  4536. * Function used to defines an exponential back off strategy
  4537. * @param maxRetries defines the maximum number of retries (3 by default)
  4538. * @param baseInterval defines the interval between retries
  4539. * @returns the strategy function to use
  4540. */
  4541. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4542. }
  4543. }
  4544. declare module BABYLON {
  4545. /**
  4546. * @hidden
  4547. */
  4548. export class FileTools {
  4549. /**
  4550. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4551. */
  4552. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4553. /**
  4554. * Gets or sets the base URL to use to load assets
  4555. */
  4556. static BaseUrl: string;
  4557. /**
  4558. * Default behaviour for cors in the application.
  4559. * It can be a string if the expected behavior is identical in the entire app.
  4560. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4561. */
  4562. static CorsBehavior: string | ((url: string | string[]) => string);
  4563. /**
  4564. * Gets or sets a function used to pre-process url before using them to load assets
  4565. */
  4566. static PreprocessUrl: (url: string) => string;
  4567. /**
  4568. * Removes unwanted characters from an url
  4569. * @param url defines the url to clean
  4570. * @returns the cleaned url
  4571. */
  4572. private static _CleanUrl;
  4573. /**
  4574. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4575. * @param url define the url we are trying
  4576. * @param element define the dom element where to configure the cors policy
  4577. */
  4578. static SetCorsBehavior(url: string | string[], element: {
  4579. crossOrigin: string | null;
  4580. }): void;
  4581. /**
  4582. * Loads an image as an HTMLImageElement.
  4583. * @param input url string, ArrayBuffer, or Blob to load
  4584. * @param onLoad callback called when the image successfully loads
  4585. * @param onError callback called when the image fails to load
  4586. * @param offlineProvider offline provider for caching
  4587. * @returns the HTMLImageElement of the loaded image
  4588. */
  4589. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4590. /**
  4591. * Loads a file
  4592. * @param fileToLoad defines the file to load
  4593. * @param callback defines the callback to call when data is loaded
  4594. * @param progressCallBack defines the callback to call during loading process
  4595. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4596. * @returns a file request object
  4597. */
  4598. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4599. /**
  4600. * Loads a file
  4601. * @param url url string, ArrayBuffer, or Blob to load
  4602. * @param onSuccess callback called when the file successfully loads
  4603. * @param onProgress callback called while file is loading (if the server supports this mode)
  4604. * @param offlineProvider defines the offline provider for caching
  4605. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4606. * @param onError callback called when the file fails to load
  4607. * @returns a file request object
  4608. */
  4609. 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;
  4610. /**
  4611. * Checks if the loaded document was accessed via `file:`-Protocol.
  4612. * @returns boolean
  4613. */
  4614. static IsFileURL(): boolean;
  4615. }
  4616. }
  4617. declare module BABYLON {
  4618. /** @hidden */
  4619. export class ShaderProcessor {
  4620. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4621. private static _ProcessPrecision;
  4622. private static _ExtractOperation;
  4623. private static _BuildSubExpression;
  4624. private static _BuildExpression;
  4625. private static _MoveCursorWithinIf;
  4626. private static _MoveCursor;
  4627. private static _EvaluatePreProcessors;
  4628. private static _PreparePreProcessors;
  4629. private static _ProcessShaderConversion;
  4630. private static _ProcessIncludes;
  4631. }
  4632. }
  4633. declare module BABYLON {
  4634. /**
  4635. * Class used to hold a RBG color
  4636. */
  4637. export class Color3 {
  4638. /**
  4639. * Defines the red component (between 0 and 1, default is 0)
  4640. */
  4641. r: number;
  4642. /**
  4643. * Defines the green component (between 0 and 1, default is 0)
  4644. */
  4645. g: number;
  4646. /**
  4647. * Defines the blue component (between 0 and 1, default is 0)
  4648. */
  4649. b: number;
  4650. /**
  4651. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4652. * @param r defines the red component (between 0 and 1, default is 0)
  4653. * @param g defines the green component (between 0 and 1, default is 0)
  4654. * @param b defines the blue component (between 0 and 1, default is 0)
  4655. */
  4656. constructor(
  4657. /**
  4658. * Defines the red component (between 0 and 1, default is 0)
  4659. */
  4660. r?: number,
  4661. /**
  4662. * Defines the green component (between 0 and 1, default is 0)
  4663. */
  4664. g?: number,
  4665. /**
  4666. * Defines the blue component (between 0 and 1, default is 0)
  4667. */
  4668. b?: number);
  4669. /**
  4670. * Creates a string with the Color3 current values
  4671. * @returns the string representation of the Color3 object
  4672. */
  4673. toString(): string;
  4674. /**
  4675. * Returns the string "Color3"
  4676. * @returns "Color3"
  4677. */
  4678. getClassName(): string;
  4679. /**
  4680. * Compute the Color3 hash code
  4681. * @returns an unique number that can be used to hash Color3 objects
  4682. */
  4683. getHashCode(): number;
  4684. /**
  4685. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4686. * @param array defines the array where to store the r,g,b components
  4687. * @param index defines an optional index in the target array to define where to start storing values
  4688. * @returns the current Color3 object
  4689. */
  4690. toArray(array: FloatArray, index?: number): Color3;
  4691. /**
  4692. * Returns a new Color4 object from the current Color3 and the given alpha
  4693. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4694. * @returns a new Color4 object
  4695. */
  4696. toColor4(alpha?: number): Color4;
  4697. /**
  4698. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4699. * @returns the new array
  4700. */
  4701. asArray(): number[];
  4702. /**
  4703. * Returns the luminance value
  4704. * @returns a float value
  4705. */
  4706. toLuminance(): number;
  4707. /**
  4708. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4709. * @param otherColor defines the second operand
  4710. * @returns the new Color3 object
  4711. */
  4712. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4713. /**
  4714. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4715. * @param otherColor defines the second operand
  4716. * @param result defines the Color3 object where to store the result
  4717. * @returns the current Color3
  4718. */
  4719. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4720. /**
  4721. * Determines equality between Color3 objects
  4722. * @param otherColor defines the second operand
  4723. * @returns true if the rgb values are equal to the given ones
  4724. */
  4725. equals(otherColor: DeepImmutable<Color3>): boolean;
  4726. /**
  4727. * Determines equality between the current Color3 object and a set of r,b,g values
  4728. * @param r defines the red component to check
  4729. * @param g defines the green component to check
  4730. * @param b defines the blue component to check
  4731. * @returns true if the rgb values are equal to the given ones
  4732. */
  4733. equalsFloats(r: number, g: number, b: number): boolean;
  4734. /**
  4735. * Multiplies in place each rgb value by scale
  4736. * @param scale defines the scaling factor
  4737. * @returns the updated Color3
  4738. */
  4739. scale(scale: number): Color3;
  4740. /**
  4741. * Multiplies the rgb values by scale and stores the result into "result"
  4742. * @param scale defines the scaling factor
  4743. * @param result defines the Color3 object where to store the result
  4744. * @returns the unmodified current Color3
  4745. */
  4746. scaleToRef(scale: number, result: Color3): Color3;
  4747. /**
  4748. * Scale the current Color3 values by a factor and add the result to a given Color3
  4749. * @param scale defines the scale factor
  4750. * @param result defines color to store the result into
  4751. * @returns the unmodified current Color3
  4752. */
  4753. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4754. /**
  4755. * Clamps the rgb values by the min and max values and stores the result into "result"
  4756. * @param min defines minimum clamping value (default is 0)
  4757. * @param max defines maximum clamping value (default is 1)
  4758. * @param result defines color to store the result into
  4759. * @returns the original Color3
  4760. */
  4761. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4762. /**
  4763. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4764. * @param otherColor defines the second operand
  4765. * @returns the new Color3
  4766. */
  4767. add(otherColor: DeepImmutable<Color3>): Color3;
  4768. /**
  4769. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4770. * @param otherColor defines the second operand
  4771. * @param result defines Color3 object to store the result into
  4772. * @returns the unmodified current Color3
  4773. */
  4774. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4775. /**
  4776. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4777. * @param otherColor defines the second operand
  4778. * @returns the new Color3
  4779. */
  4780. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4781. /**
  4782. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4783. * @param otherColor defines the second operand
  4784. * @param result defines Color3 object to store the result into
  4785. * @returns the unmodified current Color3
  4786. */
  4787. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4788. /**
  4789. * Copy the current object
  4790. * @returns a new Color3 copied the current one
  4791. */
  4792. clone(): Color3;
  4793. /**
  4794. * Copies the rgb values from the source in the current Color3
  4795. * @param source defines the source Color3 object
  4796. * @returns the updated Color3 object
  4797. */
  4798. copyFrom(source: DeepImmutable<Color3>): Color3;
  4799. /**
  4800. * Updates the Color3 rgb values from the given floats
  4801. * @param r defines the red component to read from
  4802. * @param g defines the green component to read from
  4803. * @param b defines the blue component to read from
  4804. * @returns the current Color3 object
  4805. */
  4806. copyFromFloats(r: number, g: number, b: number): Color3;
  4807. /**
  4808. * Updates the Color3 rgb values from the given floats
  4809. * @param r defines the red component to read from
  4810. * @param g defines the green component to read from
  4811. * @param b defines the blue component to read from
  4812. * @returns the current Color3 object
  4813. */
  4814. set(r: number, g: number, b: number): Color3;
  4815. /**
  4816. * Compute the Color3 hexadecimal code as a string
  4817. * @returns a string containing the hexadecimal representation of the Color3 object
  4818. */
  4819. toHexString(): string;
  4820. /**
  4821. * Computes a new Color3 converted from the current one to linear space
  4822. * @returns a new Color3 object
  4823. */
  4824. toLinearSpace(): Color3;
  4825. /**
  4826. * Converts current color in rgb space to HSV values
  4827. * @returns a new color3 representing the HSV values
  4828. */
  4829. toHSV(): Color3;
  4830. /**
  4831. * Converts current color in rgb space to HSV values
  4832. * @param result defines the Color3 where to store the HSV values
  4833. */
  4834. toHSVToRef(result: Color3): void;
  4835. /**
  4836. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  4837. * @param convertedColor defines the Color3 object where to store the linear space version
  4838. * @returns the unmodified Color3
  4839. */
  4840. toLinearSpaceToRef(convertedColor: Color3): Color3;
  4841. /**
  4842. * Computes a new Color3 converted from the current one to gamma space
  4843. * @returns a new Color3 object
  4844. */
  4845. toGammaSpace(): Color3;
  4846. /**
  4847. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  4848. * @param convertedColor defines the Color3 object where to store the gamma space version
  4849. * @returns the unmodified Color3
  4850. */
  4851. toGammaSpaceToRef(convertedColor: Color3): Color3;
  4852. private static _BlackReadOnly;
  4853. /**
  4854. * Convert Hue, saturation and value to a Color3 (RGB)
  4855. * @param hue defines the hue
  4856. * @param saturation defines the saturation
  4857. * @param value defines the value
  4858. * @param result defines the Color3 where to store the RGB values
  4859. */
  4860. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  4861. /**
  4862. * Creates a new Color3 from the string containing valid hexadecimal values
  4863. * @param hex defines a string containing valid hexadecimal values
  4864. * @returns a new Color3 object
  4865. */
  4866. static FromHexString(hex: string): Color3;
  4867. /**
  4868. * Creates a new Color3 from the starting index of the given array
  4869. * @param array defines the source array
  4870. * @param offset defines an offset in the source array
  4871. * @returns a new Color3 object
  4872. */
  4873. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  4874. /**
  4875. * Creates a new Color3 from integer values (< 256)
  4876. * @param r defines the red component to read from (value between 0 and 255)
  4877. * @param g defines the green component to read from (value between 0 and 255)
  4878. * @param b defines the blue component to read from (value between 0 and 255)
  4879. * @returns a new Color3 object
  4880. */
  4881. static FromInts(r: number, g: number, b: number): Color3;
  4882. /**
  4883. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  4884. * @param start defines the start Color3 value
  4885. * @param end defines the end Color3 value
  4886. * @param amount defines the gradient value between start and end
  4887. * @returns a new Color3 object
  4888. */
  4889. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  4890. /**
  4891. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  4892. * @param left defines the start value
  4893. * @param right defines the end value
  4894. * @param amount defines the gradient factor
  4895. * @param result defines the Color3 object where to store the result
  4896. */
  4897. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  4898. /**
  4899. * Returns a Color3 value containing a red color
  4900. * @returns a new Color3 object
  4901. */
  4902. static Red(): Color3;
  4903. /**
  4904. * Returns a Color3 value containing a green color
  4905. * @returns a new Color3 object
  4906. */
  4907. static Green(): Color3;
  4908. /**
  4909. * Returns a Color3 value containing a blue color
  4910. * @returns a new Color3 object
  4911. */
  4912. static Blue(): Color3;
  4913. /**
  4914. * Returns a Color3 value containing a black color
  4915. * @returns a new Color3 object
  4916. */
  4917. static Black(): Color3;
  4918. /**
  4919. * Gets a Color3 value containing a black color that must not be updated
  4920. */
  4921. static readonly BlackReadOnly: DeepImmutable<Color3>;
  4922. /**
  4923. * Returns a Color3 value containing a white color
  4924. * @returns a new Color3 object
  4925. */
  4926. static White(): Color3;
  4927. /**
  4928. * Returns a Color3 value containing a purple color
  4929. * @returns a new Color3 object
  4930. */
  4931. static Purple(): Color3;
  4932. /**
  4933. * Returns a Color3 value containing a magenta color
  4934. * @returns a new Color3 object
  4935. */
  4936. static Magenta(): Color3;
  4937. /**
  4938. * Returns a Color3 value containing a yellow color
  4939. * @returns a new Color3 object
  4940. */
  4941. static Yellow(): Color3;
  4942. /**
  4943. * Returns a Color3 value containing a gray color
  4944. * @returns a new Color3 object
  4945. */
  4946. static Gray(): Color3;
  4947. /**
  4948. * Returns a Color3 value containing a teal color
  4949. * @returns a new Color3 object
  4950. */
  4951. static Teal(): Color3;
  4952. /**
  4953. * Returns a Color3 value containing a random color
  4954. * @returns a new Color3 object
  4955. */
  4956. static Random(): Color3;
  4957. }
  4958. /**
  4959. * Class used to hold a RBGA color
  4960. */
  4961. export class Color4 {
  4962. /**
  4963. * Defines the red component (between 0 and 1, default is 0)
  4964. */
  4965. r: number;
  4966. /**
  4967. * Defines the green component (between 0 and 1, default is 0)
  4968. */
  4969. g: number;
  4970. /**
  4971. * Defines the blue component (between 0 and 1, default is 0)
  4972. */
  4973. b: number;
  4974. /**
  4975. * Defines the alpha component (between 0 and 1, default is 1)
  4976. */
  4977. a: number;
  4978. /**
  4979. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  4980. * @param r defines the red component (between 0 and 1, default is 0)
  4981. * @param g defines the green component (between 0 and 1, default is 0)
  4982. * @param b defines the blue component (between 0 and 1, default is 0)
  4983. * @param a defines the alpha component (between 0 and 1, default is 1)
  4984. */
  4985. constructor(
  4986. /**
  4987. * Defines the red component (between 0 and 1, default is 0)
  4988. */
  4989. r?: number,
  4990. /**
  4991. * Defines the green component (between 0 and 1, default is 0)
  4992. */
  4993. g?: number,
  4994. /**
  4995. * Defines the blue component (between 0 and 1, default is 0)
  4996. */
  4997. b?: number,
  4998. /**
  4999. * Defines the alpha component (between 0 and 1, default is 1)
  5000. */
  5001. a?: number);
  5002. /**
  5003. * Adds in place the given Color4 values to the current Color4 object
  5004. * @param right defines the second operand
  5005. * @returns the current updated Color4 object
  5006. */
  5007. addInPlace(right: DeepImmutable<Color4>): Color4;
  5008. /**
  5009. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5010. * @returns the new array
  5011. */
  5012. asArray(): number[];
  5013. /**
  5014. * Stores from the starting index in the given array the Color4 successive values
  5015. * @param array defines the array where to store the r,g,b components
  5016. * @param index defines an optional index in the target array to define where to start storing values
  5017. * @returns the current Color4 object
  5018. */
  5019. toArray(array: number[], index?: number): Color4;
  5020. /**
  5021. * Determines equality between Color4 objects
  5022. * @param otherColor defines the second operand
  5023. * @returns true if the rgba values are equal to the given ones
  5024. */
  5025. equals(otherColor: DeepImmutable<Color4>): boolean;
  5026. /**
  5027. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5028. * @param right defines the second operand
  5029. * @returns a new Color4 object
  5030. */
  5031. add(right: DeepImmutable<Color4>): Color4;
  5032. /**
  5033. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5034. * @param right defines the second operand
  5035. * @returns a new Color4 object
  5036. */
  5037. subtract(right: DeepImmutable<Color4>): Color4;
  5038. /**
  5039. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5040. * @param right defines the second operand
  5041. * @param result defines the Color4 object where to store the result
  5042. * @returns the current Color4 object
  5043. */
  5044. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5045. /**
  5046. * Creates a new Color4 with the current Color4 values multiplied by scale
  5047. * @param scale defines the scaling factor to apply
  5048. * @returns a new Color4 object
  5049. */
  5050. scale(scale: number): Color4;
  5051. /**
  5052. * Multiplies the current Color4 values by scale and stores the result in "result"
  5053. * @param scale defines the scaling factor to apply
  5054. * @param result defines the Color4 object where to store the result
  5055. * @returns the current unmodified Color4
  5056. */
  5057. scaleToRef(scale: number, result: Color4): Color4;
  5058. /**
  5059. * Scale the current Color4 values by a factor and add the result to a given Color4
  5060. * @param scale defines the scale factor
  5061. * @param result defines the Color4 object where to store the result
  5062. * @returns the unmodified current Color4
  5063. */
  5064. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5065. /**
  5066. * Clamps the rgb values by the min and max values and stores the result into "result"
  5067. * @param min defines minimum clamping value (default is 0)
  5068. * @param max defines maximum clamping value (default is 1)
  5069. * @param result defines color to store the result into.
  5070. * @returns the cuurent Color4
  5071. */
  5072. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5073. /**
  5074. * Multipy an Color4 value by another and return a new Color4 object
  5075. * @param color defines the Color4 value to multiply by
  5076. * @returns a new Color4 object
  5077. */
  5078. multiply(color: Color4): Color4;
  5079. /**
  5080. * Multipy a Color4 value by another and push the result in a reference value
  5081. * @param color defines the Color4 value to multiply by
  5082. * @param result defines the Color4 to fill the result in
  5083. * @returns the result Color4
  5084. */
  5085. multiplyToRef(color: Color4, result: Color4): Color4;
  5086. /**
  5087. * Creates a string with the Color4 current values
  5088. * @returns the string representation of the Color4 object
  5089. */
  5090. toString(): string;
  5091. /**
  5092. * Returns the string "Color4"
  5093. * @returns "Color4"
  5094. */
  5095. getClassName(): string;
  5096. /**
  5097. * Compute the Color4 hash code
  5098. * @returns an unique number that can be used to hash Color4 objects
  5099. */
  5100. getHashCode(): number;
  5101. /**
  5102. * Creates a new Color4 copied from the current one
  5103. * @returns a new Color4 object
  5104. */
  5105. clone(): Color4;
  5106. /**
  5107. * Copies the given Color4 values into the current one
  5108. * @param source defines the source Color4 object
  5109. * @returns the current updated Color4 object
  5110. */
  5111. copyFrom(source: Color4): Color4;
  5112. /**
  5113. * Copies the given float values into the current one
  5114. * @param r defines the red component to read from
  5115. * @param g defines the green component to read from
  5116. * @param b defines the blue component to read from
  5117. * @param a defines the alpha component to read from
  5118. * @returns the current updated Color4 object
  5119. */
  5120. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5121. /**
  5122. * Copies the given float values into the current one
  5123. * @param r defines the red component to read from
  5124. * @param g defines the green component to read from
  5125. * @param b defines the blue component to read from
  5126. * @param a defines the alpha component to read from
  5127. * @returns the current updated Color4 object
  5128. */
  5129. set(r: number, g: number, b: number, a: number): Color4;
  5130. /**
  5131. * Compute the Color4 hexadecimal code as a string
  5132. * @returns a string containing the hexadecimal representation of the Color4 object
  5133. */
  5134. toHexString(): string;
  5135. /**
  5136. * Computes a new Color4 converted from the current one to linear space
  5137. * @returns a new Color4 object
  5138. */
  5139. toLinearSpace(): Color4;
  5140. /**
  5141. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5142. * @param convertedColor defines the Color4 object where to store the linear space version
  5143. * @returns the unmodified Color4
  5144. */
  5145. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5146. /**
  5147. * Computes a new Color4 converted from the current one to gamma space
  5148. * @returns a new Color4 object
  5149. */
  5150. toGammaSpace(): Color4;
  5151. /**
  5152. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5153. * @param convertedColor defines the Color4 object where to store the gamma space version
  5154. * @returns the unmodified Color4
  5155. */
  5156. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5157. /**
  5158. * Creates a new Color4 from the string containing valid hexadecimal values
  5159. * @param hex defines a string containing valid hexadecimal values
  5160. * @returns a new Color4 object
  5161. */
  5162. static FromHexString(hex: string): Color4;
  5163. /**
  5164. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5165. * @param left defines the start value
  5166. * @param right defines the end value
  5167. * @param amount defines the gradient factor
  5168. * @returns a new Color4 object
  5169. */
  5170. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5171. /**
  5172. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5173. * @param left defines the start value
  5174. * @param right defines the end value
  5175. * @param amount defines the gradient factor
  5176. * @param result defines the Color4 object where to store data
  5177. */
  5178. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5179. /**
  5180. * Creates a new Color4 from a Color3 and an alpha value
  5181. * @param color3 defines the source Color3 to read from
  5182. * @param alpha defines the alpha component (1.0 by default)
  5183. * @returns a new Color4 object
  5184. */
  5185. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5186. /**
  5187. * Creates a new Color4 from the starting index element of the given array
  5188. * @param array defines the source array to read from
  5189. * @param offset defines the offset in the source array
  5190. * @returns a new Color4 object
  5191. */
  5192. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5193. /**
  5194. * Creates a new Color3 from integer values (< 256)
  5195. * @param r defines the red component to read from (value between 0 and 255)
  5196. * @param g defines the green component to read from (value between 0 and 255)
  5197. * @param b defines the blue component to read from (value between 0 and 255)
  5198. * @param a defines the alpha component to read from (value between 0 and 255)
  5199. * @returns a new Color3 object
  5200. */
  5201. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5202. /**
  5203. * Check the content of a given array and convert it to an array containing RGBA data
  5204. * If the original array was already containing count * 4 values then it is returned directly
  5205. * @param colors defines the array to check
  5206. * @param count defines the number of RGBA data to expect
  5207. * @returns an array containing count * 4 values (RGBA)
  5208. */
  5209. static CheckColors4(colors: number[], count: number): number[];
  5210. }
  5211. /**
  5212. * @hidden
  5213. */
  5214. export class TmpColors {
  5215. static Color3: Color3[];
  5216. static Color4: Color4[];
  5217. }
  5218. }
  5219. declare module BABYLON {
  5220. /**
  5221. * Class representing spherical harmonics coefficients to the 3rd degree
  5222. */
  5223. export class SphericalHarmonics {
  5224. /**
  5225. * Defines whether or not the harmonics have been prescaled for rendering.
  5226. */
  5227. preScaled: boolean;
  5228. /**
  5229. * The l0,0 coefficients of the spherical harmonics
  5230. */
  5231. l00: Vector3;
  5232. /**
  5233. * The l1,-1 coefficients of the spherical harmonics
  5234. */
  5235. l1_1: Vector3;
  5236. /**
  5237. * The l1,0 coefficients of the spherical harmonics
  5238. */
  5239. l10: Vector3;
  5240. /**
  5241. * The l1,1 coefficients of the spherical harmonics
  5242. */
  5243. l11: Vector3;
  5244. /**
  5245. * The l2,-2 coefficients of the spherical harmonics
  5246. */
  5247. l2_2: Vector3;
  5248. /**
  5249. * The l2,-1 coefficients of the spherical harmonics
  5250. */
  5251. l2_1: Vector3;
  5252. /**
  5253. * The l2,0 coefficients of the spherical harmonics
  5254. */
  5255. l20: Vector3;
  5256. /**
  5257. * The l2,1 coefficients of the spherical harmonics
  5258. */
  5259. l21: Vector3;
  5260. /**
  5261. * The l2,2 coefficients of the spherical harmonics
  5262. */
  5263. l22: Vector3;
  5264. /**
  5265. * Adds a light to the spherical harmonics
  5266. * @param direction the direction of the light
  5267. * @param color the color of the light
  5268. * @param deltaSolidAngle the delta solid angle of the light
  5269. */
  5270. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5271. /**
  5272. * Scales the spherical harmonics by the given amount
  5273. * @param scale the amount to scale
  5274. */
  5275. scaleInPlace(scale: number): void;
  5276. /**
  5277. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5278. *
  5279. * ```
  5280. * E_lm = A_l * L_lm
  5281. * ```
  5282. *
  5283. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5284. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5285. * the scaling factors are given in equation 9.
  5286. */
  5287. convertIncidentRadianceToIrradiance(): void;
  5288. /**
  5289. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5290. *
  5291. * ```
  5292. * L = (1/pi) * E * rho
  5293. * ```
  5294. *
  5295. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5296. */
  5297. convertIrradianceToLambertianRadiance(): void;
  5298. /**
  5299. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5300. * required operations at run time.
  5301. *
  5302. * This is simply done by scaling back the SH with Ylm constants parameter.
  5303. * The trigonometric part being applied by the shader at run time.
  5304. */
  5305. preScaleForRendering(): void;
  5306. /**
  5307. * Constructs a spherical harmonics from an array.
  5308. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5309. * @returns the spherical harmonics
  5310. */
  5311. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5312. /**
  5313. * Gets the spherical harmonics from polynomial
  5314. * @param polynomial the spherical polynomial
  5315. * @returns the spherical harmonics
  5316. */
  5317. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5318. }
  5319. /**
  5320. * Class representing spherical polynomial coefficients to the 3rd degree
  5321. */
  5322. export class SphericalPolynomial {
  5323. private _harmonics;
  5324. /**
  5325. * The spherical harmonics used to create the polynomials.
  5326. */
  5327. readonly preScaledHarmonics: SphericalHarmonics;
  5328. /**
  5329. * The x coefficients of the spherical polynomial
  5330. */
  5331. x: Vector3;
  5332. /**
  5333. * The y coefficients of the spherical polynomial
  5334. */
  5335. y: Vector3;
  5336. /**
  5337. * The z coefficients of the spherical polynomial
  5338. */
  5339. z: Vector3;
  5340. /**
  5341. * The xx coefficients of the spherical polynomial
  5342. */
  5343. xx: Vector3;
  5344. /**
  5345. * The yy coefficients of the spherical polynomial
  5346. */
  5347. yy: Vector3;
  5348. /**
  5349. * The zz coefficients of the spherical polynomial
  5350. */
  5351. zz: Vector3;
  5352. /**
  5353. * The xy coefficients of the spherical polynomial
  5354. */
  5355. xy: Vector3;
  5356. /**
  5357. * The yz coefficients of the spherical polynomial
  5358. */
  5359. yz: Vector3;
  5360. /**
  5361. * The zx coefficients of the spherical polynomial
  5362. */
  5363. zx: Vector3;
  5364. /**
  5365. * Adds an ambient color to the spherical polynomial
  5366. * @param color the color to add
  5367. */
  5368. addAmbient(color: Color3): void;
  5369. /**
  5370. * Scales the spherical polynomial by the given amount
  5371. * @param scale the amount to scale
  5372. */
  5373. scaleInPlace(scale: number): void;
  5374. /**
  5375. * Gets the spherical polynomial from harmonics
  5376. * @param harmonics the spherical harmonics
  5377. * @returns the spherical polynomial
  5378. */
  5379. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5380. /**
  5381. * Constructs a spherical polynomial from an array.
  5382. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5383. * @returns the spherical polynomial
  5384. */
  5385. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5386. }
  5387. }
  5388. declare module BABYLON {
  5389. /**
  5390. * Define options used to create a render target texture
  5391. */
  5392. export class RenderTargetCreationOptions {
  5393. /**
  5394. * Specifies is mipmaps must be generated
  5395. */
  5396. generateMipMaps?: boolean;
  5397. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5398. generateDepthBuffer?: boolean;
  5399. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5400. generateStencilBuffer?: boolean;
  5401. /** Defines texture type (int by default) */
  5402. type?: number;
  5403. /** Defines sampling mode (trilinear by default) */
  5404. samplingMode?: number;
  5405. /** Defines format (RGBA by default) */
  5406. format?: number;
  5407. }
  5408. }
  5409. declare module BABYLON {
  5410. /**
  5411. * @hidden
  5412. **/
  5413. export class _AlphaState {
  5414. private _isAlphaBlendDirty;
  5415. private _isBlendFunctionParametersDirty;
  5416. private _isBlendEquationParametersDirty;
  5417. private _isBlendConstantsDirty;
  5418. private _alphaBlend;
  5419. private _blendFunctionParameters;
  5420. private _blendEquationParameters;
  5421. private _blendConstants;
  5422. /**
  5423. * Initializes the state.
  5424. */
  5425. constructor();
  5426. readonly isDirty: boolean;
  5427. alphaBlend: boolean;
  5428. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5429. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5430. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5431. reset(): void;
  5432. apply(gl: WebGLRenderingContext): void;
  5433. }
  5434. }
  5435. declare module BABYLON {
  5436. /**
  5437. * @hidden
  5438. **/
  5439. export class _DepthCullingState {
  5440. private _isDepthTestDirty;
  5441. private _isDepthMaskDirty;
  5442. private _isDepthFuncDirty;
  5443. private _isCullFaceDirty;
  5444. private _isCullDirty;
  5445. private _isZOffsetDirty;
  5446. private _isFrontFaceDirty;
  5447. private _depthTest;
  5448. private _depthMask;
  5449. private _depthFunc;
  5450. private _cull;
  5451. private _cullFace;
  5452. private _zOffset;
  5453. private _frontFace;
  5454. /**
  5455. * Initializes the state.
  5456. */
  5457. constructor();
  5458. readonly isDirty: boolean;
  5459. zOffset: number;
  5460. cullFace: Nullable<number>;
  5461. cull: Nullable<boolean>;
  5462. depthFunc: Nullable<number>;
  5463. depthMask: boolean;
  5464. depthTest: boolean;
  5465. frontFace: Nullable<number>;
  5466. reset(): void;
  5467. apply(gl: WebGLRenderingContext): void;
  5468. }
  5469. }
  5470. declare module BABYLON {
  5471. /**
  5472. * @hidden
  5473. **/
  5474. export class _StencilState {
  5475. /** 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 */
  5476. static readonly ALWAYS: number;
  5477. /** Passed to stencilOperation to specify that stencil value must be kept */
  5478. static readonly KEEP: number;
  5479. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5480. static readonly REPLACE: number;
  5481. private _isStencilTestDirty;
  5482. private _isStencilMaskDirty;
  5483. private _isStencilFuncDirty;
  5484. private _isStencilOpDirty;
  5485. private _stencilTest;
  5486. private _stencilMask;
  5487. private _stencilFunc;
  5488. private _stencilFuncRef;
  5489. private _stencilFuncMask;
  5490. private _stencilOpStencilFail;
  5491. private _stencilOpDepthFail;
  5492. private _stencilOpStencilDepthPass;
  5493. readonly isDirty: boolean;
  5494. stencilFunc: number;
  5495. stencilFuncRef: number;
  5496. stencilFuncMask: number;
  5497. stencilOpStencilFail: number;
  5498. stencilOpDepthFail: number;
  5499. stencilOpStencilDepthPass: number;
  5500. stencilMask: number;
  5501. stencilTest: boolean;
  5502. constructor();
  5503. reset(): void;
  5504. apply(gl: WebGLRenderingContext): void;
  5505. }
  5506. }
  5507. declare module BABYLON {
  5508. /**
  5509. * @hidden
  5510. **/
  5511. export class _TimeToken {
  5512. _startTimeQuery: Nullable<WebGLQuery>;
  5513. _endTimeQuery: Nullable<WebGLQuery>;
  5514. _timeElapsedQuery: Nullable<WebGLQuery>;
  5515. _timeElapsedQueryEnded: boolean;
  5516. }
  5517. }
  5518. declare module BABYLON {
  5519. /**
  5520. * Class used to evalaute queries containing `and` and `or` operators
  5521. */
  5522. export class AndOrNotEvaluator {
  5523. /**
  5524. * Evaluate a query
  5525. * @param query defines the query to evaluate
  5526. * @param evaluateCallback defines the callback used to filter result
  5527. * @returns true if the query matches
  5528. */
  5529. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5530. private static _HandleParenthesisContent;
  5531. private static _SimplifyNegation;
  5532. }
  5533. }
  5534. declare module BABYLON {
  5535. /**
  5536. * Class used to store custom tags
  5537. */
  5538. export class Tags {
  5539. /**
  5540. * Adds support for tags on the given object
  5541. * @param obj defines the object to use
  5542. */
  5543. static EnableFor(obj: any): void;
  5544. /**
  5545. * Removes tags support
  5546. * @param obj defines the object to use
  5547. */
  5548. static DisableFor(obj: any): void;
  5549. /**
  5550. * Gets a boolean indicating if the given object has tags
  5551. * @param obj defines the object to use
  5552. * @returns a boolean
  5553. */
  5554. static HasTags(obj: any): boolean;
  5555. /**
  5556. * Gets the tags available on a given object
  5557. * @param obj defines the object to use
  5558. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5559. * @returns the tags
  5560. */
  5561. static GetTags(obj: any, asString?: boolean): any;
  5562. /**
  5563. * Adds tags to an object
  5564. * @param obj defines the object to use
  5565. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5566. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5567. */
  5568. static AddTagsTo(obj: any, tagsString: string): void;
  5569. /**
  5570. * @hidden
  5571. */
  5572. static _AddTagTo(obj: any, tag: string): void;
  5573. /**
  5574. * Removes specific tags from a specific object
  5575. * @param obj defines the object to use
  5576. * @param tagsString defines the tags to remove
  5577. */
  5578. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5579. /**
  5580. * @hidden
  5581. */
  5582. static _RemoveTagFrom(obj: any, tag: string): void;
  5583. /**
  5584. * Defines if tags hosted on an object match a given query
  5585. * @param obj defines the object to use
  5586. * @param tagsQuery defines the tag query
  5587. * @returns a boolean
  5588. */
  5589. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5590. }
  5591. }
  5592. declare module BABYLON {
  5593. /**
  5594. * Defines potential orientation for back face culling
  5595. */
  5596. export enum Orientation {
  5597. /**
  5598. * Clockwise
  5599. */
  5600. CW = 0,
  5601. /** Counter clockwise */
  5602. CCW = 1
  5603. }
  5604. /** Class used to represent a Bezier curve */
  5605. export class BezierCurve {
  5606. /**
  5607. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5608. * @param t defines the time
  5609. * @param x1 defines the left coordinate on X axis
  5610. * @param y1 defines the left coordinate on Y axis
  5611. * @param x2 defines the right coordinate on X axis
  5612. * @param y2 defines the right coordinate on Y axis
  5613. * @returns the interpolated value
  5614. */
  5615. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5616. }
  5617. /**
  5618. * Defines angle representation
  5619. */
  5620. export class Angle {
  5621. private _radians;
  5622. /**
  5623. * Creates an Angle object of "radians" radians (float).
  5624. * @param radians the angle in radians
  5625. */
  5626. constructor(radians: number);
  5627. /**
  5628. * Get value in degrees
  5629. * @returns the Angle value in degrees (float)
  5630. */
  5631. degrees(): number;
  5632. /**
  5633. * Get value in radians
  5634. * @returns the Angle value in radians (float)
  5635. */
  5636. radians(): number;
  5637. /**
  5638. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5639. * @param a defines first vector
  5640. * @param b defines second vector
  5641. * @returns a new Angle
  5642. */
  5643. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5644. /**
  5645. * Gets a new Angle object from the given float in radians
  5646. * @param radians defines the angle value in radians
  5647. * @returns a new Angle
  5648. */
  5649. static FromRadians(radians: number): Angle;
  5650. /**
  5651. * Gets a new Angle object from the given float in degrees
  5652. * @param degrees defines the angle value in degrees
  5653. * @returns a new Angle
  5654. */
  5655. static FromDegrees(degrees: number): Angle;
  5656. }
  5657. /**
  5658. * This represents an arc in a 2d space.
  5659. */
  5660. export class Arc2 {
  5661. /** Defines the start point of the arc */
  5662. startPoint: Vector2;
  5663. /** Defines the mid point of the arc */
  5664. midPoint: Vector2;
  5665. /** Defines the end point of the arc */
  5666. endPoint: Vector2;
  5667. /**
  5668. * Defines the center point of the arc.
  5669. */
  5670. centerPoint: Vector2;
  5671. /**
  5672. * Defines the radius of the arc.
  5673. */
  5674. radius: number;
  5675. /**
  5676. * Defines the angle of the arc (from mid point to end point).
  5677. */
  5678. angle: Angle;
  5679. /**
  5680. * Defines the start angle of the arc (from start point to middle point).
  5681. */
  5682. startAngle: Angle;
  5683. /**
  5684. * Defines the orientation of the arc (clock wise/counter clock wise).
  5685. */
  5686. orientation: Orientation;
  5687. /**
  5688. * Creates an Arc object from the three given points : start, middle and end.
  5689. * @param startPoint Defines the start point of the arc
  5690. * @param midPoint Defines the midlle point of the arc
  5691. * @param endPoint Defines the end point of the arc
  5692. */
  5693. constructor(
  5694. /** Defines the start point of the arc */
  5695. startPoint: Vector2,
  5696. /** Defines the mid point of the arc */
  5697. midPoint: Vector2,
  5698. /** Defines the end point of the arc */
  5699. endPoint: Vector2);
  5700. }
  5701. /**
  5702. * Represents a 2D path made up of multiple 2D points
  5703. */
  5704. export class Path2 {
  5705. private _points;
  5706. private _length;
  5707. /**
  5708. * If the path start and end point are the same
  5709. */
  5710. closed: boolean;
  5711. /**
  5712. * Creates a Path2 object from the starting 2D coordinates x and y.
  5713. * @param x the starting points x value
  5714. * @param y the starting points y value
  5715. */
  5716. constructor(x: number, y: number);
  5717. /**
  5718. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5719. * @param x the added points x value
  5720. * @param y the added points y value
  5721. * @returns the updated Path2.
  5722. */
  5723. addLineTo(x: number, y: number): Path2;
  5724. /**
  5725. * 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.
  5726. * @param midX middle point x value
  5727. * @param midY middle point y value
  5728. * @param endX end point x value
  5729. * @param endY end point y value
  5730. * @param numberOfSegments (default: 36)
  5731. * @returns the updated Path2.
  5732. */
  5733. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5734. /**
  5735. * Closes the Path2.
  5736. * @returns the Path2.
  5737. */
  5738. close(): Path2;
  5739. /**
  5740. * Gets the sum of the distance between each sequential point in the path
  5741. * @returns the Path2 total length (float).
  5742. */
  5743. length(): number;
  5744. /**
  5745. * Gets the points which construct the path
  5746. * @returns the Path2 internal array of points.
  5747. */
  5748. getPoints(): Vector2[];
  5749. /**
  5750. * Retreives the point at the distance aways from the starting point
  5751. * @param normalizedLengthPosition the length along the path to retreive the point from
  5752. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5753. */
  5754. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5755. /**
  5756. * Creates a new path starting from an x and y position
  5757. * @param x starting x value
  5758. * @param y starting y value
  5759. * @returns a new Path2 starting at the coordinates (x, y).
  5760. */
  5761. static StartingAt(x: number, y: number): Path2;
  5762. }
  5763. /**
  5764. * Represents a 3D path made up of multiple 3D points
  5765. */
  5766. export class Path3D {
  5767. /**
  5768. * an array of Vector3, the curve axis of the Path3D
  5769. */
  5770. path: Vector3[];
  5771. private _curve;
  5772. private _distances;
  5773. private _tangents;
  5774. private _normals;
  5775. private _binormals;
  5776. private _raw;
  5777. /**
  5778. * new Path3D(path, normal, raw)
  5779. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5780. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5781. * @param path an array of Vector3, the curve axis of the Path3D
  5782. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5783. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5784. */
  5785. constructor(
  5786. /**
  5787. * an array of Vector3, the curve axis of the Path3D
  5788. */
  5789. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5790. /**
  5791. * Returns the Path3D array of successive Vector3 designing its curve.
  5792. * @returns the Path3D array of successive Vector3 designing its curve.
  5793. */
  5794. getCurve(): Vector3[];
  5795. /**
  5796. * Returns an array populated with tangent vectors on each Path3D curve point.
  5797. * @returns an array populated with tangent vectors on each Path3D curve point.
  5798. */
  5799. getTangents(): Vector3[];
  5800. /**
  5801. * Returns an array populated with normal vectors on each Path3D curve point.
  5802. * @returns an array populated with normal vectors on each Path3D curve point.
  5803. */
  5804. getNormals(): Vector3[];
  5805. /**
  5806. * Returns an array populated with binormal vectors on each Path3D curve point.
  5807. * @returns an array populated with binormal vectors on each Path3D curve point.
  5808. */
  5809. getBinormals(): Vector3[];
  5810. /**
  5811. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5812. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5813. */
  5814. getDistances(): number[];
  5815. /**
  5816. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5817. * @param path path which all values are copied into the curves points
  5818. * @param firstNormal which should be projected onto the curve
  5819. * @returns the same object updated.
  5820. */
  5821. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5822. private _compute;
  5823. private _getFirstNonNullVector;
  5824. private _getLastNonNullVector;
  5825. private _normalVector;
  5826. }
  5827. /**
  5828. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5829. * A Curve3 is designed from a series of successive Vector3.
  5830. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5831. */
  5832. export class Curve3 {
  5833. private _points;
  5834. private _length;
  5835. /**
  5836. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5837. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5838. * @param v1 (Vector3) the control point
  5839. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5840. * @param nbPoints (integer) the wanted number of points in the curve
  5841. * @returns the created Curve3
  5842. */
  5843. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5844. /**
  5845. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5846. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5847. * @param v1 (Vector3) the first control point
  5848. * @param v2 (Vector3) the second control point
  5849. * @param v3 (Vector3) the end point of the Cubic Bezier
  5850. * @param nbPoints (integer) the wanted number of points in the curve
  5851. * @returns the created Curve3
  5852. */
  5853. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5854. /**
  5855. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5856. * @param p1 (Vector3) the origin point of the Hermite Spline
  5857. * @param t1 (Vector3) the tangent vector at the origin point
  5858. * @param p2 (Vector3) the end point of the Hermite Spline
  5859. * @param t2 (Vector3) the tangent vector at the end point
  5860. * @param nbPoints (integer) the wanted number of points in the curve
  5861. * @returns the created Curve3
  5862. */
  5863. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5864. /**
  5865. * Returns a Curve3 object along a CatmullRom Spline curve :
  5866. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5867. * @param nbPoints (integer) the wanted number of points between each curve control points
  5868. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5869. * @returns the created Curve3
  5870. */
  5871. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5872. /**
  5873. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5874. * A Curve3 is designed from a series of successive Vector3.
  5875. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5876. * @param points points which make up the curve
  5877. */
  5878. constructor(points: Vector3[]);
  5879. /**
  5880. * @returns the Curve3 stored array of successive Vector3
  5881. */
  5882. getPoints(): Vector3[];
  5883. /**
  5884. * @returns the computed length (float) of the curve.
  5885. */
  5886. length(): number;
  5887. /**
  5888. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5889. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5890. * curveA and curveB keep unchanged.
  5891. * @param curve the curve to continue from this curve
  5892. * @returns the newly constructed curve
  5893. */
  5894. continue(curve: DeepImmutable<Curve3>): Curve3;
  5895. private _computeLength;
  5896. }
  5897. }
  5898. declare module BABYLON {
  5899. /**
  5900. * This represents the main contract an easing function should follow.
  5901. * Easing functions are used throughout the animation system.
  5902. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5903. */
  5904. export interface IEasingFunction {
  5905. /**
  5906. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5907. * of the easing function.
  5908. * The link below provides some of the most common examples of easing functions.
  5909. * @see https://easings.net/
  5910. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5911. * @returns the corresponding value on the curve defined by the easing function
  5912. */
  5913. ease(gradient: number): number;
  5914. }
  5915. /**
  5916. * Base class used for every default easing function.
  5917. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5918. */
  5919. export class EasingFunction implements IEasingFunction {
  5920. /**
  5921. * Interpolation follows the mathematical formula associated with the easing function.
  5922. */
  5923. static readonly EASINGMODE_EASEIN: number;
  5924. /**
  5925. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5926. */
  5927. static readonly EASINGMODE_EASEOUT: number;
  5928. /**
  5929. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5930. */
  5931. static readonly EASINGMODE_EASEINOUT: number;
  5932. private _easingMode;
  5933. /**
  5934. * Sets the easing mode of the current function.
  5935. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5936. */
  5937. setEasingMode(easingMode: number): void;
  5938. /**
  5939. * Gets the current easing mode.
  5940. * @returns the easing mode
  5941. */
  5942. getEasingMode(): number;
  5943. /**
  5944. * @hidden
  5945. */
  5946. easeInCore(gradient: number): number;
  5947. /**
  5948. * Given an input gradient between 0 and 1, this returns the corresponding value
  5949. * of the easing function.
  5950. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5951. * @returns the corresponding value on the curve defined by the easing function
  5952. */
  5953. ease(gradient: number): number;
  5954. }
  5955. /**
  5956. * Easing function with a circle shape (see link below).
  5957. * @see https://easings.net/#easeInCirc
  5958. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5959. */
  5960. export class CircleEase extends EasingFunction implements IEasingFunction {
  5961. /** @hidden */
  5962. easeInCore(gradient: number): number;
  5963. }
  5964. /**
  5965. * Easing function with a ease back shape (see link below).
  5966. * @see https://easings.net/#easeInBack
  5967. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5968. */
  5969. export class BackEase extends EasingFunction implements IEasingFunction {
  5970. /** Defines the amplitude of the function */
  5971. amplitude: number;
  5972. /**
  5973. * Instantiates a back ease easing
  5974. * @see https://easings.net/#easeInBack
  5975. * @param amplitude Defines the amplitude of the function
  5976. */
  5977. constructor(
  5978. /** Defines the amplitude of the function */
  5979. amplitude?: number);
  5980. /** @hidden */
  5981. easeInCore(gradient: number): number;
  5982. }
  5983. /**
  5984. * Easing function with a bouncing shape (see link below).
  5985. * @see https://easings.net/#easeInBounce
  5986. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5987. */
  5988. export class BounceEase extends EasingFunction implements IEasingFunction {
  5989. /** Defines the number of bounces */
  5990. bounces: number;
  5991. /** Defines the amplitude of the bounce */
  5992. bounciness: number;
  5993. /**
  5994. * Instantiates a bounce easing
  5995. * @see https://easings.net/#easeInBounce
  5996. * @param bounces Defines the number of bounces
  5997. * @param bounciness Defines the amplitude of the bounce
  5998. */
  5999. constructor(
  6000. /** Defines the number of bounces */
  6001. bounces?: number,
  6002. /** Defines the amplitude of the bounce */
  6003. bounciness?: number);
  6004. /** @hidden */
  6005. easeInCore(gradient: number): number;
  6006. }
  6007. /**
  6008. * Easing function with a power of 3 shape (see link below).
  6009. * @see https://easings.net/#easeInCubic
  6010. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6011. */
  6012. export class CubicEase extends EasingFunction implements IEasingFunction {
  6013. /** @hidden */
  6014. easeInCore(gradient: number): number;
  6015. }
  6016. /**
  6017. * Easing function with an elastic shape (see link below).
  6018. * @see https://easings.net/#easeInElastic
  6019. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6020. */
  6021. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6022. /** Defines the number of oscillations*/
  6023. oscillations: number;
  6024. /** Defines the amplitude of the oscillations*/
  6025. springiness: number;
  6026. /**
  6027. * Instantiates an elastic easing function
  6028. * @see https://easings.net/#easeInElastic
  6029. * @param oscillations Defines the number of oscillations
  6030. * @param springiness Defines the amplitude of the oscillations
  6031. */
  6032. constructor(
  6033. /** Defines the number of oscillations*/
  6034. oscillations?: number,
  6035. /** Defines the amplitude of the oscillations*/
  6036. springiness?: number);
  6037. /** @hidden */
  6038. easeInCore(gradient: number): number;
  6039. }
  6040. /**
  6041. * Easing function with an exponential shape (see link below).
  6042. * @see https://easings.net/#easeInExpo
  6043. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6044. */
  6045. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6046. /** Defines the exponent of the function */
  6047. exponent: number;
  6048. /**
  6049. * Instantiates an exponential easing function
  6050. * @see https://easings.net/#easeInExpo
  6051. * @param exponent Defines the exponent of the function
  6052. */
  6053. constructor(
  6054. /** Defines the exponent of the function */
  6055. exponent?: number);
  6056. /** @hidden */
  6057. easeInCore(gradient: number): number;
  6058. }
  6059. /**
  6060. * Easing function with a power shape (see link below).
  6061. * @see https://easings.net/#easeInQuad
  6062. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6063. */
  6064. export class PowerEase extends EasingFunction implements IEasingFunction {
  6065. /** Defines the power of the function */
  6066. power: number;
  6067. /**
  6068. * Instantiates an power base easing function
  6069. * @see https://easings.net/#easeInQuad
  6070. * @param power Defines the power of the function
  6071. */
  6072. constructor(
  6073. /** Defines the power of the function */
  6074. power?: number);
  6075. /** @hidden */
  6076. easeInCore(gradient: number): number;
  6077. }
  6078. /**
  6079. * Easing function with a power of 2 shape (see link below).
  6080. * @see https://easings.net/#easeInQuad
  6081. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6082. */
  6083. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6084. /** @hidden */
  6085. easeInCore(gradient: number): number;
  6086. }
  6087. /**
  6088. * Easing function with a power of 4 shape (see link below).
  6089. * @see https://easings.net/#easeInQuart
  6090. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6091. */
  6092. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6093. /** @hidden */
  6094. easeInCore(gradient: number): number;
  6095. }
  6096. /**
  6097. * Easing function with a power of 5 shape (see link below).
  6098. * @see https://easings.net/#easeInQuint
  6099. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6100. */
  6101. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6102. /** @hidden */
  6103. easeInCore(gradient: number): number;
  6104. }
  6105. /**
  6106. * Easing function with a sin shape (see link below).
  6107. * @see https://easings.net/#easeInSine
  6108. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6109. */
  6110. export class SineEase extends EasingFunction implements IEasingFunction {
  6111. /** @hidden */
  6112. easeInCore(gradient: number): number;
  6113. }
  6114. /**
  6115. * Easing function with a bezier shape (see link below).
  6116. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6117. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6118. */
  6119. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6120. /** Defines the x component of the start tangent in the bezier curve */
  6121. x1: number;
  6122. /** Defines the y component of the start tangent in the bezier curve */
  6123. y1: number;
  6124. /** Defines the x component of the end tangent in the bezier curve */
  6125. x2: number;
  6126. /** Defines the y component of the end tangent in the bezier curve */
  6127. y2: number;
  6128. /**
  6129. * Instantiates a bezier function
  6130. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6131. * @param x1 Defines the x component of the start tangent in the bezier curve
  6132. * @param y1 Defines the y component of the start tangent in the bezier curve
  6133. * @param x2 Defines the x component of the end tangent in the bezier curve
  6134. * @param y2 Defines the y component of the end tangent in the bezier curve
  6135. */
  6136. constructor(
  6137. /** Defines the x component of the start tangent in the bezier curve */
  6138. x1?: number,
  6139. /** Defines the y component of the start tangent in the bezier curve */
  6140. y1?: number,
  6141. /** Defines the x component of the end tangent in the bezier curve */
  6142. x2?: number,
  6143. /** Defines the y component of the end tangent in the bezier curve */
  6144. y2?: number);
  6145. /** @hidden */
  6146. easeInCore(gradient: number): number;
  6147. }
  6148. }
  6149. declare module BABYLON {
  6150. /**
  6151. * Defines an interface which represents an animation key frame
  6152. */
  6153. export interface IAnimationKey {
  6154. /**
  6155. * Frame of the key frame
  6156. */
  6157. frame: number;
  6158. /**
  6159. * Value at the specifies key frame
  6160. */
  6161. value: any;
  6162. /**
  6163. * The input tangent for the cubic hermite spline
  6164. */
  6165. inTangent?: any;
  6166. /**
  6167. * The output tangent for the cubic hermite spline
  6168. */
  6169. outTangent?: any;
  6170. /**
  6171. * The animation interpolation type
  6172. */
  6173. interpolation?: AnimationKeyInterpolation;
  6174. }
  6175. /**
  6176. * Enum for the animation key frame interpolation type
  6177. */
  6178. export enum AnimationKeyInterpolation {
  6179. /**
  6180. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6181. */
  6182. STEP = 1
  6183. }
  6184. }
  6185. declare module BABYLON {
  6186. /**
  6187. * Represents the range of an animation
  6188. */
  6189. export class AnimationRange {
  6190. /**The name of the animation range**/
  6191. name: string;
  6192. /**The starting frame of the animation */
  6193. from: number;
  6194. /**The ending frame of the animation*/
  6195. to: number;
  6196. /**
  6197. * Initializes the range of an animation
  6198. * @param name The name of the animation range
  6199. * @param from The starting frame of the animation
  6200. * @param to The ending frame of the animation
  6201. */
  6202. constructor(
  6203. /**The name of the animation range**/
  6204. name: string,
  6205. /**The starting frame of the animation */
  6206. from: number,
  6207. /**The ending frame of the animation*/
  6208. to: number);
  6209. /**
  6210. * Makes a copy of the animation range
  6211. * @returns A copy of the animation range
  6212. */
  6213. clone(): AnimationRange;
  6214. }
  6215. }
  6216. declare module BABYLON {
  6217. /**
  6218. * Composed of a frame, and an action function
  6219. */
  6220. export class AnimationEvent {
  6221. /** The frame for which the event is triggered **/
  6222. frame: number;
  6223. /** The event to perform when triggered **/
  6224. action: (currentFrame: number) => void;
  6225. /** Specifies if the event should be triggered only once**/
  6226. onlyOnce?: boolean | undefined;
  6227. /**
  6228. * Specifies if the animation event is done
  6229. */
  6230. isDone: boolean;
  6231. /**
  6232. * Initializes the animation event
  6233. * @param frame The frame for which the event is triggered
  6234. * @param action The event to perform when triggered
  6235. * @param onlyOnce Specifies if the event should be triggered only once
  6236. */
  6237. constructor(
  6238. /** The frame for which the event is triggered **/
  6239. frame: number,
  6240. /** The event to perform when triggered **/
  6241. action: (currentFrame: number) => void,
  6242. /** Specifies if the event should be triggered only once**/
  6243. onlyOnce?: boolean | undefined);
  6244. /** @hidden */
  6245. _clone(): AnimationEvent;
  6246. }
  6247. }
  6248. declare module BABYLON {
  6249. /**
  6250. * Interface used to define a behavior
  6251. */
  6252. export interface Behavior<T> {
  6253. /** gets or sets behavior's name */
  6254. name: string;
  6255. /**
  6256. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6257. */
  6258. init(): void;
  6259. /**
  6260. * Called when the behavior is attached to a target
  6261. * @param target defines the target where the behavior is attached to
  6262. */
  6263. attach(target: T): void;
  6264. /**
  6265. * Called when the behavior is detached from its target
  6266. */
  6267. detach(): void;
  6268. }
  6269. /**
  6270. * Interface implemented by classes supporting behaviors
  6271. */
  6272. export interface IBehaviorAware<T> {
  6273. /**
  6274. * Attach a behavior
  6275. * @param behavior defines the behavior to attach
  6276. * @returns the current host
  6277. */
  6278. addBehavior(behavior: Behavior<T>): T;
  6279. /**
  6280. * Remove a behavior from the current object
  6281. * @param behavior defines the behavior to detach
  6282. * @returns the current host
  6283. */
  6284. removeBehavior(behavior: Behavior<T>): T;
  6285. /**
  6286. * Gets a behavior using its name to search
  6287. * @param name defines the name to search
  6288. * @returns the behavior or null if not found
  6289. */
  6290. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6291. }
  6292. }
  6293. declare module BABYLON {
  6294. /**
  6295. * Defines an array and its length.
  6296. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6297. */
  6298. export interface ISmartArrayLike<T> {
  6299. /**
  6300. * The data of the array.
  6301. */
  6302. data: Array<T>;
  6303. /**
  6304. * The active length of the array.
  6305. */
  6306. length: number;
  6307. }
  6308. /**
  6309. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6310. */
  6311. export class SmartArray<T> implements ISmartArrayLike<T> {
  6312. /**
  6313. * The full set of data from the array.
  6314. */
  6315. data: Array<T>;
  6316. /**
  6317. * The active length of the array.
  6318. */
  6319. length: number;
  6320. protected _id: number;
  6321. /**
  6322. * Instantiates a Smart Array.
  6323. * @param capacity defines the default capacity of the array.
  6324. */
  6325. constructor(capacity: number);
  6326. /**
  6327. * Pushes a value at the end of the active data.
  6328. * @param value defines the object to push in the array.
  6329. */
  6330. push(value: T): void;
  6331. /**
  6332. * Iterates over the active data and apply the lambda to them.
  6333. * @param func defines the action to apply on each value.
  6334. */
  6335. forEach(func: (content: T) => void): void;
  6336. /**
  6337. * Sorts the full sets of data.
  6338. * @param compareFn defines the comparison function to apply.
  6339. */
  6340. sort(compareFn: (a: T, b: T) => number): void;
  6341. /**
  6342. * Resets the active data to an empty array.
  6343. */
  6344. reset(): void;
  6345. /**
  6346. * Releases all the data from the array as well as the array.
  6347. */
  6348. dispose(): void;
  6349. /**
  6350. * Concats the active data with a given array.
  6351. * @param array defines the data to concatenate with.
  6352. */
  6353. concat(array: any): void;
  6354. /**
  6355. * Returns the position of a value in the active data.
  6356. * @param value defines the value to find the index for
  6357. * @returns the index if found in the active data otherwise -1
  6358. */
  6359. indexOf(value: T): number;
  6360. /**
  6361. * Returns whether an element is part of the active data.
  6362. * @param value defines the value to look for
  6363. * @returns true if found in the active data otherwise false
  6364. */
  6365. contains(value: T): boolean;
  6366. private static _GlobalId;
  6367. }
  6368. /**
  6369. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6370. * The data in this array can only be present once
  6371. */
  6372. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6373. private _duplicateId;
  6374. /**
  6375. * Pushes a value at the end of the active data.
  6376. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6377. * @param value defines the object to push in the array.
  6378. */
  6379. push(value: T): void;
  6380. /**
  6381. * Pushes a value at the end of the active data.
  6382. * If the data is already present, it won t be added again
  6383. * @param value defines the object to push in the array.
  6384. * @returns true if added false if it was already present
  6385. */
  6386. pushNoDuplicate(value: T): boolean;
  6387. /**
  6388. * Resets the active data to an empty array.
  6389. */
  6390. reset(): void;
  6391. /**
  6392. * Concats the active data with a given array.
  6393. * This ensures no dupplicate will be present in the result.
  6394. * @param array defines the data to concatenate with.
  6395. */
  6396. concatWithNoDuplicate(array: any): void;
  6397. }
  6398. }
  6399. declare module BABYLON {
  6400. /**
  6401. * @ignore
  6402. * This is a list of all the different input types that are available in the application.
  6403. * Fo instance: ArcRotateCameraGamepadInput...
  6404. */
  6405. export var CameraInputTypes: {};
  6406. /**
  6407. * This is the contract to implement in order to create a new input class.
  6408. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6409. */
  6410. export interface ICameraInput<TCamera extends Camera> {
  6411. /**
  6412. * Defines the camera the input is attached to.
  6413. */
  6414. camera: Nullable<TCamera>;
  6415. /**
  6416. * Gets the class name of the current intput.
  6417. * @returns the class name
  6418. */
  6419. getClassName(): string;
  6420. /**
  6421. * Get the friendly name associated with the input class.
  6422. * @returns the input friendly name
  6423. */
  6424. getSimpleName(): string;
  6425. /**
  6426. * Attach the input controls to a specific dom element to get the input from.
  6427. * @param element Defines the element the controls should be listened from
  6428. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6429. */
  6430. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6431. /**
  6432. * Detach the current controls from the specified dom element.
  6433. * @param element Defines the element to stop listening the inputs from
  6434. */
  6435. detachControl(element: Nullable<HTMLElement>): void;
  6436. /**
  6437. * Update the current camera state depending on the inputs that have been used this frame.
  6438. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6439. */
  6440. checkInputs?: () => void;
  6441. }
  6442. /**
  6443. * Represents a map of input types to input instance or input index to input instance.
  6444. */
  6445. export interface CameraInputsMap<TCamera extends Camera> {
  6446. /**
  6447. * Accessor to the input by input type.
  6448. */
  6449. [name: string]: ICameraInput<TCamera>;
  6450. /**
  6451. * Accessor to the input by input index.
  6452. */
  6453. [idx: number]: ICameraInput<TCamera>;
  6454. }
  6455. /**
  6456. * This represents the input manager used within a camera.
  6457. * It helps dealing with all the different kind of input attached to a camera.
  6458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6459. */
  6460. export class CameraInputsManager<TCamera extends Camera> {
  6461. /**
  6462. * Defines the list of inputs attahed to the camera.
  6463. */
  6464. attached: CameraInputsMap<TCamera>;
  6465. /**
  6466. * Defines the dom element the camera is collecting inputs from.
  6467. * This is null if the controls have not been attached.
  6468. */
  6469. attachedElement: Nullable<HTMLElement>;
  6470. /**
  6471. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6472. */
  6473. noPreventDefault: boolean;
  6474. /**
  6475. * Defined the camera the input manager belongs to.
  6476. */
  6477. camera: TCamera;
  6478. /**
  6479. * Update the current camera state depending on the inputs that have been used this frame.
  6480. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6481. */
  6482. checkInputs: () => void;
  6483. /**
  6484. * Instantiate a new Camera Input Manager.
  6485. * @param camera Defines the camera the input manager blongs to
  6486. */
  6487. constructor(camera: TCamera);
  6488. /**
  6489. * Add an input method to a camera
  6490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6491. * @param input camera input method
  6492. */
  6493. add(input: ICameraInput<TCamera>): void;
  6494. /**
  6495. * Remove a specific input method from a camera
  6496. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6497. * @param inputToRemove camera input method
  6498. */
  6499. remove(inputToRemove: ICameraInput<TCamera>): void;
  6500. /**
  6501. * Remove a specific input type from a camera
  6502. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6503. * @param inputType the type of the input to remove
  6504. */
  6505. removeByType(inputType: string): void;
  6506. private _addCheckInputs;
  6507. /**
  6508. * Attach the input controls to the currently attached dom element to listen the events from.
  6509. * @param input Defines the input to attach
  6510. */
  6511. attachInput(input: ICameraInput<TCamera>): void;
  6512. /**
  6513. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6514. * @param element Defines the dom element to collect the events from
  6515. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6516. */
  6517. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6518. /**
  6519. * Detach the current manager inputs controls from a specific dom element.
  6520. * @param element Defines the dom element to collect the events from
  6521. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6522. */
  6523. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6524. /**
  6525. * Rebuild the dynamic inputCheck function from the current list of
  6526. * defined inputs in the manager.
  6527. */
  6528. rebuildInputCheck(): void;
  6529. /**
  6530. * Remove all attached input methods from a camera
  6531. */
  6532. clear(): void;
  6533. /**
  6534. * Serialize the current input manager attached to a camera.
  6535. * This ensures than once parsed,
  6536. * the input associated to the camera will be identical to the current ones
  6537. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6538. */
  6539. serialize(serializedCamera: any): void;
  6540. /**
  6541. * Parses an input manager serialized JSON to restore the previous list of inputs
  6542. * and states associated to a camera.
  6543. * @param parsedCamera Defines the JSON to parse
  6544. */
  6545. parse(parsedCamera: any): void;
  6546. }
  6547. }
  6548. declare module BABYLON {
  6549. /**
  6550. * @hidden
  6551. */
  6552. export class IntersectionInfo {
  6553. bu: Nullable<number>;
  6554. bv: Nullable<number>;
  6555. distance: number;
  6556. faceId: number;
  6557. subMeshId: number;
  6558. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6559. }
  6560. }
  6561. declare module BABYLON {
  6562. /**
  6563. * Represens a plane by the equation ax + by + cz + d = 0
  6564. */
  6565. export class Plane {
  6566. private static _TmpMatrix;
  6567. /**
  6568. * Normal of the plane (a,b,c)
  6569. */
  6570. normal: Vector3;
  6571. /**
  6572. * d component of the plane
  6573. */
  6574. d: number;
  6575. /**
  6576. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6577. * @param a a component of the plane
  6578. * @param b b component of the plane
  6579. * @param c c component of the plane
  6580. * @param d d component of the plane
  6581. */
  6582. constructor(a: number, b: number, c: number, d: number);
  6583. /**
  6584. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6585. */
  6586. asArray(): number[];
  6587. /**
  6588. * @returns a new plane copied from the current Plane.
  6589. */
  6590. clone(): Plane;
  6591. /**
  6592. * @returns the string "Plane".
  6593. */
  6594. getClassName(): string;
  6595. /**
  6596. * @returns the Plane hash code.
  6597. */
  6598. getHashCode(): number;
  6599. /**
  6600. * Normalize the current Plane in place.
  6601. * @returns the updated Plane.
  6602. */
  6603. normalize(): Plane;
  6604. /**
  6605. * Applies a transformation the plane and returns the result
  6606. * @param transformation the transformation matrix to be applied to the plane
  6607. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6608. */
  6609. transform(transformation: DeepImmutable<Matrix>): Plane;
  6610. /**
  6611. * Calcualtte the dot product between the point and the plane normal
  6612. * @param point point to calculate the dot product with
  6613. * @returns the dot product (float) of the point coordinates and the plane normal.
  6614. */
  6615. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6616. /**
  6617. * Updates the current Plane from the plane defined by the three given points.
  6618. * @param point1 one of the points used to contruct the plane
  6619. * @param point2 one of the points used to contruct the plane
  6620. * @param point3 one of the points used to contruct the plane
  6621. * @returns the updated Plane.
  6622. */
  6623. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6624. /**
  6625. * Checks if the plane is facing a given direction
  6626. * @param direction the direction to check if the plane is facing
  6627. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6628. * @returns True is the vector "direction" is the same side than the plane normal.
  6629. */
  6630. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6631. /**
  6632. * Calculates the distance to a point
  6633. * @param point point to calculate distance to
  6634. * @returns the signed distance (float) from the given point to the Plane.
  6635. */
  6636. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6637. /**
  6638. * Creates a plane from an array
  6639. * @param array the array to create a plane from
  6640. * @returns a new Plane from the given array.
  6641. */
  6642. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6643. /**
  6644. * Creates a plane from three points
  6645. * @param point1 point used to create the plane
  6646. * @param point2 point used to create the plane
  6647. * @param point3 point used to create the plane
  6648. * @returns a new Plane defined by the three given points.
  6649. */
  6650. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6651. /**
  6652. * Creates a plane from an origin point and a normal
  6653. * @param origin origin of the plane to be constructed
  6654. * @param normal normal of the plane to be constructed
  6655. * @returns a new Plane the normal vector to this plane at the given origin point.
  6656. * Note : the vector "normal" is updated because normalized.
  6657. */
  6658. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6659. /**
  6660. * Calculates the distance from a plane and a point
  6661. * @param origin origin of the plane to be constructed
  6662. * @param normal normal of the plane to be constructed
  6663. * @param point point to calculate distance to
  6664. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6665. */
  6666. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6667. }
  6668. }
  6669. declare module BABYLON {
  6670. /**
  6671. * Class used to store bounding sphere information
  6672. */
  6673. export class BoundingSphere {
  6674. /**
  6675. * Gets the center of the bounding sphere in local space
  6676. */
  6677. readonly center: Vector3;
  6678. /**
  6679. * Radius of the bounding sphere in local space
  6680. */
  6681. radius: number;
  6682. /**
  6683. * Gets the center of the bounding sphere in world space
  6684. */
  6685. readonly centerWorld: Vector3;
  6686. /**
  6687. * Radius of the bounding sphere in world space
  6688. */
  6689. radiusWorld: number;
  6690. /**
  6691. * Gets the minimum vector in local space
  6692. */
  6693. readonly minimum: Vector3;
  6694. /**
  6695. * Gets the maximum vector in local space
  6696. */
  6697. readonly maximum: Vector3;
  6698. private _worldMatrix;
  6699. private static readonly TmpVector3;
  6700. /**
  6701. * Creates a new bounding sphere
  6702. * @param min defines the minimum vector (in local space)
  6703. * @param max defines the maximum vector (in local space)
  6704. * @param worldMatrix defines the new world matrix
  6705. */
  6706. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6707. /**
  6708. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6709. * @param min defines the new minimum vector (in local space)
  6710. * @param max defines the new maximum vector (in local space)
  6711. * @param worldMatrix defines the new world matrix
  6712. */
  6713. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6714. /**
  6715. * Scale the current bounding sphere by applying a scale factor
  6716. * @param factor defines the scale factor to apply
  6717. * @returns the current bounding box
  6718. */
  6719. scale(factor: number): BoundingSphere;
  6720. /**
  6721. * Gets the world matrix of the bounding box
  6722. * @returns a matrix
  6723. */
  6724. getWorldMatrix(): DeepImmutable<Matrix>;
  6725. /** @hidden */
  6726. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6727. /**
  6728. * Tests if the bounding sphere is intersecting the frustum planes
  6729. * @param frustumPlanes defines the frustum planes to test
  6730. * @returns true if there is an intersection
  6731. */
  6732. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6733. /**
  6734. * Tests if the bounding sphere center is in between the frustum planes.
  6735. * Used for optimistic fast inclusion.
  6736. * @param frustumPlanes defines the frustum planes to test
  6737. * @returns true if the sphere center is in between the frustum planes
  6738. */
  6739. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6740. /**
  6741. * Tests if a point is inside the bounding sphere
  6742. * @param point defines the point to test
  6743. * @returns true if the point is inside the bounding sphere
  6744. */
  6745. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6746. /**
  6747. * Checks if two sphere intersct
  6748. * @param sphere0 sphere 0
  6749. * @param sphere1 sphere 1
  6750. * @returns true if the speres intersect
  6751. */
  6752. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6753. }
  6754. }
  6755. declare module BABYLON {
  6756. /**
  6757. * Class used to store bounding box information
  6758. */
  6759. export class BoundingBox implements ICullable {
  6760. /**
  6761. * Gets the 8 vectors representing the bounding box in local space
  6762. */
  6763. readonly vectors: Vector3[];
  6764. /**
  6765. * Gets the center of the bounding box in local space
  6766. */
  6767. readonly center: Vector3;
  6768. /**
  6769. * Gets the center of the bounding box in world space
  6770. */
  6771. readonly centerWorld: Vector3;
  6772. /**
  6773. * Gets the extend size in local space
  6774. */
  6775. readonly extendSize: Vector3;
  6776. /**
  6777. * Gets the extend size in world space
  6778. */
  6779. readonly extendSizeWorld: Vector3;
  6780. /**
  6781. * Gets the OBB (object bounding box) directions
  6782. */
  6783. readonly directions: Vector3[];
  6784. /**
  6785. * Gets the 8 vectors representing the bounding box in world space
  6786. */
  6787. readonly vectorsWorld: Vector3[];
  6788. /**
  6789. * Gets the minimum vector in world space
  6790. */
  6791. readonly minimumWorld: Vector3;
  6792. /**
  6793. * Gets the maximum vector in world space
  6794. */
  6795. readonly maximumWorld: Vector3;
  6796. /**
  6797. * Gets the minimum vector in local space
  6798. */
  6799. readonly minimum: Vector3;
  6800. /**
  6801. * Gets the maximum vector in local space
  6802. */
  6803. readonly maximum: Vector3;
  6804. private _worldMatrix;
  6805. private static readonly TmpVector3;
  6806. /**
  6807. * @hidden
  6808. */
  6809. _tag: number;
  6810. /**
  6811. * Creates a new bounding box
  6812. * @param min defines the minimum vector (in local space)
  6813. * @param max defines the maximum vector (in local space)
  6814. * @param worldMatrix defines the new world matrix
  6815. */
  6816. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6817. /**
  6818. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6819. * @param min defines the new minimum vector (in local space)
  6820. * @param max defines the new maximum vector (in local space)
  6821. * @param worldMatrix defines the new world matrix
  6822. */
  6823. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6824. /**
  6825. * Scale the current bounding box by applying a scale factor
  6826. * @param factor defines the scale factor to apply
  6827. * @returns the current bounding box
  6828. */
  6829. scale(factor: number): BoundingBox;
  6830. /**
  6831. * Gets the world matrix of the bounding box
  6832. * @returns a matrix
  6833. */
  6834. getWorldMatrix(): DeepImmutable<Matrix>;
  6835. /** @hidden */
  6836. _update(world: DeepImmutable<Matrix>): void;
  6837. /**
  6838. * Tests if the bounding box is intersecting the frustum planes
  6839. * @param frustumPlanes defines the frustum planes to test
  6840. * @returns true if there is an intersection
  6841. */
  6842. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6843. /**
  6844. * Tests if the bounding box is entirely inside the frustum planes
  6845. * @param frustumPlanes defines the frustum planes to test
  6846. * @returns true if there is an inclusion
  6847. */
  6848. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6849. /**
  6850. * Tests if a point is inside the bounding box
  6851. * @param point defines the point to test
  6852. * @returns true if the point is inside the bounding box
  6853. */
  6854. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6855. /**
  6856. * Tests if the bounding box intersects with a bounding sphere
  6857. * @param sphere defines the sphere to test
  6858. * @returns true if there is an intersection
  6859. */
  6860. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6861. /**
  6862. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6863. * @param min defines the min vector to use
  6864. * @param max defines the max vector to use
  6865. * @returns true if there is an intersection
  6866. */
  6867. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6868. /**
  6869. * Tests if two bounding boxes are intersections
  6870. * @param box0 defines the first box to test
  6871. * @param box1 defines the second box to test
  6872. * @returns true if there is an intersection
  6873. */
  6874. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6875. /**
  6876. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6877. * @param minPoint defines the minimum vector of the bounding box
  6878. * @param maxPoint defines the maximum vector of the bounding box
  6879. * @param sphereCenter defines the sphere center
  6880. * @param sphereRadius defines the sphere radius
  6881. * @returns true if there is an intersection
  6882. */
  6883. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6884. /**
  6885. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6886. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6887. * @param frustumPlanes defines the frustum planes to test
  6888. * @return true if there is an inclusion
  6889. */
  6890. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6891. /**
  6892. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6893. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6894. * @param frustumPlanes defines the frustum planes to test
  6895. * @return true if there is an intersection
  6896. */
  6897. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6898. }
  6899. }
  6900. declare module BABYLON {
  6901. /** @hidden */
  6902. export class Collider {
  6903. /** Define if a collision was found */
  6904. collisionFound: boolean;
  6905. /**
  6906. * Define last intersection point in local space
  6907. */
  6908. intersectionPoint: Vector3;
  6909. /**
  6910. * Define last collided mesh
  6911. */
  6912. collidedMesh: Nullable<AbstractMesh>;
  6913. private _collisionPoint;
  6914. private _planeIntersectionPoint;
  6915. private _tempVector;
  6916. private _tempVector2;
  6917. private _tempVector3;
  6918. private _tempVector4;
  6919. private _edge;
  6920. private _baseToVertex;
  6921. private _destinationPoint;
  6922. private _slidePlaneNormal;
  6923. private _displacementVector;
  6924. /** @hidden */
  6925. _radius: Vector3;
  6926. /** @hidden */
  6927. _retry: number;
  6928. private _velocity;
  6929. private _basePoint;
  6930. private _epsilon;
  6931. /** @hidden */
  6932. _velocityWorldLength: number;
  6933. /** @hidden */
  6934. _basePointWorld: Vector3;
  6935. private _velocityWorld;
  6936. private _normalizedVelocity;
  6937. /** @hidden */
  6938. _initialVelocity: Vector3;
  6939. /** @hidden */
  6940. _initialPosition: Vector3;
  6941. private _nearestDistance;
  6942. private _collisionMask;
  6943. collisionMask: number;
  6944. /**
  6945. * Gets the plane normal used to compute the sliding response (in local space)
  6946. */
  6947. readonly slidePlaneNormal: Vector3;
  6948. /** @hidden */
  6949. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6950. /** @hidden */
  6951. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6952. /** @hidden */
  6953. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6954. /** @hidden */
  6955. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6956. /** @hidden */
  6957. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6958. /** @hidden */
  6959. _getResponse(pos: Vector3, vel: Vector3): void;
  6960. }
  6961. }
  6962. declare module BABYLON {
  6963. /**
  6964. * Interface for cullable objects
  6965. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6966. */
  6967. export interface ICullable {
  6968. /**
  6969. * Checks if the object or part of the object is in the frustum
  6970. * @param frustumPlanes Camera near/planes
  6971. * @returns true if the object is in frustum otherwise false
  6972. */
  6973. isInFrustum(frustumPlanes: Plane[]): boolean;
  6974. /**
  6975. * Checks if a cullable object (mesh...) is in the camera frustum
  6976. * Unlike isInFrustum this cheks the full bounding box
  6977. * @param frustumPlanes Camera near/planes
  6978. * @returns true if the object is in frustum otherwise false
  6979. */
  6980. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6981. }
  6982. /**
  6983. * Info for a bounding data of a mesh
  6984. */
  6985. export class BoundingInfo implements ICullable {
  6986. /**
  6987. * Bounding box for the mesh
  6988. */
  6989. readonly boundingBox: BoundingBox;
  6990. /**
  6991. * Bounding sphere for the mesh
  6992. */
  6993. readonly boundingSphere: BoundingSphere;
  6994. private _isLocked;
  6995. private static readonly TmpVector3;
  6996. /**
  6997. * Constructs bounding info
  6998. * @param minimum min vector of the bounding box/sphere
  6999. * @param maximum max vector of the bounding box/sphere
  7000. * @param worldMatrix defines the new world matrix
  7001. */
  7002. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7003. /**
  7004. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7005. * @param min defines the new minimum vector (in local space)
  7006. * @param max defines the new maximum vector (in local space)
  7007. * @param worldMatrix defines the new world matrix
  7008. */
  7009. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7010. /**
  7011. * min vector of the bounding box/sphere
  7012. */
  7013. readonly minimum: Vector3;
  7014. /**
  7015. * max vector of the bounding box/sphere
  7016. */
  7017. readonly maximum: Vector3;
  7018. /**
  7019. * If the info is locked and won't be updated to avoid perf overhead
  7020. */
  7021. isLocked: boolean;
  7022. /**
  7023. * Updates the bounding sphere and box
  7024. * @param world world matrix to be used to update
  7025. */
  7026. update(world: DeepImmutable<Matrix>): void;
  7027. /**
  7028. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7029. * @param center New center of the bounding info
  7030. * @param extend New extend of the bounding info
  7031. * @returns the current bounding info
  7032. */
  7033. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7034. /**
  7035. * Scale the current bounding info by applying a scale factor
  7036. * @param factor defines the scale factor to apply
  7037. * @returns the current bounding info
  7038. */
  7039. scale(factor: number): BoundingInfo;
  7040. /**
  7041. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7042. * @param frustumPlanes defines the frustum to test
  7043. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7044. * @returns true if the bounding info is in the frustum planes
  7045. */
  7046. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7047. /**
  7048. * Gets the world distance between the min and max points of the bounding box
  7049. */
  7050. readonly diagonalLength: number;
  7051. /**
  7052. * Checks if a cullable object (mesh...) is in the camera frustum
  7053. * Unlike isInFrustum this cheks the full bounding box
  7054. * @param frustumPlanes Camera near/planes
  7055. * @returns true if the object is in frustum otherwise false
  7056. */
  7057. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7058. /** @hidden */
  7059. _checkCollision(collider: Collider): boolean;
  7060. /**
  7061. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7062. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7063. * @param point the point to check intersection with
  7064. * @returns if the point intersects
  7065. */
  7066. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7067. /**
  7068. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7069. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7070. * @param boundingInfo the bounding info to check intersection with
  7071. * @param precise if the intersection should be done using OBB
  7072. * @returns if the bounding info intersects
  7073. */
  7074. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7075. }
  7076. }
  7077. declare module BABYLON {
  7078. /**
  7079. * Extracts minimum and maximum values from a list of indexed positions
  7080. * @param positions defines the positions to use
  7081. * @param indices defines the indices to the positions
  7082. * @param indexStart defines the start index
  7083. * @param indexCount defines the end index
  7084. * @param bias defines bias value to add to the result
  7085. * @return minimum and maximum values
  7086. */
  7087. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7088. minimum: Vector3;
  7089. maximum: Vector3;
  7090. };
  7091. /**
  7092. * Extracts minimum and maximum values from a list of positions
  7093. * @param positions defines the positions to use
  7094. * @param start defines the start index in the positions array
  7095. * @param count defines the number of positions to handle
  7096. * @param bias defines bias value to add to the result
  7097. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7098. * @return minimum and maximum values
  7099. */
  7100. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7101. minimum: Vector3;
  7102. maximum: Vector3;
  7103. };
  7104. }
  7105. declare module BABYLON {
  7106. /**
  7107. * Enum that determines the text-wrapping mode to use.
  7108. */
  7109. export enum InspectableType {
  7110. /**
  7111. * Checkbox for booleans
  7112. */
  7113. Checkbox = 0,
  7114. /**
  7115. * Sliders for numbers
  7116. */
  7117. Slider = 1,
  7118. /**
  7119. * Vector3
  7120. */
  7121. Vector3 = 2,
  7122. /**
  7123. * Quaternions
  7124. */
  7125. Quaternion = 3,
  7126. /**
  7127. * Color3
  7128. */
  7129. Color3 = 4,
  7130. /**
  7131. * String
  7132. */
  7133. String = 5
  7134. }
  7135. /**
  7136. * Interface used to define custom inspectable properties.
  7137. * This interface is used by the inspector to display custom property grids
  7138. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7139. */
  7140. export interface IInspectable {
  7141. /**
  7142. * Gets the label to display
  7143. */
  7144. label: string;
  7145. /**
  7146. * Gets the name of the property to edit
  7147. */
  7148. propertyName: string;
  7149. /**
  7150. * Gets the type of the editor to use
  7151. */
  7152. type: InspectableType;
  7153. /**
  7154. * Gets the minimum value of the property when using in "slider" mode
  7155. */
  7156. min?: number;
  7157. /**
  7158. * Gets the maximum value of the property when using in "slider" mode
  7159. */
  7160. max?: number;
  7161. /**
  7162. * Gets the setp to use when using in "slider" mode
  7163. */
  7164. step?: number;
  7165. }
  7166. }
  7167. declare module BABYLON {
  7168. /**
  7169. * Class used to provide helper for timing
  7170. */
  7171. export class TimingTools {
  7172. /**
  7173. * Polyfill for setImmediate
  7174. * @param action defines the action to execute after the current execution block
  7175. */
  7176. static SetImmediate(action: () => void): void;
  7177. }
  7178. }
  7179. declare module BABYLON {
  7180. /**
  7181. * Class used to enable instatition of objects by class name
  7182. */
  7183. export class InstantiationTools {
  7184. /**
  7185. * Use this object to register external classes like custom textures or material
  7186. * to allow the laoders to instantiate them
  7187. */
  7188. static RegisteredExternalClasses: {
  7189. [key: string]: Object;
  7190. };
  7191. /**
  7192. * Tries to instantiate a new object from a given class name
  7193. * @param className defines the class name to instantiate
  7194. * @returns the new object or null if the system was not able to do the instantiation
  7195. */
  7196. static Instantiate(className: string): any;
  7197. }
  7198. }
  7199. declare module BABYLON {
  7200. /**
  7201. * This represents the required contract to create a new type of texture loader.
  7202. */
  7203. export interface IInternalTextureLoader {
  7204. /**
  7205. * Defines wether the loader supports cascade loading the different faces.
  7206. */
  7207. supportCascades: boolean;
  7208. /**
  7209. * This returns if the loader support the current file information.
  7210. * @param extension defines the file extension of the file being loaded
  7211. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7212. * @param fallback defines the fallback internal texture if any
  7213. * @param isBase64 defines whether the texture is encoded as a base64
  7214. * @param isBuffer defines whether the texture data are stored as a buffer
  7215. * @returns true if the loader can load the specified file
  7216. */
  7217. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7218. /**
  7219. * Transform the url before loading if required.
  7220. * @param rootUrl the url of the texture
  7221. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7222. * @returns the transformed texture
  7223. */
  7224. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7225. /**
  7226. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7227. * @param rootUrl the url of the texture
  7228. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7229. * @returns the fallback texture
  7230. */
  7231. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7232. /**
  7233. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7234. * @param data contains the texture data
  7235. * @param texture defines the BabylonJS internal texture
  7236. * @param createPolynomials will be true if polynomials have been requested
  7237. * @param onLoad defines the callback to trigger once the texture is ready
  7238. * @param onError defines the callback to trigger in case of error
  7239. */
  7240. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7241. /**
  7242. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7243. * @param data contains the texture data
  7244. * @param texture defines the BabylonJS internal texture
  7245. * @param callback defines the method to call once ready to upload
  7246. */
  7247. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7248. }
  7249. }
  7250. declare module BABYLON {
  7251. interface Engine {
  7252. /**
  7253. * Creates a depth stencil cube texture.
  7254. * This is only available in WebGL 2.
  7255. * @param size The size of face edge in the cube texture.
  7256. * @param options The options defining the cube texture.
  7257. * @returns The cube texture
  7258. */
  7259. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7260. /**
  7261. * Creates a cube texture
  7262. * @param rootUrl defines the url where the files to load is located
  7263. * @param scene defines the current scene
  7264. * @param files defines the list of files to load (1 per face)
  7265. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7266. * @param onLoad defines an optional callback raised when the texture is loaded
  7267. * @param onError defines an optional callback raised if there is an issue to load the texture
  7268. * @param format defines the format of the data
  7269. * @param forcedExtension defines the extension to use to pick the right loader
  7270. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7271. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7272. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7273. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7274. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7275. * @returns the cube texture as an InternalTexture
  7276. */
  7277. 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;
  7278. /**
  7279. * Creates a cube texture
  7280. * @param rootUrl defines the url where the files to load is located
  7281. * @param scene defines the current scene
  7282. * @param files defines the list of files to load (1 per face)
  7283. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7284. * @param onLoad defines an optional callback raised when the texture is loaded
  7285. * @param onError defines an optional callback raised if there is an issue to load the texture
  7286. * @param format defines the format of the data
  7287. * @param forcedExtension defines the extension to use to pick the right loader
  7288. * @returns the cube texture as an InternalTexture
  7289. */
  7290. 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;
  7291. /**
  7292. * Creates a cube texture
  7293. * @param rootUrl defines the url where the files to load is located
  7294. * @param scene defines the current scene
  7295. * @param files defines the list of files to load (1 per face)
  7296. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7297. * @param onLoad defines an optional callback raised when the texture is loaded
  7298. * @param onError defines an optional callback raised if there is an issue to load the texture
  7299. * @param format defines the format of the data
  7300. * @param forcedExtension defines the extension to use to pick the right loader
  7301. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7302. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7303. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7304. * @returns the cube texture as an InternalTexture
  7305. */
  7306. 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;
  7307. /** @hidden */
  7308. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7309. /** @hidden */
  7310. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7311. /** @hidden */
  7312. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7313. /** @hidden */
  7314. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7315. }
  7316. }
  7317. declare module BABYLON {
  7318. /**
  7319. * Class for creating a cube texture
  7320. */
  7321. export class CubeTexture extends BaseTexture {
  7322. private _delayedOnLoad;
  7323. /**
  7324. * The url of the texture
  7325. */
  7326. url: string;
  7327. /**
  7328. * Gets or sets the center of the bounding box associated with the cube texture.
  7329. * It must define where the camera used to render the texture was set
  7330. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7331. */
  7332. boundingBoxPosition: Vector3;
  7333. private _boundingBoxSize;
  7334. /**
  7335. * Gets or sets the size of the bounding box associated with the cube texture
  7336. * When defined, the cubemap will switch to local mode
  7337. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7338. * @example https://www.babylonjs-playground.com/#RNASML
  7339. */
  7340. /**
  7341. * Returns the bounding box size
  7342. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7343. */
  7344. boundingBoxSize: Vector3;
  7345. protected _rotationY: number;
  7346. /**
  7347. * Sets texture matrix rotation angle around Y axis in radians.
  7348. */
  7349. /**
  7350. * Gets texture matrix rotation angle around Y axis radians.
  7351. */
  7352. rotationY: number;
  7353. /**
  7354. * Are mip maps generated for this texture or not.
  7355. */
  7356. readonly noMipmap: boolean;
  7357. private _noMipmap;
  7358. private _files;
  7359. private _extensions;
  7360. private _textureMatrix;
  7361. private _format;
  7362. private _createPolynomials;
  7363. /** @hidden */
  7364. _prefiltered: boolean;
  7365. /**
  7366. * Creates a cube texture from an array of image urls
  7367. * @param files defines an array of image urls
  7368. * @param scene defines the hosting scene
  7369. * @param noMipmap specifies if mip maps are not used
  7370. * @returns a cube texture
  7371. */
  7372. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7373. /**
  7374. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7375. * @param url defines the url of the prefiltered texture
  7376. * @param scene defines the scene the texture is attached to
  7377. * @param forcedExtension defines the extension of the file if different from the url
  7378. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7379. * @return the prefiltered texture
  7380. */
  7381. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7382. /**
  7383. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7384. * as prefiltered data.
  7385. * @param rootUrl defines the url of the texture or the root name of the six images
  7386. * @param scene defines the scene the texture is attached to
  7387. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7388. * @param noMipmap defines if mipmaps should be created or not
  7389. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7390. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7391. * @param onError defines a callback triggered in case of error during load
  7392. * @param format defines the internal format to use for the texture once loaded
  7393. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7394. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7395. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7396. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7397. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7398. * @return the cube texture
  7399. */
  7400. 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);
  7401. /**
  7402. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7403. */
  7404. readonly isPrefiltered: boolean;
  7405. /**
  7406. * Get the current class name of the texture useful for serialization or dynamic coding.
  7407. * @returns "CubeTexture"
  7408. */
  7409. getClassName(): string;
  7410. /**
  7411. * Update the url (and optional buffer) of this texture if url was null during construction.
  7412. * @param url the url of the texture
  7413. * @param forcedExtension defines the extension to use
  7414. * @param onLoad callback called when the texture is loaded (defaults to null)
  7415. */
  7416. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7417. /**
  7418. * Delays loading of the cube texture
  7419. * @param forcedExtension defines the extension to use
  7420. */
  7421. delayLoad(forcedExtension?: string): void;
  7422. /**
  7423. * Returns the reflection texture matrix
  7424. * @returns the reflection texture matrix
  7425. */
  7426. getReflectionTextureMatrix(): Matrix;
  7427. /**
  7428. * Sets the reflection texture matrix
  7429. * @param value Reflection texture matrix
  7430. */
  7431. setReflectionTextureMatrix(value: Matrix): void;
  7432. /**
  7433. * Parses text to create a cube texture
  7434. * @param parsedTexture define the serialized text to read from
  7435. * @param scene defines the hosting scene
  7436. * @param rootUrl defines the root url of the cube texture
  7437. * @returns a cube texture
  7438. */
  7439. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7440. /**
  7441. * Makes a clone, or deep copy, of the cube texture
  7442. * @returns a new cube texture
  7443. */
  7444. clone(): CubeTexture;
  7445. }
  7446. }
  7447. declare module BABYLON {
  7448. /**
  7449. * Manages the defines for the Material
  7450. */
  7451. export class MaterialDefines {
  7452. /** @hidden */
  7453. protected _keys: string[];
  7454. private _isDirty;
  7455. /** @hidden */
  7456. _renderId: number;
  7457. /** @hidden */
  7458. _areLightsDirty: boolean;
  7459. /** @hidden */
  7460. _areLightsDisposed: boolean;
  7461. /** @hidden */
  7462. _areAttributesDirty: boolean;
  7463. /** @hidden */
  7464. _areTexturesDirty: boolean;
  7465. /** @hidden */
  7466. _areFresnelDirty: boolean;
  7467. /** @hidden */
  7468. _areMiscDirty: boolean;
  7469. /** @hidden */
  7470. _areImageProcessingDirty: boolean;
  7471. /** @hidden */
  7472. _normals: boolean;
  7473. /** @hidden */
  7474. _uvs: boolean;
  7475. /** @hidden */
  7476. _needNormals: boolean;
  7477. /** @hidden */
  7478. _needUVs: boolean;
  7479. [id: string]: any;
  7480. /**
  7481. * Specifies if the material needs to be re-calculated
  7482. */
  7483. readonly isDirty: boolean;
  7484. /**
  7485. * Marks the material to indicate that it has been re-calculated
  7486. */
  7487. markAsProcessed(): void;
  7488. /**
  7489. * Marks the material to indicate that it needs to be re-calculated
  7490. */
  7491. markAsUnprocessed(): void;
  7492. /**
  7493. * Marks the material to indicate all of its defines need to be re-calculated
  7494. */
  7495. markAllAsDirty(): void;
  7496. /**
  7497. * Marks the material to indicate that image processing needs to be re-calculated
  7498. */
  7499. markAsImageProcessingDirty(): void;
  7500. /**
  7501. * Marks the material to indicate the lights need to be re-calculated
  7502. * @param disposed Defines whether the light is dirty due to dispose or not
  7503. */
  7504. markAsLightDirty(disposed?: boolean): void;
  7505. /**
  7506. * Marks the attribute state as changed
  7507. */
  7508. markAsAttributesDirty(): void;
  7509. /**
  7510. * Marks the texture state as changed
  7511. */
  7512. markAsTexturesDirty(): void;
  7513. /**
  7514. * Marks the fresnel state as changed
  7515. */
  7516. markAsFresnelDirty(): void;
  7517. /**
  7518. * Marks the misc state as changed
  7519. */
  7520. markAsMiscDirty(): void;
  7521. /**
  7522. * Rebuilds the material defines
  7523. */
  7524. rebuild(): void;
  7525. /**
  7526. * Specifies if two material defines are equal
  7527. * @param other - A material define instance to compare to
  7528. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7529. */
  7530. isEqual(other: MaterialDefines): boolean;
  7531. /**
  7532. * Clones this instance's defines to another instance
  7533. * @param other - material defines to clone values to
  7534. */
  7535. cloneTo(other: MaterialDefines): void;
  7536. /**
  7537. * Resets the material define values
  7538. */
  7539. reset(): void;
  7540. /**
  7541. * Converts the material define values to a string
  7542. * @returns - String of material define information
  7543. */
  7544. toString(): string;
  7545. }
  7546. }
  7547. declare module BABYLON {
  7548. /**
  7549. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7550. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7551. * 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;
  7552. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7553. */
  7554. export class ColorCurves {
  7555. private _dirty;
  7556. private _tempColor;
  7557. private _globalCurve;
  7558. private _highlightsCurve;
  7559. private _midtonesCurve;
  7560. private _shadowsCurve;
  7561. private _positiveCurve;
  7562. private _negativeCurve;
  7563. private _globalHue;
  7564. private _globalDensity;
  7565. private _globalSaturation;
  7566. private _globalExposure;
  7567. /**
  7568. * Gets the global Hue value.
  7569. * 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).
  7570. */
  7571. /**
  7572. * Sets the global Hue value.
  7573. * 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).
  7574. */
  7575. globalHue: number;
  7576. /**
  7577. * Gets the global Density value.
  7578. * 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.
  7579. * Values less than zero provide a filter of opposite hue.
  7580. */
  7581. /**
  7582. * Sets the global Density value.
  7583. * 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.
  7584. * Values less than zero provide a filter of opposite hue.
  7585. */
  7586. globalDensity: number;
  7587. /**
  7588. * Gets the global Saturation value.
  7589. * 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.
  7590. */
  7591. /**
  7592. * Sets the global Saturation value.
  7593. * 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.
  7594. */
  7595. globalSaturation: number;
  7596. /**
  7597. * Gets the global Exposure value.
  7598. * 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.
  7599. */
  7600. /**
  7601. * Sets the global Exposure value.
  7602. * 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.
  7603. */
  7604. globalExposure: number;
  7605. private _highlightsHue;
  7606. private _highlightsDensity;
  7607. private _highlightsSaturation;
  7608. private _highlightsExposure;
  7609. /**
  7610. * Gets the highlights Hue value.
  7611. * 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).
  7612. */
  7613. /**
  7614. * Sets the highlights Hue value.
  7615. * 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).
  7616. */
  7617. highlightsHue: number;
  7618. /**
  7619. * Gets the highlights Density value.
  7620. * 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.
  7621. * Values less than zero provide a filter of opposite hue.
  7622. */
  7623. /**
  7624. * Sets the highlights Density value.
  7625. * 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.
  7626. * Values less than zero provide a filter of opposite hue.
  7627. */
  7628. highlightsDensity: number;
  7629. /**
  7630. * Gets the highlights Saturation value.
  7631. * 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.
  7632. */
  7633. /**
  7634. * Sets the highlights Saturation value.
  7635. * 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.
  7636. */
  7637. highlightsSaturation: number;
  7638. /**
  7639. * Gets the highlights Exposure value.
  7640. * 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.
  7641. */
  7642. /**
  7643. * Sets the highlights Exposure value.
  7644. * 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.
  7645. */
  7646. highlightsExposure: number;
  7647. private _midtonesHue;
  7648. private _midtonesDensity;
  7649. private _midtonesSaturation;
  7650. private _midtonesExposure;
  7651. /**
  7652. * Gets the midtones Hue value.
  7653. * 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).
  7654. */
  7655. /**
  7656. * Sets the midtones Hue value.
  7657. * 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).
  7658. */
  7659. midtonesHue: number;
  7660. /**
  7661. * Gets the midtones Density value.
  7662. * 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.
  7663. * Values less than zero provide a filter of opposite hue.
  7664. */
  7665. /**
  7666. * Sets the midtones Density value.
  7667. * 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.
  7668. * Values less than zero provide a filter of opposite hue.
  7669. */
  7670. midtonesDensity: number;
  7671. /**
  7672. * Gets the midtones Saturation value.
  7673. * 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.
  7674. */
  7675. /**
  7676. * Sets the midtones Saturation value.
  7677. * 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.
  7678. */
  7679. midtonesSaturation: number;
  7680. /**
  7681. * Gets the midtones Exposure value.
  7682. * 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.
  7683. */
  7684. /**
  7685. * Sets the midtones Exposure value.
  7686. * 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.
  7687. */
  7688. midtonesExposure: number;
  7689. private _shadowsHue;
  7690. private _shadowsDensity;
  7691. private _shadowsSaturation;
  7692. private _shadowsExposure;
  7693. /**
  7694. * Gets the shadows Hue value.
  7695. * 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).
  7696. */
  7697. /**
  7698. * Sets the shadows Hue value.
  7699. * 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).
  7700. */
  7701. shadowsHue: number;
  7702. /**
  7703. * Gets the shadows Density value.
  7704. * 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.
  7705. * Values less than zero provide a filter of opposite hue.
  7706. */
  7707. /**
  7708. * Sets the shadows Density value.
  7709. * 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.
  7710. * Values less than zero provide a filter of opposite hue.
  7711. */
  7712. shadowsDensity: number;
  7713. /**
  7714. * Gets the shadows Saturation value.
  7715. * 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.
  7716. */
  7717. /**
  7718. * Sets the shadows Saturation value.
  7719. * 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.
  7720. */
  7721. shadowsSaturation: number;
  7722. /**
  7723. * Gets the shadows Exposure value.
  7724. * 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.
  7725. */
  7726. /**
  7727. * Sets the shadows Exposure value.
  7728. * 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.
  7729. */
  7730. shadowsExposure: number;
  7731. /**
  7732. * Returns the class name
  7733. * @returns The class name
  7734. */
  7735. getClassName(): string;
  7736. /**
  7737. * Binds the color curves to the shader.
  7738. * @param colorCurves The color curve to bind
  7739. * @param effect The effect to bind to
  7740. * @param positiveUniform The positive uniform shader parameter
  7741. * @param neutralUniform The neutral uniform shader parameter
  7742. * @param negativeUniform The negative uniform shader parameter
  7743. */
  7744. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7745. /**
  7746. * Prepare the list of uniforms associated with the ColorCurves effects.
  7747. * @param uniformsList The list of uniforms used in the effect
  7748. */
  7749. static PrepareUniforms(uniformsList: string[]): void;
  7750. /**
  7751. * Returns color grading data based on a hue, density, saturation and exposure value.
  7752. * @param filterHue The hue of the color filter.
  7753. * @param filterDensity The density of the color filter.
  7754. * @param saturation The saturation.
  7755. * @param exposure The exposure.
  7756. * @param result The result data container.
  7757. */
  7758. private getColorGradingDataToRef;
  7759. /**
  7760. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7761. * @param value The input slider value in range [-100,100].
  7762. * @returns Adjusted value.
  7763. */
  7764. private static applyColorGradingSliderNonlinear;
  7765. /**
  7766. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7767. * @param hue The hue (H) input.
  7768. * @param saturation The saturation (S) input.
  7769. * @param brightness The brightness (B) input.
  7770. * @result An RGBA color represented as Vector4.
  7771. */
  7772. private static fromHSBToRef;
  7773. /**
  7774. * Returns a value clamped between min and max
  7775. * @param value The value to clamp
  7776. * @param min The minimum of value
  7777. * @param max The maximum of value
  7778. * @returns The clamped value.
  7779. */
  7780. private static clamp;
  7781. /**
  7782. * Clones the current color curve instance.
  7783. * @return The cloned curves
  7784. */
  7785. clone(): ColorCurves;
  7786. /**
  7787. * Serializes the current color curve instance to a json representation.
  7788. * @return a JSON representation
  7789. */
  7790. serialize(): any;
  7791. /**
  7792. * Parses the color curve from a json representation.
  7793. * @param source the JSON source to parse
  7794. * @return The parsed curves
  7795. */
  7796. static Parse(source: any): ColorCurves;
  7797. }
  7798. }
  7799. declare module BABYLON {
  7800. /**
  7801. * Interface to follow in your material defines to integrate easily the
  7802. * Image proccessing functions.
  7803. * @hidden
  7804. */
  7805. export interface IImageProcessingConfigurationDefines {
  7806. IMAGEPROCESSING: boolean;
  7807. VIGNETTE: boolean;
  7808. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7809. VIGNETTEBLENDMODEOPAQUE: boolean;
  7810. TONEMAPPING: boolean;
  7811. TONEMAPPING_ACES: boolean;
  7812. CONTRAST: boolean;
  7813. EXPOSURE: boolean;
  7814. COLORCURVES: boolean;
  7815. COLORGRADING: boolean;
  7816. COLORGRADING3D: boolean;
  7817. SAMPLER3DGREENDEPTH: boolean;
  7818. SAMPLER3DBGRMAP: boolean;
  7819. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7820. }
  7821. /**
  7822. * @hidden
  7823. */
  7824. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7825. IMAGEPROCESSING: boolean;
  7826. VIGNETTE: boolean;
  7827. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7828. VIGNETTEBLENDMODEOPAQUE: boolean;
  7829. TONEMAPPING: boolean;
  7830. TONEMAPPING_ACES: boolean;
  7831. CONTRAST: boolean;
  7832. COLORCURVES: boolean;
  7833. COLORGRADING: boolean;
  7834. COLORGRADING3D: boolean;
  7835. SAMPLER3DGREENDEPTH: boolean;
  7836. SAMPLER3DBGRMAP: boolean;
  7837. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7838. EXPOSURE: boolean;
  7839. constructor();
  7840. }
  7841. /**
  7842. * This groups together the common properties used for image processing either in direct forward pass
  7843. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7844. * or not.
  7845. */
  7846. export class ImageProcessingConfiguration {
  7847. /**
  7848. * Default tone mapping applied in BabylonJS.
  7849. */
  7850. static readonly TONEMAPPING_STANDARD: number;
  7851. /**
  7852. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  7853. * to other engines rendering to increase portability.
  7854. */
  7855. static readonly TONEMAPPING_ACES: number;
  7856. /**
  7857. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  7858. */
  7859. colorCurves: Nullable<ColorCurves>;
  7860. private _colorCurvesEnabled;
  7861. /**
  7862. * Gets wether the color curves effect is enabled.
  7863. */
  7864. /**
  7865. * Sets wether the color curves effect is enabled.
  7866. */
  7867. colorCurvesEnabled: boolean;
  7868. private _colorGradingTexture;
  7869. /**
  7870. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7871. */
  7872. /**
  7873. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7874. */
  7875. colorGradingTexture: Nullable<BaseTexture>;
  7876. private _colorGradingEnabled;
  7877. /**
  7878. * Gets wether the color grading effect is enabled.
  7879. */
  7880. /**
  7881. * Sets wether the color grading effect is enabled.
  7882. */
  7883. colorGradingEnabled: boolean;
  7884. private _colorGradingWithGreenDepth;
  7885. /**
  7886. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  7887. */
  7888. /**
  7889. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  7890. */
  7891. colorGradingWithGreenDepth: boolean;
  7892. private _colorGradingBGR;
  7893. /**
  7894. * Gets wether the color grading texture contains BGR values.
  7895. */
  7896. /**
  7897. * Sets wether the color grading texture contains BGR values.
  7898. */
  7899. colorGradingBGR: boolean;
  7900. /** @hidden */
  7901. _exposure: number;
  7902. /**
  7903. * Gets the Exposure used in the effect.
  7904. */
  7905. /**
  7906. * Sets the Exposure used in the effect.
  7907. */
  7908. exposure: number;
  7909. private _toneMappingEnabled;
  7910. /**
  7911. * Gets wether the tone mapping effect is enabled.
  7912. */
  7913. /**
  7914. * Sets wether the tone mapping effect is enabled.
  7915. */
  7916. toneMappingEnabled: boolean;
  7917. private _toneMappingType;
  7918. /**
  7919. * Gets the type of tone mapping effect.
  7920. */
  7921. /**
  7922. * Sets the type of tone mapping effect used in BabylonJS.
  7923. */
  7924. toneMappingType: number;
  7925. protected _contrast: number;
  7926. /**
  7927. * Gets the contrast used in the effect.
  7928. */
  7929. /**
  7930. * Sets the contrast used in the effect.
  7931. */
  7932. contrast: number;
  7933. /**
  7934. * Vignette stretch size.
  7935. */
  7936. vignetteStretch: number;
  7937. /**
  7938. * Vignette centre X Offset.
  7939. */
  7940. vignetteCentreX: number;
  7941. /**
  7942. * Vignette centre Y Offset.
  7943. */
  7944. vignetteCentreY: number;
  7945. /**
  7946. * Vignette weight or intensity of the vignette effect.
  7947. */
  7948. vignetteWeight: number;
  7949. /**
  7950. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  7951. * if vignetteEnabled is set to true.
  7952. */
  7953. vignetteColor: Color4;
  7954. /**
  7955. * Camera field of view used by the Vignette effect.
  7956. */
  7957. vignetteCameraFov: number;
  7958. private _vignetteBlendMode;
  7959. /**
  7960. * Gets the vignette blend mode allowing different kind of effect.
  7961. */
  7962. /**
  7963. * Sets the vignette blend mode allowing different kind of effect.
  7964. */
  7965. vignetteBlendMode: number;
  7966. private _vignetteEnabled;
  7967. /**
  7968. * Gets wether the vignette effect is enabled.
  7969. */
  7970. /**
  7971. * Sets wether the vignette effect is enabled.
  7972. */
  7973. vignetteEnabled: boolean;
  7974. private _applyByPostProcess;
  7975. /**
  7976. * Gets wether the image processing is applied through a post process or not.
  7977. */
  7978. /**
  7979. * Sets wether the image processing is applied through a post process or not.
  7980. */
  7981. applyByPostProcess: boolean;
  7982. private _isEnabled;
  7983. /**
  7984. * Gets wether the image processing is enabled or not.
  7985. */
  7986. /**
  7987. * Sets wether the image processing is enabled or not.
  7988. */
  7989. isEnabled: boolean;
  7990. /**
  7991. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  7992. */
  7993. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  7994. /**
  7995. * Method called each time the image processing information changes requires to recompile the effect.
  7996. */
  7997. protected _updateParameters(): void;
  7998. /**
  7999. * Gets the current class name.
  8000. * @return "ImageProcessingConfiguration"
  8001. */
  8002. getClassName(): string;
  8003. /**
  8004. * Prepare the list of uniforms associated with the Image Processing effects.
  8005. * @param uniforms The list of uniforms used in the effect
  8006. * @param defines the list of defines currently in use
  8007. */
  8008. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8009. /**
  8010. * Prepare the list of samplers associated with the Image Processing effects.
  8011. * @param samplersList The list of uniforms used in the effect
  8012. * @param defines the list of defines currently in use
  8013. */
  8014. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8015. /**
  8016. * Prepare the list of defines associated to the shader.
  8017. * @param defines the list of defines to complete
  8018. * @param forPostProcess Define if we are currently in post process mode or not
  8019. */
  8020. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8021. /**
  8022. * Returns true if all the image processing information are ready.
  8023. * @returns True if ready, otherwise, false
  8024. */
  8025. isReady(): boolean;
  8026. /**
  8027. * Binds the image processing to the shader.
  8028. * @param effect The effect to bind to
  8029. * @param aspectRatio Define the current aspect ratio of the effect
  8030. */
  8031. bind(effect: Effect, aspectRatio?: number): void;
  8032. /**
  8033. * Clones the current image processing instance.
  8034. * @return The cloned image processing
  8035. */
  8036. clone(): ImageProcessingConfiguration;
  8037. /**
  8038. * Serializes the current image processing instance to a json representation.
  8039. * @return a JSON representation
  8040. */
  8041. serialize(): any;
  8042. /**
  8043. * Parses the image processing from a json representation.
  8044. * @param source the JSON source to parse
  8045. * @return The parsed image processing
  8046. */
  8047. static Parse(source: any): ImageProcessingConfiguration;
  8048. private static _VIGNETTEMODE_MULTIPLY;
  8049. private static _VIGNETTEMODE_OPAQUE;
  8050. /**
  8051. * Used to apply the vignette as a mix with the pixel color.
  8052. */
  8053. static readonly VIGNETTEMODE_MULTIPLY: number;
  8054. /**
  8055. * Used to apply the vignette as a replacement of the pixel color.
  8056. */
  8057. static readonly VIGNETTEMODE_OPAQUE: number;
  8058. }
  8059. }
  8060. declare module BABYLON {
  8061. /** @hidden */
  8062. export var postprocessVertexShader: {
  8063. name: string;
  8064. shader: string;
  8065. };
  8066. }
  8067. declare module BABYLON {
  8068. /** Defines supported spaces */
  8069. export enum Space {
  8070. /** Local (object) space */
  8071. LOCAL = 0,
  8072. /** World space */
  8073. WORLD = 1,
  8074. /** Bone space */
  8075. BONE = 2
  8076. }
  8077. /** Defines the 3 main axes */
  8078. export class Axis {
  8079. /** X axis */
  8080. static X: Vector3;
  8081. /** Y axis */
  8082. static Y: Vector3;
  8083. /** Z axis */
  8084. static Z: Vector3;
  8085. }
  8086. }
  8087. declare module BABYLON {
  8088. /**
  8089. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8090. * This is the base of the follow, arc rotate cameras and Free camera
  8091. * @see http://doc.babylonjs.com/features/cameras
  8092. */
  8093. export class TargetCamera extends Camera {
  8094. private static _RigCamTransformMatrix;
  8095. private static _TargetTransformMatrix;
  8096. private static _TargetFocalPoint;
  8097. /**
  8098. * Define the current direction the camera is moving to
  8099. */
  8100. cameraDirection: Vector3;
  8101. /**
  8102. * Define the current rotation the camera is rotating to
  8103. */
  8104. cameraRotation: Vector2;
  8105. /**
  8106. * When set, the up vector of the camera will be updated by the rotation of the camera
  8107. */
  8108. updateUpVectorFromRotation: boolean;
  8109. private _tmpQuaternion;
  8110. /**
  8111. * Define the current rotation of the camera
  8112. */
  8113. rotation: Vector3;
  8114. /**
  8115. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8116. */
  8117. rotationQuaternion: Quaternion;
  8118. /**
  8119. * Define the current speed of the camera
  8120. */
  8121. speed: number;
  8122. /**
  8123. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8124. * around all axis.
  8125. */
  8126. noRotationConstraint: boolean;
  8127. /**
  8128. * Define the current target of the camera as an object or a position.
  8129. */
  8130. lockedTarget: any;
  8131. /** @hidden */
  8132. _currentTarget: Vector3;
  8133. /** @hidden */
  8134. _initialFocalDistance: number;
  8135. /** @hidden */
  8136. _viewMatrix: Matrix;
  8137. /** @hidden */
  8138. _camMatrix: Matrix;
  8139. /** @hidden */
  8140. _cameraTransformMatrix: Matrix;
  8141. /** @hidden */
  8142. _cameraRotationMatrix: Matrix;
  8143. /** @hidden */
  8144. _referencePoint: Vector3;
  8145. /** @hidden */
  8146. _transformedReferencePoint: Vector3;
  8147. protected _globalCurrentTarget: Vector3;
  8148. protected _globalCurrentUpVector: Vector3;
  8149. /** @hidden */
  8150. _reset: () => void;
  8151. private _defaultUp;
  8152. /**
  8153. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8154. * This is the base of the follow, arc rotate cameras and Free camera
  8155. * @see http://doc.babylonjs.com/features/cameras
  8156. * @param name Defines the name of the camera in the scene
  8157. * @param position Defines the start position of the camera in the scene
  8158. * @param scene Defines the scene the camera belongs to
  8159. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8160. */
  8161. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8162. /**
  8163. * Gets the position in front of the camera at a given distance.
  8164. * @param distance The distance from the camera we want the position to be
  8165. * @returns the position
  8166. */
  8167. getFrontPosition(distance: number): Vector3;
  8168. /** @hidden */
  8169. _getLockedTargetPosition(): Nullable<Vector3>;
  8170. private _storedPosition;
  8171. private _storedRotation;
  8172. private _storedRotationQuaternion;
  8173. /**
  8174. * Store current camera state of the camera (fov, position, rotation, etc..)
  8175. * @returns the camera
  8176. */
  8177. storeState(): Camera;
  8178. /**
  8179. * Restored camera state. You must call storeState() first
  8180. * @returns whether it was successful or not
  8181. * @hidden
  8182. */
  8183. _restoreStateValues(): boolean;
  8184. /** @hidden */
  8185. _initCache(): void;
  8186. /** @hidden */
  8187. _updateCache(ignoreParentClass?: boolean): void;
  8188. /** @hidden */
  8189. _isSynchronizedViewMatrix(): boolean;
  8190. /** @hidden */
  8191. _computeLocalCameraSpeed(): number;
  8192. /**
  8193. * Defines the target the camera should look at.
  8194. * @param target Defines the new target as a Vector or a mesh
  8195. */
  8196. setTarget(target: Vector3): void;
  8197. /**
  8198. * Return the current target position of the camera. This value is expressed in local space.
  8199. * @returns the target position
  8200. */
  8201. getTarget(): Vector3;
  8202. /** @hidden */
  8203. _decideIfNeedsToMove(): boolean;
  8204. /** @hidden */
  8205. _updatePosition(): void;
  8206. /** @hidden */
  8207. _checkInputs(): void;
  8208. protected _updateCameraRotationMatrix(): void;
  8209. /**
  8210. * 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)
  8211. * @returns the current camera
  8212. */
  8213. private _rotateUpVectorWithCameraRotationMatrix;
  8214. private _cachedRotationZ;
  8215. private _cachedQuaternionRotationZ;
  8216. /** @hidden */
  8217. _getViewMatrix(): Matrix;
  8218. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8219. /**
  8220. * @hidden
  8221. */
  8222. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8223. /**
  8224. * @hidden
  8225. */
  8226. _updateRigCameras(): void;
  8227. private _getRigCamPositionAndTarget;
  8228. /**
  8229. * Gets the current object class name.
  8230. * @return the class name
  8231. */
  8232. getClassName(): string;
  8233. }
  8234. }
  8235. declare module BABYLON {
  8236. /**
  8237. * Gather the list of keyboard event types as constants.
  8238. */
  8239. export class KeyboardEventTypes {
  8240. /**
  8241. * The keydown event is fired when a key becomes active (pressed).
  8242. */
  8243. static readonly KEYDOWN: number;
  8244. /**
  8245. * The keyup event is fired when a key has been released.
  8246. */
  8247. static readonly KEYUP: number;
  8248. }
  8249. /**
  8250. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8251. */
  8252. export class KeyboardInfo {
  8253. /**
  8254. * Defines the type of event (KeyboardEventTypes)
  8255. */
  8256. type: number;
  8257. /**
  8258. * Defines the related dom event
  8259. */
  8260. event: KeyboardEvent;
  8261. /**
  8262. * Instantiates a new keyboard info.
  8263. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8264. * @param type Defines the type of event (KeyboardEventTypes)
  8265. * @param event Defines the related dom event
  8266. */
  8267. constructor(
  8268. /**
  8269. * Defines the type of event (KeyboardEventTypes)
  8270. */
  8271. type: number,
  8272. /**
  8273. * Defines the related dom event
  8274. */
  8275. event: KeyboardEvent);
  8276. }
  8277. /**
  8278. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8279. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8280. */
  8281. export class KeyboardInfoPre extends KeyboardInfo {
  8282. /**
  8283. * Defines the type of event (KeyboardEventTypes)
  8284. */
  8285. type: number;
  8286. /**
  8287. * Defines the related dom event
  8288. */
  8289. event: KeyboardEvent;
  8290. /**
  8291. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8292. */
  8293. skipOnPointerObservable: boolean;
  8294. /**
  8295. * Instantiates a new keyboard pre info.
  8296. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8297. * @param type Defines the type of event (KeyboardEventTypes)
  8298. * @param event Defines the related dom event
  8299. */
  8300. constructor(
  8301. /**
  8302. * Defines the type of event (KeyboardEventTypes)
  8303. */
  8304. type: number,
  8305. /**
  8306. * Defines the related dom event
  8307. */
  8308. event: KeyboardEvent);
  8309. }
  8310. }
  8311. declare module BABYLON {
  8312. /**
  8313. * Manage the keyboard inputs to control the movement of a free camera.
  8314. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8315. */
  8316. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8317. /**
  8318. * Defines the camera the input is attached to.
  8319. */
  8320. camera: FreeCamera;
  8321. /**
  8322. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8323. */
  8324. keysUp: number[];
  8325. /**
  8326. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8327. */
  8328. keysDown: number[];
  8329. /**
  8330. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8331. */
  8332. keysLeft: number[];
  8333. /**
  8334. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8335. */
  8336. keysRight: number[];
  8337. private _keys;
  8338. private _onCanvasBlurObserver;
  8339. private _onKeyboardObserver;
  8340. private _engine;
  8341. private _scene;
  8342. /**
  8343. * Attach the input controls to a specific dom element to get the input from.
  8344. * @param element Defines the element the controls should be listened from
  8345. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8346. */
  8347. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8348. /**
  8349. * Detach the current controls from the specified dom element.
  8350. * @param element Defines the element to stop listening the inputs from
  8351. */
  8352. detachControl(element: Nullable<HTMLElement>): void;
  8353. /**
  8354. * Update the current camera state depending on the inputs that have been used this frame.
  8355. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8356. */
  8357. checkInputs(): void;
  8358. /**
  8359. * Gets the class name of the current intput.
  8360. * @returns the class name
  8361. */
  8362. getClassName(): string;
  8363. /** @hidden */
  8364. _onLostFocus(): void;
  8365. /**
  8366. * Get the friendly name associated with the input class.
  8367. * @returns the input friendly name
  8368. */
  8369. getSimpleName(): string;
  8370. }
  8371. }
  8372. declare module BABYLON {
  8373. /**
  8374. * Interface describing all the common properties and methods a shadow light needs to implement.
  8375. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8376. * as well as binding the different shadow properties to the effects.
  8377. */
  8378. export interface IShadowLight extends Light {
  8379. /**
  8380. * The light id in the scene (used in scene.findLighById for instance)
  8381. */
  8382. id: string;
  8383. /**
  8384. * The position the shdow will be casted from.
  8385. */
  8386. position: Vector3;
  8387. /**
  8388. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8389. */
  8390. direction: Vector3;
  8391. /**
  8392. * The transformed position. Position of the light in world space taking parenting in account.
  8393. */
  8394. transformedPosition: Vector3;
  8395. /**
  8396. * The transformed direction. Direction of the light in world space taking parenting in account.
  8397. */
  8398. transformedDirection: Vector3;
  8399. /**
  8400. * The friendly name of the light in the scene.
  8401. */
  8402. name: string;
  8403. /**
  8404. * Defines the shadow projection clipping minimum z value.
  8405. */
  8406. shadowMinZ: number;
  8407. /**
  8408. * Defines the shadow projection clipping maximum z value.
  8409. */
  8410. shadowMaxZ: number;
  8411. /**
  8412. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8413. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8414. */
  8415. computeTransformedInformation(): boolean;
  8416. /**
  8417. * Gets the scene the light belongs to.
  8418. * @returns The scene
  8419. */
  8420. getScene(): Scene;
  8421. /**
  8422. * Callback defining a custom Projection Matrix Builder.
  8423. * This can be used to override the default projection matrix computation.
  8424. */
  8425. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8426. /**
  8427. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8428. * @param matrix The materix to updated with the projection information
  8429. * @param viewMatrix The transform matrix of the light
  8430. * @param renderList The list of mesh to render in the map
  8431. * @returns The current light
  8432. */
  8433. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8434. /**
  8435. * Gets the current depth scale used in ESM.
  8436. * @returns The scale
  8437. */
  8438. getDepthScale(): number;
  8439. /**
  8440. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8441. * @returns true if a cube texture needs to be use
  8442. */
  8443. needCube(): boolean;
  8444. /**
  8445. * Detects if the projection matrix requires to be recomputed this frame.
  8446. * @returns true if it requires to be recomputed otherwise, false.
  8447. */
  8448. needProjectionMatrixCompute(): boolean;
  8449. /**
  8450. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8451. */
  8452. forceProjectionMatrixCompute(): void;
  8453. /**
  8454. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8455. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8456. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8457. */
  8458. getShadowDirection(faceIndex?: number): Vector3;
  8459. /**
  8460. * Gets the minZ used for shadow according to both the scene and the light.
  8461. * @param activeCamera The camera we are returning the min for
  8462. * @returns the depth min z
  8463. */
  8464. getDepthMinZ(activeCamera: Camera): number;
  8465. /**
  8466. * Gets the maxZ used for shadow according to both the scene and the light.
  8467. * @param activeCamera The camera we are returning the max for
  8468. * @returns the depth max z
  8469. */
  8470. getDepthMaxZ(activeCamera: Camera): number;
  8471. }
  8472. /**
  8473. * Base implementation IShadowLight
  8474. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8475. */
  8476. export abstract class ShadowLight extends Light implements IShadowLight {
  8477. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8478. protected _position: Vector3;
  8479. protected _setPosition(value: Vector3): void;
  8480. /**
  8481. * Sets the position the shadow will be casted from. Also use as the light position for both
  8482. * point and spot lights.
  8483. */
  8484. /**
  8485. * Sets the position the shadow will be casted from. Also use as the light position for both
  8486. * point and spot lights.
  8487. */
  8488. position: Vector3;
  8489. protected _direction: Vector3;
  8490. protected _setDirection(value: Vector3): void;
  8491. /**
  8492. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8493. * Also use as the light direction on spot and directional lights.
  8494. */
  8495. /**
  8496. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8497. * Also use as the light direction on spot and directional lights.
  8498. */
  8499. direction: Vector3;
  8500. private _shadowMinZ;
  8501. /**
  8502. * Gets the shadow projection clipping minimum z value.
  8503. */
  8504. /**
  8505. * Sets the shadow projection clipping minimum z value.
  8506. */
  8507. shadowMinZ: number;
  8508. private _shadowMaxZ;
  8509. /**
  8510. * Sets the shadow projection clipping maximum z value.
  8511. */
  8512. /**
  8513. * Gets the shadow projection clipping maximum z value.
  8514. */
  8515. shadowMaxZ: number;
  8516. /**
  8517. * Callback defining a custom Projection Matrix Builder.
  8518. * This can be used to override the default projection matrix computation.
  8519. */
  8520. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8521. /**
  8522. * The transformed position. Position of the light in world space taking parenting in account.
  8523. */
  8524. transformedPosition: Vector3;
  8525. /**
  8526. * The transformed direction. Direction of the light in world space taking parenting in account.
  8527. */
  8528. transformedDirection: Vector3;
  8529. private _needProjectionMatrixCompute;
  8530. /**
  8531. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8532. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8533. */
  8534. computeTransformedInformation(): boolean;
  8535. /**
  8536. * Return the depth scale used for the shadow map.
  8537. * @returns the depth scale.
  8538. */
  8539. getDepthScale(): number;
  8540. /**
  8541. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8542. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8543. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8544. */
  8545. getShadowDirection(faceIndex?: number): Vector3;
  8546. /**
  8547. * Returns the ShadowLight absolute position in the World.
  8548. * @returns the position vector in world space
  8549. */
  8550. getAbsolutePosition(): Vector3;
  8551. /**
  8552. * Sets the ShadowLight direction toward the passed target.
  8553. * @param target The point to target in local space
  8554. * @returns the updated ShadowLight direction
  8555. */
  8556. setDirectionToTarget(target: Vector3): Vector3;
  8557. /**
  8558. * Returns the light rotation in euler definition.
  8559. * @returns the x y z rotation in local space.
  8560. */
  8561. getRotation(): Vector3;
  8562. /**
  8563. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8564. * @returns true if a cube texture needs to be use
  8565. */
  8566. needCube(): boolean;
  8567. /**
  8568. * Detects if the projection matrix requires to be recomputed this frame.
  8569. * @returns true if it requires to be recomputed otherwise, false.
  8570. */
  8571. needProjectionMatrixCompute(): boolean;
  8572. /**
  8573. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8574. */
  8575. forceProjectionMatrixCompute(): void;
  8576. /** @hidden */
  8577. _initCache(): void;
  8578. /** @hidden */
  8579. _isSynchronized(): boolean;
  8580. /**
  8581. * Computes the world matrix of the node
  8582. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8583. * @returns the world matrix
  8584. */
  8585. computeWorldMatrix(force?: boolean): Matrix;
  8586. /**
  8587. * Gets the minZ used for shadow according to both the scene and the light.
  8588. * @param activeCamera The camera we are returning the min for
  8589. * @returns the depth min z
  8590. */
  8591. getDepthMinZ(activeCamera: Camera): number;
  8592. /**
  8593. * Gets the maxZ used for shadow according to both the scene and the light.
  8594. * @param activeCamera The camera we are returning the max for
  8595. * @returns the depth max z
  8596. */
  8597. getDepthMaxZ(activeCamera: Camera): number;
  8598. /**
  8599. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8600. * @param matrix The materix to updated with the projection information
  8601. * @param viewMatrix The transform matrix of the light
  8602. * @param renderList The list of mesh to render in the map
  8603. * @returns The current light
  8604. */
  8605. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8606. }
  8607. }
  8608. declare module BABYLON {
  8609. /**
  8610. * "Static Class" containing the most commonly used helper while dealing with material for
  8611. * rendering purpose.
  8612. *
  8613. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8614. *
  8615. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8616. */
  8617. export class MaterialHelper {
  8618. /**
  8619. * Bind the current view position to an effect.
  8620. * @param effect The effect to be bound
  8621. * @param scene The scene the eyes position is used from
  8622. */
  8623. static BindEyePosition(effect: Effect, scene: Scene): void;
  8624. /**
  8625. * Helps preparing the defines values about the UVs in used in the effect.
  8626. * UVs are shared as much as we can accross channels in the shaders.
  8627. * @param texture The texture we are preparing the UVs for
  8628. * @param defines The defines to update
  8629. * @param key The channel key "diffuse", "specular"... used in the shader
  8630. */
  8631. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8632. /**
  8633. * Binds a texture matrix value to its corrsponding uniform
  8634. * @param texture The texture to bind the matrix for
  8635. * @param uniformBuffer The uniform buffer receivin the data
  8636. * @param key The channel key "diffuse", "specular"... used in the shader
  8637. */
  8638. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8639. /**
  8640. * Gets the current status of the fog (should it be enabled?)
  8641. * @param mesh defines the mesh to evaluate for fog support
  8642. * @param scene defines the hosting scene
  8643. * @returns true if fog must be enabled
  8644. */
  8645. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8646. /**
  8647. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8648. * @param mesh defines the current mesh
  8649. * @param scene defines the current scene
  8650. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8651. * @param pointsCloud defines if point cloud rendering has to be turned on
  8652. * @param fogEnabled defines if fog has to be turned on
  8653. * @param alphaTest defines if alpha testing has to be turned on
  8654. * @param defines defines the current list of defines
  8655. */
  8656. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8657. /**
  8658. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8659. * @param scene defines the current scene
  8660. * @param engine defines the current engine
  8661. * @param defines specifies the list of active defines
  8662. * @param useInstances defines if instances have to be turned on
  8663. * @param useClipPlane defines if clip plane have to be turned on
  8664. */
  8665. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8666. /**
  8667. * Prepares the defines for bones
  8668. * @param mesh The mesh containing the geometry data we will draw
  8669. * @param defines The defines to update
  8670. */
  8671. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8672. /**
  8673. * Prepares the defines for morph targets
  8674. * @param mesh The mesh containing the geometry data we will draw
  8675. * @param defines The defines to update
  8676. */
  8677. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8678. /**
  8679. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8680. * @param mesh The mesh containing the geometry data we will draw
  8681. * @param defines The defines to update
  8682. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8683. * @param useBones Precise whether bones should be used or not (override mesh info)
  8684. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8685. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8686. * @returns false if defines are considered not dirty and have not been checked
  8687. */
  8688. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8689. /**
  8690. * Prepares the defines related to multiview
  8691. * @param scene The scene we are intending to draw
  8692. * @param defines The defines to update
  8693. */
  8694. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8695. /**
  8696. * Prepares the defines related to the light information passed in parameter
  8697. * @param scene The scene we are intending to draw
  8698. * @param mesh The mesh the effect is compiling for
  8699. * @param light The light the effect is compiling for
  8700. * @param lightIndex The index of the light
  8701. * @param defines The defines to update
  8702. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8703. * @param state Defines the current state regarding what is needed (normals, etc...)
  8704. */
  8705. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8706. needNormals: boolean;
  8707. needRebuild: boolean;
  8708. shadowEnabled: boolean;
  8709. specularEnabled: boolean;
  8710. lightmapMode: boolean;
  8711. }): void;
  8712. /**
  8713. * Prepares the defines related to the light information passed in parameter
  8714. * @param scene The scene we are intending to draw
  8715. * @param mesh The mesh the effect is compiling for
  8716. * @param defines The defines to update
  8717. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8718. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8719. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8720. * @returns true if normals will be required for the rest of the effect
  8721. */
  8722. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8723. /**
  8724. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8725. * @param lightIndex defines the light index
  8726. * @param uniformsList The uniform list
  8727. * @param samplersList The sampler list
  8728. * @param projectedLightTexture defines if projected texture must be used
  8729. * @param uniformBuffersList defines an optional list of uniform buffers
  8730. */
  8731. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8732. /**
  8733. * Prepares the uniforms and samplers list to be used in the effect
  8734. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8735. * @param samplersList The sampler list
  8736. * @param defines The defines helping in the list generation
  8737. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8738. */
  8739. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8740. /**
  8741. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8742. * @param defines The defines to update while falling back
  8743. * @param fallbacks The authorized effect fallbacks
  8744. * @param maxSimultaneousLights The maximum number of lights allowed
  8745. * @param rank the current rank of the Effect
  8746. * @returns The newly affected rank
  8747. */
  8748. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8749. private static _TmpMorphInfluencers;
  8750. /**
  8751. * Prepares the list of attributes required for morph targets according to the effect defines.
  8752. * @param attribs The current list of supported attribs
  8753. * @param mesh The mesh to prepare the morph targets attributes for
  8754. * @param influencers The number of influencers
  8755. */
  8756. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8757. /**
  8758. * Prepares the list of attributes required for morph targets according to the effect defines.
  8759. * @param attribs The current list of supported attribs
  8760. * @param mesh The mesh to prepare the morph targets attributes for
  8761. * @param defines The current Defines of the effect
  8762. */
  8763. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8764. /**
  8765. * Prepares the list of attributes required for bones according to the effect defines.
  8766. * @param attribs The current list of supported attribs
  8767. * @param mesh The mesh to prepare the bones attributes for
  8768. * @param defines The current Defines of the effect
  8769. * @param fallbacks The current efffect fallback strategy
  8770. */
  8771. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8772. /**
  8773. * Check and prepare the list of attributes required for instances according to the effect defines.
  8774. * @param attribs The current list of supported attribs
  8775. * @param defines The current MaterialDefines of the effect
  8776. */
  8777. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8778. /**
  8779. * Add the list of attributes required for instances to the attribs array.
  8780. * @param attribs The current list of supported attribs
  8781. */
  8782. static PushAttributesForInstances(attribs: string[]): void;
  8783. /**
  8784. * Binds the light shadow information to the effect for the given mesh.
  8785. * @param light The light containing the generator
  8786. * @param scene The scene the lights belongs to
  8787. * @param mesh The mesh we are binding the information to render
  8788. * @param lightIndex The light index in the effect used to render the mesh
  8789. * @param effect The effect we are binding the data to
  8790. */
  8791. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8792. /**
  8793. * Binds the light information to the effect.
  8794. * @param light The light containing the generator
  8795. * @param effect The effect we are binding the data to
  8796. * @param lightIndex The light index in the effect used to render
  8797. */
  8798. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8799. /**
  8800. * Binds the lights information from the scene to the effect for the given mesh.
  8801. * @param light Light to bind
  8802. * @param lightIndex Light index
  8803. * @param scene The scene where the light belongs to
  8804. * @param mesh The mesh we are binding the information to render
  8805. * @param effect The effect we are binding the data to
  8806. * @param useSpecular Defines if specular is supported
  8807. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8808. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8809. */
  8810. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8811. /**
  8812. * Binds the lights information from the scene to the effect for the given mesh.
  8813. * @param scene The scene the lights belongs to
  8814. * @param mesh The mesh we are binding the information to render
  8815. * @param effect The effect we are binding the data to
  8816. * @param defines The generated defines for the effect
  8817. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8818. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8819. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8820. */
  8821. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8822. private static _tempFogColor;
  8823. /**
  8824. * Binds the fog information from the scene to the effect for the given mesh.
  8825. * @param scene The scene the lights belongs to
  8826. * @param mesh The mesh we are binding the information to render
  8827. * @param effect The effect we are binding the data to
  8828. * @param linearSpace Defines if the fog effect is applied in linear space
  8829. */
  8830. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8831. /**
  8832. * Binds the bones information from the mesh to the effect.
  8833. * @param mesh The mesh we are binding the information to render
  8834. * @param effect The effect we are binding the data to
  8835. */
  8836. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8837. /**
  8838. * Binds the morph targets information from the mesh to the effect.
  8839. * @param abstractMesh The mesh we are binding the information to render
  8840. * @param effect The effect we are binding the data to
  8841. */
  8842. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8843. /**
  8844. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8845. * @param defines The generated defines used in the effect
  8846. * @param effect The effect we are binding the data to
  8847. * @param scene The scene we are willing to render with logarithmic scale for
  8848. */
  8849. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  8850. /**
  8851. * Binds the clip plane information from the scene to the effect.
  8852. * @param scene The scene the clip plane information are extracted from
  8853. * @param effect The effect we are binding the data to
  8854. */
  8855. static BindClipPlane(effect: Effect, scene: Scene): void;
  8856. }
  8857. }
  8858. declare module BABYLON {
  8859. /** @hidden */
  8860. export var packingFunctions: {
  8861. name: string;
  8862. shader: string;
  8863. };
  8864. }
  8865. declare module BABYLON {
  8866. /** @hidden */
  8867. export var shadowMapPixelShader: {
  8868. name: string;
  8869. shader: string;
  8870. };
  8871. }
  8872. declare module BABYLON {
  8873. /** @hidden */
  8874. export var bonesDeclaration: {
  8875. name: string;
  8876. shader: string;
  8877. };
  8878. }
  8879. declare module BABYLON {
  8880. /** @hidden */
  8881. export var morphTargetsVertexGlobalDeclaration: {
  8882. name: string;
  8883. shader: string;
  8884. };
  8885. }
  8886. declare module BABYLON {
  8887. /** @hidden */
  8888. export var morphTargetsVertexDeclaration: {
  8889. name: string;
  8890. shader: string;
  8891. };
  8892. }
  8893. declare module BABYLON {
  8894. /** @hidden */
  8895. export var instancesDeclaration: {
  8896. name: string;
  8897. shader: string;
  8898. };
  8899. }
  8900. declare module BABYLON {
  8901. /** @hidden */
  8902. export var helperFunctions: {
  8903. name: string;
  8904. shader: string;
  8905. };
  8906. }
  8907. declare module BABYLON {
  8908. /** @hidden */
  8909. export var morphTargetsVertex: {
  8910. name: string;
  8911. shader: string;
  8912. };
  8913. }
  8914. declare module BABYLON {
  8915. /** @hidden */
  8916. export var instancesVertex: {
  8917. name: string;
  8918. shader: string;
  8919. };
  8920. }
  8921. declare module BABYLON {
  8922. /** @hidden */
  8923. export var bonesVertex: {
  8924. name: string;
  8925. shader: string;
  8926. };
  8927. }
  8928. declare module BABYLON {
  8929. /** @hidden */
  8930. export var shadowMapVertexShader: {
  8931. name: string;
  8932. shader: string;
  8933. };
  8934. }
  8935. declare module BABYLON {
  8936. /** @hidden */
  8937. export var depthBoxBlurPixelShader: {
  8938. name: string;
  8939. shader: string;
  8940. };
  8941. }
  8942. declare module BABYLON {
  8943. /**
  8944. * Defines the options associated with the creation of a custom shader for a shadow generator.
  8945. */
  8946. export interface ICustomShaderOptions {
  8947. /**
  8948. * Gets or sets the custom shader name to use
  8949. */
  8950. shaderName: string;
  8951. /**
  8952. * The list of attribute names used in the shader
  8953. */
  8954. attributes?: string[];
  8955. /**
  8956. * The list of unifrom names used in the shader
  8957. */
  8958. uniforms?: string[];
  8959. /**
  8960. * The list of sampler names used in the shader
  8961. */
  8962. samplers?: string[];
  8963. /**
  8964. * The list of defines used in the shader
  8965. */
  8966. defines?: string[];
  8967. }
  8968. /**
  8969. * Interface to implement to create a shadow generator compatible with BJS.
  8970. */
  8971. export interface IShadowGenerator {
  8972. /**
  8973. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  8974. * @returns The render target texture if present otherwise, null
  8975. */
  8976. getShadowMap(): Nullable<RenderTargetTexture>;
  8977. /**
  8978. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  8979. * @returns The render target texture if the shadow map is present otherwise, null
  8980. */
  8981. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  8982. /**
  8983. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  8984. * @param subMesh The submesh we want to render in the shadow map
  8985. * @param useInstances Defines wether will draw in the map using instances
  8986. * @returns true if ready otherwise, false
  8987. */
  8988. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  8989. /**
  8990. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  8991. * @param defines Defines of the material we want to update
  8992. * @param lightIndex Index of the light in the enabled light list of the material
  8993. */
  8994. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  8995. /**
  8996. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  8997. * defined in the generator but impacting the effect).
  8998. * It implies the unifroms available on the materials are the standard BJS ones.
  8999. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9000. * @param effect The effect we are binfing the information for
  9001. */
  9002. bindShadowLight(lightIndex: string, effect: Effect): void;
  9003. /**
  9004. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9005. * (eq to shadow prjection matrix * light transform matrix)
  9006. * @returns The transform matrix used to create the shadow map
  9007. */
  9008. getTransformMatrix(): Matrix;
  9009. /**
  9010. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9011. * Cube and 2D textures for instance.
  9012. */
  9013. recreateShadowMap(): void;
  9014. /**
  9015. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9016. * @param onCompiled Callback triggered at the and of the effects compilation
  9017. * @param options Sets of optional options forcing the compilation with different modes
  9018. */
  9019. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9020. useInstances: boolean;
  9021. }>): void;
  9022. /**
  9023. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9024. * @param options Sets of optional options forcing the compilation with different modes
  9025. * @returns A promise that resolves when the compilation completes
  9026. */
  9027. forceCompilationAsync(options?: Partial<{
  9028. useInstances: boolean;
  9029. }>): Promise<void>;
  9030. /**
  9031. * Serializes the shadow generator setup to a json object.
  9032. * @returns The serialized JSON object
  9033. */
  9034. serialize(): any;
  9035. /**
  9036. * Disposes the Shadow map and related Textures and effects.
  9037. */
  9038. dispose(): void;
  9039. }
  9040. /**
  9041. * Default implementation IShadowGenerator.
  9042. * This is the main object responsible of generating shadows in the framework.
  9043. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9044. */
  9045. export class ShadowGenerator implements IShadowGenerator {
  9046. /**
  9047. * Shadow generator mode None: no filtering applied.
  9048. */
  9049. static readonly FILTER_NONE: number;
  9050. /**
  9051. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9052. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9053. */
  9054. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9055. /**
  9056. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9057. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9058. */
  9059. static readonly FILTER_POISSONSAMPLING: number;
  9060. /**
  9061. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9062. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9063. */
  9064. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9065. /**
  9066. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9067. * edge artifacts on steep falloff.
  9068. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9069. */
  9070. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9071. /**
  9072. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9073. * edge artifacts on steep falloff.
  9074. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9075. */
  9076. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9077. /**
  9078. * Shadow generator mode PCF: Percentage Closer Filtering
  9079. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9080. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9081. */
  9082. static readonly FILTER_PCF: number;
  9083. /**
  9084. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9085. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9086. * Contact Hardening
  9087. */
  9088. static readonly FILTER_PCSS: number;
  9089. /**
  9090. * Reserved for PCF and PCSS
  9091. * Highest Quality.
  9092. *
  9093. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9094. *
  9095. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9096. */
  9097. static readonly QUALITY_HIGH: number;
  9098. /**
  9099. * Reserved for PCF and PCSS
  9100. * Good tradeoff for quality/perf cross devices
  9101. *
  9102. * Execute PCF on a 3*3 kernel.
  9103. *
  9104. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9105. */
  9106. static readonly QUALITY_MEDIUM: number;
  9107. /**
  9108. * Reserved for PCF and PCSS
  9109. * The lowest quality but the fastest.
  9110. *
  9111. * Execute PCF on a 1*1 kernel.
  9112. *
  9113. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9114. */
  9115. static readonly QUALITY_LOW: number;
  9116. /** Gets or sets the custom shader name to use */
  9117. customShaderOptions: ICustomShaderOptions;
  9118. /**
  9119. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9120. */
  9121. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9122. /**
  9123. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9124. */
  9125. onAfterShadowMapRenderObservable: Observable<Effect>;
  9126. /**
  9127. * Observable triggered before a mesh is rendered in the shadow map.
  9128. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9129. */
  9130. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9131. /**
  9132. * Observable triggered after a mesh is rendered in the shadow map.
  9133. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9134. */
  9135. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9136. private _bias;
  9137. /**
  9138. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9139. */
  9140. /**
  9141. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9142. */
  9143. bias: number;
  9144. private _normalBias;
  9145. /**
  9146. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9147. */
  9148. /**
  9149. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9150. */
  9151. normalBias: number;
  9152. private _blurBoxOffset;
  9153. /**
  9154. * Gets the blur box offset: offset applied during the blur pass.
  9155. * Only useful if useKernelBlur = false
  9156. */
  9157. /**
  9158. * Sets the blur box offset: offset applied during the blur pass.
  9159. * Only useful if useKernelBlur = false
  9160. */
  9161. blurBoxOffset: number;
  9162. private _blurScale;
  9163. /**
  9164. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9165. * 2 means half of the size.
  9166. */
  9167. /**
  9168. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9169. * 2 means half of the size.
  9170. */
  9171. blurScale: number;
  9172. private _blurKernel;
  9173. /**
  9174. * Gets the blur kernel: kernel size of the blur pass.
  9175. * Only useful if useKernelBlur = true
  9176. */
  9177. /**
  9178. * Sets the blur kernel: kernel size of the blur pass.
  9179. * Only useful if useKernelBlur = true
  9180. */
  9181. blurKernel: number;
  9182. private _useKernelBlur;
  9183. /**
  9184. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9185. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9186. */
  9187. /**
  9188. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9189. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9190. */
  9191. useKernelBlur: boolean;
  9192. private _depthScale;
  9193. /**
  9194. * Gets the depth scale used in ESM mode.
  9195. */
  9196. /**
  9197. * Sets the depth scale used in ESM mode.
  9198. * This can override the scale stored on the light.
  9199. */
  9200. depthScale: number;
  9201. private _filter;
  9202. /**
  9203. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9204. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9205. */
  9206. /**
  9207. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9208. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9209. */
  9210. filter: number;
  9211. /**
  9212. * Gets if the current filter is set to Poisson Sampling.
  9213. */
  9214. /**
  9215. * Sets the current filter to Poisson Sampling.
  9216. */
  9217. usePoissonSampling: boolean;
  9218. /**
  9219. * Gets if the current filter is set to ESM.
  9220. */
  9221. /**
  9222. * Sets the current filter is to ESM.
  9223. */
  9224. useExponentialShadowMap: boolean;
  9225. /**
  9226. * Gets if the current filter is set to filtered ESM.
  9227. */
  9228. /**
  9229. * Gets if the current filter is set to filtered ESM.
  9230. */
  9231. useBlurExponentialShadowMap: boolean;
  9232. /**
  9233. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9234. * exponential to prevent steep falloff artifacts).
  9235. */
  9236. /**
  9237. * Sets the current filter to "close ESM" (using the inverse of the
  9238. * exponential to prevent steep falloff artifacts).
  9239. */
  9240. useCloseExponentialShadowMap: boolean;
  9241. /**
  9242. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9243. * exponential to prevent steep falloff artifacts).
  9244. */
  9245. /**
  9246. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9247. * exponential to prevent steep falloff artifacts).
  9248. */
  9249. useBlurCloseExponentialShadowMap: boolean;
  9250. /**
  9251. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9252. */
  9253. /**
  9254. * Sets the current filter to "PCF" (percentage closer filtering).
  9255. */
  9256. usePercentageCloserFiltering: boolean;
  9257. private _filteringQuality;
  9258. /**
  9259. * Gets the PCF or PCSS Quality.
  9260. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9261. */
  9262. /**
  9263. * Sets the PCF or PCSS Quality.
  9264. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9265. */
  9266. filteringQuality: number;
  9267. /**
  9268. * Gets if the current filter is set to "PCSS" (contact hardening).
  9269. */
  9270. /**
  9271. * Sets the current filter to "PCSS" (contact hardening).
  9272. */
  9273. useContactHardeningShadow: boolean;
  9274. private _contactHardeningLightSizeUVRatio;
  9275. /**
  9276. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9277. * Using a ratio helps keeping shape stability independently of the map size.
  9278. *
  9279. * It does not account for the light projection as it was having too much
  9280. * instability during the light setup or during light position changes.
  9281. *
  9282. * Only valid if useContactHardeningShadow is true.
  9283. */
  9284. /**
  9285. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9286. * Using a ratio helps keeping shape stability independently of the map size.
  9287. *
  9288. * It does not account for the light projection as it was having too much
  9289. * instability during the light setup or during light position changes.
  9290. *
  9291. * Only valid if useContactHardeningShadow is true.
  9292. */
  9293. contactHardeningLightSizeUVRatio: number;
  9294. private _darkness;
  9295. /** Gets or sets the actual darkness of a shadow */
  9296. darkness: number;
  9297. /**
  9298. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9299. * 0 means strongest and 1 would means no shadow.
  9300. * @returns the darkness.
  9301. */
  9302. getDarkness(): number;
  9303. /**
  9304. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9305. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9306. * @returns the shadow generator allowing fluent coding.
  9307. */
  9308. setDarkness(darkness: number): ShadowGenerator;
  9309. private _transparencyShadow;
  9310. /** Gets or sets the ability to have transparent shadow */
  9311. transparencyShadow: boolean;
  9312. /**
  9313. * Sets the ability to have transparent shadow (boolean).
  9314. * @param transparent True if transparent else False
  9315. * @returns the shadow generator allowing fluent coding
  9316. */
  9317. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9318. private _shadowMap;
  9319. private _shadowMap2;
  9320. /**
  9321. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9322. * @returns The render target texture if present otherwise, null
  9323. */
  9324. getShadowMap(): Nullable<RenderTargetTexture>;
  9325. /**
  9326. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9327. * @returns The render target texture if the shadow map is present otherwise, null
  9328. */
  9329. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9330. /**
  9331. * Gets the class name of that object
  9332. * @returns "ShadowGenerator"
  9333. */
  9334. getClassName(): string;
  9335. /**
  9336. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9337. * @param mesh Mesh to add
  9338. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9339. * @returns the Shadow Generator itself
  9340. */
  9341. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9342. /**
  9343. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9344. * @param mesh Mesh to remove
  9345. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9346. * @returns the Shadow Generator itself
  9347. */
  9348. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9349. /**
  9350. * Controls the extent to which the shadows fade out at the edge of the frustum
  9351. * Used only by directionals and spots
  9352. */
  9353. frustumEdgeFalloff: number;
  9354. private _light;
  9355. /**
  9356. * Returns the associated light object.
  9357. * @returns the light generating the shadow
  9358. */
  9359. getLight(): IShadowLight;
  9360. /**
  9361. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9362. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9363. * It might on the other hand introduce peter panning.
  9364. */
  9365. forceBackFacesOnly: boolean;
  9366. private _scene;
  9367. private _lightDirection;
  9368. private _effect;
  9369. private _viewMatrix;
  9370. private _projectionMatrix;
  9371. private _transformMatrix;
  9372. private _cachedPosition;
  9373. private _cachedDirection;
  9374. private _cachedDefines;
  9375. private _currentRenderID;
  9376. private _boxBlurPostprocess;
  9377. private _kernelBlurXPostprocess;
  9378. private _kernelBlurYPostprocess;
  9379. private _blurPostProcesses;
  9380. private _mapSize;
  9381. private _currentFaceIndex;
  9382. private _currentFaceIndexCache;
  9383. private _textureType;
  9384. private _defaultTextureMatrix;
  9385. /** @hidden */
  9386. static _SceneComponentInitialization: (scene: Scene) => void;
  9387. /**
  9388. * Creates a ShadowGenerator object.
  9389. * A ShadowGenerator is the required tool to use the shadows.
  9390. * Each light casting shadows needs to use its own ShadowGenerator.
  9391. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9392. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9393. * @param light The light object generating the shadows.
  9394. * @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.
  9395. */
  9396. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9397. private _initializeGenerator;
  9398. private _initializeShadowMap;
  9399. private _initializeBlurRTTAndPostProcesses;
  9400. private _renderForShadowMap;
  9401. private _renderSubMeshForShadowMap;
  9402. private _applyFilterValues;
  9403. /**
  9404. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9405. * @param onCompiled Callback triggered at the and of the effects compilation
  9406. * @param options Sets of optional options forcing the compilation with different modes
  9407. */
  9408. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9409. useInstances: boolean;
  9410. }>): void;
  9411. /**
  9412. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9413. * @param options Sets of optional options forcing the compilation with different modes
  9414. * @returns A promise that resolves when the compilation completes
  9415. */
  9416. forceCompilationAsync(options?: Partial<{
  9417. useInstances: boolean;
  9418. }>): Promise<void>;
  9419. /**
  9420. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9421. * @param subMesh The submesh we want to render in the shadow map
  9422. * @param useInstances Defines wether will draw in the map using instances
  9423. * @returns true if ready otherwise, false
  9424. */
  9425. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9426. /**
  9427. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9428. * @param defines Defines of the material we want to update
  9429. * @param lightIndex Index of the light in the enabled light list of the material
  9430. */
  9431. prepareDefines(defines: any, lightIndex: number): void;
  9432. /**
  9433. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9434. * defined in the generator but impacting the effect).
  9435. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9436. * @param effect The effect we are binfing the information for
  9437. */
  9438. bindShadowLight(lightIndex: string, effect: Effect): void;
  9439. /**
  9440. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9441. * (eq to shadow prjection matrix * light transform matrix)
  9442. * @returns The transform matrix used to create the shadow map
  9443. */
  9444. getTransformMatrix(): Matrix;
  9445. /**
  9446. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9447. * Cube and 2D textures for instance.
  9448. */
  9449. recreateShadowMap(): void;
  9450. private _disposeBlurPostProcesses;
  9451. private _disposeRTTandPostProcesses;
  9452. /**
  9453. * Disposes the ShadowGenerator.
  9454. * Returns nothing.
  9455. */
  9456. dispose(): void;
  9457. /**
  9458. * Serializes the shadow generator setup to a json object.
  9459. * @returns The serialized JSON object
  9460. */
  9461. serialize(): any;
  9462. /**
  9463. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9464. * @param parsedShadowGenerator The JSON object to parse
  9465. * @param scene The scene to create the shadow map for
  9466. * @returns The parsed shadow generator
  9467. */
  9468. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9469. }
  9470. }
  9471. declare module BABYLON {
  9472. /**
  9473. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9474. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9475. * 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.
  9476. */
  9477. export abstract class Light extends Node {
  9478. /**
  9479. * Falloff Default: light is falling off following the material specification:
  9480. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9481. */
  9482. static readonly FALLOFF_DEFAULT: number;
  9483. /**
  9484. * Falloff Physical: light is falling off following the inverse squared distance law.
  9485. */
  9486. static readonly FALLOFF_PHYSICAL: number;
  9487. /**
  9488. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9489. * to enhance interoperability with other engines.
  9490. */
  9491. static readonly FALLOFF_GLTF: number;
  9492. /**
  9493. * Falloff Standard: light is falling off like in the standard material
  9494. * to enhance interoperability with other materials.
  9495. */
  9496. static readonly FALLOFF_STANDARD: number;
  9497. /**
  9498. * If every light affecting the material is in this lightmapMode,
  9499. * material.lightmapTexture adds or multiplies
  9500. * (depends on material.useLightmapAsShadowmap)
  9501. * after every other light calculations.
  9502. */
  9503. static readonly LIGHTMAP_DEFAULT: number;
  9504. /**
  9505. * material.lightmapTexture as only diffuse lighting from this light
  9506. * adds only specular lighting from this light
  9507. * adds dynamic shadows
  9508. */
  9509. static readonly LIGHTMAP_SPECULAR: number;
  9510. /**
  9511. * material.lightmapTexture as only lighting
  9512. * no light calculation from this light
  9513. * only adds dynamic shadows from this light
  9514. */
  9515. static readonly LIGHTMAP_SHADOWSONLY: number;
  9516. /**
  9517. * Each light type uses the default quantity according to its type:
  9518. * point/spot lights use luminous intensity
  9519. * directional lights use illuminance
  9520. */
  9521. static readonly INTENSITYMODE_AUTOMATIC: number;
  9522. /**
  9523. * lumen (lm)
  9524. */
  9525. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9526. /**
  9527. * candela (lm/sr)
  9528. */
  9529. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9530. /**
  9531. * lux (lm/m^2)
  9532. */
  9533. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9534. /**
  9535. * nit (cd/m^2)
  9536. */
  9537. static readonly INTENSITYMODE_LUMINANCE: number;
  9538. /**
  9539. * Light type const id of the point light.
  9540. */
  9541. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9542. /**
  9543. * Light type const id of the directional light.
  9544. */
  9545. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9546. /**
  9547. * Light type const id of the spot light.
  9548. */
  9549. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9550. /**
  9551. * Light type const id of the hemispheric light.
  9552. */
  9553. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9554. /**
  9555. * Diffuse gives the basic color to an object.
  9556. */
  9557. diffuse: Color3;
  9558. /**
  9559. * Specular produces a highlight color on an object.
  9560. * Note: This is note affecting PBR materials.
  9561. */
  9562. specular: Color3;
  9563. /**
  9564. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9565. * falling off base on range or angle.
  9566. * This can be set to any values in Light.FALLOFF_x.
  9567. *
  9568. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9569. * other types of materials.
  9570. */
  9571. falloffType: number;
  9572. /**
  9573. * Strength of the light.
  9574. * Note: By default it is define in the framework own unit.
  9575. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9576. */
  9577. intensity: number;
  9578. private _range;
  9579. protected _inverseSquaredRange: number;
  9580. /**
  9581. * Defines how far from the source the light is impacting in scene units.
  9582. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9583. */
  9584. /**
  9585. * Defines how far from the source the light is impacting in scene units.
  9586. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9587. */
  9588. range: number;
  9589. /**
  9590. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9591. * of light.
  9592. */
  9593. private _photometricScale;
  9594. private _intensityMode;
  9595. /**
  9596. * Gets the photometric scale used to interpret the intensity.
  9597. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9598. */
  9599. /**
  9600. * Sets the photometric scale used to interpret the intensity.
  9601. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9602. */
  9603. intensityMode: number;
  9604. private _radius;
  9605. /**
  9606. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9607. */
  9608. /**
  9609. * sets the light radius used by PBR Materials to simulate soft area lights.
  9610. */
  9611. radius: number;
  9612. private _renderPriority;
  9613. /**
  9614. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9615. * exceeding the number allowed of the materials.
  9616. */
  9617. renderPriority: number;
  9618. private _shadowEnabled;
  9619. /**
  9620. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9621. * the current shadow generator.
  9622. */
  9623. /**
  9624. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9625. * the current shadow generator.
  9626. */
  9627. shadowEnabled: boolean;
  9628. private _includedOnlyMeshes;
  9629. /**
  9630. * Gets the only meshes impacted by this light.
  9631. */
  9632. /**
  9633. * Sets the only meshes impacted by this light.
  9634. */
  9635. includedOnlyMeshes: AbstractMesh[];
  9636. private _excludedMeshes;
  9637. /**
  9638. * Gets the meshes not impacted by this light.
  9639. */
  9640. /**
  9641. * Sets the meshes not impacted by this light.
  9642. */
  9643. excludedMeshes: AbstractMesh[];
  9644. private _excludeWithLayerMask;
  9645. /**
  9646. * Gets the layer id use to find what meshes are not impacted by the light.
  9647. * Inactive if 0
  9648. */
  9649. /**
  9650. * Sets the layer id use to find what meshes are not impacted by the light.
  9651. * Inactive if 0
  9652. */
  9653. excludeWithLayerMask: number;
  9654. private _includeOnlyWithLayerMask;
  9655. /**
  9656. * Gets the layer id use to find what meshes are impacted by the light.
  9657. * Inactive if 0
  9658. */
  9659. /**
  9660. * Sets the layer id use to find what meshes are impacted by the light.
  9661. * Inactive if 0
  9662. */
  9663. includeOnlyWithLayerMask: number;
  9664. private _lightmapMode;
  9665. /**
  9666. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9667. */
  9668. /**
  9669. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9670. */
  9671. lightmapMode: number;
  9672. /**
  9673. * Shadow generator associted to the light.
  9674. * @hidden Internal use only.
  9675. */
  9676. _shadowGenerator: Nullable<IShadowGenerator>;
  9677. /**
  9678. * @hidden Internal use only.
  9679. */
  9680. _excludedMeshesIds: string[];
  9681. /**
  9682. * @hidden Internal use only.
  9683. */
  9684. _includedOnlyMeshesIds: string[];
  9685. /**
  9686. * The current light unifom buffer.
  9687. * @hidden Internal use only.
  9688. */
  9689. _uniformBuffer: UniformBuffer;
  9690. /**
  9691. * Creates a Light object in the scene.
  9692. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9693. * @param name The firendly name of the light
  9694. * @param scene The scene the light belongs too
  9695. */
  9696. constructor(name: string, scene: Scene);
  9697. protected abstract _buildUniformLayout(): void;
  9698. /**
  9699. * Sets the passed Effect "effect" with the Light information.
  9700. * @param effect The effect to update
  9701. * @param lightIndex The index of the light in the effect to update
  9702. * @returns The light
  9703. */
  9704. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9705. /**
  9706. * Sets the passed Effect "effect" with the Light information.
  9707. * @param effect The effect to update
  9708. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9709. * @returns The light
  9710. */
  9711. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9712. /**
  9713. * Returns the string "Light".
  9714. * @returns the class name
  9715. */
  9716. getClassName(): string;
  9717. /** @hidden */
  9718. readonly _isLight: boolean;
  9719. /**
  9720. * Converts the light information to a readable string for debug purpose.
  9721. * @param fullDetails Supports for multiple levels of logging within scene loading
  9722. * @returns the human readable light info
  9723. */
  9724. toString(fullDetails?: boolean): string;
  9725. /** @hidden */
  9726. protected _syncParentEnabledState(): void;
  9727. /**
  9728. * Set the enabled state of this node.
  9729. * @param value - the new enabled state
  9730. */
  9731. setEnabled(value: boolean): void;
  9732. /**
  9733. * Returns the Light associated shadow generator if any.
  9734. * @return the associated shadow generator.
  9735. */
  9736. getShadowGenerator(): Nullable<IShadowGenerator>;
  9737. /**
  9738. * Returns a Vector3, the absolute light position in the World.
  9739. * @returns the world space position of the light
  9740. */
  9741. getAbsolutePosition(): Vector3;
  9742. /**
  9743. * Specifies if the light will affect the passed mesh.
  9744. * @param mesh The mesh to test against the light
  9745. * @return true the mesh is affected otherwise, false.
  9746. */
  9747. canAffectMesh(mesh: AbstractMesh): boolean;
  9748. /**
  9749. * Sort function to order lights for rendering.
  9750. * @param a First Light object to compare to second.
  9751. * @param b Second Light object to compare first.
  9752. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9753. */
  9754. static CompareLightsPriority(a: Light, b: Light): number;
  9755. /**
  9756. * Releases resources associated with this node.
  9757. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9758. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9759. */
  9760. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9761. /**
  9762. * Returns the light type ID (integer).
  9763. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9764. */
  9765. getTypeID(): number;
  9766. /**
  9767. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9768. * @returns the scaled intensity in intensity mode unit
  9769. */
  9770. getScaledIntensity(): number;
  9771. /**
  9772. * Returns a new Light object, named "name", from the current one.
  9773. * @param name The name of the cloned light
  9774. * @returns the new created light
  9775. */
  9776. clone(name: string): Nullable<Light>;
  9777. /**
  9778. * Serializes the current light into a Serialization object.
  9779. * @returns the serialized object.
  9780. */
  9781. serialize(): any;
  9782. /**
  9783. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9784. * This new light is named "name" and added to the passed scene.
  9785. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9786. * @param name The friendly name of the light
  9787. * @param scene The scene the new light will belong to
  9788. * @returns the constructor function
  9789. */
  9790. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9791. /**
  9792. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9793. * @param parsedLight The JSON representation of the light
  9794. * @param scene The scene to create the parsed light in
  9795. * @returns the created light after parsing
  9796. */
  9797. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9798. private _hookArrayForExcluded;
  9799. private _hookArrayForIncludedOnly;
  9800. private _resyncMeshes;
  9801. /**
  9802. * Forces the meshes to update their light related information in their rendering used effects
  9803. * @hidden Internal Use Only
  9804. */
  9805. _markMeshesAsLightDirty(): void;
  9806. /**
  9807. * Recomputes the cached photometric scale if needed.
  9808. */
  9809. private _computePhotometricScale;
  9810. /**
  9811. * Returns the Photometric Scale according to the light type and intensity mode.
  9812. */
  9813. private _getPhotometricScale;
  9814. /**
  9815. * Reorder the light in the scene according to their defined priority.
  9816. * @hidden Internal Use Only
  9817. */
  9818. _reorderLightsInScene(): void;
  9819. /**
  9820. * Prepares the list of defines specific to the light type.
  9821. * @param defines the list of defines
  9822. * @param lightIndex defines the index of the light for the effect
  9823. */
  9824. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9825. }
  9826. }
  9827. declare module BABYLON {
  9828. /**
  9829. * Interface used to define Action
  9830. */
  9831. export interface IAction {
  9832. /**
  9833. * Trigger for the action
  9834. */
  9835. trigger: number;
  9836. /** Options of the trigger */
  9837. triggerOptions: any;
  9838. /**
  9839. * Gets the trigger parameters
  9840. * @returns the trigger parameters
  9841. */
  9842. getTriggerParameter(): any;
  9843. /**
  9844. * Internal only - executes current action event
  9845. * @hidden
  9846. */
  9847. _executeCurrent(evt?: ActionEvent): void;
  9848. /**
  9849. * Serialize placeholder for child classes
  9850. * @param parent of child
  9851. * @returns the serialized object
  9852. */
  9853. serialize(parent: any): any;
  9854. /**
  9855. * Internal only
  9856. * @hidden
  9857. */
  9858. _prepare(): void;
  9859. /**
  9860. * Internal only - manager for action
  9861. * @hidden
  9862. */
  9863. _actionManager: AbstractActionManager;
  9864. /**
  9865. * Adds action to chain of actions, may be a DoNothingAction
  9866. * @param action defines the next action to execute
  9867. * @returns The action passed in
  9868. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9869. */
  9870. then(action: IAction): IAction;
  9871. }
  9872. /**
  9873. * The action to be carried out following a trigger
  9874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9875. */
  9876. export class Action implements IAction {
  9877. /** the trigger, with or without parameters, for the action */
  9878. triggerOptions: any;
  9879. /**
  9880. * Trigger for the action
  9881. */
  9882. trigger: number;
  9883. /**
  9884. * Internal only - manager for action
  9885. * @hidden
  9886. */
  9887. _actionManager: ActionManager;
  9888. private _nextActiveAction;
  9889. private _child;
  9890. private _condition?;
  9891. private _triggerParameter;
  9892. /**
  9893. * An event triggered prior to action being executed.
  9894. */
  9895. onBeforeExecuteObservable: Observable<Action>;
  9896. /**
  9897. * Creates a new Action
  9898. * @param triggerOptions the trigger, with or without parameters, for the action
  9899. * @param condition an optional determinant of action
  9900. */
  9901. constructor(
  9902. /** the trigger, with or without parameters, for the action */
  9903. triggerOptions: any, condition?: Condition);
  9904. /**
  9905. * Internal only
  9906. * @hidden
  9907. */
  9908. _prepare(): void;
  9909. /**
  9910. * Gets the trigger parameters
  9911. * @returns the trigger parameters
  9912. */
  9913. getTriggerParameter(): any;
  9914. /**
  9915. * Internal only - executes current action event
  9916. * @hidden
  9917. */
  9918. _executeCurrent(evt?: ActionEvent): void;
  9919. /**
  9920. * Execute placeholder for child classes
  9921. * @param evt optional action event
  9922. */
  9923. execute(evt?: ActionEvent): void;
  9924. /**
  9925. * Skips to next active action
  9926. */
  9927. skipToNextActiveAction(): void;
  9928. /**
  9929. * Adds action to chain of actions, may be a DoNothingAction
  9930. * @param action defines the next action to execute
  9931. * @returns The action passed in
  9932. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9933. */
  9934. then(action: Action): Action;
  9935. /**
  9936. * Internal only
  9937. * @hidden
  9938. */
  9939. _getProperty(propertyPath: string): string;
  9940. /**
  9941. * Internal only
  9942. * @hidden
  9943. */
  9944. _getEffectiveTarget(target: any, propertyPath: string): any;
  9945. /**
  9946. * Serialize placeholder for child classes
  9947. * @param parent of child
  9948. * @returns the serialized object
  9949. */
  9950. serialize(parent: any): any;
  9951. /**
  9952. * Internal only called by serialize
  9953. * @hidden
  9954. */
  9955. protected _serialize(serializedAction: any, parent?: any): any;
  9956. /**
  9957. * Internal only
  9958. * @hidden
  9959. */
  9960. static _SerializeValueAsString: (value: any) => string;
  9961. /**
  9962. * Internal only
  9963. * @hidden
  9964. */
  9965. static _GetTargetProperty: (target: Node | Scene) => {
  9966. name: string;
  9967. targetType: string;
  9968. value: string;
  9969. };
  9970. }
  9971. }
  9972. declare module BABYLON {
  9973. /**
  9974. * A Condition applied to an Action
  9975. */
  9976. export class Condition {
  9977. /**
  9978. * Internal only - manager for action
  9979. * @hidden
  9980. */
  9981. _actionManager: ActionManager;
  9982. /**
  9983. * Internal only
  9984. * @hidden
  9985. */
  9986. _evaluationId: number;
  9987. /**
  9988. * Internal only
  9989. * @hidden
  9990. */
  9991. _currentResult: boolean;
  9992. /**
  9993. * Creates a new Condition
  9994. * @param actionManager the manager of the action the condition is applied to
  9995. */
  9996. constructor(actionManager: ActionManager);
  9997. /**
  9998. * Check if the current condition is valid
  9999. * @returns a boolean
  10000. */
  10001. isValid(): boolean;
  10002. /**
  10003. * Internal only
  10004. * @hidden
  10005. */
  10006. _getProperty(propertyPath: string): string;
  10007. /**
  10008. * Internal only
  10009. * @hidden
  10010. */
  10011. _getEffectiveTarget(target: any, propertyPath: string): any;
  10012. /**
  10013. * Serialize placeholder for child classes
  10014. * @returns the serialized object
  10015. */
  10016. serialize(): any;
  10017. /**
  10018. * Internal only
  10019. * @hidden
  10020. */
  10021. protected _serialize(serializedCondition: any): any;
  10022. }
  10023. /**
  10024. * Defines specific conditional operators as extensions of Condition
  10025. */
  10026. export class ValueCondition extends Condition {
  10027. /** path to specify the property of the target the conditional operator uses */
  10028. propertyPath: string;
  10029. /** the value compared by the conditional operator against the current value of the property */
  10030. value: any;
  10031. /** the conditional operator, default ValueCondition.IsEqual */
  10032. operator: number;
  10033. /**
  10034. * Internal only
  10035. * @hidden
  10036. */
  10037. private static _IsEqual;
  10038. /**
  10039. * Internal only
  10040. * @hidden
  10041. */
  10042. private static _IsDifferent;
  10043. /**
  10044. * Internal only
  10045. * @hidden
  10046. */
  10047. private static _IsGreater;
  10048. /**
  10049. * Internal only
  10050. * @hidden
  10051. */
  10052. private static _IsLesser;
  10053. /**
  10054. * returns the number for IsEqual
  10055. */
  10056. static readonly IsEqual: number;
  10057. /**
  10058. * Returns the number for IsDifferent
  10059. */
  10060. static readonly IsDifferent: number;
  10061. /**
  10062. * Returns the number for IsGreater
  10063. */
  10064. static readonly IsGreater: number;
  10065. /**
  10066. * Returns the number for IsLesser
  10067. */
  10068. static readonly IsLesser: number;
  10069. /**
  10070. * Internal only The action manager for the condition
  10071. * @hidden
  10072. */
  10073. _actionManager: ActionManager;
  10074. /**
  10075. * Internal only
  10076. * @hidden
  10077. */
  10078. private _target;
  10079. /**
  10080. * Internal only
  10081. * @hidden
  10082. */
  10083. private _effectiveTarget;
  10084. /**
  10085. * Internal only
  10086. * @hidden
  10087. */
  10088. private _property;
  10089. /**
  10090. * Creates a new ValueCondition
  10091. * @param actionManager manager for the action the condition applies to
  10092. * @param target for the action
  10093. * @param propertyPath path to specify the property of the target the conditional operator uses
  10094. * @param value the value compared by the conditional operator against the current value of the property
  10095. * @param operator the conditional operator, default ValueCondition.IsEqual
  10096. */
  10097. constructor(actionManager: ActionManager, target: any,
  10098. /** path to specify the property of the target the conditional operator uses */
  10099. propertyPath: string,
  10100. /** the value compared by the conditional operator against the current value of the property */
  10101. value: any,
  10102. /** the conditional operator, default ValueCondition.IsEqual */
  10103. operator?: number);
  10104. /**
  10105. * Compares the given value with the property value for the specified conditional operator
  10106. * @returns the result of the comparison
  10107. */
  10108. isValid(): boolean;
  10109. /**
  10110. * Serialize the ValueCondition into a JSON compatible object
  10111. * @returns serialization object
  10112. */
  10113. serialize(): any;
  10114. /**
  10115. * Gets the name of the conditional operator for the ValueCondition
  10116. * @param operator the conditional operator
  10117. * @returns the name
  10118. */
  10119. static GetOperatorName(operator: number): string;
  10120. }
  10121. /**
  10122. * Defines a predicate condition as an extension of Condition
  10123. */
  10124. export class PredicateCondition extends Condition {
  10125. /** defines the predicate function used to validate the condition */
  10126. predicate: () => boolean;
  10127. /**
  10128. * Internal only - manager for action
  10129. * @hidden
  10130. */
  10131. _actionManager: ActionManager;
  10132. /**
  10133. * Creates a new PredicateCondition
  10134. * @param actionManager manager for the action the condition applies to
  10135. * @param predicate defines the predicate function used to validate the condition
  10136. */
  10137. constructor(actionManager: ActionManager,
  10138. /** defines the predicate function used to validate the condition */
  10139. predicate: () => boolean);
  10140. /**
  10141. * @returns the validity of the predicate condition
  10142. */
  10143. isValid(): boolean;
  10144. }
  10145. /**
  10146. * Defines a state condition as an extension of Condition
  10147. */
  10148. export class StateCondition extends Condition {
  10149. /** Value to compare with target state */
  10150. value: string;
  10151. /**
  10152. * Internal only - manager for action
  10153. * @hidden
  10154. */
  10155. _actionManager: ActionManager;
  10156. /**
  10157. * Internal only
  10158. * @hidden
  10159. */
  10160. private _target;
  10161. /**
  10162. * Creates a new StateCondition
  10163. * @param actionManager manager for the action the condition applies to
  10164. * @param target of the condition
  10165. * @param value to compare with target state
  10166. */
  10167. constructor(actionManager: ActionManager, target: any,
  10168. /** Value to compare with target state */
  10169. value: string);
  10170. /**
  10171. * Gets a boolean indicating if the current condition is met
  10172. * @returns the validity of the state
  10173. */
  10174. isValid(): boolean;
  10175. /**
  10176. * Serialize the StateCondition into a JSON compatible object
  10177. * @returns serialization object
  10178. */
  10179. serialize(): any;
  10180. }
  10181. }
  10182. declare module BABYLON {
  10183. /**
  10184. * This defines an action responsible to toggle a boolean once triggered.
  10185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10186. */
  10187. export class SwitchBooleanAction extends Action {
  10188. /**
  10189. * The path to the boolean property in the target object
  10190. */
  10191. propertyPath: string;
  10192. private _target;
  10193. private _effectiveTarget;
  10194. private _property;
  10195. /**
  10196. * Instantiate the action
  10197. * @param triggerOptions defines the trigger options
  10198. * @param target defines the object containing the boolean
  10199. * @param propertyPath defines the path to the boolean property in the target object
  10200. * @param condition defines the trigger related conditions
  10201. */
  10202. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10203. /** @hidden */
  10204. _prepare(): void;
  10205. /**
  10206. * Execute the action toggle the boolean value.
  10207. */
  10208. execute(): void;
  10209. /**
  10210. * Serializes the actions and its related information.
  10211. * @param parent defines the object to serialize in
  10212. * @returns the serialized object
  10213. */
  10214. serialize(parent: any): any;
  10215. }
  10216. /**
  10217. * This defines an action responsible to set a the state field of the target
  10218. * to a desired value once triggered.
  10219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10220. */
  10221. export class SetStateAction extends Action {
  10222. /**
  10223. * The value to store in the state field.
  10224. */
  10225. value: string;
  10226. private _target;
  10227. /**
  10228. * Instantiate the action
  10229. * @param triggerOptions defines the trigger options
  10230. * @param target defines the object containing the state property
  10231. * @param value defines the value to store in the state field
  10232. * @param condition defines the trigger related conditions
  10233. */
  10234. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10235. /**
  10236. * Execute the action and store the value on the target state property.
  10237. */
  10238. execute(): void;
  10239. /**
  10240. * Serializes the actions and its related information.
  10241. * @param parent defines the object to serialize in
  10242. * @returns the serialized object
  10243. */
  10244. serialize(parent: any): any;
  10245. }
  10246. /**
  10247. * This defines an action responsible to set a property of the target
  10248. * to a desired value once triggered.
  10249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10250. */
  10251. export class SetValueAction extends Action {
  10252. /**
  10253. * The path of the property to set in the target.
  10254. */
  10255. propertyPath: string;
  10256. /**
  10257. * The value to set in the property
  10258. */
  10259. value: any;
  10260. private _target;
  10261. private _effectiveTarget;
  10262. private _property;
  10263. /**
  10264. * Instantiate the action
  10265. * @param triggerOptions defines the trigger options
  10266. * @param target defines the object containing the property
  10267. * @param propertyPath defines the path of the property to set in the target
  10268. * @param value defines the value to set in the property
  10269. * @param condition defines the trigger related conditions
  10270. */
  10271. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10272. /** @hidden */
  10273. _prepare(): void;
  10274. /**
  10275. * Execute the action and set the targetted property to the desired value.
  10276. */
  10277. execute(): void;
  10278. /**
  10279. * Serializes the actions and its related information.
  10280. * @param parent defines the object to serialize in
  10281. * @returns the serialized object
  10282. */
  10283. serialize(parent: any): any;
  10284. }
  10285. /**
  10286. * This defines an action responsible to increment the target value
  10287. * to a desired value once triggered.
  10288. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10289. */
  10290. export class IncrementValueAction extends Action {
  10291. /**
  10292. * The path of the property to increment in the target.
  10293. */
  10294. propertyPath: string;
  10295. /**
  10296. * The value we should increment the property by.
  10297. */
  10298. value: any;
  10299. private _target;
  10300. private _effectiveTarget;
  10301. private _property;
  10302. /**
  10303. * Instantiate the action
  10304. * @param triggerOptions defines the trigger options
  10305. * @param target defines the object containing the property
  10306. * @param propertyPath defines the path of the property to increment in the target
  10307. * @param value defines the value value we should increment the property by
  10308. * @param condition defines the trigger related conditions
  10309. */
  10310. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10311. /** @hidden */
  10312. _prepare(): void;
  10313. /**
  10314. * Execute the action and increment the target of the value amount.
  10315. */
  10316. execute(): void;
  10317. /**
  10318. * Serializes the actions and its related information.
  10319. * @param parent defines the object to serialize in
  10320. * @returns the serialized object
  10321. */
  10322. serialize(parent: any): any;
  10323. }
  10324. /**
  10325. * This defines an action responsible to start an animation once triggered.
  10326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10327. */
  10328. export class PlayAnimationAction extends Action {
  10329. /**
  10330. * Where the animation should start (animation frame)
  10331. */
  10332. from: number;
  10333. /**
  10334. * Where the animation should stop (animation frame)
  10335. */
  10336. to: number;
  10337. /**
  10338. * Define if the animation should loop or stop after the first play.
  10339. */
  10340. loop?: boolean;
  10341. private _target;
  10342. /**
  10343. * Instantiate the action
  10344. * @param triggerOptions defines the trigger options
  10345. * @param target defines the target animation or animation name
  10346. * @param from defines from where the animation should start (animation frame)
  10347. * @param end defines where the animation should stop (animation frame)
  10348. * @param loop defines if the animation should loop or stop after the first play
  10349. * @param condition defines the trigger related conditions
  10350. */
  10351. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10352. /** @hidden */
  10353. _prepare(): void;
  10354. /**
  10355. * Execute the action and play the animation.
  10356. */
  10357. execute(): void;
  10358. /**
  10359. * Serializes the actions and its related information.
  10360. * @param parent defines the object to serialize in
  10361. * @returns the serialized object
  10362. */
  10363. serialize(parent: any): any;
  10364. }
  10365. /**
  10366. * This defines an action responsible to stop an animation once triggered.
  10367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10368. */
  10369. export class StopAnimationAction extends Action {
  10370. private _target;
  10371. /**
  10372. * Instantiate the action
  10373. * @param triggerOptions defines the trigger options
  10374. * @param target defines the target animation or animation name
  10375. * @param condition defines the trigger related conditions
  10376. */
  10377. constructor(triggerOptions: any, target: any, condition?: Condition);
  10378. /** @hidden */
  10379. _prepare(): void;
  10380. /**
  10381. * Execute the action and stop the animation.
  10382. */
  10383. execute(): void;
  10384. /**
  10385. * Serializes the actions and its related information.
  10386. * @param parent defines the object to serialize in
  10387. * @returns the serialized object
  10388. */
  10389. serialize(parent: any): any;
  10390. }
  10391. /**
  10392. * This defines an action responsible that does nothing once triggered.
  10393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10394. */
  10395. export class DoNothingAction extends Action {
  10396. /**
  10397. * Instantiate the action
  10398. * @param triggerOptions defines the trigger options
  10399. * @param condition defines the trigger related conditions
  10400. */
  10401. constructor(triggerOptions?: any, condition?: Condition);
  10402. /**
  10403. * Execute the action and do nothing.
  10404. */
  10405. execute(): void;
  10406. /**
  10407. * Serializes the actions and its related information.
  10408. * @param parent defines the object to serialize in
  10409. * @returns the serialized object
  10410. */
  10411. serialize(parent: any): any;
  10412. }
  10413. /**
  10414. * This defines an action responsible to trigger several actions once triggered.
  10415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10416. */
  10417. export class CombineAction extends Action {
  10418. /**
  10419. * The list of aggregated animations to run.
  10420. */
  10421. children: Action[];
  10422. /**
  10423. * Instantiate the action
  10424. * @param triggerOptions defines the trigger options
  10425. * @param children defines the list of aggregated animations to run
  10426. * @param condition defines the trigger related conditions
  10427. */
  10428. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10429. /** @hidden */
  10430. _prepare(): void;
  10431. /**
  10432. * Execute the action and executes all the aggregated actions.
  10433. */
  10434. execute(evt: ActionEvent): void;
  10435. /**
  10436. * Serializes the actions and its related information.
  10437. * @param parent defines the object to serialize in
  10438. * @returns the serialized object
  10439. */
  10440. serialize(parent: any): any;
  10441. }
  10442. /**
  10443. * This defines an action responsible to run code (external event) once triggered.
  10444. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10445. */
  10446. export class ExecuteCodeAction extends Action {
  10447. /**
  10448. * The callback function to run.
  10449. */
  10450. func: (evt: ActionEvent) => void;
  10451. /**
  10452. * Instantiate the action
  10453. * @param triggerOptions defines the trigger options
  10454. * @param func defines the callback function to run
  10455. * @param condition defines the trigger related conditions
  10456. */
  10457. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10458. /**
  10459. * Execute the action and run the attached code.
  10460. */
  10461. execute(evt: ActionEvent): void;
  10462. }
  10463. /**
  10464. * This defines an action responsible to set the parent property of the target once triggered.
  10465. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10466. */
  10467. export class SetParentAction extends Action {
  10468. private _parent;
  10469. private _target;
  10470. /**
  10471. * Instantiate the action
  10472. * @param triggerOptions defines the trigger options
  10473. * @param target defines the target containing the parent property
  10474. * @param parent defines from where the animation should start (animation frame)
  10475. * @param condition defines the trigger related conditions
  10476. */
  10477. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10478. /** @hidden */
  10479. _prepare(): void;
  10480. /**
  10481. * Execute the action and set the parent property.
  10482. */
  10483. execute(): void;
  10484. /**
  10485. * Serializes the actions and its related information.
  10486. * @param parent defines the object to serialize in
  10487. * @returns the serialized object
  10488. */
  10489. serialize(parent: any): any;
  10490. }
  10491. }
  10492. declare module BABYLON {
  10493. /**
  10494. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10495. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10496. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10497. */
  10498. export class ActionManager extends AbstractActionManager {
  10499. /**
  10500. * Nothing
  10501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10502. */
  10503. static readonly NothingTrigger: number;
  10504. /**
  10505. * On pick
  10506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10507. */
  10508. static readonly OnPickTrigger: number;
  10509. /**
  10510. * On left pick
  10511. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10512. */
  10513. static readonly OnLeftPickTrigger: number;
  10514. /**
  10515. * On right pick
  10516. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10517. */
  10518. static readonly OnRightPickTrigger: number;
  10519. /**
  10520. * On center pick
  10521. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10522. */
  10523. static readonly OnCenterPickTrigger: number;
  10524. /**
  10525. * On pick down
  10526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10527. */
  10528. static readonly OnPickDownTrigger: number;
  10529. /**
  10530. * On double pick
  10531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10532. */
  10533. static readonly OnDoublePickTrigger: number;
  10534. /**
  10535. * On pick up
  10536. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10537. */
  10538. static readonly OnPickUpTrigger: number;
  10539. /**
  10540. * On pick out.
  10541. * This trigger will only be raised if you also declared a OnPickDown
  10542. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10543. */
  10544. static readonly OnPickOutTrigger: number;
  10545. /**
  10546. * On long press
  10547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10548. */
  10549. static readonly OnLongPressTrigger: number;
  10550. /**
  10551. * On pointer over
  10552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10553. */
  10554. static readonly OnPointerOverTrigger: number;
  10555. /**
  10556. * On pointer out
  10557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10558. */
  10559. static readonly OnPointerOutTrigger: number;
  10560. /**
  10561. * On every frame
  10562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10563. */
  10564. static readonly OnEveryFrameTrigger: number;
  10565. /**
  10566. * On intersection enter
  10567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10568. */
  10569. static readonly OnIntersectionEnterTrigger: number;
  10570. /**
  10571. * On intersection exit
  10572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10573. */
  10574. static readonly OnIntersectionExitTrigger: number;
  10575. /**
  10576. * On key down
  10577. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10578. */
  10579. static readonly OnKeyDownTrigger: number;
  10580. /**
  10581. * On key up
  10582. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10583. */
  10584. static readonly OnKeyUpTrigger: number;
  10585. private _scene;
  10586. /**
  10587. * Creates a new action manager
  10588. * @param scene defines the hosting scene
  10589. */
  10590. constructor(scene: Scene);
  10591. /**
  10592. * Releases all associated resources
  10593. */
  10594. dispose(): void;
  10595. /**
  10596. * Gets hosting scene
  10597. * @returns the hosting scene
  10598. */
  10599. getScene(): Scene;
  10600. /**
  10601. * Does this action manager handles actions of any of the given triggers
  10602. * @param triggers defines the triggers to be tested
  10603. * @return a boolean indicating whether one (or more) of the triggers is handled
  10604. */
  10605. hasSpecificTriggers(triggers: number[]): boolean;
  10606. /**
  10607. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10608. * speed.
  10609. * @param triggerA defines the trigger to be tested
  10610. * @param triggerB defines the trigger to be tested
  10611. * @return a boolean indicating whether one (or more) of the triggers is handled
  10612. */
  10613. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10614. /**
  10615. * Does this action manager handles actions of a given trigger
  10616. * @param trigger defines the trigger to be tested
  10617. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10618. * @return whether the trigger is handled
  10619. */
  10620. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10621. /**
  10622. * Does this action manager has pointer triggers
  10623. */
  10624. readonly hasPointerTriggers: boolean;
  10625. /**
  10626. * Does this action manager has pick triggers
  10627. */
  10628. readonly hasPickTriggers: boolean;
  10629. /**
  10630. * Registers an action to this action manager
  10631. * @param action defines the action to be registered
  10632. * @return the action amended (prepared) after registration
  10633. */
  10634. registerAction(action: IAction): Nullable<IAction>;
  10635. /**
  10636. * Unregisters an action to this action manager
  10637. * @param action defines the action to be unregistered
  10638. * @return a boolean indicating whether the action has been unregistered
  10639. */
  10640. unregisterAction(action: IAction): Boolean;
  10641. /**
  10642. * Process a specific trigger
  10643. * @param trigger defines the trigger to process
  10644. * @param evt defines the event details to be processed
  10645. */
  10646. processTrigger(trigger: number, evt?: IActionEvent): void;
  10647. /** @hidden */
  10648. _getEffectiveTarget(target: any, propertyPath: string): any;
  10649. /** @hidden */
  10650. _getProperty(propertyPath: string): string;
  10651. /**
  10652. * Serialize this manager to a JSON object
  10653. * @param name defines the property name to store this manager
  10654. * @returns a JSON representation of this manager
  10655. */
  10656. serialize(name: string): any;
  10657. /**
  10658. * Creates a new ActionManager from a JSON data
  10659. * @param parsedActions defines the JSON data to read from
  10660. * @param object defines the hosting mesh
  10661. * @param scene defines the hosting scene
  10662. */
  10663. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10664. /**
  10665. * Get a trigger name by index
  10666. * @param trigger defines the trigger index
  10667. * @returns a trigger name
  10668. */
  10669. static GetTriggerName(trigger: number): string;
  10670. }
  10671. }
  10672. declare module BABYLON {
  10673. /**
  10674. * Class representing a ray with position and direction
  10675. */
  10676. export class Ray {
  10677. /** origin point */
  10678. origin: Vector3;
  10679. /** direction */
  10680. direction: Vector3;
  10681. /** length of the ray */
  10682. length: number;
  10683. private static readonly TmpVector3;
  10684. private _tmpRay;
  10685. /**
  10686. * Creates a new ray
  10687. * @param origin origin point
  10688. * @param direction direction
  10689. * @param length length of the ray
  10690. */
  10691. constructor(
  10692. /** origin point */
  10693. origin: Vector3,
  10694. /** direction */
  10695. direction: Vector3,
  10696. /** length of the ray */
  10697. length?: number);
  10698. /**
  10699. * Checks if the ray intersects a box
  10700. * @param minimum bound of the box
  10701. * @param maximum bound of the box
  10702. * @param intersectionTreshold extra extend to be added to the box in all direction
  10703. * @returns if the box was hit
  10704. */
  10705. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10706. /**
  10707. * Checks if the ray intersects a box
  10708. * @param box the bounding box to check
  10709. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10710. * @returns if the box was hit
  10711. */
  10712. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10713. /**
  10714. * If the ray hits a sphere
  10715. * @param sphere the bounding sphere to check
  10716. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10717. * @returns true if it hits the sphere
  10718. */
  10719. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10720. /**
  10721. * If the ray hits a triange
  10722. * @param vertex0 triangle vertex
  10723. * @param vertex1 triangle vertex
  10724. * @param vertex2 triangle vertex
  10725. * @returns intersection information if hit
  10726. */
  10727. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10728. /**
  10729. * Checks if ray intersects a plane
  10730. * @param plane the plane to check
  10731. * @returns the distance away it was hit
  10732. */
  10733. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10734. /**
  10735. * Calculate the intercept of a ray on a given axis
  10736. * @param axis to check 'x' | 'y' | 'z'
  10737. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10738. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10739. */
  10740. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10741. /**
  10742. * Checks if ray intersects a mesh
  10743. * @param mesh the mesh to check
  10744. * @param fastCheck if only the bounding box should checked
  10745. * @returns picking info of the intersecton
  10746. */
  10747. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10748. /**
  10749. * Checks if ray intersects a mesh
  10750. * @param meshes the meshes to check
  10751. * @param fastCheck if only the bounding box should checked
  10752. * @param results array to store result in
  10753. * @returns Array of picking infos
  10754. */
  10755. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10756. private _comparePickingInfo;
  10757. private static smallnum;
  10758. private static rayl;
  10759. /**
  10760. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10761. * @param sega the first point of the segment to test the intersection against
  10762. * @param segb the second point of the segment to test the intersection against
  10763. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10764. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10765. */
  10766. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10767. /**
  10768. * Update the ray from viewport position
  10769. * @param x position
  10770. * @param y y position
  10771. * @param viewportWidth viewport width
  10772. * @param viewportHeight viewport height
  10773. * @param world world matrix
  10774. * @param view view matrix
  10775. * @param projection projection matrix
  10776. * @returns this ray updated
  10777. */
  10778. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10779. /**
  10780. * Creates a ray with origin and direction of 0,0,0
  10781. * @returns the new ray
  10782. */
  10783. static Zero(): Ray;
  10784. /**
  10785. * Creates a new ray from screen space and viewport
  10786. * @param x position
  10787. * @param y y position
  10788. * @param viewportWidth viewport width
  10789. * @param viewportHeight viewport height
  10790. * @param world world matrix
  10791. * @param view view matrix
  10792. * @param projection projection matrix
  10793. * @returns new ray
  10794. */
  10795. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10796. /**
  10797. * 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
  10798. * transformed to the given world matrix.
  10799. * @param origin The origin point
  10800. * @param end The end point
  10801. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10802. * @returns the new ray
  10803. */
  10804. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10805. /**
  10806. * Transforms a ray by a matrix
  10807. * @param ray ray to transform
  10808. * @param matrix matrix to apply
  10809. * @returns the resulting new ray
  10810. */
  10811. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10812. /**
  10813. * Transforms a ray by a matrix
  10814. * @param ray ray to transform
  10815. * @param matrix matrix to apply
  10816. * @param result ray to store result in
  10817. */
  10818. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10819. /**
  10820. * Unproject a ray from screen space to object space
  10821. * @param sourceX defines the screen space x coordinate to use
  10822. * @param sourceY defines the screen space y coordinate to use
  10823. * @param viewportWidth defines the current width of the viewport
  10824. * @param viewportHeight defines the current height of the viewport
  10825. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10826. * @param view defines the view matrix to use
  10827. * @param projection defines the projection matrix to use
  10828. */
  10829. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10830. }
  10831. /**
  10832. * Type used to define predicate used to select faces when a mesh intersection is detected
  10833. */
  10834. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10835. interface Scene {
  10836. /** @hidden */
  10837. _tempPickingRay: Nullable<Ray>;
  10838. /** @hidden */
  10839. _cachedRayForTransform: Ray;
  10840. /** @hidden */
  10841. _pickWithRayInverseMatrix: Matrix;
  10842. /** @hidden */
  10843. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10844. /** @hidden */
  10845. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10846. }
  10847. }
  10848. declare module BABYLON {
  10849. /**
  10850. * Groups all the scene component constants in one place to ease maintenance.
  10851. * @hidden
  10852. */
  10853. export class SceneComponentConstants {
  10854. static readonly NAME_EFFECTLAYER: string;
  10855. static readonly NAME_LAYER: string;
  10856. static readonly NAME_LENSFLARESYSTEM: string;
  10857. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10858. static readonly NAME_PARTICLESYSTEM: string;
  10859. static readonly NAME_GAMEPAD: string;
  10860. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10861. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10862. static readonly NAME_DEPTHRENDERER: string;
  10863. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10864. static readonly NAME_SPRITE: string;
  10865. static readonly NAME_OUTLINERENDERER: string;
  10866. static readonly NAME_PROCEDURALTEXTURE: string;
  10867. static readonly NAME_SHADOWGENERATOR: string;
  10868. static readonly NAME_OCTREE: string;
  10869. static readonly NAME_PHYSICSENGINE: string;
  10870. static readonly NAME_AUDIO: string;
  10871. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10872. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10873. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10874. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10875. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10876. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10877. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10878. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10879. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10880. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10881. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10882. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10883. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10884. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10885. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10886. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10887. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10888. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10889. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10890. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10891. static readonly STEP_AFTERRENDER_AUDIO: number;
  10892. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10893. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10894. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10895. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10896. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10897. static readonly STEP_POINTERMOVE_SPRITE: number;
  10898. static readonly STEP_POINTERDOWN_SPRITE: number;
  10899. static readonly STEP_POINTERUP_SPRITE: number;
  10900. }
  10901. /**
  10902. * This represents a scene component.
  10903. *
  10904. * This is used to decouple the dependency the scene is having on the different workloads like
  10905. * layers, post processes...
  10906. */
  10907. export interface ISceneComponent {
  10908. /**
  10909. * The name of the component. Each component must have a unique name.
  10910. */
  10911. name: string;
  10912. /**
  10913. * The scene the component belongs to.
  10914. */
  10915. scene: Scene;
  10916. /**
  10917. * Register the component to one instance of a scene.
  10918. */
  10919. register(): void;
  10920. /**
  10921. * Rebuilds the elements related to this component in case of
  10922. * context lost for instance.
  10923. */
  10924. rebuild(): void;
  10925. /**
  10926. * Disposes the component and the associated ressources.
  10927. */
  10928. dispose(): void;
  10929. }
  10930. /**
  10931. * This represents a SERIALIZABLE scene component.
  10932. *
  10933. * This extends Scene Component to add Serialization methods on top.
  10934. */
  10935. export interface ISceneSerializableComponent extends ISceneComponent {
  10936. /**
  10937. * Adds all the elements from the container to the scene
  10938. * @param container the container holding the elements
  10939. */
  10940. addFromContainer(container: AbstractScene): void;
  10941. /**
  10942. * Removes all the elements in the container from the scene
  10943. * @param container contains the elements to remove
  10944. * @param dispose if the removed element should be disposed (default: false)
  10945. */
  10946. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10947. /**
  10948. * Serializes the component data to the specified json object
  10949. * @param serializationObject The object to serialize to
  10950. */
  10951. serialize(serializationObject: any): void;
  10952. }
  10953. /**
  10954. * Strong typing of a Mesh related stage step action
  10955. */
  10956. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10957. /**
  10958. * Strong typing of a Evaluate Sub Mesh related stage step action
  10959. */
  10960. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10961. /**
  10962. * Strong typing of a Active Mesh related stage step action
  10963. */
  10964. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10965. /**
  10966. * Strong typing of a Camera related stage step action
  10967. */
  10968. export type CameraStageAction = (camera: Camera) => void;
  10969. /**
  10970. * Strong typing of a Camera Frame buffer related stage step action
  10971. */
  10972. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10973. /**
  10974. * Strong typing of a Render Target related stage step action
  10975. */
  10976. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10977. /**
  10978. * Strong typing of a RenderingGroup related stage step action
  10979. */
  10980. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10981. /**
  10982. * Strong typing of a Mesh Render related stage step action
  10983. */
  10984. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10985. /**
  10986. * Strong typing of a simple stage step action
  10987. */
  10988. export type SimpleStageAction = () => void;
  10989. /**
  10990. * Strong typing of a render target action.
  10991. */
  10992. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10993. /**
  10994. * Strong typing of a pointer move action.
  10995. */
  10996. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10997. /**
  10998. * Strong typing of a pointer up/down action.
  10999. */
  11000. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11001. /**
  11002. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11003. * @hidden
  11004. */
  11005. export class Stage<T extends Function> extends Array<{
  11006. index: number;
  11007. component: ISceneComponent;
  11008. action: T;
  11009. }> {
  11010. /**
  11011. * Hide ctor from the rest of the world.
  11012. * @param items The items to add.
  11013. */
  11014. private constructor();
  11015. /**
  11016. * Creates a new Stage.
  11017. * @returns A new instance of a Stage
  11018. */
  11019. static Create<T extends Function>(): Stage<T>;
  11020. /**
  11021. * Registers a step in an ordered way in the targeted stage.
  11022. * @param index Defines the position to register the step in
  11023. * @param component Defines the component attached to the step
  11024. * @param action Defines the action to launch during the step
  11025. */
  11026. registerStep(index: number, component: ISceneComponent, action: T): void;
  11027. /**
  11028. * Clears all the steps from the stage.
  11029. */
  11030. clear(): void;
  11031. }
  11032. }
  11033. declare module BABYLON {
  11034. interface Scene {
  11035. /** @hidden */
  11036. _pointerOverSprite: Nullable<Sprite>;
  11037. /** @hidden */
  11038. _pickedDownSprite: Nullable<Sprite>;
  11039. /** @hidden */
  11040. _tempSpritePickingRay: Nullable<Ray>;
  11041. /**
  11042. * All of the sprite managers added to this scene
  11043. * @see http://doc.babylonjs.com/babylon101/sprites
  11044. */
  11045. spriteManagers: Array<ISpriteManager>;
  11046. /**
  11047. * An event triggered when sprites rendering is about to start
  11048. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11049. */
  11050. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11051. /**
  11052. * An event triggered when sprites rendering is done
  11053. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11054. */
  11055. onAfterSpritesRenderingObservable: Observable<Scene>;
  11056. /** @hidden */
  11057. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11058. /** Launch a ray to try to pick a sprite in the scene
  11059. * @param x position on screen
  11060. * @param y position on screen
  11061. * @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
  11062. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11063. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11064. * @returns a PickingInfo
  11065. */
  11066. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11067. /** Use the given ray to pick a sprite in the scene
  11068. * @param ray The ray (in world space) to use to pick meshes
  11069. * @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
  11070. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11071. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11072. * @returns a PickingInfo
  11073. */
  11074. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11075. /** @hidden */
  11076. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11077. /** Launch a ray to try to pick sprites in the scene
  11078. * @param x position on screen
  11079. * @param y position on screen
  11080. * @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
  11081. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11082. * @returns a PickingInfo array
  11083. */
  11084. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11085. /** Use the given ray to pick sprites in the scene
  11086. * @param ray The ray (in world space) to use to pick meshes
  11087. * @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
  11088. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11089. * @returns a PickingInfo array
  11090. */
  11091. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11092. /**
  11093. * Force the sprite under the pointer
  11094. * @param sprite defines the sprite to use
  11095. */
  11096. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11097. /**
  11098. * Gets the sprite under the pointer
  11099. * @returns a Sprite or null if no sprite is under the pointer
  11100. */
  11101. getPointerOverSprite(): Nullable<Sprite>;
  11102. }
  11103. /**
  11104. * Defines the sprite scene component responsible to manage sprites
  11105. * in a given scene.
  11106. */
  11107. export class SpriteSceneComponent implements ISceneComponent {
  11108. /**
  11109. * The component name helpfull to identify the component in the list of scene components.
  11110. */
  11111. readonly name: string;
  11112. /**
  11113. * The scene the component belongs to.
  11114. */
  11115. scene: Scene;
  11116. /** @hidden */
  11117. private _spritePredicate;
  11118. /**
  11119. * Creates a new instance of the component for the given scene
  11120. * @param scene Defines the scene to register the component in
  11121. */
  11122. constructor(scene: Scene);
  11123. /**
  11124. * Registers the component in a given scene
  11125. */
  11126. register(): void;
  11127. /**
  11128. * Rebuilds the elements related to this component in case of
  11129. * context lost for instance.
  11130. */
  11131. rebuild(): void;
  11132. /**
  11133. * Disposes the component and the associated ressources.
  11134. */
  11135. dispose(): void;
  11136. private _pickSpriteButKeepRay;
  11137. private _pointerMove;
  11138. private _pointerDown;
  11139. private _pointerUp;
  11140. }
  11141. }
  11142. declare module BABYLON {
  11143. /** @hidden */
  11144. export var fogFragmentDeclaration: {
  11145. name: string;
  11146. shader: string;
  11147. };
  11148. }
  11149. declare module BABYLON {
  11150. /** @hidden */
  11151. export var fogFragment: {
  11152. name: string;
  11153. shader: string;
  11154. };
  11155. }
  11156. declare module BABYLON {
  11157. /** @hidden */
  11158. export var spritesPixelShader: {
  11159. name: string;
  11160. shader: string;
  11161. };
  11162. }
  11163. declare module BABYLON {
  11164. /** @hidden */
  11165. export var fogVertexDeclaration: {
  11166. name: string;
  11167. shader: string;
  11168. };
  11169. }
  11170. declare module BABYLON {
  11171. /** @hidden */
  11172. export var spritesVertexShader: {
  11173. name: string;
  11174. shader: string;
  11175. };
  11176. }
  11177. declare module BABYLON {
  11178. /**
  11179. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11180. */
  11181. export interface ISpriteManager extends IDisposable {
  11182. /**
  11183. * Restricts the camera to viewing objects with the same layerMask.
  11184. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11185. */
  11186. layerMask: number;
  11187. /**
  11188. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11189. */
  11190. isPickable: boolean;
  11191. /**
  11192. * Specifies the rendering group id for this mesh (0 by default)
  11193. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11194. */
  11195. renderingGroupId: number;
  11196. /**
  11197. * Defines the list of sprites managed by the manager.
  11198. */
  11199. sprites: Array<Sprite>;
  11200. /**
  11201. * Tests the intersection of a sprite with a specific ray.
  11202. * @param ray The ray we are sending to test the collision
  11203. * @param camera The camera space we are sending rays in
  11204. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11205. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11206. * @returns picking info or null.
  11207. */
  11208. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11209. /**
  11210. * Intersects the sprites with a ray
  11211. * @param ray defines the ray to intersect with
  11212. * @param camera defines the current active camera
  11213. * @param predicate defines a predicate used to select candidate sprites
  11214. * @returns null if no hit or a PickingInfo array
  11215. */
  11216. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11217. /**
  11218. * Renders the list of sprites on screen.
  11219. */
  11220. render(): void;
  11221. }
  11222. /**
  11223. * Class used to manage multiple sprites on the same spritesheet
  11224. * @see http://doc.babylonjs.com/babylon101/sprites
  11225. */
  11226. export class SpriteManager implements ISpriteManager {
  11227. /** defines the manager's name */
  11228. name: string;
  11229. /** Gets the list of sprites */
  11230. sprites: Sprite[];
  11231. /** Gets or sets the rendering group id (0 by default) */
  11232. renderingGroupId: number;
  11233. /** Gets or sets camera layer mask */
  11234. layerMask: number;
  11235. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11236. fogEnabled: boolean;
  11237. /** Gets or sets a boolean indicating if the sprites are pickable */
  11238. isPickable: boolean;
  11239. /** Defines the default width of a cell in the spritesheet */
  11240. cellWidth: number;
  11241. /** Defines the default height of a cell in the spritesheet */
  11242. cellHeight: number;
  11243. /** Associative array from JSON sprite data file */
  11244. private _cellData;
  11245. /** Array of sprite names from JSON sprite data file */
  11246. private _spriteMap;
  11247. /** True when packed cell data from JSON file is ready*/
  11248. private _packedAndReady;
  11249. /**
  11250. * An event triggered when the manager is disposed.
  11251. */
  11252. onDisposeObservable: Observable<SpriteManager>;
  11253. private _onDisposeObserver;
  11254. /**
  11255. * Callback called when the manager is disposed
  11256. */
  11257. onDispose: () => void;
  11258. private _capacity;
  11259. private _fromPacked;
  11260. private _spriteTexture;
  11261. private _epsilon;
  11262. private _scene;
  11263. private _vertexData;
  11264. private _buffer;
  11265. private _vertexBuffers;
  11266. private _indexBuffer;
  11267. private _effectBase;
  11268. private _effectFog;
  11269. /**
  11270. * Gets or sets the spritesheet texture
  11271. */
  11272. texture: Texture;
  11273. /**
  11274. * Creates a new sprite manager
  11275. * @param name defines the manager's name
  11276. * @param imgUrl defines the sprite sheet url
  11277. * @param capacity defines the maximum allowed number of sprites
  11278. * @param cellSize defines the size of a sprite cell
  11279. * @param scene defines the hosting scene
  11280. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11281. * @param samplingMode defines the smapling mode to use with spritesheet
  11282. * @param fromPacked set to false; do not alter
  11283. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11284. */
  11285. constructor(
  11286. /** defines the manager's name */
  11287. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11288. private _makePacked;
  11289. private _appendSpriteVertex;
  11290. /**
  11291. * Intersects the sprites with a ray
  11292. * @param ray defines the ray to intersect with
  11293. * @param camera defines the current active camera
  11294. * @param predicate defines a predicate used to select candidate sprites
  11295. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11296. * @returns null if no hit or a PickingInfo
  11297. */
  11298. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11299. /**
  11300. * Intersects the sprites with a ray
  11301. * @param ray defines the ray to intersect with
  11302. * @param camera defines the current active camera
  11303. * @param predicate defines a predicate used to select candidate sprites
  11304. * @returns null if no hit or a PickingInfo array
  11305. */
  11306. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11307. /**
  11308. * Render all child sprites
  11309. */
  11310. render(): void;
  11311. /**
  11312. * Release associated resources
  11313. */
  11314. dispose(): void;
  11315. }
  11316. }
  11317. declare module BABYLON {
  11318. /**
  11319. * Class used to represent a sprite
  11320. * @see http://doc.babylonjs.com/babylon101/sprites
  11321. */
  11322. export class Sprite {
  11323. /** defines the name */
  11324. name: string;
  11325. /** Gets or sets the current world position */
  11326. position: Vector3;
  11327. /** Gets or sets the main color */
  11328. color: Color4;
  11329. /** Gets or sets the width */
  11330. width: number;
  11331. /** Gets or sets the height */
  11332. height: number;
  11333. /** Gets or sets rotation angle */
  11334. angle: number;
  11335. /** Gets or sets the cell index in the sprite sheet */
  11336. cellIndex: number;
  11337. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11338. cellRef: string;
  11339. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11340. invertU: number;
  11341. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11342. invertV: number;
  11343. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11344. disposeWhenFinishedAnimating: boolean;
  11345. /** Gets the list of attached animations */
  11346. animations: Animation[];
  11347. /** Gets or sets a boolean indicating if the sprite can be picked */
  11348. isPickable: boolean;
  11349. /**
  11350. * Gets or sets the associated action manager
  11351. */
  11352. actionManager: Nullable<ActionManager>;
  11353. private _animationStarted;
  11354. private _loopAnimation;
  11355. private _fromIndex;
  11356. private _toIndex;
  11357. private _delay;
  11358. private _direction;
  11359. private _manager;
  11360. private _time;
  11361. private _onAnimationEnd;
  11362. /**
  11363. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11364. */
  11365. isVisible: boolean;
  11366. /**
  11367. * Gets or sets the sprite size
  11368. */
  11369. size: number;
  11370. /**
  11371. * Creates a new Sprite
  11372. * @param name defines the name
  11373. * @param manager defines the manager
  11374. */
  11375. constructor(
  11376. /** defines the name */
  11377. name: string, manager: ISpriteManager);
  11378. /**
  11379. * Starts an animation
  11380. * @param from defines the initial key
  11381. * @param to defines the end key
  11382. * @param loop defines if the animation must loop
  11383. * @param delay defines the start delay (in ms)
  11384. * @param onAnimationEnd defines a callback to call when animation ends
  11385. */
  11386. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11387. /** Stops current animation (if any) */
  11388. stopAnimation(): void;
  11389. /** @hidden */
  11390. _animate(deltaTime: number): void;
  11391. /** Release associated resources */
  11392. dispose(): void;
  11393. }
  11394. }
  11395. declare module BABYLON {
  11396. /**
  11397. * Information about the result of picking within a scene
  11398. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11399. */
  11400. export class PickingInfo {
  11401. /** @hidden */
  11402. _pickingUnavailable: boolean;
  11403. /**
  11404. * If the pick collided with an object
  11405. */
  11406. hit: boolean;
  11407. /**
  11408. * Distance away where the pick collided
  11409. */
  11410. distance: number;
  11411. /**
  11412. * The location of pick collision
  11413. */
  11414. pickedPoint: Nullable<Vector3>;
  11415. /**
  11416. * The mesh corresponding the the pick collision
  11417. */
  11418. pickedMesh: Nullable<AbstractMesh>;
  11419. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11420. bu: number;
  11421. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11422. bv: number;
  11423. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11424. faceId: number;
  11425. /** Id of the the submesh that was picked */
  11426. subMeshId: number;
  11427. /** If a sprite was picked, this will be the sprite the pick collided with */
  11428. pickedSprite: Nullable<Sprite>;
  11429. /**
  11430. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11431. */
  11432. originMesh: Nullable<AbstractMesh>;
  11433. /**
  11434. * The ray that was used to perform the picking.
  11435. */
  11436. ray: Nullable<Ray>;
  11437. /**
  11438. * Gets the normal correspodning to the face the pick collided with
  11439. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11440. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11441. * @returns The normal correspodning to the face the pick collided with
  11442. */
  11443. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11444. /**
  11445. * Gets the texture coordinates of where the pick occured
  11446. * @returns the vector containing the coordnates of the texture
  11447. */
  11448. getTextureCoordinates(): Nullable<Vector2>;
  11449. }
  11450. }
  11451. declare module BABYLON {
  11452. /**
  11453. * Gather the list of pointer event types as constants.
  11454. */
  11455. export class PointerEventTypes {
  11456. /**
  11457. * 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.
  11458. */
  11459. static readonly POINTERDOWN: number;
  11460. /**
  11461. * The pointerup event is fired when a pointer is no longer active.
  11462. */
  11463. static readonly POINTERUP: number;
  11464. /**
  11465. * The pointermove event is fired when a pointer changes coordinates.
  11466. */
  11467. static readonly POINTERMOVE: number;
  11468. /**
  11469. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11470. */
  11471. static readonly POINTERWHEEL: number;
  11472. /**
  11473. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11474. */
  11475. static readonly POINTERPICK: number;
  11476. /**
  11477. * The pointertap event is fired when a the object has been touched and released without drag.
  11478. */
  11479. static readonly POINTERTAP: number;
  11480. /**
  11481. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11482. */
  11483. static readonly POINTERDOUBLETAP: number;
  11484. }
  11485. /**
  11486. * Base class of pointer info types.
  11487. */
  11488. export class PointerInfoBase {
  11489. /**
  11490. * Defines the type of event (PointerEventTypes)
  11491. */
  11492. type: number;
  11493. /**
  11494. * Defines the related dom event
  11495. */
  11496. event: PointerEvent | MouseWheelEvent;
  11497. /**
  11498. * Instantiates the base class of pointers info.
  11499. * @param type Defines the type of event (PointerEventTypes)
  11500. * @param event Defines the related dom event
  11501. */
  11502. constructor(
  11503. /**
  11504. * Defines the type of event (PointerEventTypes)
  11505. */
  11506. type: number,
  11507. /**
  11508. * Defines the related dom event
  11509. */
  11510. event: PointerEvent | MouseWheelEvent);
  11511. }
  11512. /**
  11513. * This class is used to store pointer related info for the onPrePointerObservable event.
  11514. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11515. */
  11516. export class PointerInfoPre extends PointerInfoBase {
  11517. /**
  11518. * Ray from a pointer if availible (eg. 6dof controller)
  11519. */
  11520. ray: Nullable<Ray>;
  11521. /**
  11522. * Defines the local position of the pointer on the canvas.
  11523. */
  11524. localPosition: Vector2;
  11525. /**
  11526. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11527. */
  11528. skipOnPointerObservable: boolean;
  11529. /**
  11530. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11531. * @param type Defines the type of event (PointerEventTypes)
  11532. * @param event Defines the related dom event
  11533. * @param localX Defines the local x coordinates of the pointer when the event occured
  11534. * @param localY Defines the local y coordinates of the pointer when the event occured
  11535. */
  11536. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11537. }
  11538. /**
  11539. * This type contains all the data related to a pointer event in Babylon.js.
  11540. * 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.
  11541. */
  11542. export class PointerInfo extends PointerInfoBase {
  11543. /**
  11544. * Defines the picking info associated to the info (if any)\
  11545. */
  11546. pickInfo: Nullable<PickingInfo>;
  11547. /**
  11548. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11549. * @param type Defines the type of event (PointerEventTypes)
  11550. * @param event Defines the related dom event
  11551. * @param pickInfo Defines the picking info associated to the info (if any)\
  11552. */
  11553. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11554. /**
  11555. * Defines the picking info associated to the info (if any)\
  11556. */
  11557. pickInfo: Nullable<PickingInfo>);
  11558. }
  11559. /**
  11560. * Data relating to a touch event on the screen.
  11561. */
  11562. export interface PointerTouch {
  11563. /**
  11564. * X coordinate of touch.
  11565. */
  11566. x: number;
  11567. /**
  11568. * Y coordinate of touch.
  11569. */
  11570. y: number;
  11571. /**
  11572. * Id of touch. Unique for each finger.
  11573. */
  11574. pointerId: number;
  11575. /**
  11576. * Event type passed from DOM.
  11577. */
  11578. type: any;
  11579. }
  11580. }
  11581. declare module BABYLON {
  11582. /**
  11583. * Manage the mouse inputs to control the movement of a free camera.
  11584. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11585. */
  11586. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11587. /**
  11588. * Define if touch is enabled in the mouse input
  11589. */
  11590. touchEnabled: boolean;
  11591. /**
  11592. * Defines the camera the input is attached to.
  11593. */
  11594. camera: FreeCamera;
  11595. /**
  11596. * Defines the buttons associated with the input to handle camera move.
  11597. */
  11598. buttons: number[];
  11599. /**
  11600. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11601. */
  11602. angularSensibility: number;
  11603. private _pointerInput;
  11604. private _onMouseMove;
  11605. private _observer;
  11606. private previousPosition;
  11607. /**
  11608. * Observable for when a pointer move event occurs containing the move offset
  11609. */
  11610. onPointerMovedObservable: Observable<{
  11611. offsetX: number;
  11612. offsetY: number;
  11613. }>;
  11614. /**
  11615. * @hidden
  11616. * If the camera should be rotated automatically based on pointer movement
  11617. */
  11618. _allowCameraRotation: boolean;
  11619. /**
  11620. * Manage the mouse inputs to control the movement of a free camera.
  11621. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11622. * @param touchEnabled Defines if touch is enabled or not
  11623. */
  11624. constructor(
  11625. /**
  11626. * Define if touch is enabled in the mouse input
  11627. */
  11628. touchEnabled?: boolean);
  11629. /**
  11630. * Attach the input controls to a specific dom element to get the input from.
  11631. * @param element Defines the element the controls should be listened from
  11632. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11633. */
  11634. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11635. /**
  11636. * Called on JS contextmenu event.
  11637. * Override this method to provide functionality.
  11638. */
  11639. protected onContextMenu(evt: PointerEvent): void;
  11640. /**
  11641. * Detach the current controls from the specified dom element.
  11642. * @param element Defines the element to stop listening the inputs from
  11643. */
  11644. detachControl(element: Nullable<HTMLElement>): void;
  11645. /**
  11646. * Gets the class name of the current intput.
  11647. * @returns the class name
  11648. */
  11649. getClassName(): string;
  11650. /**
  11651. * Get the friendly name associated with the input class.
  11652. * @returns the input friendly name
  11653. */
  11654. getSimpleName(): string;
  11655. }
  11656. }
  11657. declare module BABYLON {
  11658. /**
  11659. * Manage the touch inputs to control the movement of a free camera.
  11660. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11661. */
  11662. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11663. /**
  11664. * Defines the camera the input is attached to.
  11665. */
  11666. camera: FreeCamera;
  11667. /**
  11668. * Defines the touch sensibility for rotation.
  11669. * The higher the faster.
  11670. */
  11671. touchAngularSensibility: number;
  11672. /**
  11673. * Defines the touch sensibility for move.
  11674. * The higher the faster.
  11675. */
  11676. touchMoveSensibility: number;
  11677. private _offsetX;
  11678. private _offsetY;
  11679. private _pointerPressed;
  11680. private _pointerInput;
  11681. private _observer;
  11682. private _onLostFocus;
  11683. /**
  11684. * Attach the input controls to a specific dom element to get the input from.
  11685. * @param element Defines the element the controls should be listened from
  11686. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11687. */
  11688. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11689. /**
  11690. * Detach the current controls from the specified dom element.
  11691. * @param element Defines the element to stop listening the inputs from
  11692. */
  11693. detachControl(element: Nullable<HTMLElement>): void;
  11694. /**
  11695. * Update the current camera state depending on the inputs that have been used this frame.
  11696. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11697. */
  11698. checkInputs(): void;
  11699. /**
  11700. * Gets the class name of the current intput.
  11701. * @returns the class name
  11702. */
  11703. getClassName(): string;
  11704. /**
  11705. * Get the friendly name associated with the input class.
  11706. * @returns the input friendly name
  11707. */
  11708. getSimpleName(): string;
  11709. }
  11710. }
  11711. declare module BABYLON {
  11712. /**
  11713. * Default Inputs manager for the FreeCamera.
  11714. * It groups all the default supported inputs for ease of use.
  11715. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11716. */
  11717. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11718. /**
  11719. * @hidden
  11720. */
  11721. _mouseInput: Nullable<FreeCameraMouseInput>;
  11722. /**
  11723. * Instantiates a new FreeCameraInputsManager.
  11724. * @param camera Defines the camera the inputs belong to
  11725. */
  11726. constructor(camera: FreeCamera);
  11727. /**
  11728. * Add keyboard input support to the input manager.
  11729. * @returns the current input manager
  11730. */
  11731. addKeyboard(): FreeCameraInputsManager;
  11732. /**
  11733. * Add mouse input support to the input manager.
  11734. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11735. * @returns the current input manager
  11736. */
  11737. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11738. /**
  11739. * Removes the mouse input support from the manager
  11740. * @returns the current input manager
  11741. */
  11742. removeMouse(): FreeCameraInputsManager;
  11743. /**
  11744. * Add touch input support to the input manager.
  11745. * @returns the current input manager
  11746. */
  11747. addTouch(): FreeCameraInputsManager;
  11748. /**
  11749. * Remove all attached input methods from a camera
  11750. */
  11751. clear(): void;
  11752. }
  11753. }
  11754. declare module BABYLON {
  11755. /**
  11756. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11757. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11758. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11759. */
  11760. export class FreeCamera extends TargetCamera {
  11761. /**
  11762. * Define the collision ellipsoid of the camera.
  11763. * This is helpful to simulate a camera body like the player body around the camera
  11764. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11765. */
  11766. ellipsoid: Vector3;
  11767. /**
  11768. * Define an offset for the position of the ellipsoid around the camera.
  11769. * This can be helpful to determine the center of the body near the gravity center of the body
  11770. * instead of its head.
  11771. */
  11772. ellipsoidOffset: Vector3;
  11773. /**
  11774. * Enable or disable collisions of the camera with the rest of the scene objects.
  11775. */
  11776. checkCollisions: boolean;
  11777. /**
  11778. * Enable or disable gravity on the camera.
  11779. */
  11780. applyGravity: boolean;
  11781. /**
  11782. * Define the input manager associated to the camera.
  11783. */
  11784. inputs: FreeCameraInputsManager;
  11785. /**
  11786. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11787. * Higher values reduce sensitivity.
  11788. */
  11789. /**
  11790. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11791. * Higher values reduce sensitivity.
  11792. */
  11793. angularSensibility: number;
  11794. /**
  11795. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11796. */
  11797. keysUp: number[];
  11798. /**
  11799. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11800. */
  11801. keysDown: number[];
  11802. /**
  11803. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11804. */
  11805. keysLeft: number[];
  11806. /**
  11807. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11808. */
  11809. keysRight: number[];
  11810. /**
  11811. * Event raised when the camera collide with a mesh in the scene.
  11812. */
  11813. onCollide: (collidedMesh: AbstractMesh) => void;
  11814. private _collider;
  11815. private _needMoveForGravity;
  11816. private _oldPosition;
  11817. private _diffPosition;
  11818. private _newPosition;
  11819. /** @hidden */
  11820. _localDirection: Vector3;
  11821. /** @hidden */
  11822. _transformedDirection: Vector3;
  11823. /**
  11824. * Instantiates a Free Camera.
  11825. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11826. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11827. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11828. * @param name Define the name of the camera in the scene
  11829. * @param position Define the start position of the camera in the scene
  11830. * @param scene Define the scene the camera belongs to
  11831. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11832. */
  11833. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11834. /**
  11835. * Attached controls to the current camera.
  11836. * @param element Defines the element the controls should be listened from
  11837. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11838. */
  11839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11840. /**
  11841. * Detach the current controls from the camera.
  11842. * The camera will stop reacting to inputs.
  11843. * @param element Defines the element to stop listening the inputs from
  11844. */
  11845. detachControl(element: HTMLElement): void;
  11846. private _collisionMask;
  11847. /**
  11848. * Define a collision mask to limit the list of object the camera can collide with
  11849. */
  11850. collisionMask: number;
  11851. /** @hidden */
  11852. _collideWithWorld(displacement: Vector3): void;
  11853. private _onCollisionPositionChange;
  11854. /** @hidden */
  11855. _checkInputs(): void;
  11856. /** @hidden */
  11857. _decideIfNeedsToMove(): boolean;
  11858. /** @hidden */
  11859. _updatePosition(): void;
  11860. /**
  11861. * Destroy the camera and release the current resources hold by it.
  11862. */
  11863. dispose(): void;
  11864. /**
  11865. * Gets the current object class name.
  11866. * @return the class name
  11867. */
  11868. getClassName(): string;
  11869. }
  11870. }
  11871. declare module BABYLON {
  11872. /**
  11873. * Represents a gamepad control stick position
  11874. */
  11875. export class StickValues {
  11876. /**
  11877. * The x component of the control stick
  11878. */
  11879. x: number;
  11880. /**
  11881. * The y component of the control stick
  11882. */
  11883. y: number;
  11884. /**
  11885. * Initializes the gamepad x and y control stick values
  11886. * @param x The x component of the gamepad control stick value
  11887. * @param y The y component of the gamepad control stick value
  11888. */
  11889. constructor(
  11890. /**
  11891. * The x component of the control stick
  11892. */
  11893. x: number,
  11894. /**
  11895. * The y component of the control stick
  11896. */
  11897. y: number);
  11898. }
  11899. /**
  11900. * An interface which manages callbacks for gamepad button changes
  11901. */
  11902. export interface GamepadButtonChanges {
  11903. /**
  11904. * Called when a gamepad has been changed
  11905. */
  11906. changed: boolean;
  11907. /**
  11908. * Called when a gamepad press event has been triggered
  11909. */
  11910. pressChanged: boolean;
  11911. /**
  11912. * Called when a touch event has been triggered
  11913. */
  11914. touchChanged: boolean;
  11915. /**
  11916. * Called when a value has changed
  11917. */
  11918. valueChanged: boolean;
  11919. }
  11920. /**
  11921. * Represents a gamepad
  11922. */
  11923. export class Gamepad {
  11924. /**
  11925. * The id of the gamepad
  11926. */
  11927. id: string;
  11928. /**
  11929. * The index of the gamepad
  11930. */
  11931. index: number;
  11932. /**
  11933. * The browser gamepad
  11934. */
  11935. browserGamepad: any;
  11936. /**
  11937. * Specifies what type of gamepad this represents
  11938. */
  11939. type: number;
  11940. private _leftStick;
  11941. private _rightStick;
  11942. /** @hidden */
  11943. _isConnected: boolean;
  11944. private _leftStickAxisX;
  11945. private _leftStickAxisY;
  11946. private _rightStickAxisX;
  11947. private _rightStickAxisY;
  11948. /**
  11949. * Triggered when the left control stick has been changed
  11950. */
  11951. private _onleftstickchanged;
  11952. /**
  11953. * Triggered when the right control stick has been changed
  11954. */
  11955. private _onrightstickchanged;
  11956. /**
  11957. * Represents a gamepad controller
  11958. */
  11959. static GAMEPAD: number;
  11960. /**
  11961. * Represents a generic controller
  11962. */
  11963. static GENERIC: number;
  11964. /**
  11965. * Represents an XBox controller
  11966. */
  11967. static XBOX: number;
  11968. /**
  11969. * Represents a pose-enabled controller
  11970. */
  11971. static POSE_ENABLED: number;
  11972. /**
  11973. * Represents an Dual Shock controller
  11974. */
  11975. static DUALSHOCK: number;
  11976. /**
  11977. * Specifies whether the left control stick should be Y-inverted
  11978. */
  11979. protected _invertLeftStickY: boolean;
  11980. /**
  11981. * Specifies if the gamepad has been connected
  11982. */
  11983. readonly isConnected: boolean;
  11984. /**
  11985. * Initializes the gamepad
  11986. * @param id The id of the gamepad
  11987. * @param index The index of the gamepad
  11988. * @param browserGamepad The browser gamepad
  11989. * @param leftStickX The x component of the left joystick
  11990. * @param leftStickY The y component of the left joystick
  11991. * @param rightStickX The x component of the right joystick
  11992. * @param rightStickY The y component of the right joystick
  11993. */
  11994. constructor(
  11995. /**
  11996. * The id of the gamepad
  11997. */
  11998. id: string,
  11999. /**
  12000. * The index of the gamepad
  12001. */
  12002. index: number,
  12003. /**
  12004. * The browser gamepad
  12005. */
  12006. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12007. /**
  12008. * Callback triggered when the left joystick has changed
  12009. * @param callback
  12010. */
  12011. onleftstickchanged(callback: (values: StickValues) => void): void;
  12012. /**
  12013. * Callback triggered when the right joystick has changed
  12014. * @param callback
  12015. */
  12016. onrightstickchanged(callback: (values: StickValues) => void): void;
  12017. /**
  12018. * Gets the left joystick
  12019. */
  12020. /**
  12021. * Sets the left joystick values
  12022. */
  12023. leftStick: StickValues;
  12024. /**
  12025. * Gets the right joystick
  12026. */
  12027. /**
  12028. * Sets the right joystick value
  12029. */
  12030. rightStick: StickValues;
  12031. /**
  12032. * Updates the gamepad joystick positions
  12033. */
  12034. update(): void;
  12035. /**
  12036. * Disposes the gamepad
  12037. */
  12038. dispose(): void;
  12039. }
  12040. /**
  12041. * Represents a generic gamepad
  12042. */
  12043. export class GenericPad extends Gamepad {
  12044. private _buttons;
  12045. private _onbuttondown;
  12046. private _onbuttonup;
  12047. /**
  12048. * Observable triggered when a button has been pressed
  12049. */
  12050. onButtonDownObservable: Observable<number>;
  12051. /**
  12052. * Observable triggered when a button has been released
  12053. */
  12054. onButtonUpObservable: Observable<number>;
  12055. /**
  12056. * Callback triggered when a button has been pressed
  12057. * @param callback Called when a button has been pressed
  12058. */
  12059. onbuttondown(callback: (buttonPressed: number) => void): void;
  12060. /**
  12061. * Callback triggered when a button has been released
  12062. * @param callback Called when a button has been released
  12063. */
  12064. onbuttonup(callback: (buttonReleased: number) => void): void;
  12065. /**
  12066. * Initializes the generic gamepad
  12067. * @param id The id of the generic gamepad
  12068. * @param index The index of the generic gamepad
  12069. * @param browserGamepad The browser gamepad
  12070. */
  12071. constructor(id: string, index: number, browserGamepad: any);
  12072. private _setButtonValue;
  12073. /**
  12074. * Updates the generic gamepad
  12075. */
  12076. update(): void;
  12077. /**
  12078. * Disposes the generic gamepad
  12079. */
  12080. dispose(): void;
  12081. }
  12082. }
  12083. declare module BABYLON {
  12084. interface Engine {
  12085. /**
  12086. * Creates a raw texture
  12087. * @param data defines the data to store in the texture
  12088. * @param width defines the width of the texture
  12089. * @param height defines the height of the texture
  12090. * @param format defines the format of the data
  12091. * @param generateMipMaps defines if the engine should generate the mip levels
  12092. * @param invertY defines if data must be stored with Y axis inverted
  12093. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12094. * @param compression defines the compression used (null by default)
  12095. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12096. * @returns the raw texture inside an InternalTexture
  12097. */
  12098. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12099. /**
  12100. * Update a raw texture
  12101. * @param texture defines the texture to update
  12102. * @param data defines the data to store in the texture
  12103. * @param format defines the format of the data
  12104. * @param invertY defines if data must be stored with Y axis inverted
  12105. */
  12106. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12107. /**
  12108. * Update a raw texture
  12109. * @param texture defines the texture to update
  12110. * @param data defines the data to store in the texture
  12111. * @param format defines the format of the data
  12112. * @param invertY defines if data must be stored with Y axis inverted
  12113. * @param compression defines the compression used (null by default)
  12114. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12115. */
  12116. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12117. /**
  12118. * Creates a new raw cube texture
  12119. * @param data defines the array of data to use to create each face
  12120. * @param size defines the size of the textures
  12121. * @param format defines the format of the data
  12122. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12123. * @param generateMipMaps defines if the engine should generate the mip levels
  12124. * @param invertY defines if data must be stored with Y axis inverted
  12125. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12126. * @param compression defines the compression used (null by default)
  12127. * @returns the cube texture as an InternalTexture
  12128. */
  12129. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12130. /**
  12131. * Update a raw cube texture
  12132. * @param texture defines the texture to udpdate
  12133. * @param data defines the data to store
  12134. * @param format defines the data format
  12135. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12136. * @param invertY defines if data must be stored with Y axis inverted
  12137. */
  12138. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12139. /**
  12140. * Update a raw cube texture
  12141. * @param texture defines the texture to udpdate
  12142. * @param data defines the data to store
  12143. * @param format defines the data format
  12144. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12145. * @param invertY defines if data must be stored with Y axis inverted
  12146. * @param compression defines the compression used (null by default)
  12147. */
  12148. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12149. /**
  12150. * Update a raw cube texture
  12151. * @param texture defines the texture to udpdate
  12152. * @param data defines the data to store
  12153. * @param format defines the data format
  12154. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12155. * @param invertY defines if data must be stored with Y axis inverted
  12156. * @param compression defines the compression used (null by default)
  12157. * @param level defines which level of the texture to update
  12158. */
  12159. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12160. /**
  12161. * Creates a new raw cube texture from a specified url
  12162. * @param url defines the url where the data is located
  12163. * @param scene defines the current scene
  12164. * @param size defines the size of the textures
  12165. * @param format defines the format of the data
  12166. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12167. * @param noMipmap defines if the engine should avoid generating the mip levels
  12168. * @param callback defines a callback used to extract texture data from loaded data
  12169. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12170. * @param onLoad defines a callback called when texture is loaded
  12171. * @param onError defines a callback called if there is an error
  12172. * @returns the cube texture as an InternalTexture
  12173. */
  12174. 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;
  12175. /**
  12176. * Creates a new raw cube texture from a specified url
  12177. * @param url defines the url where the data is located
  12178. * @param scene defines the current scene
  12179. * @param size defines the size of the textures
  12180. * @param format defines the format of the data
  12181. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12182. * @param noMipmap defines if the engine should avoid generating the mip levels
  12183. * @param callback defines a callback used to extract texture data from loaded data
  12184. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12185. * @param onLoad defines a callback called when texture is loaded
  12186. * @param onError defines a callback called if there is an error
  12187. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12188. * @param invertY defines if data must be stored with Y axis inverted
  12189. * @returns the cube texture as an InternalTexture
  12190. */
  12191. 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;
  12192. /**
  12193. * Creates a new raw 3D texture
  12194. * @param data defines the data used to create the texture
  12195. * @param width defines the width of the texture
  12196. * @param height defines the height of the texture
  12197. * @param depth defines the depth of the texture
  12198. * @param format defines the format of the texture
  12199. * @param generateMipMaps defines if the engine must generate mip levels
  12200. * @param invertY defines if data must be stored with Y axis inverted
  12201. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12202. * @param compression defines the compressed used (can be null)
  12203. * @param textureType defines the compressed used (can be null)
  12204. * @returns a new raw 3D texture (stored in an InternalTexture)
  12205. */
  12206. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12207. /**
  12208. * Update a raw 3D texture
  12209. * @param texture defines the texture to update
  12210. * @param data defines the data to store
  12211. * @param format defines the data format
  12212. * @param invertY defines if data must be stored with Y axis inverted
  12213. */
  12214. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12215. /**
  12216. * Update a raw 3D texture
  12217. * @param texture defines the texture to update
  12218. * @param data defines the data to store
  12219. * @param format defines the data format
  12220. * @param invertY defines if data must be stored with Y axis inverted
  12221. * @param compression defines the used compression (can be null)
  12222. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12223. */
  12224. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12225. }
  12226. }
  12227. declare module BABYLON {
  12228. /**
  12229. * Raw texture can help creating a texture directly from an array of data.
  12230. * This can be super useful if you either get the data from an uncompressed source or
  12231. * if you wish to create your texture pixel by pixel.
  12232. */
  12233. export class RawTexture extends Texture {
  12234. /**
  12235. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12236. */
  12237. format: number;
  12238. private _engine;
  12239. /**
  12240. * Instantiates a new RawTexture.
  12241. * Raw texture can help creating a texture directly from an array of data.
  12242. * This can be super useful if you either get the data from an uncompressed source or
  12243. * if you wish to create your texture pixel by pixel.
  12244. * @param data define the array of data to use to create the texture
  12245. * @param width define the width of the texture
  12246. * @param height define the height of the texture
  12247. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12248. * @param scene define the scene the texture belongs to
  12249. * @param generateMipMaps define whether mip maps should be generated or not
  12250. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12251. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12252. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12253. */
  12254. constructor(data: ArrayBufferView, width: number, height: number,
  12255. /**
  12256. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12257. */
  12258. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12259. /**
  12260. * Updates the texture underlying data.
  12261. * @param data Define the new data of the texture
  12262. */
  12263. update(data: ArrayBufferView): void;
  12264. /**
  12265. * Creates a luminance texture from some data.
  12266. * @param data Define the texture data
  12267. * @param width Define the width of the texture
  12268. * @param height Define the height of the texture
  12269. * @param scene Define the scene the texture belongs to
  12270. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12271. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12272. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12273. * @returns the luminance texture
  12274. */
  12275. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12276. /**
  12277. * Creates a luminance alpha texture from some data.
  12278. * @param data Define the texture data
  12279. * @param width Define the width of the texture
  12280. * @param height Define the height of the texture
  12281. * @param scene Define the scene the texture belongs to
  12282. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12283. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12284. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12285. * @returns the luminance alpha texture
  12286. */
  12287. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12288. /**
  12289. * Creates an alpha texture from some data.
  12290. * @param data Define the texture data
  12291. * @param width Define the width of the texture
  12292. * @param height Define the height of the texture
  12293. * @param scene Define the scene the texture belongs to
  12294. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12295. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12296. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12297. * @returns the alpha texture
  12298. */
  12299. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12300. /**
  12301. * Creates a RGB texture from some data.
  12302. * @param data Define the texture data
  12303. * @param width Define the width of the texture
  12304. * @param height Define the height of the texture
  12305. * @param scene Define the scene the texture belongs to
  12306. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12307. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12308. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12309. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12310. * @returns the RGB alpha texture
  12311. */
  12312. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12313. /**
  12314. * Creates a RGBA texture from some data.
  12315. * @param data Define the texture data
  12316. * @param width Define the width of the texture
  12317. * @param height Define the height of the texture
  12318. * @param scene Define the scene the texture belongs to
  12319. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12320. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12321. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12322. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12323. * @returns the RGBA texture
  12324. */
  12325. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12326. /**
  12327. * Creates a R texture from some data.
  12328. * @param data Define the texture data
  12329. * @param width Define the width of the texture
  12330. * @param height Define the height of the texture
  12331. * @param scene Define the scene the texture belongs to
  12332. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12333. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12334. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12335. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12336. * @returns the R texture
  12337. */
  12338. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12339. }
  12340. }
  12341. declare module BABYLON {
  12342. /**
  12343. * Interface for the size containing width and height
  12344. */
  12345. export interface ISize {
  12346. /**
  12347. * Width
  12348. */
  12349. width: number;
  12350. /**
  12351. * Heighht
  12352. */
  12353. height: number;
  12354. }
  12355. /**
  12356. * Size containing widht and height
  12357. */
  12358. export class Size implements ISize {
  12359. /**
  12360. * Width
  12361. */
  12362. width: number;
  12363. /**
  12364. * Height
  12365. */
  12366. height: number;
  12367. /**
  12368. * Creates a Size object from the given width and height (floats).
  12369. * @param width width of the new size
  12370. * @param height height of the new size
  12371. */
  12372. constructor(width: number, height: number);
  12373. /**
  12374. * Returns a string with the Size width and height
  12375. * @returns a string with the Size width and height
  12376. */
  12377. toString(): string;
  12378. /**
  12379. * "Size"
  12380. * @returns the string "Size"
  12381. */
  12382. getClassName(): string;
  12383. /**
  12384. * Returns the Size hash code.
  12385. * @returns a hash code for a unique width and height
  12386. */
  12387. getHashCode(): number;
  12388. /**
  12389. * Updates the current size from the given one.
  12390. * @param src the given size
  12391. */
  12392. copyFrom(src: Size): void;
  12393. /**
  12394. * Updates in place the current Size from the given floats.
  12395. * @param width width of the new size
  12396. * @param height height of the new size
  12397. * @returns the updated Size.
  12398. */
  12399. copyFromFloats(width: number, height: number): Size;
  12400. /**
  12401. * Updates in place the current Size from the given floats.
  12402. * @param width width to set
  12403. * @param height height to set
  12404. * @returns the updated Size.
  12405. */
  12406. set(width: number, height: number): Size;
  12407. /**
  12408. * Multiplies the width and height by numbers
  12409. * @param w factor to multiple the width by
  12410. * @param h factor to multiple the height by
  12411. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12412. */
  12413. multiplyByFloats(w: number, h: number): Size;
  12414. /**
  12415. * Clones the size
  12416. * @returns a new Size copied from the given one.
  12417. */
  12418. clone(): Size;
  12419. /**
  12420. * True if the current Size and the given one width and height are strictly equal.
  12421. * @param other the other size to compare against
  12422. * @returns True if the current Size and the given one width and height are strictly equal.
  12423. */
  12424. equals(other: Size): boolean;
  12425. /**
  12426. * The surface of the Size : width * height (float).
  12427. */
  12428. readonly surface: number;
  12429. /**
  12430. * Create a new size of zero
  12431. * @returns a new Size set to (0.0, 0.0)
  12432. */
  12433. static Zero(): Size;
  12434. /**
  12435. * Sums the width and height of two sizes
  12436. * @param otherSize size to add to this size
  12437. * @returns a new Size set as the addition result of the current Size and the given one.
  12438. */
  12439. add(otherSize: Size): Size;
  12440. /**
  12441. * Subtracts the width and height of two
  12442. * @param otherSize size to subtract to this size
  12443. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12444. */
  12445. subtract(otherSize: Size): Size;
  12446. /**
  12447. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12448. * @param start starting size to lerp between
  12449. * @param end end size to lerp between
  12450. * @param amount amount to lerp between the start and end values
  12451. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12452. */
  12453. static Lerp(start: Size, end: Size, amount: number): Size;
  12454. }
  12455. }
  12456. declare module BABYLON {
  12457. /**
  12458. * Defines a runtime animation
  12459. */
  12460. export class RuntimeAnimation {
  12461. private _events;
  12462. /**
  12463. * The current frame of the runtime animation
  12464. */
  12465. private _currentFrame;
  12466. /**
  12467. * The animation used by the runtime animation
  12468. */
  12469. private _animation;
  12470. /**
  12471. * The target of the runtime animation
  12472. */
  12473. private _target;
  12474. /**
  12475. * The initiating animatable
  12476. */
  12477. private _host;
  12478. /**
  12479. * The original value of the runtime animation
  12480. */
  12481. private _originalValue;
  12482. /**
  12483. * The original blend value of the runtime animation
  12484. */
  12485. private _originalBlendValue;
  12486. /**
  12487. * The offsets cache of the runtime animation
  12488. */
  12489. private _offsetsCache;
  12490. /**
  12491. * The high limits cache of the runtime animation
  12492. */
  12493. private _highLimitsCache;
  12494. /**
  12495. * Specifies if the runtime animation has been stopped
  12496. */
  12497. private _stopped;
  12498. /**
  12499. * The blending factor of the runtime animation
  12500. */
  12501. private _blendingFactor;
  12502. /**
  12503. * The BabylonJS scene
  12504. */
  12505. private _scene;
  12506. /**
  12507. * The current value of the runtime animation
  12508. */
  12509. private _currentValue;
  12510. /** @hidden */
  12511. _animationState: _IAnimationState;
  12512. /**
  12513. * The active target of the runtime animation
  12514. */
  12515. private _activeTargets;
  12516. private _currentActiveTarget;
  12517. private _directTarget;
  12518. /**
  12519. * The target path of the runtime animation
  12520. */
  12521. private _targetPath;
  12522. /**
  12523. * The weight of the runtime animation
  12524. */
  12525. private _weight;
  12526. /**
  12527. * The ratio offset of the runtime animation
  12528. */
  12529. private _ratioOffset;
  12530. /**
  12531. * The previous delay of the runtime animation
  12532. */
  12533. private _previousDelay;
  12534. /**
  12535. * The previous ratio of the runtime animation
  12536. */
  12537. private _previousRatio;
  12538. private _enableBlending;
  12539. private _keys;
  12540. private _minFrame;
  12541. private _maxFrame;
  12542. private _minValue;
  12543. private _maxValue;
  12544. private _targetIsArray;
  12545. /**
  12546. * Gets the current frame of the runtime animation
  12547. */
  12548. readonly currentFrame: number;
  12549. /**
  12550. * Gets the weight of the runtime animation
  12551. */
  12552. readonly weight: number;
  12553. /**
  12554. * Gets the current value of the runtime animation
  12555. */
  12556. readonly currentValue: any;
  12557. /**
  12558. * Gets the target path of the runtime animation
  12559. */
  12560. readonly targetPath: string;
  12561. /**
  12562. * Gets the actual target of the runtime animation
  12563. */
  12564. readonly target: any;
  12565. /** @hidden */
  12566. _onLoop: () => void;
  12567. /**
  12568. * Create a new RuntimeAnimation object
  12569. * @param target defines the target of the animation
  12570. * @param animation defines the source animation object
  12571. * @param scene defines the hosting scene
  12572. * @param host defines the initiating Animatable
  12573. */
  12574. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12575. private _preparePath;
  12576. /**
  12577. * Gets the animation from the runtime animation
  12578. */
  12579. readonly animation: Animation;
  12580. /**
  12581. * Resets the runtime animation to the beginning
  12582. * @param restoreOriginal defines whether to restore the target property to the original value
  12583. */
  12584. reset(restoreOriginal?: boolean): void;
  12585. /**
  12586. * Specifies if the runtime animation is stopped
  12587. * @returns Boolean specifying if the runtime animation is stopped
  12588. */
  12589. isStopped(): boolean;
  12590. /**
  12591. * Disposes of the runtime animation
  12592. */
  12593. dispose(): void;
  12594. /**
  12595. * Apply the interpolated value to the target
  12596. * @param currentValue defines the value computed by the animation
  12597. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12598. */
  12599. setValue(currentValue: any, weight: number): void;
  12600. private _getOriginalValues;
  12601. private _setValue;
  12602. /**
  12603. * Gets the loop pmode of the runtime animation
  12604. * @returns Loop Mode
  12605. */
  12606. private _getCorrectLoopMode;
  12607. /**
  12608. * Move the current animation to a given frame
  12609. * @param frame defines the frame to move to
  12610. */
  12611. goToFrame(frame: number): void;
  12612. /**
  12613. * @hidden Internal use only
  12614. */
  12615. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12616. /**
  12617. * Execute the current animation
  12618. * @param delay defines the delay to add to the current frame
  12619. * @param from defines the lower bound of the animation range
  12620. * @param to defines the upper bound of the animation range
  12621. * @param loop defines if the current animation must loop
  12622. * @param speedRatio defines the current speed ratio
  12623. * @param weight defines the weight of the animation (default is -1 so no weight)
  12624. * @param onLoop optional callback called when animation loops
  12625. * @returns a boolean indicating if the animation is running
  12626. */
  12627. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12628. }
  12629. }
  12630. declare module BABYLON {
  12631. /**
  12632. * Class used to store an actual running animation
  12633. */
  12634. export class Animatable {
  12635. /** defines the target object */
  12636. target: any;
  12637. /** defines the starting frame number (default is 0) */
  12638. fromFrame: number;
  12639. /** defines the ending frame number (default is 100) */
  12640. toFrame: number;
  12641. /** defines if the animation must loop (default is false) */
  12642. loopAnimation: boolean;
  12643. /** defines a callback to call when animation ends if it is not looping */
  12644. onAnimationEnd?: (() => void) | null | undefined;
  12645. /** defines a callback to call when animation loops */
  12646. onAnimationLoop?: (() => void) | null | undefined;
  12647. private _localDelayOffset;
  12648. private _pausedDelay;
  12649. private _runtimeAnimations;
  12650. private _paused;
  12651. private _scene;
  12652. private _speedRatio;
  12653. private _weight;
  12654. private _syncRoot;
  12655. /**
  12656. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12657. * This will only apply for non looping animation (default is true)
  12658. */
  12659. disposeOnEnd: boolean;
  12660. /**
  12661. * Gets a boolean indicating if the animation has started
  12662. */
  12663. animationStarted: boolean;
  12664. /**
  12665. * Observer raised when the animation ends
  12666. */
  12667. onAnimationEndObservable: Observable<Animatable>;
  12668. /**
  12669. * Observer raised when the animation loops
  12670. */
  12671. onAnimationLoopObservable: Observable<Animatable>;
  12672. /**
  12673. * Gets the root Animatable used to synchronize and normalize animations
  12674. */
  12675. readonly syncRoot: Nullable<Animatable>;
  12676. /**
  12677. * Gets the current frame of the first RuntimeAnimation
  12678. * Used to synchronize Animatables
  12679. */
  12680. readonly masterFrame: number;
  12681. /**
  12682. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12683. */
  12684. weight: number;
  12685. /**
  12686. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12687. */
  12688. speedRatio: number;
  12689. /**
  12690. * Creates a new Animatable
  12691. * @param scene defines the hosting scene
  12692. * @param target defines the target object
  12693. * @param fromFrame defines the starting frame number (default is 0)
  12694. * @param toFrame defines the ending frame number (default is 100)
  12695. * @param loopAnimation defines if the animation must loop (default is false)
  12696. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12697. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12698. * @param animations defines a group of animation to add to the new Animatable
  12699. * @param onAnimationLoop defines a callback to call when animation loops
  12700. */
  12701. constructor(scene: Scene,
  12702. /** defines the target object */
  12703. target: any,
  12704. /** defines the starting frame number (default is 0) */
  12705. fromFrame?: number,
  12706. /** defines the ending frame number (default is 100) */
  12707. toFrame?: number,
  12708. /** defines if the animation must loop (default is false) */
  12709. loopAnimation?: boolean, speedRatio?: number,
  12710. /** defines a callback to call when animation ends if it is not looping */
  12711. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12712. /** defines a callback to call when animation loops */
  12713. onAnimationLoop?: (() => void) | null | undefined);
  12714. /**
  12715. * Synchronize and normalize current Animatable with a source Animatable
  12716. * This is useful when using animation weights and when animations are not of the same length
  12717. * @param root defines the root Animatable to synchronize with
  12718. * @returns the current Animatable
  12719. */
  12720. syncWith(root: Animatable): Animatable;
  12721. /**
  12722. * Gets the list of runtime animations
  12723. * @returns an array of RuntimeAnimation
  12724. */
  12725. getAnimations(): RuntimeAnimation[];
  12726. /**
  12727. * Adds more animations to the current animatable
  12728. * @param target defines the target of the animations
  12729. * @param animations defines the new animations to add
  12730. */
  12731. appendAnimations(target: any, animations: Animation[]): void;
  12732. /**
  12733. * Gets the source animation for a specific property
  12734. * @param property defines the propertyu to look for
  12735. * @returns null or the source animation for the given property
  12736. */
  12737. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12738. /**
  12739. * Gets the runtime animation for a specific property
  12740. * @param property defines the propertyu to look for
  12741. * @returns null or the runtime animation for the given property
  12742. */
  12743. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12744. /**
  12745. * Resets the animatable to its original state
  12746. */
  12747. reset(): void;
  12748. /**
  12749. * Allows the animatable to blend with current running animations
  12750. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12751. * @param blendingSpeed defines the blending speed to use
  12752. */
  12753. enableBlending(blendingSpeed: number): void;
  12754. /**
  12755. * Disable animation blending
  12756. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12757. */
  12758. disableBlending(): void;
  12759. /**
  12760. * Jump directly to a given frame
  12761. * @param frame defines the frame to jump to
  12762. */
  12763. goToFrame(frame: number): void;
  12764. /**
  12765. * Pause the animation
  12766. */
  12767. pause(): void;
  12768. /**
  12769. * Restart the animation
  12770. */
  12771. restart(): void;
  12772. private _raiseOnAnimationEnd;
  12773. /**
  12774. * Stop and delete the current animation
  12775. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12776. * @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)
  12777. */
  12778. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12779. /**
  12780. * Wait asynchronously for the animation to end
  12781. * @returns a promise which will be fullfilled when the animation ends
  12782. */
  12783. waitAsync(): Promise<Animatable>;
  12784. /** @hidden */
  12785. _animate(delay: number): boolean;
  12786. }
  12787. interface Scene {
  12788. /** @hidden */
  12789. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12790. /** @hidden */
  12791. _processLateAnimationBindingsForMatrices(holder: {
  12792. totalWeight: number;
  12793. animations: RuntimeAnimation[];
  12794. originalValue: Matrix;
  12795. }): any;
  12796. /** @hidden */
  12797. _processLateAnimationBindingsForQuaternions(holder: {
  12798. totalWeight: number;
  12799. animations: RuntimeAnimation[];
  12800. originalValue: Quaternion;
  12801. }, refQuaternion: Quaternion): Quaternion;
  12802. /** @hidden */
  12803. _processLateAnimationBindings(): void;
  12804. /**
  12805. * Will start the animation sequence of a given target
  12806. * @param target defines the target
  12807. * @param from defines from which frame should animation start
  12808. * @param to defines until which frame should animation run.
  12809. * @param weight defines the weight to apply to the animation (1.0 by default)
  12810. * @param loop defines if the animation loops
  12811. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12812. * @param onAnimationEnd defines the function to be executed when the animation ends
  12813. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12814. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12815. * @param onAnimationLoop defines the callback to call when an animation loops
  12816. * @returns the animatable object created for this animation
  12817. */
  12818. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12819. /**
  12820. * Will start the animation sequence of a given target
  12821. * @param target defines the target
  12822. * @param from defines from which frame should animation start
  12823. * @param to defines until which frame should animation run.
  12824. * @param loop defines if the animation loops
  12825. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12826. * @param onAnimationEnd defines the function to be executed when the animation ends
  12827. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12828. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12829. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12830. * @param onAnimationLoop defines the callback to call when an animation loops
  12831. * @returns the animatable object created for this animation
  12832. */
  12833. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12834. /**
  12835. * Will start the animation sequence of a given target and its hierarchy
  12836. * @param target defines the target
  12837. * @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.
  12838. * @param from defines from which frame should animation start
  12839. * @param to defines until which frame should animation run.
  12840. * @param loop defines if the animation loops
  12841. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12842. * @param onAnimationEnd defines the function to be executed when the animation ends
  12843. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12844. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12845. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12846. * @param onAnimationLoop defines the callback to call when an animation loops
  12847. * @returns the list of created animatables
  12848. */
  12849. 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[];
  12850. /**
  12851. * Begin a new animation on a given node
  12852. * @param target defines the target where the animation will take place
  12853. * @param animations defines the list of animations to start
  12854. * @param from defines the initial value
  12855. * @param to defines the final value
  12856. * @param loop defines if you want animation to loop (off by default)
  12857. * @param speedRatio defines the speed ratio to apply to all animations
  12858. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12859. * @param onAnimationLoop defines the callback to call when an animation loops
  12860. * @returns the list of created animatables
  12861. */
  12862. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  12863. /**
  12864. * Begin a new animation on a given node and its hierarchy
  12865. * @param target defines the root node where the animation will take place
  12866. * @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.
  12867. * @param animations defines the list of animations to start
  12868. * @param from defines the initial value
  12869. * @param to defines the final value
  12870. * @param loop defines if you want animation to loop (off by default)
  12871. * @param speedRatio defines the speed ratio to apply to all animations
  12872. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12873. * @param onAnimationLoop defines the callback to call when an animation loops
  12874. * @returns the list of animatables created for all nodes
  12875. */
  12876. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  12877. /**
  12878. * Gets the animatable associated with a specific target
  12879. * @param target defines the target of the animatable
  12880. * @returns the required animatable if found
  12881. */
  12882. getAnimatableByTarget(target: any): Nullable<Animatable>;
  12883. /**
  12884. * Gets all animatables associated with a given target
  12885. * @param target defines the target to look animatables for
  12886. * @returns an array of Animatables
  12887. */
  12888. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  12889. /**
  12890. * Stops and removes all animations that have been applied to the scene
  12891. */
  12892. stopAllAnimations(): void;
  12893. }
  12894. interface Bone {
  12895. /**
  12896. * Copy an animation range from another bone
  12897. * @param source defines the source bone
  12898. * @param rangeName defines the range name to copy
  12899. * @param frameOffset defines the frame offset
  12900. * @param rescaleAsRequired defines if rescaling must be applied if required
  12901. * @param skelDimensionsRatio defines the scaling ratio
  12902. * @returns true if operation was successful
  12903. */
  12904. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  12905. }
  12906. }
  12907. declare module BABYLON {
  12908. /**
  12909. * Class used to override all child animations of a given target
  12910. */
  12911. export class AnimationPropertiesOverride {
  12912. /**
  12913. * Gets or sets a value indicating if animation blending must be used
  12914. */
  12915. enableBlending: boolean;
  12916. /**
  12917. * Gets or sets the blending speed to use when enableBlending is true
  12918. */
  12919. blendingSpeed: number;
  12920. /**
  12921. * Gets or sets the default loop mode to use
  12922. */
  12923. loopMode: number;
  12924. }
  12925. }
  12926. declare module BABYLON {
  12927. /**
  12928. * Class used to handle skinning animations
  12929. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  12930. */
  12931. export class Skeleton implements IAnimatable {
  12932. /** defines the skeleton name */
  12933. name: string;
  12934. /** defines the skeleton Id */
  12935. id: string;
  12936. /**
  12937. * Defines the list of child bones
  12938. */
  12939. bones: Bone[];
  12940. /**
  12941. * Defines an estimate of the dimension of the skeleton at rest
  12942. */
  12943. dimensionsAtRest: Vector3;
  12944. /**
  12945. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  12946. */
  12947. needInitialSkinMatrix: boolean;
  12948. /**
  12949. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  12950. */
  12951. overrideMesh: Nullable<AbstractMesh>;
  12952. /**
  12953. * Gets the list of animations attached to this skeleton
  12954. */
  12955. animations: Array<Animation>;
  12956. private _scene;
  12957. private _isDirty;
  12958. private _transformMatrices;
  12959. private _transformMatrixTexture;
  12960. private _meshesWithPoseMatrix;
  12961. private _animatables;
  12962. private _identity;
  12963. private _synchronizedWithMesh;
  12964. private _ranges;
  12965. private _lastAbsoluteTransformsUpdateId;
  12966. private _canUseTextureForBones;
  12967. private _uniqueId;
  12968. /** @hidden */
  12969. _numBonesWithLinkedTransformNode: number;
  12970. /** @hidden */
  12971. _hasWaitingData: Nullable<boolean>;
  12972. /**
  12973. * Specifies if the skeleton should be serialized
  12974. */
  12975. doNotSerialize: boolean;
  12976. private _useTextureToStoreBoneMatrices;
  12977. /**
  12978. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  12979. * Please note that this option is not available if the hardware does not support it
  12980. */
  12981. useTextureToStoreBoneMatrices: boolean;
  12982. private _animationPropertiesOverride;
  12983. /**
  12984. * Gets or sets the animation properties override
  12985. */
  12986. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  12987. /**
  12988. * List of inspectable custom properties (used by the Inspector)
  12989. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  12990. */
  12991. inspectableCustomProperties: IInspectable[];
  12992. /**
  12993. * An observable triggered before computing the skeleton's matrices
  12994. */
  12995. onBeforeComputeObservable: Observable<Skeleton>;
  12996. /**
  12997. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  12998. */
  12999. readonly isUsingTextureForMatrices: boolean;
  13000. /**
  13001. * Gets the unique ID of this skeleton
  13002. */
  13003. readonly uniqueId: number;
  13004. /**
  13005. * Creates a new skeleton
  13006. * @param name defines the skeleton name
  13007. * @param id defines the skeleton Id
  13008. * @param scene defines the hosting scene
  13009. */
  13010. constructor(
  13011. /** defines the skeleton name */
  13012. name: string,
  13013. /** defines the skeleton Id */
  13014. id: string, scene: Scene);
  13015. /**
  13016. * Gets the current object class name.
  13017. * @return the class name
  13018. */
  13019. getClassName(): string;
  13020. /**
  13021. * Returns an array containing the root bones
  13022. * @returns an array containing the root bones
  13023. */
  13024. getChildren(): Array<Bone>;
  13025. /**
  13026. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13027. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13028. * @returns a Float32Array containing matrices data
  13029. */
  13030. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13031. /**
  13032. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13033. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13034. * @returns a raw texture containing the data
  13035. */
  13036. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13037. /**
  13038. * Gets the current hosting scene
  13039. * @returns a scene object
  13040. */
  13041. getScene(): Scene;
  13042. /**
  13043. * Gets a string representing the current skeleton data
  13044. * @param fullDetails defines a boolean indicating if we want a verbose version
  13045. * @returns a string representing the current skeleton data
  13046. */
  13047. toString(fullDetails?: boolean): string;
  13048. /**
  13049. * Get bone's index searching by name
  13050. * @param name defines bone's name to search for
  13051. * @return the indice of the bone. Returns -1 if not found
  13052. */
  13053. getBoneIndexByName(name: string): number;
  13054. /**
  13055. * Creater a new animation range
  13056. * @param name defines the name of the range
  13057. * @param from defines the start key
  13058. * @param to defines the end key
  13059. */
  13060. createAnimationRange(name: string, from: number, to: number): void;
  13061. /**
  13062. * Delete a specific animation range
  13063. * @param name defines the name of the range
  13064. * @param deleteFrames defines if frames must be removed as well
  13065. */
  13066. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13067. /**
  13068. * Gets a specific animation range
  13069. * @param name defines the name of the range to look for
  13070. * @returns the requested animation range or null if not found
  13071. */
  13072. getAnimationRange(name: string): Nullable<AnimationRange>;
  13073. /**
  13074. * Gets the list of all animation ranges defined on this skeleton
  13075. * @returns an array
  13076. */
  13077. getAnimationRanges(): Nullable<AnimationRange>[];
  13078. /**
  13079. * Copy animation range from a source skeleton.
  13080. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13081. * @param source defines the source skeleton
  13082. * @param name defines the name of the range to copy
  13083. * @param rescaleAsRequired defines if rescaling must be applied if required
  13084. * @returns true if operation was successful
  13085. */
  13086. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13087. /**
  13088. * Forces the skeleton to go to rest pose
  13089. */
  13090. returnToRest(): void;
  13091. private _getHighestAnimationFrame;
  13092. /**
  13093. * Begin a specific animation range
  13094. * @param name defines the name of the range to start
  13095. * @param loop defines if looping must be turned on (false by default)
  13096. * @param speedRatio defines the speed ratio to apply (1 by default)
  13097. * @param onAnimationEnd defines a callback which will be called when animation will end
  13098. * @returns a new animatable
  13099. */
  13100. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13101. /** @hidden */
  13102. _markAsDirty(): void;
  13103. /** @hidden */
  13104. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13105. /** @hidden */
  13106. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13107. private _computeTransformMatrices;
  13108. /**
  13109. * Build all resources required to render a skeleton
  13110. */
  13111. prepare(): void;
  13112. /**
  13113. * Gets the list of animatables currently running for this skeleton
  13114. * @returns an array of animatables
  13115. */
  13116. getAnimatables(): IAnimatable[];
  13117. /**
  13118. * Clone the current skeleton
  13119. * @param name defines the name of the new skeleton
  13120. * @param id defines the id of the new skeleton
  13121. * @returns the new skeleton
  13122. */
  13123. clone(name: string, id: string): Skeleton;
  13124. /**
  13125. * Enable animation blending for this skeleton
  13126. * @param blendingSpeed defines the blending speed to apply
  13127. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13128. */
  13129. enableBlending(blendingSpeed?: number): void;
  13130. /**
  13131. * Releases all resources associated with the current skeleton
  13132. */
  13133. dispose(): void;
  13134. /**
  13135. * Serialize the skeleton in a JSON object
  13136. * @returns a JSON object
  13137. */
  13138. serialize(): any;
  13139. /**
  13140. * Creates a new skeleton from serialized data
  13141. * @param parsedSkeleton defines the serialized data
  13142. * @param scene defines the hosting scene
  13143. * @returns a new skeleton
  13144. */
  13145. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13146. /**
  13147. * Compute all node absolute transforms
  13148. * @param forceUpdate defines if computation must be done even if cache is up to date
  13149. */
  13150. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13151. /**
  13152. * Gets the root pose matrix
  13153. * @returns a matrix
  13154. */
  13155. getPoseMatrix(): Nullable<Matrix>;
  13156. /**
  13157. * Sorts bones per internal index
  13158. */
  13159. sortBones(): void;
  13160. private _sortBones;
  13161. }
  13162. }
  13163. declare module BABYLON {
  13164. /**
  13165. * Class used to store bone information
  13166. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13167. */
  13168. export class Bone extends Node {
  13169. /**
  13170. * defines the bone name
  13171. */
  13172. name: string;
  13173. private static _tmpVecs;
  13174. private static _tmpQuat;
  13175. private static _tmpMats;
  13176. /**
  13177. * Gets the list of child bones
  13178. */
  13179. children: Bone[];
  13180. /** Gets the animations associated with this bone */
  13181. animations: Animation[];
  13182. /**
  13183. * Gets or sets bone length
  13184. */
  13185. length: number;
  13186. /**
  13187. * @hidden Internal only
  13188. * Set this value to map this bone to a different index in the transform matrices
  13189. * Set this value to -1 to exclude the bone from the transform matrices
  13190. */
  13191. _index: Nullable<number>;
  13192. private _skeleton;
  13193. private _localMatrix;
  13194. private _restPose;
  13195. private _baseMatrix;
  13196. private _absoluteTransform;
  13197. private _invertedAbsoluteTransform;
  13198. private _parent;
  13199. private _scalingDeterminant;
  13200. private _worldTransform;
  13201. private _localScaling;
  13202. private _localRotation;
  13203. private _localPosition;
  13204. private _needToDecompose;
  13205. private _needToCompose;
  13206. /** @hidden */
  13207. _linkedTransformNode: Nullable<TransformNode>;
  13208. /** @hidden */
  13209. _waitingTransformNodeId: Nullable<string>;
  13210. /** @hidden */
  13211. /** @hidden */
  13212. _matrix: Matrix;
  13213. /**
  13214. * Create a new bone
  13215. * @param name defines the bone name
  13216. * @param skeleton defines the parent skeleton
  13217. * @param parentBone defines the parent (can be null if the bone is the root)
  13218. * @param localMatrix defines the local matrix
  13219. * @param restPose defines the rest pose matrix
  13220. * @param baseMatrix defines the base matrix
  13221. * @param index defines index of the bone in the hiearchy
  13222. */
  13223. constructor(
  13224. /**
  13225. * defines the bone name
  13226. */
  13227. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13228. /**
  13229. * Gets the current object class name.
  13230. * @return the class name
  13231. */
  13232. getClassName(): string;
  13233. /**
  13234. * Gets the parent skeleton
  13235. * @returns a skeleton
  13236. */
  13237. getSkeleton(): Skeleton;
  13238. /**
  13239. * Gets parent bone
  13240. * @returns a bone or null if the bone is the root of the bone hierarchy
  13241. */
  13242. getParent(): Nullable<Bone>;
  13243. /**
  13244. * Returns an array containing the root bones
  13245. * @returns an array containing the root bones
  13246. */
  13247. getChildren(): Array<Bone>;
  13248. /**
  13249. * Sets the parent bone
  13250. * @param parent defines the parent (can be null if the bone is the root)
  13251. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13252. */
  13253. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13254. /**
  13255. * Gets the local matrix
  13256. * @returns a matrix
  13257. */
  13258. getLocalMatrix(): Matrix;
  13259. /**
  13260. * Gets the base matrix (initial matrix which remains unchanged)
  13261. * @returns a matrix
  13262. */
  13263. getBaseMatrix(): Matrix;
  13264. /**
  13265. * Gets the rest pose matrix
  13266. * @returns a matrix
  13267. */
  13268. getRestPose(): Matrix;
  13269. /**
  13270. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13271. */
  13272. getWorldMatrix(): Matrix;
  13273. /**
  13274. * Sets the local matrix to rest pose matrix
  13275. */
  13276. returnToRest(): void;
  13277. /**
  13278. * Gets the inverse of the absolute transform matrix.
  13279. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13280. * @returns a matrix
  13281. */
  13282. getInvertedAbsoluteTransform(): Matrix;
  13283. /**
  13284. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13285. * @returns a matrix
  13286. */
  13287. getAbsoluteTransform(): Matrix;
  13288. /**
  13289. * Links with the given transform node.
  13290. * The local matrix of this bone is copied from the transform node every frame.
  13291. * @param transformNode defines the transform node to link to
  13292. */
  13293. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13294. /**
  13295. * Gets the node used to drive the bone's transformation
  13296. * @returns a transform node or null
  13297. */
  13298. getTransformNode(): Nullable<TransformNode>;
  13299. /** Gets or sets current position (in local space) */
  13300. position: Vector3;
  13301. /** Gets or sets current rotation (in local space) */
  13302. rotation: Vector3;
  13303. /** Gets or sets current rotation quaternion (in local space) */
  13304. rotationQuaternion: Quaternion;
  13305. /** Gets or sets current scaling (in local space) */
  13306. scaling: Vector3;
  13307. /**
  13308. * Gets the animation properties override
  13309. */
  13310. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13311. private _decompose;
  13312. private _compose;
  13313. /**
  13314. * Update the base and local matrices
  13315. * @param matrix defines the new base or local matrix
  13316. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13317. * @param updateLocalMatrix defines if the local matrix should be updated
  13318. */
  13319. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13320. /** @hidden */
  13321. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13322. /**
  13323. * Flag the bone as dirty (Forcing it to update everything)
  13324. */
  13325. markAsDirty(): void;
  13326. /** @hidden */
  13327. _markAsDirtyAndCompose(): void;
  13328. private _markAsDirtyAndDecompose;
  13329. /**
  13330. * Translate the bone in local or world space
  13331. * @param vec The amount to translate the bone
  13332. * @param space The space that the translation is in
  13333. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13334. */
  13335. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13336. /**
  13337. * Set the postion of the bone in local or world space
  13338. * @param position The position to set the bone
  13339. * @param space The space that the position is in
  13340. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13341. */
  13342. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13343. /**
  13344. * Set the absolute position of the bone (world space)
  13345. * @param position The position to set the bone
  13346. * @param mesh The mesh that this bone is attached to
  13347. */
  13348. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13349. /**
  13350. * Scale the bone on the x, y and z axes (in local space)
  13351. * @param x The amount to scale the bone on the x axis
  13352. * @param y The amount to scale the bone on the y axis
  13353. * @param z The amount to scale the bone on the z axis
  13354. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13355. */
  13356. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13357. /**
  13358. * Set the bone scaling in local space
  13359. * @param scale defines the scaling vector
  13360. */
  13361. setScale(scale: Vector3): void;
  13362. /**
  13363. * Gets the current scaling in local space
  13364. * @returns the current scaling vector
  13365. */
  13366. getScale(): Vector3;
  13367. /**
  13368. * Gets the current scaling in local space and stores it in a target vector
  13369. * @param result defines the target vector
  13370. */
  13371. getScaleToRef(result: Vector3): void;
  13372. /**
  13373. * Set the yaw, pitch, and roll of the bone in local or world space
  13374. * @param yaw The rotation of the bone on the y axis
  13375. * @param pitch The rotation of the bone on the x axis
  13376. * @param roll The rotation of the bone on the z axis
  13377. * @param space The space that the axes of rotation are in
  13378. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13379. */
  13380. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13381. /**
  13382. * Add a rotation to the bone on an axis in local or world space
  13383. * @param axis The axis to rotate the bone on
  13384. * @param amount The amount to rotate the bone
  13385. * @param space The space that the axis is in
  13386. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13387. */
  13388. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13389. /**
  13390. * Set the rotation of the bone to a particular axis angle in local or world space
  13391. * @param axis The axis to rotate the bone on
  13392. * @param angle The angle that the bone should be rotated to
  13393. * @param space The space that the axis is in
  13394. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13395. */
  13396. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13397. /**
  13398. * Set the euler rotation of the bone in local of world space
  13399. * @param rotation The euler rotation that the bone should be set to
  13400. * @param space The space that the rotation is in
  13401. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13402. */
  13403. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13404. /**
  13405. * Set the quaternion rotation of the bone in local of world space
  13406. * @param quat The quaternion rotation that the bone should be set to
  13407. * @param space The space that the rotation is in
  13408. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13409. */
  13410. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13411. /**
  13412. * Set the rotation matrix of the bone in local of world space
  13413. * @param rotMat The rotation matrix that the bone should be set to
  13414. * @param space The space that the rotation is in
  13415. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13416. */
  13417. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13418. private _rotateWithMatrix;
  13419. private _getNegativeRotationToRef;
  13420. /**
  13421. * Get the position of the bone in local or world space
  13422. * @param space The space that the returned position is in
  13423. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13424. * @returns The position of the bone
  13425. */
  13426. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13427. /**
  13428. * Copy the position of the bone to a vector3 in local or world space
  13429. * @param space The space that the returned position is in
  13430. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13431. * @param result The vector3 to copy the position to
  13432. */
  13433. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13434. /**
  13435. * Get the absolute position of the bone (world space)
  13436. * @param mesh The mesh that this bone is attached to
  13437. * @returns The absolute position of the bone
  13438. */
  13439. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13440. /**
  13441. * Copy the absolute position of the bone (world space) to the result param
  13442. * @param mesh The mesh that this bone is attached to
  13443. * @param result The vector3 to copy the absolute position to
  13444. */
  13445. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13446. /**
  13447. * Compute the absolute transforms of this bone and its children
  13448. */
  13449. computeAbsoluteTransforms(): void;
  13450. /**
  13451. * Get the world direction from an axis that is in the local space of the bone
  13452. * @param localAxis The local direction that is used to compute the world direction
  13453. * @param mesh The mesh that this bone is attached to
  13454. * @returns The world direction
  13455. */
  13456. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13457. /**
  13458. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13459. * @param localAxis The local direction that is used to compute the world direction
  13460. * @param mesh The mesh that this bone is attached to
  13461. * @param result The vector3 that the world direction will be copied to
  13462. */
  13463. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13464. /**
  13465. * Get the euler rotation of the bone in local or world space
  13466. * @param space The space that the rotation should be in
  13467. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13468. * @returns The euler rotation
  13469. */
  13470. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13471. /**
  13472. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13473. * @param space The space that the rotation should be in
  13474. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13475. * @param result The vector3 that the rotation should be copied to
  13476. */
  13477. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13478. /**
  13479. * Get the quaternion rotation of the bone in either local or world space
  13480. * @param space The space that the rotation should be in
  13481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13482. * @returns The quaternion rotation
  13483. */
  13484. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13485. /**
  13486. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13487. * @param space The space that the rotation should be in
  13488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13489. * @param result The quaternion that the rotation should be copied to
  13490. */
  13491. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13492. /**
  13493. * Get the rotation matrix of the bone in local or world space
  13494. * @param space The space that the rotation should be in
  13495. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13496. * @returns The rotation matrix
  13497. */
  13498. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13499. /**
  13500. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13501. * @param space The space that the rotation should be in
  13502. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13503. * @param result The quaternion that the rotation should be copied to
  13504. */
  13505. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13506. /**
  13507. * Get the world position of a point that is in the local space of the bone
  13508. * @param position The local position
  13509. * @param mesh The mesh that this bone is attached to
  13510. * @returns The world position
  13511. */
  13512. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13513. /**
  13514. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13515. * @param position The local position
  13516. * @param mesh The mesh that this bone is attached to
  13517. * @param result The vector3 that the world position should be copied to
  13518. */
  13519. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13520. /**
  13521. * Get the local position of a point that is in world space
  13522. * @param position The world position
  13523. * @param mesh The mesh that this bone is attached to
  13524. * @returns The local position
  13525. */
  13526. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13527. /**
  13528. * Get the local position of a point that is in world space and copy it to the result param
  13529. * @param position The world position
  13530. * @param mesh The mesh that this bone is attached to
  13531. * @param result The vector3 that the local position should be copied to
  13532. */
  13533. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13534. }
  13535. }
  13536. declare module BABYLON {
  13537. /**
  13538. * 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.
  13539. * @see https://doc.babylonjs.com/how_to/transformnode
  13540. */
  13541. export class TransformNode extends Node {
  13542. /**
  13543. * Object will not rotate to face the camera
  13544. */
  13545. static BILLBOARDMODE_NONE: number;
  13546. /**
  13547. * Object will rotate to face the camera but only on the x axis
  13548. */
  13549. static BILLBOARDMODE_X: number;
  13550. /**
  13551. * Object will rotate to face the camera but only on the y axis
  13552. */
  13553. static BILLBOARDMODE_Y: number;
  13554. /**
  13555. * Object will rotate to face the camera but only on the z axis
  13556. */
  13557. static BILLBOARDMODE_Z: number;
  13558. /**
  13559. * Object will rotate to face the camera
  13560. */
  13561. static BILLBOARDMODE_ALL: number;
  13562. /**
  13563. * Object will rotate to face the camera's position instead of orientation
  13564. */
  13565. static BILLBOARDMODE_USE_POSITION: number;
  13566. private _forward;
  13567. private _forwardInverted;
  13568. private _up;
  13569. private _right;
  13570. private _rightInverted;
  13571. private _position;
  13572. private _rotation;
  13573. private _rotationQuaternion;
  13574. protected _scaling: Vector3;
  13575. protected _isDirty: boolean;
  13576. private _transformToBoneReferal;
  13577. private _isAbsoluteSynced;
  13578. private _billboardMode;
  13579. /**
  13580. * Gets or sets the billboard mode. Default is 0.
  13581. *
  13582. * | Value | Type | Description |
  13583. * | --- | --- | --- |
  13584. * | 0 | BILLBOARDMODE_NONE | |
  13585. * | 1 | BILLBOARDMODE_X | |
  13586. * | 2 | BILLBOARDMODE_Y | |
  13587. * | 4 | BILLBOARDMODE_Z | |
  13588. * | 7 | BILLBOARDMODE_ALL | |
  13589. *
  13590. */
  13591. billboardMode: number;
  13592. private _preserveParentRotationForBillboard;
  13593. /**
  13594. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13595. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13596. */
  13597. preserveParentRotationForBillboard: boolean;
  13598. /**
  13599. * 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
  13600. */
  13601. scalingDeterminant: number;
  13602. private _infiniteDistance;
  13603. /**
  13604. * Gets or sets the distance of the object to max, often used by skybox
  13605. */
  13606. infiniteDistance: boolean;
  13607. /**
  13608. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13609. * By default the system will update normals to compensate
  13610. */
  13611. ignoreNonUniformScaling: boolean;
  13612. /**
  13613. * 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
  13614. */
  13615. reIntegrateRotationIntoRotationQuaternion: boolean;
  13616. /** @hidden */
  13617. _poseMatrix: Nullable<Matrix>;
  13618. /** @hidden */
  13619. _localMatrix: Matrix;
  13620. private _usePivotMatrix;
  13621. private _absolutePosition;
  13622. private _absoluteScaling;
  13623. private _absoluteRotationQuaternion;
  13624. private _pivotMatrix;
  13625. private _pivotMatrixInverse;
  13626. protected _postMultiplyPivotMatrix: boolean;
  13627. protected _isWorldMatrixFrozen: boolean;
  13628. /** @hidden */
  13629. _indexInSceneTransformNodesArray: number;
  13630. /**
  13631. * An event triggered after the world matrix is updated
  13632. */
  13633. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13634. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13635. /**
  13636. * Gets a string identifying the name of the class
  13637. * @returns "TransformNode" string
  13638. */
  13639. getClassName(): string;
  13640. /**
  13641. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13642. */
  13643. position: Vector3;
  13644. /**
  13645. * 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)).
  13646. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13647. */
  13648. rotation: Vector3;
  13649. /**
  13650. * 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)).
  13651. */
  13652. scaling: Vector3;
  13653. /**
  13654. * 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).
  13655. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13656. */
  13657. rotationQuaternion: Nullable<Quaternion>;
  13658. /**
  13659. * The forward direction of that transform in world space.
  13660. */
  13661. readonly forward: Vector3;
  13662. /**
  13663. * The up direction of that transform in world space.
  13664. */
  13665. readonly up: Vector3;
  13666. /**
  13667. * The right direction of that transform in world space.
  13668. */
  13669. readonly right: Vector3;
  13670. /**
  13671. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13672. * @param matrix the matrix to copy the pose from
  13673. * @returns this TransformNode.
  13674. */
  13675. updatePoseMatrix(matrix: Matrix): TransformNode;
  13676. /**
  13677. * Returns the mesh Pose matrix.
  13678. * @returns the pose matrix
  13679. */
  13680. getPoseMatrix(): Matrix;
  13681. /** @hidden */
  13682. _isSynchronized(): boolean;
  13683. /** @hidden */
  13684. _initCache(): void;
  13685. /**
  13686. * Flag the transform node as dirty (Forcing it to update everything)
  13687. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13688. * @returns this transform node
  13689. */
  13690. markAsDirty(property: string): TransformNode;
  13691. /**
  13692. * Returns the current mesh absolute position.
  13693. * Returns a Vector3.
  13694. */
  13695. readonly absolutePosition: Vector3;
  13696. /**
  13697. * Returns the current mesh absolute scaling.
  13698. * Returns a Vector3.
  13699. */
  13700. readonly absoluteScaling: Vector3;
  13701. /**
  13702. * Returns the current mesh absolute rotation.
  13703. * Returns a Quaternion.
  13704. */
  13705. readonly absoluteRotationQuaternion: Quaternion;
  13706. /**
  13707. * Sets a new matrix to apply before all other transformation
  13708. * @param matrix defines the transform matrix
  13709. * @returns the current TransformNode
  13710. */
  13711. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13712. /**
  13713. * Sets a new pivot matrix to the current node
  13714. * @param matrix defines the new pivot matrix to use
  13715. * @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
  13716. * @returns the current TransformNode
  13717. */
  13718. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13719. /**
  13720. * Returns the mesh pivot matrix.
  13721. * Default : Identity.
  13722. * @returns the matrix
  13723. */
  13724. getPivotMatrix(): Matrix;
  13725. /**
  13726. * Instantiate (when possible) or clone that node with its hierarchy
  13727. * @param newParent defines the new parent to use for the instance (or clone)
  13728. * @returns an instance (or a clone) of the current node with its hiearchy
  13729. */
  13730. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13731. /**
  13732. * Prevents the World matrix to be computed any longer
  13733. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13734. * @returns the TransformNode.
  13735. */
  13736. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13737. /**
  13738. * Allows back the World matrix computation.
  13739. * @returns the TransformNode.
  13740. */
  13741. unfreezeWorldMatrix(): this;
  13742. /**
  13743. * True if the World matrix has been frozen.
  13744. */
  13745. readonly isWorldMatrixFrozen: boolean;
  13746. /**
  13747. * Retuns the mesh absolute position in the World.
  13748. * @returns a Vector3.
  13749. */
  13750. getAbsolutePosition(): Vector3;
  13751. /**
  13752. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13753. * @param absolutePosition the absolute position to set
  13754. * @returns the TransformNode.
  13755. */
  13756. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13757. /**
  13758. * Sets the mesh position in its local space.
  13759. * @param vector3 the position to set in localspace
  13760. * @returns the TransformNode.
  13761. */
  13762. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13763. /**
  13764. * Returns the mesh position in the local space from the current World matrix values.
  13765. * @returns a new Vector3.
  13766. */
  13767. getPositionExpressedInLocalSpace(): Vector3;
  13768. /**
  13769. * Translates the mesh along the passed Vector3 in its local space.
  13770. * @param vector3 the distance to translate in localspace
  13771. * @returns the TransformNode.
  13772. */
  13773. locallyTranslate(vector3: Vector3): TransformNode;
  13774. private static _lookAtVectorCache;
  13775. /**
  13776. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13777. * @param targetPoint the position (must be in same space as current mesh) to look at
  13778. * @param yawCor optional yaw (y-axis) correction in radians
  13779. * @param pitchCor optional pitch (x-axis) correction in radians
  13780. * @param rollCor optional roll (z-axis) correction in radians
  13781. * @param space the choosen space of the target
  13782. * @returns the TransformNode.
  13783. */
  13784. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13785. /**
  13786. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13787. * This Vector3 is expressed in the World space.
  13788. * @param localAxis axis to rotate
  13789. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13790. */
  13791. getDirection(localAxis: Vector3): Vector3;
  13792. /**
  13793. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13794. * localAxis is expressed in the mesh local space.
  13795. * result is computed in the Wordl space from the mesh World matrix.
  13796. * @param localAxis axis to rotate
  13797. * @param result the resulting transformnode
  13798. * @returns this TransformNode.
  13799. */
  13800. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13801. /**
  13802. * Sets this transform node rotation to the given local axis.
  13803. * @param localAxis the axis in local space
  13804. * @param yawCor optional yaw (y-axis) correction in radians
  13805. * @param pitchCor optional pitch (x-axis) correction in radians
  13806. * @param rollCor optional roll (z-axis) correction in radians
  13807. * @returns this TransformNode
  13808. */
  13809. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13810. /**
  13811. * Sets a new pivot point to the current node
  13812. * @param point defines the new pivot point to use
  13813. * @param space defines if the point is in world or local space (local by default)
  13814. * @returns the current TransformNode
  13815. */
  13816. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13817. /**
  13818. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13819. * @returns the pivot point
  13820. */
  13821. getPivotPoint(): Vector3;
  13822. /**
  13823. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13824. * @param result the vector3 to store the result
  13825. * @returns this TransformNode.
  13826. */
  13827. getPivotPointToRef(result: Vector3): TransformNode;
  13828. /**
  13829. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13830. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13831. */
  13832. getAbsolutePivotPoint(): Vector3;
  13833. /**
  13834. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13835. * @param result vector3 to store the result
  13836. * @returns this TransformNode.
  13837. */
  13838. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13839. /**
  13840. * Defines the passed node as the parent of the current node.
  13841. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13842. * @see https://doc.babylonjs.com/how_to/parenting
  13843. * @param node the node ot set as the parent
  13844. * @returns this TransformNode.
  13845. */
  13846. setParent(node: Nullable<Node>): TransformNode;
  13847. private _nonUniformScaling;
  13848. /**
  13849. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13850. */
  13851. readonly nonUniformScaling: boolean;
  13852. /** @hidden */
  13853. _updateNonUniformScalingState(value: boolean): boolean;
  13854. /**
  13855. * Attach the current TransformNode to another TransformNode associated with a bone
  13856. * @param bone Bone affecting the TransformNode
  13857. * @param affectedTransformNode TransformNode associated with the bone
  13858. * @returns this object
  13859. */
  13860. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13861. /**
  13862. * Detach the transform node if its associated with a bone
  13863. * @returns this object
  13864. */
  13865. detachFromBone(): TransformNode;
  13866. private static _rotationAxisCache;
  13867. /**
  13868. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13869. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13870. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13871. * The passed axis is also normalized.
  13872. * @param axis the axis to rotate around
  13873. * @param amount the amount to rotate in radians
  13874. * @param space Space to rotate in (Default: local)
  13875. * @returns the TransformNode.
  13876. */
  13877. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13878. /**
  13879. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13880. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13881. * The passed axis is also normalized. .
  13882. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13883. * @param point the point to rotate around
  13884. * @param axis the axis to rotate around
  13885. * @param amount the amount to rotate in radians
  13886. * @returns the TransformNode
  13887. */
  13888. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13889. /**
  13890. * Translates the mesh along the axis vector for the passed distance in the given space.
  13891. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13892. * @param axis the axis to translate in
  13893. * @param distance the distance to translate
  13894. * @param space Space to rotate in (Default: local)
  13895. * @returns the TransformNode.
  13896. */
  13897. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13898. /**
  13899. * Adds a rotation step to the mesh current rotation.
  13900. * x, y, z are Euler angles expressed in radians.
  13901. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13902. * This means this rotation is made in the mesh local space only.
  13903. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13904. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13905. * ```javascript
  13906. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13907. * ```
  13908. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13909. * 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.
  13910. * @param x Rotation to add
  13911. * @param y Rotation to add
  13912. * @param z Rotation to add
  13913. * @returns the TransformNode.
  13914. */
  13915. addRotation(x: number, y: number, z: number): TransformNode;
  13916. /**
  13917. * @hidden
  13918. */
  13919. protected _getEffectiveParent(): Nullable<Node>;
  13920. /**
  13921. * Computes the world matrix of the node
  13922. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13923. * @returns the world matrix
  13924. */
  13925. computeWorldMatrix(force?: boolean): Matrix;
  13926. protected _afterComputeWorldMatrix(): void;
  13927. /**
  13928. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13929. * @param func callback function to add
  13930. *
  13931. * @returns the TransformNode.
  13932. */
  13933. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13934. /**
  13935. * Removes a registered callback function.
  13936. * @param func callback function to remove
  13937. * @returns the TransformNode.
  13938. */
  13939. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13940. /**
  13941. * Gets the position of the current mesh in camera space
  13942. * @param camera defines the camera to use
  13943. * @returns a position
  13944. */
  13945. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13946. /**
  13947. * Returns the distance from the mesh to the active camera
  13948. * @param camera defines the camera to use
  13949. * @returns the distance
  13950. */
  13951. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13952. /**
  13953. * Clone the current transform node
  13954. * @param name Name of the new clone
  13955. * @param newParent New parent for the clone
  13956. * @param doNotCloneChildren Do not clone children hierarchy
  13957. * @returns the new transform node
  13958. */
  13959. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13960. /**
  13961. * Serializes the objects information.
  13962. * @param currentSerializationObject defines the object to serialize in
  13963. * @returns the serialized object
  13964. */
  13965. serialize(currentSerializationObject?: any): any;
  13966. /**
  13967. * Returns a new TransformNode object parsed from the source provided.
  13968. * @param parsedTransformNode is the source.
  13969. * @param scene the scne the object belongs to
  13970. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13971. * @returns a new TransformNode object parsed from the source provided.
  13972. */
  13973. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13974. /**
  13975. * Get all child-transformNodes of this node
  13976. * @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
  13977. * @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
  13978. * @returns an array of TransformNode
  13979. */
  13980. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  13981. /**
  13982. * Releases resources associated with this transform node.
  13983. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13984. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13985. */
  13986. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13987. /**
  13988. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  13989. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  13990. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  13991. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  13992. * @returns the current mesh
  13993. */
  13994. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  13995. private _syncAbsoluteScalingAndRotation;
  13996. }
  13997. }
  13998. declare module BABYLON {
  13999. /**
  14000. * Defines the types of pose enabled controllers that are supported
  14001. */
  14002. export enum PoseEnabledControllerType {
  14003. /**
  14004. * HTC Vive
  14005. */
  14006. VIVE = 0,
  14007. /**
  14008. * Oculus Rift
  14009. */
  14010. OCULUS = 1,
  14011. /**
  14012. * Windows mixed reality
  14013. */
  14014. WINDOWS = 2,
  14015. /**
  14016. * Samsung gear VR
  14017. */
  14018. GEAR_VR = 3,
  14019. /**
  14020. * Google Daydream
  14021. */
  14022. DAYDREAM = 4,
  14023. /**
  14024. * Generic
  14025. */
  14026. GENERIC = 5
  14027. }
  14028. /**
  14029. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14030. */
  14031. export interface MutableGamepadButton {
  14032. /**
  14033. * Value of the button/trigger
  14034. */
  14035. value: number;
  14036. /**
  14037. * If the button/trigger is currently touched
  14038. */
  14039. touched: boolean;
  14040. /**
  14041. * If the button/trigger is currently pressed
  14042. */
  14043. pressed: boolean;
  14044. }
  14045. /**
  14046. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14047. * @hidden
  14048. */
  14049. export interface ExtendedGamepadButton extends GamepadButton {
  14050. /**
  14051. * If the button/trigger is currently pressed
  14052. */
  14053. readonly pressed: boolean;
  14054. /**
  14055. * If the button/trigger is currently touched
  14056. */
  14057. readonly touched: boolean;
  14058. /**
  14059. * Value of the button/trigger
  14060. */
  14061. readonly value: number;
  14062. }
  14063. /** @hidden */
  14064. export interface _GamePadFactory {
  14065. /**
  14066. * Returns wether or not the current gamepad can be created for this type of controller.
  14067. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14068. * @returns true if it can be created, otherwise false
  14069. */
  14070. canCreate(gamepadInfo: any): boolean;
  14071. /**
  14072. * Creates a new instance of the Gamepad.
  14073. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14074. * @returns the new gamepad instance
  14075. */
  14076. create(gamepadInfo: any): Gamepad;
  14077. }
  14078. /**
  14079. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14080. */
  14081. export class PoseEnabledControllerHelper {
  14082. /** @hidden */
  14083. static _ControllerFactories: _GamePadFactory[];
  14084. /** @hidden */
  14085. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14086. /**
  14087. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14088. * @param vrGamepad the gamepad to initialized
  14089. * @returns a vr controller of the type the gamepad identified as
  14090. */
  14091. static InitiateController(vrGamepad: any): Gamepad;
  14092. }
  14093. /**
  14094. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14095. */
  14096. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14097. /**
  14098. * If the controller is used in a webXR session
  14099. */
  14100. isXR: boolean;
  14101. private _deviceRoomPosition;
  14102. private _deviceRoomRotationQuaternion;
  14103. /**
  14104. * The device position in babylon space
  14105. */
  14106. devicePosition: Vector3;
  14107. /**
  14108. * The device rotation in babylon space
  14109. */
  14110. deviceRotationQuaternion: Quaternion;
  14111. /**
  14112. * The scale factor of the device in babylon space
  14113. */
  14114. deviceScaleFactor: number;
  14115. /**
  14116. * (Likely devicePosition should be used instead) The device position in its room space
  14117. */
  14118. position: Vector3;
  14119. /**
  14120. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14121. */
  14122. rotationQuaternion: Quaternion;
  14123. /**
  14124. * The type of controller (Eg. Windows mixed reality)
  14125. */
  14126. controllerType: PoseEnabledControllerType;
  14127. protected _calculatedPosition: Vector3;
  14128. private _calculatedRotation;
  14129. /**
  14130. * The raw pose from the device
  14131. */
  14132. rawPose: DevicePose;
  14133. private _trackPosition;
  14134. private _maxRotationDistFromHeadset;
  14135. private _draggedRoomRotation;
  14136. /**
  14137. * @hidden
  14138. */
  14139. _disableTrackPosition(fixedPosition: Vector3): void;
  14140. /**
  14141. * Internal, the mesh attached to the controller
  14142. * @hidden
  14143. */
  14144. _mesh: Nullable<AbstractMesh>;
  14145. private _poseControlledCamera;
  14146. private _leftHandSystemQuaternion;
  14147. /**
  14148. * Internal, matrix used to convert room space to babylon space
  14149. * @hidden
  14150. */
  14151. _deviceToWorld: Matrix;
  14152. /**
  14153. * Node to be used when casting a ray from the controller
  14154. * @hidden
  14155. */
  14156. _pointingPoseNode: Nullable<TransformNode>;
  14157. /**
  14158. * Name of the child mesh that can be used to cast a ray from the controller
  14159. */
  14160. static readonly POINTING_POSE: string;
  14161. /**
  14162. * Creates a new PoseEnabledController from a gamepad
  14163. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14164. */
  14165. constructor(browserGamepad: any);
  14166. private _workingMatrix;
  14167. /**
  14168. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14169. */
  14170. update(): void;
  14171. /**
  14172. * Updates only the pose device and mesh without doing any button event checking
  14173. */
  14174. protected _updatePoseAndMesh(): void;
  14175. /**
  14176. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14177. * @param poseData raw pose fromthe device
  14178. */
  14179. updateFromDevice(poseData: DevicePose): void;
  14180. /**
  14181. * @hidden
  14182. */
  14183. _meshAttachedObservable: Observable<AbstractMesh>;
  14184. /**
  14185. * Attaches a mesh to the controller
  14186. * @param mesh the mesh to be attached
  14187. */
  14188. attachToMesh(mesh: AbstractMesh): void;
  14189. /**
  14190. * Attaches the controllers mesh to a camera
  14191. * @param camera the camera the mesh should be attached to
  14192. */
  14193. attachToPoseControlledCamera(camera: TargetCamera): void;
  14194. /**
  14195. * Disposes of the controller
  14196. */
  14197. dispose(): void;
  14198. /**
  14199. * The mesh that is attached to the controller
  14200. */
  14201. readonly mesh: Nullable<AbstractMesh>;
  14202. /**
  14203. * Gets the ray of the controller in the direction the controller is pointing
  14204. * @param length the length the resulting ray should be
  14205. * @returns a ray in the direction the controller is pointing
  14206. */
  14207. getForwardRay(length?: number): Ray;
  14208. }
  14209. }
  14210. declare module BABYLON {
  14211. /**
  14212. * Defines the WebVRController object that represents controllers tracked in 3D space
  14213. */
  14214. export abstract class WebVRController extends PoseEnabledController {
  14215. /**
  14216. * Internal, the default controller model for the controller
  14217. */
  14218. protected _defaultModel: Nullable<AbstractMesh>;
  14219. /**
  14220. * Fired when the trigger state has changed
  14221. */
  14222. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14223. /**
  14224. * Fired when the main button state has changed
  14225. */
  14226. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14227. /**
  14228. * Fired when the secondary button state has changed
  14229. */
  14230. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14231. /**
  14232. * Fired when the pad state has changed
  14233. */
  14234. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14235. /**
  14236. * Fired when controllers stick values have changed
  14237. */
  14238. onPadValuesChangedObservable: Observable<StickValues>;
  14239. /**
  14240. * Array of button availible on the controller
  14241. */
  14242. protected _buttons: Array<MutableGamepadButton>;
  14243. private _onButtonStateChange;
  14244. /**
  14245. * Fired when a controller button's state has changed
  14246. * @param callback the callback containing the button that was modified
  14247. */
  14248. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14249. /**
  14250. * X and Y axis corresponding to the controllers joystick
  14251. */
  14252. pad: StickValues;
  14253. /**
  14254. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14255. */
  14256. hand: string;
  14257. /**
  14258. * The default controller model for the controller
  14259. */
  14260. readonly defaultModel: Nullable<AbstractMesh>;
  14261. /**
  14262. * Creates a new WebVRController from a gamepad
  14263. * @param vrGamepad the gamepad that the WebVRController should be created from
  14264. */
  14265. constructor(vrGamepad: any);
  14266. /**
  14267. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14268. */
  14269. update(): void;
  14270. /**
  14271. * Function to be called when a button is modified
  14272. */
  14273. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14274. /**
  14275. * Loads a mesh and attaches it to the controller
  14276. * @param scene the scene the mesh should be added to
  14277. * @param meshLoaded callback for when the mesh has been loaded
  14278. */
  14279. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14280. private _setButtonValue;
  14281. private _changes;
  14282. private _checkChanges;
  14283. /**
  14284. * Disposes of th webVRCOntroller
  14285. */
  14286. dispose(): void;
  14287. }
  14288. }
  14289. declare module BABYLON {
  14290. /**
  14291. * The HemisphericLight simulates the ambient environment light,
  14292. * so the passed direction is the light reflection direction, not the incoming direction.
  14293. */
  14294. export class HemisphericLight extends Light {
  14295. /**
  14296. * The groundColor is the light in the opposite direction to the one specified during creation.
  14297. * 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.
  14298. */
  14299. groundColor: Color3;
  14300. /**
  14301. * The light reflection direction, not the incoming direction.
  14302. */
  14303. direction: Vector3;
  14304. /**
  14305. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14306. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14307. * The HemisphericLight can't cast shadows.
  14308. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14309. * @param name The friendly name of the light
  14310. * @param direction The direction of the light reflection
  14311. * @param scene The scene the light belongs to
  14312. */
  14313. constructor(name: string, direction: Vector3, scene: Scene);
  14314. protected _buildUniformLayout(): void;
  14315. /**
  14316. * Returns the string "HemisphericLight".
  14317. * @return The class name
  14318. */
  14319. getClassName(): string;
  14320. /**
  14321. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14322. * Returns the updated direction.
  14323. * @param target The target the direction should point to
  14324. * @return The computed direction
  14325. */
  14326. setDirectionToTarget(target: Vector3): Vector3;
  14327. /**
  14328. * Returns the shadow generator associated to the light.
  14329. * @returns Always null for hemispheric lights because it does not support shadows.
  14330. */
  14331. getShadowGenerator(): Nullable<IShadowGenerator>;
  14332. /**
  14333. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14334. * @param effect The effect to update
  14335. * @param lightIndex The index of the light in the effect to update
  14336. * @returns The hemispheric light
  14337. */
  14338. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14339. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14340. /**
  14341. * Computes the world matrix of the node
  14342. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14343. * @param useWasUpdatedFlag defines a reserved property
  14344. * @returns the world matrix
  14345. */
  14346. computeWorldMatrix(): Matrix;
  14347. /**
  14348. * Returns the integer 3.
  14349. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14350. */
  14351. getTypeID(): number;
  14352. /**
  14353. * Prepares the list of defines specific to the light type.
  14354. * @param defines the list of defines
  14355. * @param lightIndex defines the index of the light for the effect
  14356. */
  14357. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14358. }
  14359. }
  14360. declare module BABYLON {
  14361. /** @hidden */
  14362. export var vrMultiviewToSingleviewPixelShader: {
  14363. name: string;
  14364. shader: string;
  14365. };
  14366. }
  14367. declare module BABYLON {
  14368. /**
  14369. * Renders to multiple views with a single draw call
  14370. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14371. */
  14372. export class MultiviewRenderTarget extends RenderTargetTexture {
  14373. /**
  14374. * Creates a multiview render target
  14375. * @param scene scene used with the render target
  14376. * @param size the size of the render target (used for each view)
  14377. */
  14378. constructor(scene: Scene, size?: number | {
  14379. width: number;
  14380. height: number;
  14381. } | {
  14382. ratio: number;
  14383. });
  14384. /**
  14385. * @hidden
  14386. * @param faceIndex the face index, if its a cube texture
  14387. */
  14388. _bindFrameBuffer(faceIndex?: number): void;
  14389. /**
  14390. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14391. * @returns the view count
  14392. */
  14393. getViewCount(): number;
  14394. }
  14395. }
  14396. declare module BABYLON {
  14397. /**
  14398. * Represents a camera frustum
  14399. */
  14400. export class Frustum {
  14401. /**
  14402. * Gets the planes representing the frustum
  14403. * @param transform matrix to be applied to the returned planes
  14404. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14405. */
  14406. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14407. /**
  14408. * Gets the near frustum plane transformed by the transform matrix
  14409. * @param transform transformation matrix to be applied to the resulting frustum plane
  14410. * @param frustumPlane the resuling frustum plane
  14411. */
  14412. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14413. /**
  14414. * Gets the far frustum plane transformed by the transform matrix
  14415. * @param transform transformation matrix to be applied to the resulting frustum plane
  14416. * @param frustumPlane the resuling frustum plane
  14417. */
  14418. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14419. /**
  14420. * Gets the left frustum plane transformed by the transform matrix
  14421. * @param transform transformation matrix to be applied to the resulting frustum plane
  14422. * @param frustumPlane the resuling frustum plane
  14423. */
  14424. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14425. /**
  14426. * Gets the right frustum plane transformed by the transform matrix
  14427. * @param transform transformation matrix to be applied to the resulting frustum plane
  14428. * @param frustumPlane the resuling frustum plane
  14429. */
  14430. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14431. /**
  14432. * Gets the top frustum plane transformed by the transform matrix
  14433. * @param transform transformation matrix to be applied to the resulting frustum plane
  14434. * @param frustumPlane the resuling frustum plane
  14435. */
  14436. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14437. /**
  14438. * Gets the bottom frustum plane transformed by the transform matrix
  14439. * @param transform transformation matrix to be applied to the resulting frustum plane
  14440. * @param frustumPlane the resuling frustum plane
  14441. */
  14442. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14443. /**
  14444. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14445. * @param transform transformation matrix to be applied to the resulting frustum planes
  14446. * @param frustumPlanes the resuling frustum planes
  14447. */
  14448. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14449. }
  14450. }
  14451. declare module BABYLON {
  14452. interface Engine {
  14453. /**
  14454. * Creates a new multiview render target
  14455. * @param width defines the width of the texture
  14456. * @param height defines the height of the texture
  14457. * @returns the created multiview texture
  14458. */
  14459. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14460. /**
  14461. * Binds a multiview framebuffer to be drawn to
  14462. * @param multiviewTexture texture to bind
  14463. */
  14464. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14465. }
  14466. interface Camera {
  14467. /**
  14468. * @hidden
  14469. * 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)
  14470. */
  14471. _useMultiviewToSingleView: boolean;
  14472. /**
  14473. * @hidden
  14474. * 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)
  14475. */
  14476. _multiviewTexture: Nullable<RenderTargetTexture>;
  14477. /**
  14478. * @hidden
  14479. * ensures the multiview texture of the camera exists and has the specified width/height
  14480. * @param width height to set on the multiview texture
  14481. * @param height width to set on the multiview texture
  14482. */
  14483. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14484. }
  14485. interface Scene {
  14486. /** @hidden */
  14487. _transformMatrixR: Matrix;
  14488. /** @hidden */
  14489. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14490. /** @hidden */
  14491. _createMultiviewUbo(): void;
  14492. /** @hidden */
  14493. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14494. /** @hidden */
  14495. _renderMultiviewToSingleView(camera: Camera): void;
  14496. }
  14497. }
  14498. declare module BABYLON {
  14499. /**
  14500. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14501. * This will not be used for webXR as it supports displaying texture arrays directly
  14502. */
  14503. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14504. /**
  14505. * Initializes a VRMultiviewToSingleview
  14506. * @param name name of the post process
  14507. * @param camera camera to be applied to
  14508. * @param scaleFactor scaling factor to the size of the output texture
  14509. */
  14510. constructor(name: string, camera: Camera, scaleFactor: number);
  14511. }
  14512. }
  14513. declare module BABYLON {
  14514. interface Engine {
  14515. /** @hidden */
  14516. _vrDisplay: any;
  14517. /** @hidden */
  14518. _vrSupported: boolean;
  14519. /** @hidden */
  14520. _oldSize: Size;
  14521. /** @hidden */
  14522. _oldHardwareScaleFactor: number;
  14523. /** @hidden */
  14524. _vrExclusivePointerMode: boolean;
  14525. /** @hidden */
  14526. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14527. /** @hidden */
  14528. _onVRDisplayPointerRestricted: () => void;
  14529. /** @hidden */
  14530. _onVRDisplayPointerUnrestricted: () => void;
  14531. /** @hidden */
  14532. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14533. /** @hidden */
  14534. _onVrDisplayDisconnect: Nullable<() => void>;
  14535. /** @hidden */
  14536. _onVrDisplayPresentChange: Nullable<() => void>;
  14537. /**
  14538. * Observable signaled when VR display mode changes
  14539. */
  14540. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14541. /**
  14542. * Observable signaled when VR request present is complete
  14543. */
  14544. onVRRequestPresentComplete: Observable<boolean>;
  14545. /**
  14546. * Observable signaled when VR request present starts
  14547. */
  14548. onVRRequestPresentStart: Observable<Engine>;
  14549. /**
  14550. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14551. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14552. */
  14553. isInVRExclusivePointerMode: boolean;
  14554. /**
  14555. * Gets a boolean indicating if a webVR device was detected
  14556. * @returns true if a webVR device was detected
  14557. */
  14558. isVRDevicePresent(): boolean;
  14559. /**
  14560. * Gets the current webVR device
  14561. * @returns the current webVR device (or null)
  14562. */
  14563. getVRDevice(): any;
  14564. /**
  14565. * Initializes a webVR display and starts listening to display change events
  14566. * The onVRDisplayChangedObservable will be notified upon these changes
  14567. * @returns A promise containing a VRDisplay and if vr is supported
  14568. */
  14569. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14570. /** @hidden */
  14571. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14572. /**
  14573. * Call this function to switch to webVR mode
  14574. * Will do nothing if webVR is not supported or if there is no webVR device
  14575. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14576. */
  14577. enableVR(): void;
  14578. /** @hidden */
  14579. _onVRFullScreenTriggered(): void;
  14580. }
  14581. }
  14582. declare module BABYLON {
  14583. /**
  14584. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14585. * IMPORTANT!! The data is right-hand data.
  14586. * @export
  14587. * @interface DevicePose
  14588. */
  14589. export interface DevicePose {
  14590. /**
  14591. * The position of the device, values in array are [x,y,z].
  14592. */
  14593. readonly position: Nullable<Float32Array>;
  14594. /**
  14595. * The linearVelocity of the device, values in array are [x,y,z].
  14596. */
  14597. readonly linearVelocity: Nullable<Float32Array>;
  14598. /**
  14599. * The linearAcceleration of the device, values in array are [x,y,z].
  14600. */
  14601. readonly linearAcceleration: Nullable<Float32Array>;
  14602. /**
  14603. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14604. */
  14605. readonly orientation: Nullable<Float32Array>;
  14606. /**
  14607. * The angularVelocity of the device, values in array are [x,y,z].
  14608. */
  14609. readonly angularVelocity: Nullable<Float32Array>;
  14610. /**
  14611. * The angularAcceleration of the device, values in array are [x,y,z].
  14612. */
  14613. readonly angularAcceleration: Nullable<Float32Array>;
  14614. }
  14615. /**
  14616. * Interface representing a pose controlled object in Babylon.
  14617. * A pose controlled object has both regular pose values as well as pose values
  14618. * from an external device such as a VR head mounted display
  14619. */
  14620. export interface PoseControlled {
  14621. /**
  14622. * The position of the object in babylon space.
  14623. */
  14624. position: Vector3;
  14625. /**
  14626. * The rotation quaternion of the object in babylon space.
  14627. */
  14628. rotationQuaternion: Quaternion;
  14629. /**
  14630. * The position of the device in babylon space.
  14631. */
  14632. devicePosition?: Vector3;
  14633. /**
  14634. * The rotation quaternion of the device in babylon space.
  14635. */
  14636. deviceRotationQuaternion: Quaternion;
  14637. /**
  14638. * The raw pose coming from the device.
  14639. */
  14640. rawPose: Nullable<DevicePose>;
  14641. /**
  14642. * The scale of the device to be used when translating from device space to babylon space.
  14643. */
  14644. deviceScaleFactor: number;
  14645. /**
  14646. * Updates the poseControlled values based on the input device pose.
  14647. * @param poseData the pose data to update the object with
  14648. */
  14649. updateFromDevice(poseData: DevicePose): void;
  14650. }
  14651. /**
  14652. * Set of options to customize the webVRCamera
  14653. */
  14654. export interface WebVROptions {
  14655. /**
  14656. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14657. */
  14658. trackPosition?: boolean;
  14659. /**
  14660. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14661. */
  14662. positionScale?: number;
  14663. /**
  14664. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14665. */
  14666. displayName?: string;
  14667. /**
  14668. * Should the native controller meshes be initialized. (default: true)
  14669. */
  14670. controllerMeshes?: boolean;
  14671. /**
  14672. * Creating a default HemiLight only on controllers. (default: true)
  14673. */
  14674. defaultLightingOnControllers?: boolean;
  14675. /**
  14676. * If you don't want to use the default VR button of the helper. (default: false)
  14677. */
  14678. useCustomVRButton?: boolean;
  14679. /**
  14680. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14681. */
  14682. customVRButton?: HTMLButtonElement;
  14683. /**
  14684. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14685. */
  14686. rayLength?: number;
  14687. /**
  14688. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14689. */
  14690. defaultHeight?: number;
  14691. /**
  14692. * If multiview should be used if availible (default: false)
  14693. */
  14694. useMultiview?: boolean;
  14695. }
  14696. /**
  14697. * This represents a WebVR camera.
  14698. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14699. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14700. */
  14701. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14702. private webVROptions;
  14703. /**
  14704. * @hidden
  14705. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14706. */
  14707. _vrDevice: any;
  14708. /**
  14709. * The rawPose of the vrDevice.
  14710. */
  14711. rawPose: Nullable<DevicePose>;
  14712. private _onVREnabled;
  14713. private _specsVersion;
  14714. private _attached;
  14715. private _frameData;
  14716. protected _descendants: Array<Node>;
  14717. private _deviceRoomPosition;
  14718. /** @hidden */
  14719. _deviceRoomRotationQuaternion: Quaternion;
  14720. private _standingMatrix;
  14721. /**
  14722. * Represents device position in babylon space.
  14723. */
  14724. devicePosition: Vector3;
  14725. /**
  14726. * Represents device rotation in babylon space.
  14727. */
  14728. deviceRotationQuaternion: Quaternion;
  14729. /**
  14730. * The scale of the device to be used when translating from device space to babylon space.
  14731. */
  14732. deviceScaleFactor: number;
  14733. private _deviceToWorld;
  14734. private _worldToDevice;
  14735. /**
  14736. * References to the webVR controllers for the vrDevice.
  14737. */
  14738. controllers: Array<WebVRController>;
  14739. /**
  14740. * Emits an event when a controller is attached.
  14741. */
  14742. onControllersAttachedObservable: Observable<WebVRController[]>;
  14743. /**
  14744. * Emits an event when a controller's mesh has been loaded;
  14745. */
  14746. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14747. /**
  14748. * Emits an event when the HMD's pose has been updated.
  14749. */
  14750. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14751. private _poseSet;
  14752. /**
  14753. * If the rig cameras be used as parent instead of this camera.
  14754. */
  14755. rigParenting: boolean;
  14756. private _lightOnControllers;
  14757. private _defaultHeight?;
  14758. /**
  14759. * Instantiates a WebVRFreeCamera.
  14760. * @param name The name of the WebVRFreeCamera
  14761. * @param position The starting anchor position for the camera
  14762. * @param scene The scene the camera belongs to
  14763. * @param webVROptions a set of customizable options for the webVRCamera
  14764. */
  14765. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14766. /**
  14767. * Gets the device distance from the ground in meters.
  14768. * @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.
  14769. */
  14770. deviceDistanceToRoomGround(): number;
  14771. /**
  14772. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14773. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14774. */
  14775. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14776. /**
  14777. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14778. * @returns A promise with a boolean set to if the standing matrix is supported.
  14779. */
  14780. useStandingMatrixAsync(): Promise<boolean>;
  14781. /**
  14782. * Disposes the camera
  14783. */
  14784. dispose(): void;
  14785. /**
  14786. * Gets a vrController by name.
  14787. * @param name The name of the controller to retreive
  14788. * @returns the controller matching the name specified or null if not found
  14789. */
  14790. getControllerByName(name: string): Nullable<WebVRController>;
  14791. private _leftController;
  14792. /**
  14793. * The controller corresponding to the users left hand.
  14794. */
  14795. readonly leftController: Nullable<WebVRController>;
  14796. private _rightController;
  14797. /**
  14798. * The controller corresponding to the users right hand.
  14799. */
  14800. readonly rightController: Nullable<WebVRController>;
  14801. /**
  14802. * Casts a ray forward from the vrCamera's gaze.
  14803. * @param length Length of the ray (default: 100)
  14804. * @returns the ray corresponding to the gaze
  14805. */
  14806. getForwardRay(length?: number): Ray;
  14807. /**
  14808. * @hidden
  14809. * Updates the camera based on device's frame data
  14810. */
  14811. _checkInputs(): void;
  14812. /**
  14813. * Updates the poseControlled values based on the input device pose.
  14814. * @param poseData Pose coming from the device
  14815. */
  14816. updateFromDevice(poseData: DevicePose): void;
  14817. private _htmlElementAttached;
  14818. private _detachIfAttached;
  14819. /**
  14820. * WebVR's attach control will start broadcasting frames to the device.
  14821. * Note that in certain browsers (chrome for example) this function must be called
  14822. * within a user-interaction callback. Example:
  14823. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14824. *
  14825. * @param element html element to attach the vrDevice to
  14826. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14827. */
  14828. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14829. /**
  14830. * Detaches the camera from the html element and disables VR
  14831. *
  14832. * @param element html element to detach from
  14833. */
  14834. detachControl(element: HTMLElement): void;
  14835. /**
  14836. * @returns the name of this class
  14837. */
  14838. getClassName(): string;
  14839. /**
  14840. * Calls resetPose on the vrDisplay
  14841. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14842. */
  14843. resetToCurrentRotation(): void;
  14844. /**
  14845. * @hidden
  14846. * Updates the rig cameras (left and right eye)
  14847. */
  14848. _updateRigCameras(): void;
  14849. private _workingVector;
  14850. private _oneVector;
  14851. private _workingMatrix;
  14852. private updateCacheCalled;
  14853. private _correctPositionIfNotTrackPosition;
  14854. /**
  14855. * @hidden
  14856. * Updates the cached values of the camera
  14857. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14858. */
  14859. _updateCache(ignoreParentClass?: boolean): void;
  14860. /**
  14861. * @hidden
  14862. * Get current device position in babylon world
  14863. */
  14864. _computeDevicePosition(): void;
  14865. /**
  14866. * Updates the current device position and rotation in the babylon world
  14867. */
  14868. update(): void;
  14869. /**
  14870. * @hidden
  14871. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14872. * @returns an identity matrix
  14873. */
  14874. _getViewMatrix(): Matrix;
  14875. private _tmpMatrix;
  14876. /**
  14877. * This function is called by the two RIG cameras.
  14878. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14879. * @hidden
  14880. */
  14881. _getWebVRViewMatrix(): Matrix;
  14882. /** @hidden */
  14883. _getWebVRProjectionMatrix(): Matrix;
  14884. private _onGamepadConnectedObserver;
  14885. private _onGamepadDisconnectedObserver;
  14886. private _updateCacheWhenTrackingDisabledObserver;
  14887. /**
  14888. * Initializes the controllers and their meshes
  14889. */
  14890. initControllers(): void;
  14891. }
  14892. }
  14893. declare module BABYLON {
  14894. /**
  14895. * Size options for a post process
  14896. */
  14897. export type PostProcessOptions = {
  14898. width: number;
  14899. height: number;
  14900. };
  14901. /**
  14902. * PostProcess can be used to apply a shader to a texture after it has been rendered
  14903. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14904. */
  14905. export class PostProcess {
  14906. /** Name of the PostProcess. */
  14907. name: string;
  14908. /**
  14909. * Gets or sets the unique id of the post process
  14910. */
  14911. uniqueId: number;
  14912. /**
  14913. * Width of the texture to apply the post process on
  14914. */
  14915. width: number;
  14916. /**
  14917. * Height of the texture to apply the post process on
  14918. */
  14919. height: number;
  14920. /**
  14921. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  14922. * @hidden
  14923. */
  14924. _outputTexture: Nullable<InternalTexture>;
  14925. /**
  14926. * Sampling mode used by the shader
  14927. * See https://doc.babylonjs.com/classes/3.1/texture
  14928. */
  14929. renderTargetSamplingMode: number;
  14930. /**
  14931. * Clear color to use when screen clearing
  14932. */
  14933. clearColor: Color4;
  14934. /**
  14935. * If the buffer needs to be cleared before applying the post process. (default: true)
  14936. * Should be set to false if shader will overwrite all previous pixels.
  14937. */
  14938. autoClear: boolean;
  14939. /**
  14940. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  14941. */
  14942. alphaMode: number;
  14943. /**
  14944. * Sets the setAlphaBlendConstants of the babylon engine
  14945. */
  14946. alphaConstants: Color4;
  14947. /**
  14948. * Animations to be used for the post processing
  14949. */
  14950. animations: Animation[];
  14951. /**
  14952. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  14953. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  14954. */
  14955. enablePixelPerfectMode: boolean;
  14956. /**
  14957. * Force the postprocess to be applied without taking in account viewport
  14958. */
  14959. forceFullscreenViewport: boolean;
  14960. /**
  14961. * List of inspectable custom properties (used by the Inspector)
  14962. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14963. */
  14964. inspectableCustomProperties: IInspectable[];
  14965. /**
  14966. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  14967. *
  14968. * | Value | Type | Description |
  14969. * | ----- | ----------------------------------- | ----------- |
  14970. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  14971. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  14972. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  14973. *
  14974. */
  14975. scaleMode: number;
  14976. /**
  14977. * Force textures to be a power of two (default: false)
  14978. */
  14979. alwaysForcePOT: boolean;
  14980. private _samples;
  14981. /**
  14982. * Number of sample textures (default: 1)
  14983. */
  14984. samples: number;
  14985. /**
  14986. * Modify the scale of the post process to be the same as the viewport (default: false)
  14987. */
  14988. adaptScaleToCurrentViewport: boolean;
  14989. private _camera;
  14990. private _scene;
  14991. private _engine;
  14992. private _options;
  14993. private _reusable;
  14994. private _textureType;
  14995. /**
  14996. * Smart array of input and output textures for the post process.
  14997. * @hidden
  14998. */
  14999. _textures: SmartArray<InternalTexture>;
  15000. /**
  15001. * The index in _textures that corresponds to the output texture.
  15002. * @hidden
  15003. */
  15004. _currentRenderTextureInd: number;
  15005. private _effect;
  15006. private _samplers;
  15007. private _fragmentUrl;
  15008. private _vertexUrl;
  15009. private _parameters;
  15010. private _scaleRatio;
  15011. protected _indexParameters: any;
  15012. private _shareOutputWithPostProcess;
  15013. private _texelSize;
  15014. private _forcedOutputTexture;
  15015. /**
  15016. * Returns the fragment url or shader name used in the post process.
  15017. * @returns the fragment url or name in the shader store.
  15018. */
  15019. getEffectName(): string;
  15020. /**
  15021. * An event triggered when the postprocess is activated.
  15022. */
  15023. onActivateObservable: Observable<Camera>;
  15024. private _onActivateObserver;
  15025. /**
  15026. * A function that is added to the onActivateObservable
  15027. */
  15028. onActivate: Nullable<(camera: Camera) => void>;
  15029. /**
  15030. * An event triggered when the postprocess changes its size.
  15031. */
  15032. onSizeChangedObservable: Observable<PostProcess>;
  15033. private _onSizeChangedObserver;
  15034. /**
  15035. * A function that is added to the onSizeChangedObservable
  15036. */
  15037. onSizeChanged: (postProcess: PostProcess) => void;
  15038. /**
  15039. * An event triggered when the postprocess applies its effect.
  15040. */
  15041. onApplyObservable: Observable<Effect>;
  15042. private _onApplyObserver;
  15043. /**
  15044. * A function that is added to the onApplyObservable
  15045. */
  15046. onApply: (effect: Effect) => void;
  15047. /**
  15048. * An event triggered before rendering the postprocess
  15049. */
  15050. onBeforeRenderObservable: Observable<Effect>;
  15051. private _onBeforeRenderObserver;
  15052. /**
  15053. * A function that is added to the onBeforeRenderObservable
  15054. */
  15055. onBeforeRender: (effect: Effect) => void;
  15056. /**
  15057. * An event triggered after rendering the postprocess
  15058. */
  15059. onAfterRenderObservable: Observable<Effect>;
  15060. private _onAfterRenderObserver;
  15061. /**
  15062. * A function that is added to the onAfterRenderObservable
  15063. */
  15064. onAfterRender: (efect: Effect) => void;
  15065. /**
  15066. * 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
  15067. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15068. */
  15069. inputTexture: InternalTexture;
  15070. /**
  15071. * Gets the camera which post process is applied to.
  15072. * @returns The camera the post process is applied to.
  15073. */
  15074. getCamera(): Camera;
  15075. /**
  15076. * Gets the texel size of the postprocess.
  15077. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15078. */
  15079. readonly texelSize: Vector2;
  15080. /**
  15081. * Creates a new instance PostProcess
  15082. * @param name The name of the PostProcess.
  15083. * @param fragmentUrl The url of the fragment shader to be used.
  15084. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15085. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15086. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15087. * @param camera The camera to apply the render pass to.
  15088. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15089. * @param engine The engine which the post process will be applied. (default: current engine)
  15090. * @param reusable If the post process can be reused on the same frame. (default: false)
  15091. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15092. * @param textureType Type of textures used when performing the post process. (default: 0)
  15093. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15094. * @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
  15095. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15096. */
  15097. constructor(
  15098. /** Name of the PostProcess. */
  15099. 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);
  15100. /**
  15101. * Gets a string idenfifying the name of the class
  15102. * @returns "PostProcess" string
  15103. */
  15104. getClassName(): string;
  15105. /**
  15106. * Gets the engine which this post process belongs to.
  15107. * @returns The engine the post process was enabled with.
  15108. */
  15109. getEngine(): Engine;
  15110. /**
  15111. * The effect that is created when initializing the post process.
  15112. * @returns The created effect corresponding the the postprocess.
  15113. */
  15114. getEffect(): Effect;
  15115. /**
  15116. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15117. * @param postProcess The post process to share the output with.
  15118. * @returns This post process.
  15119. */
  15120. shareOutputWith(postProcess: PostProcess): PostProcess;
  15121. /**
  15122. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15123. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15124. */
  15125. useOwnOutput(): void;
  15126. /**
  15127. * Updates the effect with the current post process compile time values and recompiles the shader.
  15128. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15129. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15130. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15131. * @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
  15132. * @param onCompiled Called when the shader has been compiled.
  15133. * @param onError Called if there is an error when compiling a shader.
  15134. */
  15135. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15136. /**
  15137. * The post process is reusable if it can be used multiple times within one frame.
  15138. * @returns If the post process is reusable
  15139. */
  15140. isReusable(): boolean;
  15141. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15142. markTextureDirty(): void;
  15143. /**
  15144. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15145. * 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.
  15146. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15147. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15148. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15149. * @returns The target texture that was bound to be written to.
  15150. */
  15151. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15152. /**
  15153. * If the post process is supported.
  15154. */
  15155. readonly isSupported: boolean;
  15156. /**
  15157. * The aspect ratio of the output texture.
  15158. */
  15159. readonly aspectRatio: number;
  15160. /**
  15161. * Get a value indicating if the post-process is ready to be used
  15162. * @returns true if the post-process is ready (shader is compiled)
  15163. */
  15164. isReady(): boolean;
  15165. /**
  15166. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15167. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15168. */
  15169. apply(): Nullable<Effect>;
  15170. private _disposeTextures;
  15171. /**
  15172. * Disposes the post process.
  15173. * @param camera The camera to dispose the post process on.
  15174. */
  15175. dispose(camera?: Camera): void;
  15176. }
  15177. }
  15178. declare module BABYLON {
  15179. /** @hidden */
  15180. export var kernelBlurVaryingDeclaration: {
  15181. name: string;
  15182. shader: string;
  15183. };
  15184. }
  15185. declare module BABYLON {
  15186. /** @hidden */
  15187. export var kernelBlurFragment: {
  15188. name: string;
  15189. shader: string;
  15190. };
  15191. }
  15192. declare module BABYLON {
  15193. /** @hidden */
  15194. export var kernelBlurFragment2: {
  15195. name: string;
  15196. shader: string;
  15197. };
  15198. }
  15199. declare module BABYLON {
  15200. /** @hidden */
  15201. export var kernelBlurPixelShader: {
  15202. name: string;
  15203. shader: string;
  15204. };
  15205. }
  15206. declare module BABYLON {
  15207. /** @hidden */
  15208. export var kernelBlurVertex: {
  15209. name: string;
  15210. shader: string;
  15211. };
  15212. }
  15213. declare module BABYLON {
  15214. /** @hidden */
  15215. export var kernelBlurVertexShader: {
  15216. name: string;
  15217. shader: string;
  15218. };
  15219. }
  15220. declare module BABYLON {
  15221. /**
  15222. * The Blur Post Process which blurs an image based on a kernel and direction.
  15223. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15224. */
  15225. export class BlurPostProcess extends PostProcess {
  15226. /** The direction in which to blur the image. */
  15227. direction: Vector2;
  15228. private blockCompilation;
  15229. protected _kernel: number;
  15230. protected _idealKernel: number;
  15231. protected _packedFloat: boolean;
  15232. private _staticDefines;
  15233. /**
  15234. * Sets the length in pixels of the blur sample region
  15235. */
  15236. /**
  15237. * Gets the length in pixels of the blur sample region
  15238. */
  15239. kernel: number;
  15240. /**
  15241. * Sets wether or not the blur needs to unpack/repack floats
  15242. */
  15243. /**
  15244. * Gets wether or not the blur is unpacking/repacking floats
  15245. */
  15246. packedFloat: boolean;
  15247. /**
  15248. * Creates a new instance BlurPostProcess
  15249. * @param name The name of the effect.
  15250. * @param direction The direction in which to blur the image.
  15251. * @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.
  15252. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15253. * @param camera The camera to apply the render pass to.
  15254. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15255. * @param engine The engine which the post process will be applied. (default: current engine)
  15256. * @param reusable If the post process can be reused on the same frame. (default: false)
  15257. * @param textureType Type of textures used when performing the post process. (default: 0)
  15258. * @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)
  15259. */
  15260. constructor(name: string,
  15261. /** The direction in which to blur the image. */
  15262. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15263. /**
  15264. * Updates the effect with the current post process compile time values and recompiles the shader.
  15265. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15266. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15267. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15268. * @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
  15269. * @param onCompiled Called when the shader has been compiled.
  15270. * @param onError Called if there is an error when compiling a shader.
  15271. */
  15272. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15273. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15274. /**
  15275. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15276. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15277. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15278. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15279. * The gaps between physical kernels are compensated for in the weighting of the samples
  15280. * @param idealKernel Ideal blur kernel.
  15281. * @return Nearest best kernel.
  15282. */
  15283. protected _nearestBestKernel(idealKernel: number): number;
  15284. /**
  15285. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15286. * @param x The point on the Gaussian distribution to sample.
  15287. * @return the value of the Gaussian function at x.
  15288. */
  15289. protected _gaussianWeight(x: number): number;
  15290. /**
  15291. * Generates a string that can be used as a floating point number in GLSL.
  15292. * @param x Value to print.
  15293. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15294. * @return GLSL float string.
  15295. */
  15296. protected _glslFloat(x: number, decimalFigures?: number): string;
  15297. }
  15298. }
  15299. declare module BABYLON {
  15300. /**
  15301. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15302. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15303. * You can then easily use it as a reflectionTexture on a flat surface.
  15304. * In case the surface is not a plane, please consider relying on reflection probes.
  15305. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15306. */
  15307. export class MirrorTexture extends RenderTargetTexture {
  15308. private scene;
  15309. /**
  15310. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15311. * 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.
  15312. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15313. */
  15314. mirrorPlane: Plane;
  15315. /**
  15316. * Define the blur ratio used to blur the reflection if needed.
  15317. */
  15318. blurRatio: number;
  15319. /**
  15320. * Define the adaptive blur kernel used to blur the reflection if needed.
  15321. * This will autocompute the closest best match for the `blurKernel`
  15322. */
  15323. adaptiveBlurKernel: number;
  15324. /**
  15325. * Define the blur kernel used to blur the reflection if needed.
  15326. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15327. */
  15328. blurKernel: number;
  15329. /**
  15330. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15331. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15332. */
  15333. blurKernelX: number;
  15334. /**
  15335. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15336. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15337. */
  15338. blurKernelY: number;
  15339. private _autoComputeBlurKernel;
  15340. protected _onRatioRescale(): void;
  15341. private _updateGammaSpace;
  15342. private _imageProcessingConfigChangeObserver;
  15343. private _transformMatrix;
  15344. private _mirrorMatrix;
  15345. private _savedViewMatrix;
  15346. private _blurX;
  15347. private _blurY;
  15348. private _adaptiveBlurKernel;
  15349. private _blurKernelX;
  15350. private _blurKernelY;
  15351. private _blurRatio;
  15352. /**
  15353. * Instantiates a Mirror Texture.
  15354. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15355. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15356. * You can then easily use it as a reflectionTexture on a flat surface.
  15357. * In case the surface is not a plane, please consider relying on reflection probes.
  15358. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15359. * @param name
  15360. * @param size
  15361. * @param scene
  15362. * @param generateMipMaps
  15363. * @param type
  15364. * @param samplingMode
  15365. * @param generateDepthBuffer
  15366. */
  15367. constructor(name: string, size: number | {
  15368. width: number;
  15369. height: number;
  15370. } | {
  15371. ratio: number;
  15372. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15373. private _preparePostProcesses;
  15374. /**
  15375. * Clone the mirror texture.
  15376. * @returns the cloned texture
  15377. */
  15378. clone(): MirrorTexture;
  15379. /**
  15380. * Serialize the texture to a JSON representation you could use in Parse later on
  15381. * @returns the serialized JSON representation
  15382. */
  15383. serialize(): any;
  15384. /**
  15385. * Dispose the texture and release its associated resources.
  15386. */
  15387. dispose(): void;
  15388. }
  15389. }
  15390. declare module BABYLON {
  15391. /**
  15392. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15393. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15394. */
  15395. export class Texture extends BaseTexture {
  15396. /**
  15397. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15398. */
  15399. static SerializeBuffers: boolean;
  15400. /** @hidden */
  15401. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15402. /** @hidden */
  15403. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15404. /** @hidden */
  15405. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15406. /** nearest is mag = nearest and min = nearest and mip = linear */
  15407. static readonly NEAREST_SAMPLINGMODE: number;
  15408. /** nearest is mag = nearest and min = nearest and mip = linear */
  15409. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15410. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15411. static readonly BILINEAR_SAMPLINGMODE: number;
  15412. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15413. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15414. /** Trilinear is mag = linear and min = linear and mip = linear */
  15415. static readonly TRILINEAR_SAMPLINGMODE: number;
  15416. /** Trilinear is mag = linear and min = linear and mip = linear */
  15417. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15418. /** mag = nearest and min = nearest and mip = nearest */
  15419. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15420. /** mag = nearest and min = linear and mip = nearest */
  15421. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15422. /** mag = nearest and min = linear and mip = linear */
  15423. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15424. /** mag = nearest and min = linear and mip = none */
  15425. static readonly NEAREST_LINEAR: number;
  15426. /** mag = nearest and min = nearest and mip = none */
  15427. static readonly NEAREST_NEAREST: number;
  15428. /** mag = linear and min = nearest and mip = nearest */
  15429. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15430. /** mag = linear and min = nearest and mip = linear */
  15431. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15432. /** mag = linear and min = linear and mip = none */
  15433. static readonly LINEAR_LINEAR: number;
  15434. /** mag = linear and min = nearest and mip = none */
  15435. static readonly LINEAR_NEAREST: number;
  15436. /** Explicit coordinates mode */
  15437. static readonly EXPLICIT_MODE: number;
  15438. /** Spherical coordinates mode */
  15439. static readonly SPHERICAL_MODE: number;
  15440. /** Planar coordinates mode */
  15441. static readonly PLANAR_MODE: number;
  15442. /** Cubic coordinates mode */
  15443. static readonly CUBIC_MODE: number;
  15444. /** Projection coordinates mode */
  15445. static readonly PROJECTION_MODE: number;
  15446. /** Inverse Cubic coordinates mode */
  15447. static readonly SKYBOX_MODE: number;
  15448. /** Inverse Cubic coordinates mode */
  15449. static readonly INVCUBIC_MODE: number;
  15450. /** Equirectangular coordinates mode */
  15451. static readonly EQUIRECTANGULAR_MODE: number;
  15452. /** Equirectangular Fixed coordinates mode */
  15453. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15454. /** Equirectangular Fixed Mirrored coordinates mode */
  15455. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15456. /** Texture is not repeating outside of 0..1 UVs */
  15457. static readonly CLAMP_ADDRESSMODE: number;
  15458. /** Texture is repeating outside of 0..1 UVs */
  15459. static readonly WRAP_ADDRESSMODE: number;
  15460. /** Texture is repeating and mirrored */
  15461. static readonly MIRROR_ADDRESSMODE: number;
  15462. /**
  15463. * 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
  15464. */
  15465. static UseSerializedUrlIfAny: boolean;
  15466. /**
  15467. * Define the url of the texture.
  15468. */
  15469. url: Nullable<string>;
  15470. /**
  15471. * Define an offset on the texture to offset the u coordinates of the UVs
  15472. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15473. */
  15474. uOffset: number;
  15475. /**
  15476. * Define an offset on the texture to offset the v coordinates of the UVs
  15477. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15478. */
  15479. vOffset: number;
  15480. /**
  15481. * Define an offset on the texture to scale the u coordinates of the UVs
  15482. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15483. */
  15484. uScale: number;
  15485. /**
  15486. * Define an offset on the texture to scale the v coordinates of the UVs
  15487. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15488. */
  15489. vScale: number;
  15490. /**
  15491. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15492. * @see http://doc.babylonjs.com/how_to/more_materials
  15493. */
  15494. uAng: number;
  15495. /**
  15496. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15497. * @see http://doc.babylonjs.com/how_to/more_materials
  15498. */
  15499. vAng: number;
  15500. /**
  15501. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15502. * @see http://doc.babylonjs.com/how_to/more_materials
  15503. */
  15504. wAng: number;
  15505. /**
  15506. * Defines the center of rotation (U)
  15507. */
  15508. uRotationCenter: number;
  15509. /**
  15510. * Defines the center of rotation (V)
  15511. */
  15512. vRotationCenter: number;
  15513. /**
  15514. * Defines the center of rotation (W)
  15515. */
  15516. wRotationCenter: number;
  15517. /**
  15518. * Are mip maps generated for this texture or not.
  15519. */
  15520. readonly noMipmap: boolean;
  15521. /**
  15522. * List of inspectable custom properties (used by the Inspector)
  15523. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15524. */
  15525. inspectableCustomProperties: Nullable<IInspectable[]>;
  15526. private _noMipmap;
  15527. /** @hidden */
  15528. _invertY: boolean;
  15529. private _rowGenerationMatrix;
  15530. private _cachedTextureMatrix;
  15531. private _projectionModeMatrix;
  15532. private _t0;
  15533. private _t1;
  15534. private _t2;
  15535. private _cachedUOffset;
  15536. private _cachedVOffset;
  15537. private _cachedUScale;
  15538. private _cachedVScale;
  15539. private _cachedUAng;
  15540. private _cachedVAng;
  15541. private _cachedWAng;
  15542. private _cachedProjectionMatrixId;
  15543. private _cachedCoordinatesMode;
  15544. /** @hidden */
  15545. protected _initialSamplingMode: number;
  15546. /** @hidden */
  15547. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15548. private _deleteBuffer;
  15549. protected _format: Nullable<number>;
  15550. private _delayedOnLoad;
  15551. private _delayedOnError;
  15552. /**
  15553. * Observable triggered once the texture has been loaded.
  15554. */
  15555. onLoadObservable: Observable<Texture>;
  15556. protected _isBlocking: boolean;
  15557. /**
  15558. * Is the texture preventing material to render while loading.
  15559. * If false, a default texture will be used instead of the loading one during the preparation step.
  15560. */
  15561. isBlocking: boolean;
  15562. /**
  15563. * Get the current sampling mode associated with the texture.
  15564. */
  15565. readonly samplingMode: number;
  15566. /**
  15567. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15568. */
  15569. readonly invertY: boolean;
  15570. /**
  15571. * Instantiates a new texture.
  15572. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15573. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15574. * @param url define the url of the picture to load as a texture
  15575. * @param scene define the scene or engine the texture will belong to
  15576. * @param noMipmap define if the texture will require mip maps or not
  15577. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15578. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15579. * @param onLoad define a callback triggered when the texture has been loaded
  15580. * @param onError define a callback triggered when an error occurred during the loading session
  15581. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15582. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15583. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15584. */
  15585. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15586. /**
  15587. * Update the url (and optional buffer) of this texture if url was null during construction.
  15588. * @param url the url of the texture
  15589. * @param buffer the buffer of the texture (defaults to null)
  15590. * @param onLoad callback called when the texture is loaded (defaults to null)
  15591. */
  15592. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15593. /**
  15594. * Finish the loading sequence of a texture flagged as delayed load.
  15595. * @hidden
  15596. */
  15597. delayLoad(): void;
  15598. private _prepareRowForTextureGeneration;
  15599. /**
  15600. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15601. * @returns the transform matrix of the texture.
  15602. */
  15603. getTextureMatrix(): Matrix;
  15604. /**
  15605. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15606. * @returns The reflection texture transform
  15607. */
  15608. getReflectionTextureMatrix(): Matrix;
  15609. /**
  15610. * Clones the texture.
  15611. * @returns the cloned texture
  15612. */
  15613. clone(): Texture;
  15614. /**
  15615. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15616. * @returns The JSON representation of the texture
  15617. */
  15618. serialize(): any;
  15619. /**
  15620. * Get the current class name of the texture useful for serialization or dynamic coding.
  15621. * @returns "Texture"
  15622. */
  15623. getClassName(): string;
  15624. /**
  15625. * Dispose the texture and release its associated resources.
  15626. */
  15627. dispose(): void;
  15628. /**
  15629. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15630. * @param parsedTexture Define the JSON representation of the texture
  15631. * @param scene Define the scene the parsed texture should be instantiated in
  15632. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15633. * @returns The parsed texture if successful
  15634. */
  15635. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15636. /**
  15637. * Creates a texture from its base 64 representation.
  15638. * @param data Define the base64 payload without the data: prefix
  15639. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15640. * @param scene Define the scene the texture should belong to
  15641. * @param noMipmap Forces the texture to not create mip map information if true
  15642. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15643. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15644. * @param onLoad define a callback triggered when the texture has been loaded
  15645. * @param onError define a callback triggered when an error occurred during the loading session
  15646. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15647. * @returns the created texture
  15648. */
  15649. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15650. /**
  15651. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15652. * @param data Define the base64 payload without the data: prefix
  15653. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15654. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15655. * @param scene Define the scene the texture should belong to
  15656. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15657. * @param noMipmap Forces the texture to not create mip map information if true
  15658. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15659. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15660. * @param onLoad define a callback triggered when the texture has been loaded
  15661. * @param onError define a callback triggered when an error occurred during the loading session
  15662. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15663. * @returns the created texture
  15664. */
  15665. 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;
  15666. }
  15667. }
  15668. declare module BABYLON {
  15669. /**
  15670. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15671. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15672. */
  15673. export class PostProcessManager {
  15674. private _scene;
  15675. private _indexBuffer;
  15676. private _vertexBuffers;
  15677. /**
  15678. * Creates a new instance PostProcess
  15679. * @param scene The scene that the post process is associated with.
  15680. */
  15681. constructor(scene: Scene);
  15682. private _prepareBuffers;
  15683. private _buildIndexBuffer;
  15684. /**
  15685. * Rebuilds the vertex buffers of the manager.
  15686. * @hidden
  15687. */
  15688. _rebuild(): void;
  15689. /**
  15690. * Prepares a frame to be run through a post process.
  15691. * @param sourceTexture The input texture to the post procesess. (default: null)
  15692. * @param postProcesses An array of post processes to be run. (default: null)
  15693. * @returns True if the post processes were able to be run.
  15694. * @hidden
  15695. */
  15696. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15697. /**
  15698. * Manually render a set of post processes to a texture.
  15699. * @param postProcesses An array of post processes to be run.
  15700. * @param targetTexture The target texture to render to.
  15701. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15702. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15703. * @param lodLevel defines which lod of the texture to render to
  15704. */
  15705. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15706. /**
  15707. * Finalize the result of the output of the postprocesses.
  15708. * @param doNotPresent If true the result will not be displayed to the screen.
  15709. * @param targetTexture The target texture to render to.
  15710. * @param faceIndex The index of the face to bind the target texture to.
  15711. * @param postProcesses The array of post processes to render.
  15712. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15713. * @hidden
  15714. */
  15715. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15716. /**
  15717. * Disposes of the post process manager.
  15718. */
  15719. dispose(): void;
  15720. }
  15721. }
  15722. declare module BABYLON {
  15723. /** Interface used by value gradients (color, factor, ...) */
  15724. export interface IValueGradient {
  15725. /**
  15726. * Gets or sets the gradient value (between 0 and 1)
  15727. */
  15728. gradient: number;
  15729. }
  15730. /** Class used to store color4 gradient */
  15731. export class ColorGradient implements IValueGradient {
  15732. /**
  15733. * Gets or sets the gradient value (between 0 and 1)
  15734. */
  15735. gradient: number;
  15736. /**
  15737. * Gets or sets first associated color
  15738. */
  15739. color1: Color4;
  15740. /**
  15741. * Gets or sets second associated color
  15742. */
  15743. color2?: Color4;
  15744. /**
  15745. * Will get a color picked randomly between color1 and color2.
  15746. * If color2 is undefined then color1 will be used
  15747. * @param result defines the target Color4 to store the result in
  15748. */
  15749. getColorToRef(result: Color4): void;
  15750. }
  15751. /** Class used to store color 3 gradient */
  15752. export class Color3Gradient implements IValueGradient {
  15753. /**
  15754. * Gets or sets the gradient value (between 0 and 1)
  15755. */
  15756. gradient: number;
  15757. /**
  15758. * Gets or sets the associated color
  15759. */
  15760. color: Color3;
  15761. }
  15762. /** Class used to store factor gradient */
  15763. export class FactorGradient implements IValueGradient {
  15764. /**
  15765. * Gets or sets the gradient value (between 0 and 1)
  15766. */
  15767. gradient: number;
  15768. /**
  15769. * Gets or sets first associated factor
  15770. */
  15771. factor1: number;
  15772. /**
  15773. * Gets or sets second associated factor
  15774. */
  15775. factor2?: number;
  15776. /**
  15777. * Will get a number picked randomly between factor1 and factor2.
  15778. * If factor2 is undefined then factor1 will be used
  15779. * @returns the picked number
  15780. */
  15781. getFactor(): number;
  15782. }
  15783. /**
  15784. * Helper used to simplify some generic gradient tasks
  15785. */
  15786. export class GradientHelper {
  15787. /**
  15788. * Gets the current gradient from an array of IValueGradient
  15789. * @param ratio defines the current ratio to get
  15790. * @param gradients defines the array of IValueGradient
  15791. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15792. */
  15793. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15794. }
  15795. }
  15796. declare module BABYLON {
  15797. /**
  15798. * A class extending Texture allowing drawing on a texture
  15799. * @see http://doc.babylonjs.com/how_to/dynamictexture
  15800. */
  15801. export class DynamicTexture extends Texture {
  15802. private _generateMipMaps;
  15803. private _canvas;
  15804. private _context;
  15805. private _engine;
  15806. /**
  15807. * Creates a DynamicTexture
  15808. * @param name defines the name of the texture
  15809. * @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
  15810. * @param scene defines the scene where you want the texture
  15811. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  15812. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  15813. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  15814. */
  15815. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  15816. /**
  15817. * Get the current class name of the texture useful for serialization or dynamic coding.
  15818. * @returns "DynamicTexture"
  15819. */
  15820. getClassName(): string;
  15821. /**
  15822. * Gets the current state of canRescale
  15823. */
  15824. readonly canRescale: boolean;
  15825. private _recreate;
  15826. /**
  15827. * Scales the texture
  15828. * @param ratio the scale factor to apply to both width and height
  15829. */
  15830. scale(ratio: number): void;
  15831. /**
  15832. * Resizes the texture
  15833. * @param width the new width
  15834. * @param height the new height
  15835. */
  15836. scaleTo(width: number, height: number): void;
  15837. /**
  15838. * Gets the context of the canvas used by the texture
  15839. * @returns the canvas context of the dynamic texture
  15840. */
  15841. getContext(): CanvasRenderingContext2D;
  15842. /**
  15843. * Clears the texture
  15844. */
  15845. clear(): void;
  15846. /**
  15847. * Updates the texture
  15848. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  15849. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  15850. */
  15851. update(invertY?: boolean, premulAlpha?: boolean): void;
  15852. /**
  15853. * Draws text onto the texture
  15854. * @param text defines the text to be drawn
  15855. * @param x defines the placement of the text from the left
  15856. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  15857. * @param font defines the font to be used with font-style, font-size, font-name
  15858. * @param color defines the color used for the text
  15859. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  15860. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  15861. * @param update defines whether texture is immediately update (default is true)
  15862. */
  15863. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  15864. /**
  15865. * Clones the texture
  15866. * @returns the clone of the texture.
  15867. */
  15868. clone(): DynamicTexture;
  15869. /**
  15870. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  15871. * @returns a serialized dynamic texture object
  15872. */
  15873. serialize(): any;
  15874. /** @hidden */
  15875. _rebuild(): void;
  15876. }
  15877. }
  15878. declare module BABYLON {
  15879. interface AbstractScene {
  15880. /**
  15881. * The list of procedural textures added to the scene
  15882. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15883. */
  15884. proceduralTextures: Array<ProceduralTexture>;
  15885. }
  15886. /**
  15887. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15888. * in a given scene.
  15889. */
  15890. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15891. /**
  15892. * The component name helpfull to identify the component in the list of scene components.
  15893. */
  15894. readonly name: string;
  15895. /**
  15896. * The scene the component belongs to.
  15897. */
  15898. scene: Scene;
  15899. /**
  15900. * Creates a new instance of the component for the given scene
  15901. * @param scene Defines the scene to register the component in
  15902. */
  15903. constructor(scene: Scene);
  15904. /**
  15905. * Registers the component in a given scene
  15906. */
  15907. register(): void;
  15908. /**
  15909. * Rebuilds the elements related to this component in case of
  15910. * context lost for instance.
  15911. */
  15912. rebuild(): void;
  15913. /**
  15914. * Disposes the component and the associated ressources.
  15915. */
  15916. dispose(): void;
  15917. private _beforeClear;
  15918. }
  15919. }
  15920. declare module BABYLON {
  15921. interface Engine {
  15922. /**
  15923. * Creates a new render target cube texture
  15924. * @param size defines the size of the texture
  15925. * @param options defines the options used to create the texture
  15926. * @returns a new render target cube texture stored in an InternalTexture
  15927. */
  15928. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15929. }
  15930. }
  15931. declare module BABYLON {
  15932. /** @hidden */
  15933. export var proceduralVertexShader: {
  15934. name: string;
  15935. shader: string;
  15936. };
  15937. }
  15938. declare module BABYLON {
  15939. /**
  15940. * 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.
  15941. * This is the base class of any Procedural texture and contains most of the shareable code.
  15942. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15943. */
  15944. export class ProceduralTexture extends Texture {
  15945. isCube: boolean;
  15946. /**
  15947. * Define if the texture is enabled or not (disabled texture will not render)
  15948. */
  15949. isEnabled: boolean;
  15950. /**
  15951. * Define if the texture must be cleared before rendering (default is true)
  15952. */
  15953. autoClear: boolean;
  15954. /**
  15955. * Callback called when the texture is generated
  15956. */
  15957. onGenerated: () => void;
  15958. /**
  15959. * Event raised when the texture is generated
  15960. */
  15961. onGeneratedObservable: Observable<ProceduralTexture>;
  15962. /** @hidden */
  15963. _generateMipMaps: boolean;
  15964. /** @hidden **/
  15965. _effect: Effect;
  15966. /** @hidden */
  15967. _textures: {
  15968. [key: string]: Texture;
  15969. };
  15970. private _size;
  15971. private _currentRefreshId;
  15972. private _refreshRate;
  15973. private _vertexBuffers;
  15974. private _indexBuffer;
  15975. private _uniforms;
  15976. private _samplers;
  15977. private _fragment;
  15978. private _floats;
  15979. private _ints;
  15980. private _floatsArrays;
  15981. private _colors3;
  15982. private _colors4;
  15983. private _vectors2;
  15984. private _vectors3;
  15985. private _matrices;
  15986. private _fallbackTexture;
  15987. private _fallbackTextureUsed;
  15988. private _engine;
  15989. private _cachedDefines;
  15990. private _contentUpdateId;
  15991. private _contentData;
  15992. /**
  15993. * Instantiates a new procedural texture.
  15994. * 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.
  15995. * This is the base class of any Procedural texture and contains most of the shareable code.
  15996. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15997. * @param name Define the name of the texture
  15998. * @param size Define the size of the texture to create
  15999. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16000. * @param scene Define the scene the texture belongs to
  16001. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16002. * @param generateMipMaps Define if the texture should creates mip maps or not
  16003. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16004. */
  16005. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16006. /**
  16007. * The effect that is created when initializing the post process.
  16008. * @returns The created effect corresponding the the postprocess.
  16009. */
  16010. getEffect(): Effect;
  16011. /**
  16012. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16013. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16014. */
  16015. getContent(): Nullable<ArrayBufferView>;
  16016. private _createIndexBuffer;
  16017. /** @hidden */
  16018. _rebuild(): void;
  16019. /**
  16020. * Resets the texture in order to recreate its associated resources.
  16021. * This can be called in case of context loss
  16022. */
  16023. reset(): void;
  16024. protected _getDefines(): string;
  16025. /**
  16026. * Is the texture ready to be used ? (rendered at least once)
  16027. * @returns true if ready, otherwise, false.
  16028. */
  16029. isReady(): boolean;
  16030. /**
  16031. * Resets the refresh counter of the texture and start bak from scratch.
  16032. * Could be useful to regenerate the texture if it is setup to render only once.
  16033. */
  16034. resetRefreshCounter(): void;
  16035. /**
  16036. * Set the fragment shader to use in order to render the texture.
  16037. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16038. */
  16039. setFragment(fragment: any): void;
  16040. /**
  16041. * Define the refresh rate of the texture or the rendering frequency.
  16042. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16043. */
  16044. refreshRate: number;
  16045. /** @hidden */
  16046. _shouldRender(): boolean;
  16047. /**
  16048. * Get the size the texture is rendering at.
  16049. * @returns the size (texture is always squared)
  16050. */
  16051. getRenderSize(): number;
  16052. /**
  16053. * Resize the texture to new value.
  16054. * @param size Define the new size the texture should have
  16055. * @param generateMipMaps Define whether the new texture should create mip maps
  16056. */
  16057. resize(size: number, generateMipMaps: boolean): void;
  16058. private _checkUniform;
  16059. /**
  16060. * Set a texture in the shader program used to render.
  16061. * @param name Define the name of the uniform samplers as defined in the shader
  16062. * @param texture Define the texture to bind to this sampler
  16063. * @return the texture itself allowing "fluent" like uniform updates
  16064. */
  16065. setTexture(name: string, texture: Texture): ProceduralTexture;
  16066. /**
  16067. * Set a float in the shader.
  16068. * @param name Define the name of the uniform as defined in the shader
  16069. * @param value Define the value to give to the uniform
  16070. * @return the texture itself allowing "fluent" like uniform updates
  16071. */
  16072. setFloat(name: string, value: number): ProceduralTexture;
  16073. /**
  16074. * Set a int in the shader.
  16075. * @param name Define the name of the uniform as defined in the shader
  16076. * @param value Define the value to give to the uniform
  16077. * @return the texture itself allowing "fluent" like uniform updates
  16078. */
  16079. setInt(name: string, value: number): ProceduralTexture;
  16080. /**
  16081. * Set an array of floats in the shader.
  16082. * @param name Define the name of the uniform as defined in the shader
  16083. * @param value Define the value to give to the uniform
  16084. * @return the texture itself allowing "fluent" like uniform updates
  16085. */
  16086. setFloats(name: string, value: number[]): ProceduralTexture;
  16087. /**
  16088. * Set a vec3 in the shader from a Color3.
  16089. * @param name Define the name of the uniform as defined in the shader
  16090. * @param value Define the value to give to the uniform
  16091. * @return the texture itself allowing "fluent" like uniform updates
  16092. */
  16093. setColor3(name: string, value: Color3): ProceduralTexture;
  16094. /**
  16095. * Set a vec4 in the shader from a Color4.
  16096. * @param name Define the name of the uniform as defined in the shader
  16097. * @param value Define the value to give to the uniform
  16098. * @return the texture itself allowing "fluent" like uniform updates
  16099. */
  16100. setColor4(name: string, value: Color4): ProceduralTexture;
  16101. /**
  16102. * Set a vec2 in the shader from a Vector2.
  16103. * @param name Define the name of the uniform as defined in the shader
  16104. * @param value Define the value to give to the uniform
  16105. * @return the texture itself allowing "fluent" like uniform updates
  16106. */
  16107. setVector2(name: string, value: Vector2): ProceduralTexture;
  16108. /**
  16109. * Set a vec3 in the shader from a Vector3.
  16110. * @param name Define the name of the uniform as defined in the shader
  16111. * @param value Define the value to give to the uniform
  16112. * @return the texture itself allowing "fluent" like uniform updates
  16113. */
  16114. setVector3(name: string, value: Vector3): ProceduralTexture;
  16115. /**
  16116. * Set a mat4 in the shader from a MAtrix.
  16117. * @param name Define the name of the uniform as defined in the shader
  16118. * @param value Define the value to give to the uniform
  16119. * @return the texture itself allowing "fluent" like uniform updates
  16120. */
  16121. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16122. /**
  16123. * Render the texture to its associated render target.
  16124. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16125. */
  16126. render(useCameraPostProcess?: boolean): void;
  16127. /**
  16128. * Clone the texture.
  16129. * @returns the cloned texture
  16130. */
  16131. clone(): ProceduralTexture;
  16132. /**
  16133. * Dispose the texture and release its asoociated resources.
  16134. */
  16135. dispose(): void;
  16136. }
  16137. }
  16138. declare module BABYLON {
  16139. /**
  16140. * This represents the base class for particle system in Babylon.
  16141. * 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.
  16142. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16143. * @example https://doc.babylonjs.com/babylon101/particles
  16144. */
  16145. export class BaseParticleSystem {
  16146. /**
  16147. * Source color is added to the destination color without alpha affecting the result
  16148. */
  16149. static BLENDMODE_ONEONE: number;
  16150. /**
  16151. * Blend current color and particle color using particle’s alpha
  16152. */
  16153. static BLENDMODE_STANDARD: number;
  16154. /**
  16155. * Add current color and particle color multiplied by particle’s alpha
  16156. */
  16157. static BLENDMODE_ADD: number;
  16158. /**
  16159. * Multiply current color with particle color
  16160. */
  16161. static BLENDMODE_MULTIPLY: number;
  16162. /**
  16163. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16164. */
  16165. static BLENDMODE_MULTIPLYADD: number;
  16166. /**
  16167. * List of animations used by the particle system.
  16168. */
  16169. animations: Animation[];
  16170. /**
  16171. * The id of the Particle system.
  16172. */
  16173. id: string;
  16174. /**
  16175. * The friendly name of the Particle system.
  16176. */
  16177. name: string;
  16178. /**
  16179. * The rendering group used by the Particle system to chose when to render.
  16180. */
  16181. renderingGroupId: number;
  16182. /**
  16183. * The emitter represents the Mesh or position we are attaching the particle system to.
  16184. */
  16185. emitter: Nullable<AbstractMesh | Vector3>;
  16186. /**
  16187. * The maximum number of particles to emit per frame
  16188. */
  16189. emitRate: number;
  16190. /**
  16191. * If you want to launch only a few particles at once, that can be done, as well.
  16192. */
  16193. manualEmitCount: number;
  16194. /**
  16195. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16196. */
  16197. updateSpeed: number;
  16198. /**
  16199. * The amount of time the particle system is running (depends of the overall update speed).
  16200. */
  16201. targetStopDuration: number;
  16202. /**
  16203. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16204. */
  16205. disposeOnStop: boolean;
  16206. /**
  16207. * Minimum power of emitting particles.
  16208. */
  16209. minEmitPower: number;
  16210. /**
  16211. * Maximum power of emitting particles.
  16212. */
  16213. maxEmitPower: number;
  16214. /**
  16215. * Minimum life time of emitting particles.
  16216. */
  16217. minLifeTime: number;
  16218. /**
  16219. * Maximum life time of emitting particles.
  16220. */
  16221. maxLifeTime: number;
  16222. /**
  16223. * Minimum Size of emitting particles.
  16224. */
  16225. minSize: number;
  16226. /**
  16227. * Maximum Size of emitting particles.
  16228. */
  16229. maxSize: number;
  16230. /**
  16231. * Minimum scale of emitting particles on X axis.
  16232. */
  16233. minScaleX: number;
  16234. /**
  16235. * Maximum scale of emitting particles on X axis.
  16236. */
  16237. maxScaleX: number;
  16238. /**
  16239. * Minimum scale of emitting particles on Y axis.
  16240. */
  16241. minScaleY: number;
  16242. /**
  16243. * Maximum scale of emitting particles on Y axis.
  16244. */
  16245. maxScaleY: number;
  16246. /**
  16247. * Gets or sets the minimal initial rotation in radians.
  16248. */
  16249. minInitialRotation: number;
  16250. /**
  16251. * Gets or sets the maximal initial rotation in radians.
  16252. */
  16253. maxInitialRotation: number;
  16254. /**
  16255. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16256. */
  16257. minAngularSpeed: number;
  16258. /**
  16259. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16260. */
  16261. maxAngularSpeed: number;
  16262. /**
  16263. * The texture used to render each particle. (this can be a spritesheet)
  16264. */
  16265. particleTexture: Nullable<Texture>;
  16266. /**
  16267. * The layer mask we are rendering the particles through.
  16268. */
  16269. layerMask: number;
  16270. /**
  16271. * This can help using your own shader to render the particle system.
  16272. * The according effect will be created
  16273. */
  16274. customShader: any;
  16275. /**
  16276. * By default particle system starts as soon as they are created. This prevents the
  16277. * automatic start to happen and let you decide when to start emitting particles.
  16278. */
  16279. preventAutoStart: boolean;
  16280. private _noiseTexture;
  16281. /**
  16282. * Gets or sets a texture used to add random noise to particle positions
  16283. */
  16284. noiseTexture: Nullable<ProceduralTexture>;
  16285. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16286. noiseStrength: Vector3;
  16287. /**
  16288. * Callback triggered when the particle animation is ending.
  16289. */
  16290. onAnimationEnd: Nullable<() => void>;
  16291. /**
  16292. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16293. */
  16294. blendMode: number;
  16295. /**
  16296. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16297. * to override the particles.
  16298. */
  16299. forceDepthWrite: boolean;
  16300. /** 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 */
  16301. preWarmCycles: number;
  16302. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16303. preWarmStepOffset: number;
  16304. /**
  16305. * 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)
  16306. */
  16307. spriteCellChangeSpeed: number;
  16308. /**
  16309. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16310. */
  16311. startSpriteCellID: number;
  16312. /**
  16313. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16314. */
  16315. endSpriteCellID: number;
  16316. /**
  16317. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16318. */
  16319. spriteCellWidth: number;
  16320. /**
  16321. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16322. */
  16323. spriteCellHeight: number;
  16324. /**
  16325. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16326. */
  16327. spriteRandomStartCell: boolean;
  16328. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16329. translationPivot: Vector2;
  16330. /** @hidden */
  16331. protected _isAnimationSheetEnabled: boolean;
  16332. /**
  16333. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16334. */
  16335. beginAnimationOnStart: boolean;
  16336. /**
  16337. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16338. */
  16339. beginAnimationFrom: number;
  16340. /**
  16341. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16342. */
  16343. beginAnimationTo: number;
  16344. /**
  16345. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16346. */
  16347. beginAnimationLoop: boolean;
  16348. /**
  16349. * Gets or sets a world offset applied to all particles
  16350. */
  16351. worldOffset: Vector3;
  16352. /**
  16353. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16354. */
  16355. isAnimationSheetEnabled: boolean;
  16356. /**
  16357. * Get hosting scene
  16358. * @returns the scene
  16359. */
  16360. getScene(): Scene;
  16361. /**
  16362. * You can use gravity if you want to give an orientation to your particles.
  16363. */
  16364. gravity: Vector3;
  16365. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16366. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16367. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16368. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16369. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16370. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16371. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16372. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16373. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16374. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16375. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16376. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16377. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16378. /**
  16379. * Defines the delay in milliseconds before starting the system (0 by default)
  16380. */
  16381. startDelay: number;
  16382. /**
  16383. * Gets the current list of drag gradients.
  16384. * You must use addDragGradient and removeDragGradient to udpate this list
  16385. * @returns the list of drag gradients
  16386. */
  16387. getDragGradients(): Nullable<Array<FactorGradient>>;
  16388. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16389. limitVelocityDamping: number;
  16390. /**
  16391. * Gets the current list of limit velocity gradients.
  16392. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16393. * @returns the list of limit velocity gradients
  16394. */
  16395. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16396. /**
  16397. * Gets the current list of color gradients.
  16398. * You must use addColorGradient and removeColorGradient to udpate this list
  16399. * @returns the list of color gradients
  16400. */
  16401. getColorGradients(): Nullable<Array<ColorGradient>>;
  16402. /**
  16403. * Gets the current list of size gradients.
  16404. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16405. * @returns the list of size gradients
  16406. */
  16407. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16408. /**
  16409. * Gets the current list of color remap gradients.
  16410. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16411. * @returns the list of color remap gradients
  16412. */
  16413. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16414. /**
  16415. * Gets the current list of alpha remap gradients.
  16416. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16417. * @returns the list of alpha remap gradients
  16418. */
  16419. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16420. /**
  16421. * Gets the current list of life time gradients.
  16422. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16423. * @returns the list of life time gradients
  16424. */
  16425. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16426. /**
  16427. * Gets the current list of angular speed gradients.
  16428. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16429. * @returns the list of angular speed gradients
  16430. */
  16431. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16432. /**
  16433. * Gets the current list of velocity gradients.
  16434. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16435. * @returns the list of velocity gradients
  16436. */
  16437. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16438. /**
  16439. * Gets the current list of start size gradients.
  16440. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16441. * @returns the list of start size gradients
  16442. */
  16443. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16444. /**
  16445. * Gets the current list of emit rate gradients.
  16446. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16447. * @returns the list of emit rate gradients
  16448. */
  16449. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16450. /**
  16451. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16452. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16453. */
  16454. direction1: Vector3;
  16455. /**
  16456. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16457. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16458. */
  16459. direction2: Vector3;
  16460. /**
  16461. * 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.
  16462. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16463. */
  16464. minEmitBox: Vector3;
  16465. /**
  16466. * 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.
  16467. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16468. */
  16469. maxEmitBox: Vector3;
  16470. /**
  16471. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16472. */
  16473. color1: Color4;
  16474. /**
  16475. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16476. */
  16477. color2: Color4;
  16478. /**
  16479. * Color the particle will have at the end of its lifetime
  16480. */
  16481. colorDead: Color4;
  16482. /**
  16483. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16484. */
  16485. textureMask: Color4;
  16486. /**
  16487. * The particle emitter type defines the emitter used by the particle system.
  16488. * It can be for example box, sphere, or cone...
  16489. */
  16490. particleEmitterType: IParticleEmitterType;
  16491. /** @hidden */
  16492. _isSubEmitter: boolean;
  16493. /**
  16494. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16495. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16496. */
  16497. billboardMode: number;
  16498. protected _isBillboardBased: boolean;
  16499. /**
  16500. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16501. */
  16502. isBillboardBased: boolean;
  16503. /**
  16504. * The scene the particle system belongs to.
  16505. */
  16506. protected _scene: Scene;
  16507. /**
  16508. * Local cache of defines for image processing.
  16509. */
  16510. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16511. /**
  16512. * Default configuration related to image processing available in the standard Material.
  16513. */
  16514. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16515. /**
  16516. * Gets the image processing configuration used either in this material.
  16517. */
  16518. /**
  16519. * Sets the Default image processing configuration used either in the this material.
  16520. *
  16521. * If sets to null, the scene one is in use.
  16522. */
  16523. imageProcessingConfiguration: ImageProcessingConfiguration;
  16524. /**
  16525. * Attaches a new image processing configuration to the Standard Material.
  16526. * @param configuration
  16527. */
  16528. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16529. /** @hidden */
  16530. protected _reset(): void;
  16531. /** @hidden */
  16532. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16533. /**
  16534. * Instantiates a particle system.
  16535. * 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.
  16536. * @param name The name of the particle system
  16537. */
  16538. constructor(name: string);
  16539. /**
  16540. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16541. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16542. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16543. * @returns the emitter
  16544. */
  16545. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16546. /**
  16547. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16548. * @param radius The radius of the hemisphere to emit from
  16549. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16550. * @returns the emitter
  16551. */
  16552. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16553. /**
  16554. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16555. * @param radius The radius of the sphere to emit from
  16556. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16557. * @returns the emitter
  16558. */
  16559. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16560. /**
  16561. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16562. * @param radius The radius of the sphere to emit from
  16563. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16564. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16565. * @returns the emitter
  16566. */
  16567. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16568. /**
  16569. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16570. * @param radius The radius of the emission cylinder
  16571. * @param height The height of the emission cylinder
  16572. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16573. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16574. * @returns the emitter
  16575. */
  16576. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16577. /**
  16578. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16579. * @param radius The radius of the cylinder to emit from
  16580. * @param height The height of the emission cylinder
  16581. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16582. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16583. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16584. * @returns the emitter
  16585. */
  16586. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16587. /**
  16588. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16589. * @param radius The radius of the cone to emit from
  16590. * @param angle The base angle of the cone
  16591. * @returns the emitter
  16592. */
  16593. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16594. /**
  16595. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16596. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16597. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16598. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16599. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16600. * @returns the emitter
  16601. */
  16602. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16603. }
  16604. }
  16605. declare module BABYLON {
  16606. /**
  16607. * Type of sub emitter
  16608. */
  16609. export enum SubEmitterType {
  16610. /**
  16611. * Attached to the particle over it's lifetime
  16612. */
  16613. ATTACHED = 0,
  16614. /**
  16615. * Created when the particle dies
  16616. */
  16617. END = 1
  16618. }
  16619. /**
  16620. * Sub emitter class used to emit particles from an existing particle
  16621. */
  16622. export class SubEmitter {
  16623. /**
  16624. * the particle system to be used by the sub emitter
  16625. */
  16626. particleSystem: ParticleSystem;
  16627. /**
  16628. * Type of the submitter (Default: END)
  16629. */
  16630. type: SubEmitterType;
  16631. /**
  16632. * 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)
  16633. * Note: This only is supported when using an emitter of type Mesh
  16634. */
  16635. inheritDirection: boolean;
  16636. /**
  16637. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16638. */
  16639. inheritedVelocityAmount: number;
  16640. /**
  16641. * Creates a sub emitter
  16642. * @param particleSystem the particle system to be used by the sub emitter
  16643. */
  16644. constructor(
  16645. /**
  16646. * the particle system to be used by the sub emitter
  16647. */
  16648. particleSystem: ParticleSystem);
  16649. /**
  16650. * Clones the sub emitter
  16651. * @returns the cloned sub emitter
  16652. */
  16653. clone(): SubEmitter;
  16654. /**
  16655. * Serialize current object to a JSON object
  16656. * @returns the serialized object
  16657. */
  16658. serialize(): any;
  16659. /** @hidden */
  16660. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16661. /**
  16662. * Creates a new SubEmitter from a serialized JSON version
  16663. * @param serializationObject defines the JSON object to read from
  16664. * @param scene defines the hosting scene
  16665. * @param rootUrl defines the rootUrl for data loading
  16666. * @returns a new SubEmitter
  16667. */
  16668. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16669. /** Release associated resources */
  16670. dispose(): void;
  16671. }
  16672. }
  16673. declare module BABYLON {
  16674. /** @hidden */
  16675. export var clipPlaneFragmentDeclaration: {
  16676. name: string;
  16677. shader: string;
  16678. };
  16679. }
  16680. declare module BABYLON {
  16681. /** @hidden */
  16682. export var imageProcessingDeclaration: {
  16683. name: string;
  16684. shader: string;
  16685. };
  16686. }
  16687. declare module BABYLON {
  16688. /** @hidden */
  16689. export var imageProcessingFunctions: {
  16690. name: string;
  16691. shader: string;
  16692. };
  16693. }
  16694. declare module BABYLON {
  16695. /** @hidden */
  16696. export var clipPlaneFragment: {
  16697. name: string;
  16698. shader: string;
  16699. };
  16700. }
  16701. declare module BABYLON {
  16702. /** @hidden */
  16703. export var particlesPixelShader: {
  16704. name: string;
  16705. shader: string;
  16706. };
  16707. }
  16708. declare module BABYLON {
  16709. /** @hidden */
  16710. export var clipPlaneVertexDeclaration: {
  16711. name: string;
  16712. shader: string;
  16713. };
  16714. }
  16715. declare module BABYLON {
  16716. /** @hidden */
  16717. export var clipPlaneVertex: {
  16718. name: string;
  16719. shader: string;
  16720. };
  16721. }
  16722. declare module BABYLON {
  16723. /** @hidden */
  16724. export var particlesVertexShader: {
  16725. name: string;
  16726. shader: string;
  16727. };
  16728. }
  16729. declare module BABYLON {
  16730. /**
  16731. * This represents a particle system in Babylon.
  16732. * 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.
  16733. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16734. * @example https://doc.babylonjs.com/babylon101/particles
  16735. */
  16736. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16737. /**
  16738. * Billboard mode will only apply to Y axis
  16739. */
  16740. static readonly BILLBOARDMODE_Y: number;
  16741. /**
  16742. * Billboard mode will apply to all axes
  16743. */
  16744. static readonly BILLBOARDMODE_ALL: number;
  16745. /**
  16746. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16747. */
  16748. static readonly BILLBOARDMODE_STRETCHED: number;
  16749. /**
  16750. * This function can be defined to provide custom update for active particles.
  16751. * This function will be called instead of regular update (age, position, color, etc.).
  16752. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16753. */
  16754. updateFunction: (particles: Particle[]) => void;
  16755. private _emitterWorldMatrix;
  16756. /**
  16757. * This function can be defined to specify initial direction for every new particle.
  16758. * It by default use the emitterType defined function
  16759. */
  16760. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16761. /**
  16762. * This function can be defined to specify initial position for every new particle.
  16763. * It by default use the emitterType defined function
  16764. */
  16765. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16766. /**
  16767. * @hidden
  16768. */
  16769. _inheritedVelocityOffset: Vector3;
  16770. /**
  16771. * An event triggered when the system is disposed
  16772. */
  16773. onDisposeObservable: Observable<ParticleSystem>;
  16774. private _onDisposeObserver;
  16775. /**
  16776. * Sets a callback that will be triggered when the system is disposed
  16777. */
  16778. onDispose: () => void;
  16779. private _particles;
  16780. private _epsilon;
  16781. private _capacity;
  16782. private _stockParticles;
  16783. private _newPartsExcess;
  16784. private _vertexData;
  16785. private _vertexBuffer;
  16786. private _vertexBuffers;
  16787. private _spriteBuffer;
  16788. private _indexBuffer;
  16789. private _effect;
  16790. private _customEffect;
  16791. private _cachedDefines;
  16792. private _scaledColorStep;
  16793. private _colorDiff;
  16794. private _scaledDirection;
  16795. private _scaledGravity;
  16796. private _currentRenderId;
  16797. private _alive;
  16798. private _useInstancing;
  16799. private _started;
  16800. private _stopped;
  16801. private _actualFrame;
  16802. private _scaledUpdateSpeed;
  16803. private _vertexBufferSize;
  16804. /** @hidden */
  16805. _currentEmitRateGradient: Nullable<FactorGradient>;
  16806. /** @hidden */
  16807. _currentEmitRate1: number;
  16808. /** @hidden */
  16809. _currentEmitRate2: number;
  16810. /** @hidden */
  16811. _currentStartSizeGradient: Nullable<FactorGradient>;
  16812. /** @hidden */
  16813. _currentStartSize1: number;
  16814. /** @hidden */
  16815. _currentStartSize2: number;
  16816. private readonly _rawTextureWidth;
  16817. private _rampGradientsTexture;
  16818. private _useRampGradients;
  16819. /** Gets or sets a boolean indicating that ramp gradients must be used
  16820. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16821. */
  16822. useRampGradients: boolean;
  16823. /**
  16824. * 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.
  16825. * 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: [])
  16826. */
  16827. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16828. private _subEmitters;
  16829. /**
  16830. * @hidden
  16831. * If the particle systems emitter should be disposed when the particle system is disposed
  16832. */
  16833. _disposeEmitterOnDispose: boolean;
  16834. /**
  16835. * The current active Sub-systems, this property is used by the root particle system only.
  16836. */
  16837. activeSubSystems: Array<ParticleSystem>;
  16838. private _rootParticleSystem;
  16839. /**
  16840. * Gets the current list of active particles
  16841. */
  16842. readonly particles: Particle[];
  16843. /**
  16844. * Returns the string "ParticleSystem"
  16845. * @returns a string containing the class name
  16846. */
  16847. getClassName(): string;
  16848. /**
  16849. * Instantiates a particle system.
  16850. * 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.
  16851. * @param name The name of the particle system
  16852. * @param capacity The max number of particles alive at the same time
  16853. * @param scene The scene the particle system belongs to
  16854. * @param customEffect a custom effect used to change the way particles are rendered by default
  16855. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16856. * @param epsilon Offset used to render the particles
  16857. */
  16858. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16859. private _addFactorGradient;
  16860. private _removeFactorGradient;
  16861. /**
  16862. * Adds a new life time gradient
  16863. * @param gradient defines the gradient to use (between 0 and 1)
  16864. * @param factor defines the life time factor to affect to the specified gradient
  16865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16866. * @returns the current particle system
  16867. */
  16868. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16869. /**
  16870. * Remove a specific life time gradient
  16871. * @param gradient defines the gradient to remove
  16872. * @returns the current particle system
  16873. */
  16874. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16875. /**
  16876. * Adds a new size gradient
  16877. * @param gradient defines the gradient to use (between 0 and 1)
  16878. * @param factor defines the size factor to affect to the specified gradient
  16879. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16880. * @returns the current particle system
  16881. */
  16882. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16883. /**
  16884. * Remove a specific size gradient
  16885. * @param gradient defines the gradient to remove
  16886. * @returns the current particle system
  16887. */
  16888. removeSizeGradient(gradient: number): IParticleSystem;
  16889. /**
  16890. * Adds a new color remap gradient
  16891. * @param gradient defines the gradient to use (between 0 and 1)
  16892. * @param min defines the color remap minimal range
  16893. * @param max defines the color remap maximal range
  16894. * @returns the current particle system
  16895. */
  16896. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16897. /**
  16898. * Remove a specific color remap gradient
  16899. * @param gradient defines the gradient to remove
  16900. * @returns the current particle system
  16901. */
  16902. removeColorRemapGradient(gradient: number): IParticleSystem;
  16903. /**
  16904. * Adds a new alpha remap gradient
  16905. * @param gradient defines the gradient to use (between 0 and 1)
  16906. * @param min defines the alpha remap minimal range
  16907. * @param max defines the alpha remap maximal range
  16908. * @returns the current particle system
  16909. */
  16910. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16911. /**
  16912. * Remove a specific alpha remap gradient
  16913. * @param gradient defines the gradient to remove
  16914. * @returns the current particle system
  16915. */
  16916. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16917. /**
  16918. * Adds a new angular speed gradient
  16919. * @param gradient defines the gradient to use (between 0 and 1)
  16920. * @param factor defines the angular speed to affect to the specified gradient
  16921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16922. * @returns the current particle system
  16923. */
  16924. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16925. /**
  16926. * Remove a specific angular speed gradient
  16927. * @param gradient defines the gradient to remove
  16928. * @returns the current particle system
  16929. */
  16930. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16931. /**
  16932. * Adds a new velocity gradient
  16933. * @param gradient defines the gradient to use (between 0 and 1)
  16934. * @param factor defines the velocity to affect to the specified gradient
  16935. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16936. * @returns the current particle system
  16937. */
  16938. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16939. /**
  16940. * Remove a specific velocity gradient
  16941. * @param gradient defines the gradient to remove
  16942. * @returns the current particle system
  16943. */
  16944. removeVelocityGradient(gradient: number): IParticleSystem;
  16945. /**
  16946. * Adds a new limit velocity gradient
  16947. * @param gradient defines the gradient to use (between 0 and 1)
  16948. * @param factor defines the limit velocity value to affect to the specified gradient
  16949. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16950. * @returns the current particle system
  16951. */
  16952. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16953. /**
  16954. * Remove a specific limit velocity gradient
  16955. * @param gradient defines the gradient to remove
  16956. * @returns the current particle system
  16957. */
  16958. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16959. /**
  16960. * Adds a new drag gradient
  16961. * @param gradient defines the gradient to use (between 0 and 1)
  16962. * @param factor defines the drag value to affect to the specified gradient
  16963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16964. * @returns the current particle system
  16965. */
  16966. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16967. /**
  16968. * Remove a specific drag gradient
  16969. * @param gradient defines the gradient to remove
  16970. * @returns the current particle system
  16971. */
  16972. removeDragGradient(gradient: number): IParticleSystem;
  16973. /**
  16974. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16975. * @param gradient defines the gradient to use (between 0 and 1)
  16976. * @param factor defines the emit rate value to affect to the specified gradient
  16977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16978. * @returns the current particle system
  16979. */
  16980. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16981. /**
  16982. * Remove a specific emit rate gradient
  16983. * @param gradient defines the gradient to remove
  16984. * @returns the current particle system
  16985. */
  16986. removeEmitRateGradient(gradient: number): IParticleSystem;
  16987. /**
  16988. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16989. * @param gradient defines the gradient to use (between 0 and 1)
  16990. * @param factor defines the start size value to affect to the specified gradient
  16991. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16992. * @returns the current particle system
  16993. */
  16994. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16995. /**
  16996. * Remove a specific start size gradient
  16997. * @param gradient defines the gradient to remove
  16998. * @returns the current particle system
  16999. */
  17000. removeStartSizeGradient(gradient: number): IParticleSystem;
  17001. private _createRampGradientTexture;
  17002. /**
  17003. * Gets the current list of ramp gradients.
  17004. * You must use addRampGradient and removeRampGradient to udpate this list
  17005. * @returns the list of ramp gradients
  17006. */
  17007. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17008. /**
  17009. * Adds a new ramp gradient used to remap particle colors
  17010. * @param gradient defines the gradient to use (between 0 and 1)
  17011. * @param color defines the color to affect to the specified gradient
  17012. * @returns the current particle system
  17013. */
  17014. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17015. /**
  17016. * Remove a specific ramp gradient
  17017. * @param gradient defines the gradient to remove
  17018. * @returns the current particle system
  17019. */
  17020. removeRampGradient(gradient: number): ParticleSystem;
  17021. /**
  17022. * Adds a new color gradient
  17023. * @param gradient defines the gradient to use (between 0 and 1)
  17024. * @param color1 defines the color to affect to the specified gradient
  17025. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17026. * @returns this particle system
  17027. */
  17028. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17029. /**
  17030. * Remove a specific color gradient
  17031. * @param gradient defines the gradient to remove
  17032. * @returns this particle system
  17033. */
  17034. removeColorGradient(gradient: number): IParticleSystem;
  17035. private _fetchR;
  17036. protected _reset(): void;
  17037. private _resetEffect;
  17038. private _createVertexBuffers;
  17039. private _createIndexBuffer;
  17040. /**
  17041. * Gets the maximum number of particles active at the same time.
  17042. * @returns The max number of active particles.
  17043. */
  17044. getCapacity(): number;
  17045. /**
  17046. * Gets whether there are still active particles in the system.
  17047. * @returns True if it is alive, otherwise false.
  17048. */
  17049. isAlive(): boolean;
  17050. /**
  17051. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17052. * @returns True if it has been started, otherwise false.
  17053. */
  17054. isStarted(): boolean;
  17055. private _prepareSubEmitterInternalArray;
  17056. /**
  17057. * Starts the particle system and begins to emit
  17058. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17059. */
  17060. start(delay?: number): void;
  17061. /**
  17062. * Stops the particle system.
  17063. * @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.
  17064. */
  17065. stop(stopSubEmitters?: boolean): void;
  17066. /**
  17067. * Remove all active particles
  17068. */
  17069. reset(): void;
  17070. /**
  17071. * @hidden (for internal use only)
  17072. */
  17073. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17074. /**
  17075. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17076. * Its lifetime will start back at 0.
  17077. */
  17078. recycleParticle: (particle: Particle) => void;
  17079. private _stopSubEmitters;
  17080. private _createParticle;
  17081. private _removeFromRoot;
  17082. private _emitFromParticle;
  17083. private _update;
  17084. /** @hidden */
  17085. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17086. /** @hidden */
  17087. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17088. /** @hidden */
  17089. private _getEffect;
  17090. /**
  17091. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17092. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17093. */
  17094. animate(preWarmOnly?: boolean): void;
  17095. private _appendParticleVertices;
  17096. /**
  17097. * Rebuilds the particle system.
  17098. */
  17099. rebuild(): void;
  17100. /**
  17101. * Is this system ready to be used/rendered
  17102. * @return true if the system is ready
  17103. */
  17104. isReady(): boolean;
  17105. private _render;
  17106. /**
  17107. * Renders the particle system in its current state.
  17108. * @returns the current number of particles
  17109. */
  17110. render(): number;
  17111. /**
  17112. * Disposes the particle system and free the associated resources
  17113. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17114. */
  17115. dispose(disposeTexture?: boolean): void;
  17116. /**
  17117. * Clones the particle system.
  17118. * @param name The name of the cloned object
  17119. * @param newEmitter The new emitter to use
  17120. * @returns the cloned particle system
  17121. */
  17122. clone(name: string, newEmitter: any): ParticleSystem;
  17123. /**
  17124. * Serializes the particle system to a JSON object.
  17125. * @returns the JSON object
  17126. */
  17127. serialize(): any;
  17128. /** @hidden */
  17129. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17130. /** @hidden */
  17131. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17132. /**
  17133. * Parses a JSON object to create a particle system.
  17134. * @param parsedParticleSystem The JSON object to parse
  17135. * @param scene The scene to create the particle system in
  17136. * @param rootUrl The root url to use to load external dependencies like texture
  17137. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17138. * @returns the Parsed particle system
  17139. */
  17140. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17141. }
  17142. }
  17143. declare module BABYLON {
  17144. /**
  17145. * A particle represents one of the element emitted by a particle system.
  17146. * This is mainly define by its coordinates, direction, velocity and age.
  17147. */
  17148. export class Particle {
  17149. /**
  17150. * The particle system the particle belongs to.
  17151. */
  17152. particleSystem: ParticleSystem;
  17153. private static _Count;
  17154. /**
  17155. * Unique ID of the particle
  17156. */
  17157. id: number;
  17158. /**
  17159. * The world position of the particle in the scene.
  17160. */
  17161. position: Vector3;
  17162. /**
  17163. * The world direction of the particle in the scene.
  17164. */
  17165. direction: Vector3;
  17166. /**
  17167. * The color of the particle.
  17168. */
  17169. color: Color4;
  17170. /**
  17171. * The color change of the particle per step.
  17172. */
  17173. colorStep: Color4;
  17174. /**
  17175. * Defines how long will the life of the particle be.
  17176. */
  17177. lifeTime: number;
  17178. /**
  17179. * The current age of the particle.
  17180. */
  17181. age: number;
  17182. /**
  17183. * The current size of the particle.
  17184. */
  17185. size: number;
  17186. /**
  17187. * The current scale of the particle.
  17188. */
  17189. scale: Vector2;
  17190. /**
  17191. * The current angle of the particle.
  17192. */
  17193. angle: number;
  17194. /**
  17195. * Defines how fast is the angle changing.
  17196. */
  17197. angularSpeed: number;
  17198. /**
  17199. * Defines the cell index used by the particle to be rendered from a sprite.
  17200. */
  17201. cellIndex: number;
  17202. /**
  17203. * The information required to support color remapping
  17204. */
  17205. remapData: Vector4;
  17206. /** @hidden */
  17207. _randomCellOffset?: number;
  17208. /** @hidden */
  17209. _initialDirection: Nullable<Vector3>;
  17210. /** @hidden */
  17211. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17212. /** @hidden */
  17213. _initialStartSpriteCellID: number;
  17214. /** @hidden */
  17215. _initialEndSpriteCellID: number;
  17216. /** @hidden */
  17217. _currentColorGradient: Nullable<ColorGradient>;
  17218. /** @hidden */
  17219. _currentColor1: Color4;
  17220. /** @hidden */
  17221. _currentColor2: Color4;
  17222. /** @hidden */
  17223. _currentSizeGradient: Nullable<FactorGradient>;
  17224. /** @hidden */
  17225. _currentSize1: number;
  17226. /** @hidden */
  17227. _currentSize2: number;
  17228. /** @hidden */
  17229. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17230. /** @hidden */
  17231. _currentAngularSpeed1: number;
  17232. /** @hidden */
  17233. _currentAngularSpeed2: number;
  17234. /** @hidden */
  17235. _currentVelocityGradient: Nullable<FactorGradient>;
  17236. /** @hidden */
  17237. _currentVelocity1: number;
  17238. /** @hidden */
  17239. _currentVelocity2: number;
  17240. /** @hidden */
  17241. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17242. /** @hidden */
  17243. _currentLimitVelocity1: number;
  17244. /** @hidden */
  17245. _currentLimitVelocity2: number;
  17246. /** @hidden */
  17247. _currentDragGradient: Nullable<FactorGradient>;
  17248. /** @hidden */
  17249. _currentDrag1: number;
  17250. /** @hidden */
  17251. _currentDrag2: number;
  17252. /** @hidden */
  17253. _randomNoiseCoordinates1: Vector3;
  17254. /** @hidden */
  17255. _randomNoiseCoordinates2: Vector3;
  17256. /**
  17257. * Creates a new instance Particle
  17258. * @param particleSystem the particle system the particle belongs to
  17259. */
  17260. constructor(
  17261. /**
  17262. * The particle system the particle belongs to.
  17263. */
  17264. particleSystem: ParticleSystem);
  17265. private updateCellInfoFromSystem;
  17266. /**
  17267. * Defines how the sprite cell index is updated for the particle
  17268. */
  17269. updateCellIndex(): void;
  17270. /** @hidden */
  17271. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17272. /** @hidden */
  17273. _inheritParticleInfoToSubEmitters(): void;
  17274. /** @hidden */
  17275. _reset(): void;
  17276. /**
  17277. * Copy the properties of particle to another one.
  17278. * @param other the particle to copy the information to.
  17279. */
  17280. copyTo(other: Particle): void;
  17281. }
  17282. }
  17283. declare module BABYLON {
  17284. /**
  17285. * Particle emitter represents a volume emitting particles.
  17286. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17287. */
  17288. export interface IParticleEmitterType {
  17289. /**
  17290. * Called by the particle System when the direction is computed for the created particle.
  17291. * @param worldMatrix is the world matrix of the particle system
  17292. * @param directionToUpdate is the direction vector to update with the result
  17293. * @param particle is the particle we are computed the direction for
  17294. */
  17295. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17296. /**
  17297. * Called by the particle System when the position is computed for the created particle.
  17298. * @param worldMatrix is the world matrix of the particle system
  17299. * @param positionToUpdate is the position vector to update with the result
  17300. * @param particle is the particle we are computed the position for
  17301. */
  17302. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17303. /**
  17304. * Clones the current emitter and returns a copy of it
  17305. * @returns the new emitter
  17306. */
  17307. clone(): IParticleEmitterType;
  17308. /**
  17309. * Called by the GPUParticleSystem to setup the update shader
  17310. * @param effect defines the update shader
  17311. */
  17312. applyToShader(effect: Effect): void;
  17313. /**
  17314. * Returns a string to use to update the GPU particles update shader
  17315. * @returns the effect defines string
  17316. */
  17317. getEffectDefines(): string;
  17318. /**
  17319. * Returns a string representing the class name
  17320. * @returns a string containing the class name
  17321. */
  17322. getClassName(): string;
  17323. /**
  17324. * Serializes the particle system to a JSON object.
  17325. * @returns the JSON object
  17326. */
  17327. serialize(): any;
  17328. /**
  17329. * Parse properties from a JSON object
  17330. * @param serializationObject defines the JSON object
  17331. */
  17332. parse(serializationObject: any): void;
  17333. }
  17334. }
  17335. declare module BABYLON {
  17336. /**
  17337. * Particle emitter emitting particles from the inside of a box.
  17338. * It emits the particles randomly between 2 given directions.
  17339. */
  17340. export class BoxParticleEmitter implements IParticleEmitterType {
  17341. /**
  17342. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17343. */
  17344. direction1: Vector3;
  17345. /**
  17346. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17347. */
  17348. direction2: Vector3;
  17349. /**
  17350. * 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.
  17351. */
  17352. minEmitBox: Vector3;
  17353. /**
  17354. * 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.
  17355. */
  17356. maxEmitBox: Vector3;
  17357. /**
  17358. * Creates a new instance BoxParticleEmitter
  17359. */
  17360. constructor();
  17361. /**
  17362. * Called by the particle System when the direction is computed for the created particle.
  17363. * @param worldMatrix is the world matrix of the particle system
  17364. * @param directionToUpdate is the direction vector to update with the result
  17365. * @param particle is the particle we are computed the direction for
  17366. */
  17367. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17368. /**
  17369. * Called by the particle System when the position is computed for the created particle.
  17370. * @param worldMatrix is the world matrix of the particle system
  17371. * @param positionToUpdate is the position vector to update with the result
  17372. * @param particle is the particle we are computed the position for
  17373. */
  17374. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17375. /**
  17376. * Clones the current emitter and returns a copy of it
  17377. * @returns the new emitter
  17378. */
  17379. clone(): BoxParticleEmitter;
  17380. /**
  17381. * Called by the GPUParticleSystem to setup the update shader
  17382. * @param effect defines the update shader
  17383. */
  17384. applyToShader(effect: Effect): void;
  17385. /**
  17386. * Returns a string to use to update the GPU particles update shader
  17387. * @returns a string containng the defines string
  17388. */
  17389. getEffectDefines(): string;
  17390. /**
  17391. * Returns the string "BoxParticleEmitter"
  17392. * @returns a string containing the class name
  17393. */
  17394. getClassName(): string;
  17395. /**
  17396. * Serializes the particle system to a JSON object.
  17397. * @returns the JSON object
  17398. */
  17399. serialize(): any;
  17400. /**
  17401. * Parse properties from a JSON object
  17402. * @param serializationObject defines the JSON object
  17403. */
  17404. parse(serializationObject: any): void;
  17405. }
  17406. }
  17407. declare module BABYLON {
  17408. /**
  17409. * Particle emitter emitting particles from the inside of a cone.
  17410. * It emits the particles alongside the cone volume from the base to the particle.
  17411. * The emission direction might be randomized.
  17412. */
  17413. export class ConeParticleEmitter implements IParticleEmitterType {
  17414. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17415. directionRandomizer: number;
  17416. private _radius;
  17417. private _angle;
  17418. private _height;
  17419. /**
  17420. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17421. */
  17422. radiusRange: number;
  17423. /**
  17424. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17425. */
  17426. heightRange: number;
  17427. /**
  17428. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17429. */
  17430. emitFromSpawnPointOnly: boolean;
  17431. /**
  17432. * Gets or sets the radius of the emission cone
  17433. */
  17434. radius: number;
  17435. /**
  17436. * Gets or sets the angle of the emission cone
  17437. */
  17438. angle: number;
  17439. private _buildHeight;
  17440. /**
  17441. * Creates a new instance ConeParticleEmitter
  17442. * @param radius the radius of the emission cone (1 by default)
  17443. * @param angle the cone base angle (PI by default)
  17444. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17445. */
  17446. constructor(radius?: number, angle?: number,
  17447. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17448. directionRandomizer?: number);
  17449. /**
  17450. * Called by the particle System when the direction is computed for the created particle.
  17451. * @param worldMatrix is the world matrix of the particle system
  17452. * @param directionToUpdate is the direction vector to update with the result
  17453. * @param particle is the particle we are computed the direction for
  17454. */
  17455. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17456. /**
  17457. * Called by the particle System when the position is computed for the created particle.
  17458. * @param worldMatrix is the world matrix of the particle system
  17459. * @param positionToUpdate is the position vector to update with the result
  17460. * @param particle is the particle we are computed the position for
  17461. */
  17462. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17463. /**
  17464. * Clones the current emitter and returns a copy of it
  17465. * @returns the new emitter
  17466. */
  17467. clone(): ConeParticleEmitter;
  17468. /**
  17469. * Called by the GPUParticleSystem to setup the update shader
  17470. * @param effect defines the update shader
  17471. */
  17472. applyToShader(effect: Effect): void;
  17473. /**
  17474. * Returns a string to use to update the GPU particles update shader
  17475. * @returns a string containng the defines string
  17476. */
  17477. getEffectDefines(): string;
  17478. /**
  17479. * Returns the string "ConeParticleEmitter"
  17480. * @returns a string containing the class name
  17481. */
  17482. getClassName(): string;
  17483. /**
  17484. * Serializes the particle system to a JSON object.
  17485. * @returns the JSON object
  17486. */
  17487. serialize(): any;
  17488. /**
  17489. * Parse properties from a JSON object
  17490. * @param serializationObject defines the JSON object
  17491. */
  17492. parse(serializationObject: any): void;
  17493. }
  17494. }
  17495. declare module BABYLON {
  17496. /**
  17497. * Particle emitter emitting particles from the inside of a cylinder.
  17498. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17499. */
  17500. export class CylinderParticleEmitter implements IParticleEmitterType {
  17501. /**
  17502. * The radius of the emission cylinder.
  17503. */
  17504. radius: number;
  17505. /**
  17506. * The height of the emission cylinder.
  17507. */
  17508. height: number;
  17509. /**
  17510. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17511. */
  17512. radiusRange: number;
  17513. /**
  17514. * How much to randomize the particle direction [0-1].
  17515. */
  17516. directionRandomizer: number;
  17517. /**
  17518. * Creates a new instance CylinderParticleEmitter
  17519. * @param radius the radius of the emission cylinder (1 by default)
  17520. * @param height the height of the emission cylinder (1 by default)
  17521. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17522. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17523. */
  17524. constructor(
  17525. /**
  17526. * The radius of the emission cylinder.
  17527. */
  17528. radius?: number,
  17529. /**
  17530. * The height of the emission cylinder.
  17531. */
  17532. height?: number,
  17533. /**
  17534. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17535. */
  17536. radiusRange?: number,
  17537. /**
  17538. * How much to randomize the particle direction [0-1].
  17539. */
  17540. directionRandomizer?: number);
  17541. /**
  17542. * Called by the particle System when the direction is computed for the created particle.
  17543. * @param worldMatrix is the world matrix of the particle system
  17544. * @param directionToUpdate is the direction vector to update with the result
  17545. * @param particle is the particle we are computed the direction for
  17546. */
  17547. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17548. /**
  17549. * Called by the particle System when the position is computed for the created particle.
  17550. * @param worldMatrix is the world matrix of the particle system
  17551. * @param positionToUpdate is the position vector to update with the result
  17552. * @param particle is the particle we are computed the position for
  17553. */
  17554. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17555. /**
  17556. * Clones the current emitter and returns a copy of it
  17557. * @returns the new emitter
  17558. */
  17559. clone(): CylinderParticleEmitter;
  17560. /**
  17561. * Called by the GPUParticleSystem to setup the update shader
  17562. * @param effect defines the update shader
  17563. */
  17564. applyToShader(effect: Effect): void;
  17565. /**
  17566. * Returns a string to use to update the GPU particles update shader
  17567. * @returns a string containng the defines string
  17568. */
  17569. getEffectDefines(): string;
  17570. /**
  17571. * Returns the string "CylinderParticleEmitter"
  17572. * @returns a string containing the class name
  17573. */
  17574. getClassName(): string;
  17575. /**
  17576. * Serializes the particle system to a JSON object.
  17577. * @returns the JSON object
  17578. */
  17579. serialize(): any;
  17580. /**
  17581. * Parse properties from a JSON object
  17582. * @param serializationObject defines the JSON object
  17583. */
  17584. parse(serializationObject: any): void;
  17585. }
  17586. /**
  17587. * Particle emitter emitting particles from the inside of a cylinder.
  17588. * It emits the particles randomly between two vectors.
  17589. */
  17590. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17591. /**
  17592. * The min limit of the emission direction.
  17593. */
  17594. direction1: Vector3;
  17595. /**
  17596. * The max limit of the emission direction.
  17597. */
  17598. direction2: Vector3;
  17599. /**
  17600. * Creates a new instance CylinderDirectedParticleEmitter
  17601. * @param radius the radius of the emission cylinder (1 by default)
  17602. * @param height the height of the emission cylinder (1 by default)
  17603. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17604. * @param direction1 the min limit of the emission direction (up vector by default)
  17605. * @param direction2 the max limit of the emission direction (up vector by default)
  17606. */
  17607. constructor(radius?: number, height?: number, radiusRange?: number,
  17608. /**
  17609. * The min limit of the emission direction.
  17610. */
  17611. direction1?: Vector3,
  17612. /**
  17613. * The max limit of the emission direction.
  17614. */
  17615. direction2?: Vector3);
  17616. /**
  17617. * Called by the particle System when the direction is computed for the created particle.
  17618. * @param worldMatrix is the world matrix of the particle system
  17619. * @param directionToUpdate is the direction vector to update with the result
  17620. * @param particle is the particle we are computed the direction for
  17621. */
  17622. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17623. /**
  17624. * Clones the current emitter and returns a copy of it
  17625. * @returns the new emitter
  17626. */
  17627. clone(): CylinderDirectedParticleEmitter;
  17628. /**
  17629. * Called by the GPUParticleSystem to setup the update shader
  17630. * @param effect defines the update shader
  17631. */
  17632. applyToShader(effect: Effect): void;
  17633. /**
  17634. * Returns a string to use to update the GPU particles update shader
  17635. * @returns a string containng the defines string
  17636. */
  17637. getEffectDefines(): string;
  17638. /**
  17639. * Returns the string "CylinderDirectedParticleEmitter"
  17640. * @returns a string containing the class name
  17641. */
  17642. getClassName(): string;
  17643. /**
  17644. * Serializes the particle system to a JSON object.
  17645. * @returns the JSON object
  17646. */
  17647. serialize(): any;
  17648. /**
  17649. * Parse properties from a JSON object
  17650. * @param serializationObject defines the JSON object
  17651. */
  17652. parse(serializationObject: any): void;
  17653. }
  17654. }
  17655. declare module BABYLON {
  17656. /**
  17657. * Particle emitter emitting particles from the inside of a hemisphere.
  17658. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17659. */
  17660. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17661. /**
  17662. * The radius of the emission hemisphere.
  17663. */
  17664. radius: number;
  17665. /**
  17666. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17667. */
  17668. radiusRange: number;
  17669. /**
  17670. * How much to randomize the particle direction [0-1].
  17671. */
  17672. directionRandomizer: number;
  17673. /**
  17674. * Creates a new instance HemisphericParticleEmitter
  17675. * @param radius the radius of the emission hemisphere (1 by default)
  17676. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17677. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17678. */
  17679. constructor(
  17680. /**
  17681. * The radius of the emission hemisphere.
  17682. */
  17683. radius?: number,
  17684. /**
  17685. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17686. */
  17687. radiusRange?: number,
  17688. /**
  17689. * How much to randomize the particle direction [0-1].
  17690. */
  17691. directionRandomizer?: number);
  17692. /**
  17693. * Called by the particle System when the direction is computed for the created particle.
  17694. * @param worldMatrix is the world matrix of the particle system
  17695. * @param directionToUpdate is the direction vector to update with the result
  17696. * @param particle is the particle we are computed the direction for
  17697. */
  17698. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17699. /**
  17700. * Called by the particle System when the position is computed for the created particle.
  17701. * @param worldMatrix is the world matrix of the particle system
  17702. * @param positionToUpdate is the position vector to update with the result
  17703. * @param particle is the particle we are computed the position for
  17704. */
  17705. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17706. /**
  17707. * Clones the current emitter and returns a copy of it
  17708. * @returns the new emitter
  17709. */
  17710. clone(): HemisphericParticleEmitter;
  17711. /**
  17712. * Called by the GPUParticleSystem to setup the update shader
  17713. * @param effect defines the update shader
  17714. */
  17715. applyToShader(effect: Effect): void;
  17716. /**
  17717. * Returns a string to use to update the GPU particles update shader
  17718. * @returns a string containng the defines string
  17719. */
  17720. getEffectDefines(): string;
  17721. /**
  17722. * Returns the string "HemisphericParticleEmitter"
  17723. * @returns a string containing the class name
  17724. */
  17725. getClassName(): string;
  17726. /**
  17727. * Serializes the particle system to a JSON object.
  17728. * @returns the JSON object
  17729. */
  17730. serialize(): any;
  17731. /**
  17732. * Parse properties from a JSON object
  17733. * @param serializationObject defines the JSON object
  17734. */
  17735. parse(serializationObject: any): void;
  17736. }
  17737. }
  17738. declare module BABYLON {
  17739. /**
  17740. * Particle emitter emitting particles from a point.
  17741. * It emits the particles randomly between 2 given directions.
  17742. */
  17743. export class PointParticleEmitter implements IParticleEmitterType {
  17744. /**
  17745. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17746. */
  17747. direction1: Vector3;
  17748. /**
  17749. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17750. */
  17751. direction2: Vector3;
  17752. /**
  17753. * Creates a new instance PointParticleEmitter
  17754. */
  17755. constructor();
  17756. /**
  17757. * Called by the particle System when the direction is computed for the created particle.
  17758. * @param worldMatrix is the world matrix of the particle system
  17759. * @param directionToUpdate is the direction vector to update with the result
  17760. * @param particle is the particle we are computed the direction for
  17761. */
  17762. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17763. /**
  17764. * Called by the particle System when the position is computed for the created particle.
  17765. * @param worldMatrix is the world matrix of the particle system
  17766. * @param positionToUpdate is the position vector to update with the result
  17767. * @param particle is the particle we are computed the position for
  17768. */
  17769. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17770. /**
  17771. * Clones the current emitter and returns a copy of it
  17772. * @returns the new emitter
  17773. */
  17774. clone(): PointParticleEmitter;
  17775. /**
  17776. * Called by the GPUParticleSystem to setup the update shader
  17777. * @param effect defines the update shader
  17778. */
  17779. applyToShader(effect: Effect): void;
  17780. /**
  17781. * Returns a string to use to update the GPU particles update shader
  17782. * @returns a string containng the defines string
  17783. */
  17784. getEffectDefines(): string;
  17785. /**
  17786. * Returns the string "PointParticleEmitter"
  17787. * @returns a string containing the class name
  17788. */
  17789. getClassName(): string;
  17790. /**
  17791. * Serializes the particle system to a JSON object.
  17792. * @returns the JSON object
  17793. */
  17794. serialize(): any;
  17795. /**
  17796. * Parse properties from a JSON object
  17797. * @param serializationObject defines the JSON object
  17798. */
  17799. parse(serializationObject: any): void;
  17800. }
  17801. }
  17802. declare module BABYLON {
  17803. /**
  17804. * Particle emitter emitting particles from the inside of a sphere.
  17805. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17806. */
  17807. export class SphereParticleEmitter implements IParticleEmitterType {
  17808. /**
  17809. * The radius of the emission sphere.
  17810. */
  17811. radius: number;
  17812. /**
  17813. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17814. */
  17815. radiusRange: number;
  17816. /**
  17817. * How much to randomize the particle direction [0-1].
  17818. */
  17819. directionRandomizer: number;
  17820. /**
  17821. * Creates a new instance SphereParticleEmitter
  17822. * @param radius the radius of the emission sphere (1 by default)
  17823. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17824. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17825. */
  17826. constructor(
  17827. /**
  17828. * The radius of the emission sphere.
  17829. */
  17830. radius?: number,
  17831. /**
  17832. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17833. */
  17834. radiusRange?: number,
  17835. /**
  17836. * How much to randomize the particle direction [0-1].
  17837. */
  17838. directionRandomizer?: number);
  17839. /**
  17840. * Called by the particle System when the direction is computed for the created particle.
  17841. * @param worldMatrix is the world matrix of the particle system
  17842. * @param directionToUpdate is the direction vector to update with the result
  17843. * @param particle is the particle we are computed the direction for
  17844. */
  17845. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17846. /**
  17847. * Called by the particle System when the position is computed for the created particle.
  17848. * @param worldMatrix is the world matrix of the particle system
  17849. * @param positionToUpdate is the position vector to update with the result
  17850. * @param particle is the particle we are computed the position for
  17851. */
  17852. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17853. /**
  17854. * Clones the current emitter and returns a copy of it
  17855. * @returns the new emitter
  17856. */
  17857. clone(): SphereParticleEmitter;
  17858. /**
  17859. * Called by the GPUParticleSystem to setup the update shader
  17860. * @param effect defines the update shader
  17861. */
  17862. applyToShader(effect: Effect): void;
  17863. /**
  17864. * Returns a string to use to update the GPU particles update shader
  17865. * @returns a string containng the defines string
  17866. */
  17867. getEffectDefines(): string;
  17868. /**
  17869. * Returns the string "SphereParticleEmitter"
  17870. * @returns a string containing the class name
  17871. */
  17872. getClassName(): string;
  17873. /**
  17874. * Serializes the particle system to a JSON object.
  17875. * @returns the JSON object
  17876. */
  17877. serialize(): any;
  17878. /**
  17879. * Parse properties from a JSON object
  17880. * @param serializationObject defines the JSON object
  17881. */
  17882. parse(serializationObject: any): void;
  17883. }
  17884. /**
  17885. * Particle emitter emitting particles from the inside of a sphere.
  17886. * It emits the particles randomly between two vectors.
  17887. */
  17888. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17889. /**
  17890. * The min limit of the emission direction.
  17891. */
  17892. direction1: Vector3;
  17893. /**
  17894. * The max limit of the emission direction.
  17895. */
  17896. direction2: Vector3;
  17897. /**
  17898. * Creates a new instance SphereDirectedParticleEmitter
  17899. * @param radius the radius of the emission sphere (1 by default)
  17900. * @param direction1 the min limit of the emission direction (up vector by default)
  17901. * @param direction2 the max limit of the emission direction (up vector by default)
  17902. */
  17903. constructor(radius?: number,
  17904. /**
  17905. * The min limit of the emission direction.
  17906. */
  17907. direction1?: Vector3,
  17908. /**
  17909. * The max limit of the emission direction.
  17910. */
  17911. direction2?: Vector3);
  17912. /**
  17913. * Called by the particle System when the direction is computed for the created particle.
  17914. * @param worldMatrix is the world matrix of the particle system
  17915. * @param directionToUpdate is the direction vector to update with the result
  17916. * @param particle is the particle we are computed the direction for
  17917. */
  17918. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17919. /**
  17920. * Clones the current emitter and returns a copy of it
  17921. * @returns the new emitter
  17922. */
  17923. clone(): SphereDirectedParticleEmitter;
  17924. /**
  17925. * Called by the GPUParticleSystem to setup the update shader
  17926. * @param effect defines the update shader
  17927. */
  17928. applyToShader(effect: Effect): void;
  17929. /**
  17930. * Returns a string to use to update the GPU particles update shader
  17931. * @returns a string containng the defines string
  17932. */
  17933. getEffectDefines(): string;
  17934. /**
  17935. * Returns the string "SphereDirectedParticleEmitter"
  17936. * @returns a string containing the class name
  17937. */
  17938. getClassName(): string;
  17939. /**
  17940. * Serializes the particle system to a JSON object.
  17941. * @returns the JSON object
  17942. */
  17943. serialize(): any;
  17944. /**
  17945. * Parse properties from a JSON object
  17946. * @param serializationObject defines the JSON object
  17947. */
  17948. parse(serializationObject: any): void;
  17949. }
  17950. }
  17951. declare module BABYLON {
  17952. /**
  17953. * Interface representing a particle system in Babylon.js.
  17954. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17955. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17956. */
  17957. export interface IParticleSystem {
  17958. /**
  17959. * List of animations used by the particle system.
  17960. */
  17961. animations: Animation[];
  17962. /**
  17963. * The id of the Particle system.
  17964. */
  17965. id: string;
  17966. /**
  17967. * The name of the Particle system.
  17968. */
  17969. name: string;
  17970. /**
  17971. * The emitter represents the Mesh or position we are attaching the particle system to.
  17972. */
  17973. emitter: Nullable<AbstractMesh | Vector3>;
  17974. /**
  17975. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17976. */
  17977. isBillboardBased: boolean;
  17978. /**
  17979. * The rendering group used by the Particle system to chose when to render.
  17980. */
  17981. renderingGroupId: number;
  17982. /**
  17983. * The layer mask we are rendering the particles through.
  17984. */
  17985. layerMask: number;
  17986. /**
  17987. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17988. */
  17989. updateSpeed: number;
  17990. /**
  17991. * The amount of time the particle system is running (depends of the overall update speed).
  17992. */
  17993. targetStopDuration: number;
  17994. /**
  17995. * The texture used to render each particle. (this can be a spritesheet)
  17996. */
  17997. particleTexture: Nullable<Texture>;
  17998. /**
  17999. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18000. */
  18001. blendMode: number;
  18002. /**
  18003. * Minimum life time of emitting particles.
  18004. */
  18005. minLifeTime: number;
  18006. /**
  18007. * Maximum life time of emitting particles.
  18008. */
  18009. maxLifeTime: number;
  18010. /**
  18011. * Minimum Size of emitting particles.
  18012. */
  18013. minSize: number;
  18014. /**
  18015. * Maximum Size of emitting particles.
  18016. */
  18017. maxSize: number;
  18018. /**
  18019. * Minimum scale of emitting particles on X axis.
  18020. */
  18021. minScaleX: number;
  18022. /**
  18023. * Maximum scale of emitting particles on X axis.
  18024. */
  18025. maxScaleX: number;
  18026. /**
  18027. * Minimum scale of emitting particles on Y axis.
  18028. */
  18029. minScaleY: number;
  18030. /**
  18031. * Maximum scale of emitting particles on Y axis.
  18032. */
  18033. maxScaleY: number;
  18034. /**
  18035. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18036. */
  18037. color1: Color4;
  18038. /**
  18039. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18040. */
  18041. color2: Color4;
  18042. /**
  18043. * Color the particle will have at the end of its lifetime.
  18044. */
  18045. colorDead: Color4;
  18046. /**
  18047. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18048. */
  18049. emitRate: number;
  18050. /**
  18051. * You can use gravity if you want to give an orientation to your particles.
  18052. */
  18053. gravity: Vector3;
  18054. /**
  18055. * Minimum power of emitting particles.
  18056. */
  18057. minEmitPower: number;
  18058. /**
  18059. * Maximum power of emitting particles.
  18060. */
  18061. maxEmitPower: number;
  18062. /**
  18063. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18064. */
  18065. minAngularSpeed: number;
  18066. /**
  18067. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18068. */
  18069. maxAngularSpeed: number;
  18070. /**
  18071. * Gets or sets the minimal initial rotation in radians.
  18072. */
  18073. minInitialRotation: number;
  18074. /**
  18075. * Gets or sets the maximal initial rotation in radians.
  18076. */
  18077. maxInitialRotation: number;
  18078. /**
  18079. * The particle emitter type defines the emitter used by the particle system.
  18080. * It can be for example box, sphere, or cone...
  18081. */
  18082. particleEmitterType: Nullable<IParticleEmitterType>;
  18083. /**
  18084. * Defines the delay in milliseconds before starting the system (0 by default)
  18085. */
  18086. startDelay: number;
  18087. /**
  18088. * 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
  18089. */
  18090. preWarmCycles: number;
  18091. /**
  18092. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18093. */
  18094. preWarmStepOffset: number;
  18095. /**
  18096. * 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)
  18097. */
  18098. spriteCellChangeSpeed: number;
  18099. /**
  18100. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18101. */
  18102. startSpriteCellID: number;
  18103. /**
  18104. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18105. */
  18106. endSpriteCellID: number;
  18107. /**
  18108. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18109. */
  18110. spriteCellWidth: number;
  18111. /**
  18112. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18113. */
  18114. spriteCellHeight: number;
  18115. /**
  18116. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18117. */
  18118. spriteRandomStartCell: boolean;
  18119. /**
  18120. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18121. */
  18122. isAnimationSheetEnabled: boolean;
  18123. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18124. translationPivot: Vector2;
  18125. /**
  18126. * Gets or sets a texture used to add random noise to particle positions
  18127. */
  18128. noiseTexture: Nullable<BaseTexture>;
  18129. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18130. noiseStrength: Vector3;
  18131. /**
  18132. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18133. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18134. */
  18135. billboardMode: number;
  18136. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18137. limitVelocityDamping: number;
  18138. /**
  18139. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18140. */
  18141. beginAnimationOnStart: boolean;
  18142. /**
  18143. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18144. */
  18145. beginAnimationFrom: number;
  18146. /**
  18147. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18148. */
  18149. beginAnimationTo: number;
  18150. /**
  18151. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18152. */
  18153. beginAnimationLoop: boolean;
  18154. /**
  18155. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18156. */
  18157. disposeOnStop: boolean;
  18158. /**
  18159. * Gets the maximum number of particles active at the same time.
  18160. * @returns The max number of active particles.
  18161. */
  18162. getCapacity(): number;
  18163. /**
  18164. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18165. * @returns True if it has been started, otherwise false.
  18166. */
  18167. isStarted(): boolean;
  18168. /**
  18169. * Animates the particle system for this frame.
  18170. */
  18171. animate(): void;
  18172. /**
  18173. * Renders the particle system in its current state.
  18174. * @returns the current number of particles
  18175. */
  18176. render(): number;
  18177. /**
  18178. * Dispose the particle system and frees its associated resources.
  18179. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18180. */
  18181. dispose(disposeTexture?: boolean): void;
  18182. /**
  18183. * Clones the particle system.
  18184. * @param name The name of the cloned object
  18185. * @param newEmitter The new emitter to use
  18186. * @returns the cloned particle system
  18187. */
  18188. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18189. /**
  18190. * Serializes the particle system to a JSON object.
  18191. * @returns the JSON object
  18192. */
  18193. serialize(): any;
  18194. /**
  18195. * Rebuild the particle system
  18196. */
  18197. rebuild(): void;
  18198. /**
  18199. * Starts the particle system and begins to emit
  18200. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18201. */
  18202. start(delay?: number): void;
  18203. /**
  18204. * Stops the particle system.
  18205. */
  18206. stop(): void;
  18207. /**
  18208. * Remove all active particles
  18209. */
  18210. reset(): void;
  18211. /**
  18212. * Is this system ready to be used/rendered
  18213. * @return true if the system is ready
  18214. */
  18215. isReady(): boolean;
  18216. /**
  18217. * Adds a new color gradient
  18218. * @param gradient defines the gradient to use (between 0 and 1)
  18219. * @param color1 defines the color to affect to the specified gradient
  18220. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18221. * @returns the current particle system
  18222. */
  18223. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18224. /**
  18225. * Remove a specific color gradient
  18226. * @param gradient defines the gradient to remove
  18227. * @returns the current particle system
  18228. */
  18229. removeColorGradient(gradient: number): IParticleSystem;
  18230. /**
  18231. * Adds a new size gradient
  18232. * @param gradient defines the gradient to use (between 0 and 1)
  18233. * @param factor defines the size factor to affect to the specified gradient
  18234. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18235. * @returns the current particle system
  18236. */
  18237. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18238. /**
  18239. * Remove a specific size gradient
  18240. * @param gradient defines the gradient to remove
  18241. * @returns the current particle system
  18242. */
  18243. removeSizeGradient(gradient: number): IParticleSystem;
  18244. /**
  18245. * Gets the current list of color gradients.
  18246. * You must use addColorGradient and removeColorGradient to udpate this list
  18247. * @returns the list of color gradients
  18248. */
  18249. getColorGradients(): Nullable<Array<ColorGradient>>;
  18250. /**
  18251. * Gets the current list of size gradients.
  18252. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18253. * @returns the list of size gradients
  18254. */
  18255. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18256. /**
  18257. * Gets the current list of angular speed gradients.
  18258. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18259. * @returns the list of angular speed gradients
  18260. */
  18261. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18262. /**
  18263. * Adds a new angular speed gradient
  18264. * @param gradient defines the gradient to use (between 0 and 1)
  18265. * @param factor defines the angular speed to affect to the specified gradient
  18266. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18267. * @returns the current particle system
  18268. */
  18269. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18270. /**
  18271. * Remove a specific angular speed gradient
  18272. * @param gradient defines the gradient to remove
  18273. * @returns the current particle system
  18274. */
  18275. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18276. /**
  18277. * Gets the current list of velocity gradients.
  18278. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18279. * @returns the list of velocity gradients
  18280. */
  18281. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18282. /**
  18283. * Adds a new velocity gradient
  18284. * @param gradient defines the gradient to use (between 0 and 1)
  18285. * @param factor defines the velocity to affect to the specified gradient
  18286. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18287. * @returns the current particle system
  18288. */
  18289. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18290. /**
  18291. * Remove a specific velocity gradient
  18292. * @param gradient defines the gradient to remove
  18293. * @returns the current particle system
  18294. */
  18295. removeVelocityGradient(gradient: number): IParticleSystem;
  18296. /**
  18297. * Gets the current list of limit velocity gradients.
  18298. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18299. * @returns the list of limit velocity gradients
  18300. */
  18301. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18302. /**
  18303. * Adds a new limit velocity gradient
  18304. * @param gradient defines the gradient to use (between 0 and 1)
  18305. * @param factor defines the limit velocity to affect to the specified gradient
  18306. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18307. * @returns the current particle system
  18308. */
  18309. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18310. /**
  18311. * Remove a specific limit velocity gradient
  18312. * @param gradient defines the gradient to remove
  18313. * @returns the current particle system
  18314. */
  18315. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18316. /**
  18317. * Adds a new drag gradient
  18318. * @param gradient defines the gradient to use (between 0 and 1)
  18319. * @param factor defines the drag to affect to the specified gradient
  18320. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18321. * @returns the current particle system
  18322. */
  18323. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18324. /**
  18325. * Remove a specific drag gradient
  18326. * @param gradient defines the gradient to remove
  18327. * @returns the current particle system
  18328. */
  18329. removeDragGradient(gradient: number): IParticleSystem;
  18330. /**
  18331. * Gets the current list of drag gradients.
  18332. * You must use addDragGradient and removeDragGradient to udpate this list
  18333. * @returns the list of drag gradients
  18334. */
  18335. getDragGradients(): Nullable<Array<FactorGradient>>;
  18336. /**
  18337. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18338. * @param gradient defines the gradient to use (between 0 and 1)
  18339. * @param factor defines the emit rate to affect to the specified gradient
  18340. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18341. * @returns the current particle system
  18342. */
  18343. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18344. /**
  18345. * Remove a specific emit rate gradient
  18346. * @param gradient defines the gradient to remove
  18347. * @returns the current particle system
  18348. */
  18349. removeEmitRateGradient(gradient: number): IParticleSystem;
  18350. /**
  18351. * Gets the current list of emit rate gradients.
  18352. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18353. * @returns the list of emit rate gradients
  18354. */
  18355. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18356. /**
  18357. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18358. * @param gradient defines the gradient to use (between 0 and 1)
  18359. * @param factor defines the start size to affect to the specified gradient
  18360. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18361. * @returns the current particle system
  18362. */
  18363. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18364. /**
  18365. * Remove a specific start size gradient
  18366. * @param gradient defines the gradient to remove
  18367. * @returns the current particle system
  18368. */
  18369. removeStartSizeGradient(gradient: number): IParticleSystem;
  18370. /**
  18371. * Gets the current list of start size gradients.
  18372. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18373. * @returns the list of start size gradients
  18374. */
  18375. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18376. /**
  18377. * Adds a new life time gradient
  18378. * @param gradient defines the gradient to use (between 0 and 1)
  18379. * @param factor defines the life time factor to affect to the specified gradient
  18380. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18381. * @returns the current particle system
  18382. */
  18383. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18384. /**
  18385. * Remove a specific life time gradient
  18386. * @param gradient defines the gradient to remove
  18387. * @returns the current particle system
  18388. */
  18389. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18390. /**
  18391. * Gets the current list of life time gradients.
  18392. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18393. * @returns the list of life time gradients
  18394. */
  18395. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18396. /**
  18397. * Gets the current list of color gradients.
  18398. * You must use addColorGradient and removeColorGradient to udpate this list
  18399. * @returns the list of color gradients
  18400. */
  18401. getColorGradients(): Nullable<Array<ColorGradient>>;
  18402. /**
  18403. * Adds a new ramp gradient used to remap particle colors
  18404. * @param gradient defines the gradient to use (between 0 and 1)
  18405. * @param color defines the color to affect to the specified gradient
  18406. * @returns the current particle system
  18407. */
  18408. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18409. /**
  18410. * Gets the current list of ramp gradients.
  18411. * You must use addRampGradient and removeRampGradient to udpate this list
  18412. * @returns the list of ramp gradients
  18413. */
  18414. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18415. /** Gets or sets a boolean indicating that ramp gradients must be used
  18416. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18417. */
  18418. useRampGradients: boolean;
  18419. /**
  18420. * Adds a new color remap gradient
  18421. * @param gradient defines the gradient to use (between 0 and 1)
  18422. * @param min defines the color remap minimal range
  18423. * @param max defines the color remap maximal range
  18424. * @returns the current particle system
  18425. */
  18426. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18427. /**
  18428. * Gets the current list of color remap gradients.
  18429. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18430. * @returns the list of color remap gradients
  18431. */
  18432. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18433. /**
  18434. * Adds a new alpha remap gradient
  18435. * @param gradient defines the gradient to use (between 0 and 1)
  18436. * @param min defines the alpha remap minimal range
  18437. * @param max defines the alpha remap maximal range
  18438. * @returns the current particle system
  18439. */
  18440. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18441. /**
  18442. * Gets the current list of alpha remap gradients.
  18443. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18444. * @returns the list of alpha remap gradients
  18445. */
  18446. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18447. /**
  18448. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18449. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18450. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18451. * @returns the emitter
  18452. */
  18453. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18454. /**
  18455. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18456. * @param radius The radius of the hemisphere to emit from
  18457. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18458. * @returns the emitter
  18459. */
  18460. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18461. /**
  18462. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18463. * @param radius The radius of the sphere to emit from
  18464. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18465. * @returns the emitter
  18466. */
  18467. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18468. /**
  18469. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18470. * @param radius The radius of the sphere to emit from
  18471. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18472. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18473. * @returns the emitter
  18474. */
  18475. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18476. /**
  18477. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18478. * @param radius The radius of the emission cylinder
  18479. * @param height The height of the emission cylinder
  18480. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18481. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18482. * @returns the emitter
  18483. */
  18484. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18485. /**
  18486. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18487. * @param radius The radius of the cylinder to emit from
  18488. * @param height The height of the emission cylinder
  18489. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18490. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18491. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18492. * @returns the emitter
  18493. */
  18494. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18495. /**
  18496. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18497. * @param radius The radius of the cone to emit from
  18498. * @param angle The base angle of the cone
  18499. * @returns the emitter
  18500. */
  18501. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18502. /**
  18503. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18504. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18505. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18506. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18507. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18508. * @returns the emitter
  18509. */
  18510. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18511. /**
  18512. * Get hosting scene
  18513. * @returns the scene
  18514. */
  18515. getScene(): Scene;
  18516. }
  18517. }
  18518. declare module BABYLON {
  18519. /**
  18520. * Creates an instance based on a source mesh.
  18521. */
  18522. export class InstancedMesh extends AbstractMesh {
  18523. private _sourceMesh;
  18524. private _currentLOD;
  18525. /** @hidden */
  18526. _indexInSourceMeshInstanceArray: number;
  18527. constructor(name: string, source: Mesh);
  18528. /**
  18529. * Returns the string "InstancedMesh".
  18530. */
  18531. getClassName(): string;
  18532. /** Gets the list of lights affecting that mesh */
  18533. readonly lightSources: Light[];
  18534. _resyncLightSources(): void;
  18535. _resyncLighSource(light: Light): void;
  18536. _removeLightSource(light: Light, dispose: boolean): void;
  18537. /**
  18538. * If the source mesh receives shadows
  18539. */
  18540. readonly receiveShadows: boolean;
  18541. /**
  18542. * The material of the source mesh
  18543. */
  18544. readonly material: Nullable<Material>;
  18545. /**
  18546. * Visibility of the source mesh
  18547. */
  18548. readonly visibility: number;
  18549. /**
  18550. * Skeleton of the source mesh
  18551. */
  18552. readonly skeleton: Nullable<Skeleton>;
  18553. /**
  18554. * Rendering ground id of the source mesh
  18555. */
  18556. renderingGroupId: number;
  18557. /**
  18558. * Returns the total number of vertices (integer).
  18559. */
  18560. getTotalVertices(): number;
  18561. /**
  18562. * Returns a positive integer : the total number of indices in this mesh geometry.
  18563. * @returns the numner of indices or zero if the mesh has no geometry.
  18564. */
  18565. getTotalIndices(): number;
  18566. /**
  18567. * The source mesh of the instance
  18568. */
  18569. readonly sourceMesh: Mesh;
  18570. /**
  18571. * Is this node ready to be used/rendered
  18572. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18573. * @return {boolean} is it ready
  18574. */
  18575. isReady(completeCheck?: boolean): boolean;
  18576. /**
  18577. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18578. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18579. * @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.
  18580. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18581. */
  18582. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18583. /**
  18584. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18585. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18586. * The `data` are either a numeric array either a Float32Array.
  18587. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18588. * 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).
  18589. * Note that a new underlying VertexBuffer object is created each call.
  18590. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18591. *
  18592. * Possible `kind` values :
  18593. * - VertexBuffer.PositionKind
  18594. * - VertexBuffer.UVKind
  18595. * - VertexBuffer.UV2Kind
  18596. * - VertexBuffer.UV3Kind
  18597. * - VertexBuffer.UV4Kind
  18598. * - VertexBuffer.UV5Kind
  18599. * - VertexBuffer.UV6Kind
  18600. * - VertexBuffer.ColorKind
  18601. * - VertexBuffer.MatricesIndicesKind
  18602. * - VertexBuffer.MatricesIndicesExtraKind
  18603. * - VertexBuffer.MatricesWeightsKind
  18604. * - VertexBuffer.MatricesWeightsExtraKind
  18605. *
  18606. * Returns the Mesh.
  18607. */
  18608. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18609. /**
  18610. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18611. * If the mesh has no geometry, it is simply returned as it is.
  18612. * The `data` are either a numeric array either a Float32Array.
  18613. * No new underlying VertexBuffer object is created.
  18614. * 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.
  18615. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18616. *
  18617. * Possible `kind` values :
  18618. * - VertexBuffer.PositionKind
  18619. * - VertexBuffer.UVKind
  18620. * - VertexBuffer.UV2Kind
  18621. * - VertexBuffer.UV3Kind
  18622. * - VertexBuffer.UV4Kind
  18623. * - VertexBuffer.UV5Kind
  18624. * - VertexBuffer.UV6Kind
  18625. * - VertexBuffer.ColorKind
  18626. * - VertexBuffer.MatricesIndicesKind
  18627. * - VertexBuffer.MatricesIndicesExtraKind
  18628. * - VertexBuffer.MatricesWeightsKind
  18629. * - VertexBuffer.MatricesWeightsExtraKind
  18630. *
  18631. * Returns the Mesh.
  18632. */
  18633. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18634. /**
  18635. * Sets the mesh indices.
  18636. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18637. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18638. * This method creates a new index buffer each call.
  18639. * Returns the Mesh.
  18640. */
  18641. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18642. /**
  18643. * Boolean : True if the mesh owns the requested kind of data.
  18644. */
  18645. isVerticesDataPresent(kind: string): boolean;
  18646. /**
  18647. * Returns an array of indices (IndicesArray).
  18648. */
  18649. getIndices(): Nullable<IndicesArray>;
  18650. readonly _positions: Nullable<Vector3[]>;
  18651. /**
  18652. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18653. * This means the mesh underlying bounding box and sphere are recomputed.
  18654. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18655. * @returns the current mesh
  18656. */
  18657. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18658. /** @hidden */
  18659. _preActivate(): InstancedMesh;
  18660. /** @hidden */
  18661. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18662. /** @hidden */
  18663. _postActivate(): void;
  18664. getWorldMatrix(): Matrix;
  18665. readonly isAnInstance: boolean;
  18666. /**
  18667. * Returns the current associated LOD AbstractMesh.
  18668. */
  18669. getLOD(camera: Camera): AbstractMesh;
  18670. /** @hidden */
  18671. _syncSubMeshes(): InstancedMesh;
  18672. /** @hidden */
  18673. _generatePointsArray(): boolean;
  18674. /**
  18675. * Creates a new InstancedMesh from the current mesh.
  18676. * - name (string) : the cloned mesh name
  18677. * - newParent (optional Node) : the optional Node to parent the clone to.
  18678. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18679. *
  18680. * Returns the clone.
  18681. */
  18682. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18683. /**
  18684. * Disposes the InstancedMesh.
  18685. * Returns nothing.
  18686. */
  18687. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18688. }
  18689. }
  18690. declare module BABYLON {
  18691. /**
  18692. * Defines the options associated with the creation of a shader material.
  18693. */
  18694. export interface IShaderMaterialOptions {
  18695. /**
  18696. * Does the material work in alpha blend mode
  18697. */
  18698. needAlphaBlending: boolean;
  18699. /**
  18700. * Does the material work in alpha test mode
  18701. */
  18702. needAlphaTesting: boolean;
  18703. /**
  18704. * The list of attribute names used in the shader
  18705. */
  18706. attributes: string[];
  18707. /**
  18708. * The list of unifrom names used in the shader
  18709. */
  18710. uniforms: string[];
  18711. /**
  18712. * The list of UBO names used in the shader
  18713. */
  18714. uniformBuffers: string[];
  18715. /**
  18716. * The list of sampler names used in the shader
  18717. */
  18718. samplers: string[];
  18719. /**
  18720. * The list of defines used in the shader
  18721. */
  18722. defines: string[];
  18723. }
  18724. /**
  18725. * 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.
  18726. *
  18727. * This returned material effects how the mesh will look based on the code in the shaders.
  18728. *
  18729. * @see http://doc.babylonjs.com/how_to/shader_material
  18730. */
  18731. export class ShaderMaterial extends Material {
  18732. private _shaderPath;
  18733. private _options;
  18734. private _textures;
  18735. private _textureArrays;
  18736. private _floats;
  18737. private _ints;
  18738. private _floatsArrays;
  18739. private _colors3;
  18740. private _colors3Arrays;
  18741. private _colors4;
  18742. private _colors4Arrays;
  18743. private _vectors2;
  18744. private _vectors3;
  18745. private _vectors4;
  18746. private _matrices;
  18747. private _matrices3x3;
  18748. private _matrices2x2;
  18749. private _vectors2Arrays;
  18750. private _vectors3Arrays;
  18751. private _vectors4Arrays;
  18752. private _cachedWorldViewMatrix;
  18753. private _cachedWorldViewProjectionMatrix;
  18754. private _renderId;
  18755. /**
  18756. * Instantiate a new shader material.
  18757. * 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.
  18758. * This returned material effects how the mesh will look based on the code in the shaders.
  18759. * @see http://doc.babylonjs.com/how_to/shader_material
  18760. * @param name Define the name of the material in the scene
  18761. * @param scene Define the scene the material belongs to
  18762. * @param shaderPath Defines the route to the shader code in one of three ways:
  18763. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18764. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  18765. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  18766. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18767. * @param options Define the options used to create the shader
  18768. */
  18769. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18770. /**
  18771. * Gets the options used to compile the shader.
  18772. * They can be modified to trigger a new compilation
  18773. */
  18774. readonly options: IShaderMaterialOptions;
  18775. /**
  18776. * Gets the current class name of the material e.g. "ShaderMaterial"
  18777. * Mainly use in serialization.
  18778. * @returns the class name
  18779. */
  18780. getClassName(): string;
  18781. /**
  18782. * Specifies if the material will require alpha blending
  18783. * @returns a boolean specifying if alpha blending is needed
  18784. */
  18785. needAlphaBlending(): boolean;
  18786. /**
  18787. * Specifies if this material should be rendered in alpha test mode
  18788. * @returns a boolean specifying if an alpha test is needed.
  18789. */
  18790. needAlphaTesting(): boolean;
  18791. private _checkUniform;
  18792. /**
  18793. * Set a texture in the shader.
  18794. * @param name Define the name of the uniform samplers as defined in the shader
  18795. * @param texture Define the texture to bind to this sampler
  18796. * @return the material itself allowing "fluent" like uniform updates
  18797. */
  18798. setTexture(name: string, texture: Texture): ShaderMaterial;
  18799. /**
  18800. * Set a texture array in the shader.
  18801. * @param name Define the name of the uniform sampler array as defined in the shader
  18802. * @param textures Define the list of textures to bind to this sampler
  18803. * @return the material itself allowing "fluent" like uniform updates
  18804. */
  18805. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18806. /**
  18807. * Set a float in the shader.
  18808. * @param name Define the name of the uniform as defined in the shader
  18809. * @param value Define the value to give to the uniform
  18810. * @return the material itself allowing "fluent" like uniform updates
  18811. */
  18812. setFloat(name: string, value: number): ShaderMaterial;
  18813. /**
  18814. * Set a int in the shader.
  18815. * @param name Define the name of the uniform as defined in the shader
  18816. * @param value Define the value to give to the uniform
  18817. * @return the material itself allowing "fluent" like uniform updates
  18818. */
  18819. setInt(name: string, value: number): ShaderMaterial;
  18820. /**
  18821. * Set an array of floats in the shader.
  18822. * @param name Define the name of the uniform as defined in the shader
  18823. * @param value Define the value to give to the uniform
  18824. * @return the material itself allowing "fluent" like uniform updates
  18825. */
  18826. setFloats(name: string, value: number[]): ShaderMaterial;
  18827. /**
  18828. * Set a vec3 in the shader from a Color3.
  18829. * @param name Define the name of the uniform as defined in the shader
  18830. * @param value Define the value to give to the uniform
  18831. * @return the material itself allowing "fluent" like uniform updates
  18832. */
  18833. setColor3(name: string, value: Color3): ShaderMaterial;
  18834. /**
  18835. * Set a vec3 array in the shader from a Color3 array.
  18836. * @param name Define the name of the uniform as defined in the shader
  18837. * @param value Define the value to give to the uniform
  18838. * @return the material itself allowing "fluent" like uniform updates
  18839. */
  18840. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18841. /**
  18842. * Set a vec4 in the shader from a Color4.
  18843. * @param name Define the name of the uniform as defined in the shader
  18844. * @param value Define the value to give to the uniform
  18845. * @return the material itself allowing "fluent" like uniform updates
  18846. */
  18847. setColor4(name: string, value: Color4): ShaderMaterial;
  18848. /**
  18849. * Set a vec4 array in the shader from a Color4 array.
  18850. * @param name Define the name of the uniform as defined in the shader
  18851. * @param value Define the value to give to the uniform
  18852. * @return the material itself allowing "fluent" like uniform updates
  18853. */
  18854. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18855. /**
  18856. * Set a vec2 in the shader from a Vector2.
  18857. * @param name Define the name of the uniform as defined in the shader
  18858. * @param value Define the value to give to the uniform
  18859. * @return the material itself allowing "fluent" like uniform updates
  18860. */
  18861. setVector2(name: string, value: Vector2): ShaderMaterial;
  18862. /**
  18863. * Set a vec3 in the shader from a Vector3.
  18864. * @param name Define the name of the uniform as defined in the shader
  18865. * @param value Define the value to give to the uniform
  18866. * @return the material itself allowing "fluent" like uniform updates
  18867. */
  18868. setVector3(name: string, value: Vector3): ShaderMaterial;
  18869. /**
  18870. * Set a vec4 in the shader from a Vector4.
  18871. * @param name Define the name of the uniform as defined in the shader
  18872. * @param value Define the value to give to the uniform
  18873. * @return the material itself allowing "fluent" like uniform updates
  18874. */
  18875. setVector4(name: string, value: Vector4): ShaderMaterial;
  18876. /**
  18877. * Set a mat4 in the shader from a Matrix.
  18878. * @param name Define the name of the uniform as defined in the shader
  18879. * @param value Define the value to give to the uniform
  18880. * @return the material itself allowing "fluent" like uniform updates
  18881. */
  18882. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18883. /**
  18884. * Set a mat3 in the shader from a Float32Array.
  18885. * @param name Define the name of the uniform as defined in the shader
  18886. * @param value Define the value to give to the uniform
  18887. * @return the material itself allowing "fluent" like uniform updates
  18888. */
  18889. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18890. /**
  18891. * Set a mat2 in the shader from a Float32Array.
  18892. * @param name Define the name of the uniform as defined in the shader
  18893. * @param value Define the value to give to the uniform
  18894. * @return the material itself allowing "fluent" like uniform updates
  18895. */
  18896. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18897. /**
  18898. * Set a vec2 array in the shader from a number array.
  18899. * @param name Define the name of the uniform as defined in the shader
  18900. * @param value Define the value to give to the uniform
  18901. * @return the material itself allowing "fluent" like uniform updates
  18902. */
  18903. setArray2(name: string, value: number[]): ShaderMaterial;
  18904. /**
  18905. * Set a vec3 array in the shader from a number array.
  18906. * @param name Define the name of the uniform as defined in the shader
  18907. * @param value Define the value to give to the uniform
  18908. * @return the material itself allowing "fluent" like uniform updates
  18909. */
  18910. setArray3(name: string, value: number[]): ShaderMaterial;
  18911. /**
  18912. * Set a vec4 array in the shader from a number array.
  18913. * @param name Define the name of the uniform as defined in the shader
  18914. * @param value Define the value to give to the uniform
  18915. * @return the material itself allowing "fluent" like uniform updates
  18916. */
  18917. setArray4(name: string, value: number[]): ShaderMaterial;
  18918. private _checkCache;
  18919. /**
  18920. * Specifies that the submesh is ready to be used
  18921. * @param mesh defines the mesh to check
  18922. * @param subMesh defines which submesh to check
  18923. * @param useInstances specifies that instances should be used
  18924. * @returns a boolean indicating that the submesh is ready or not
  18925. */
  18926. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18927. /**
  18928. * Checks if the material is ready to render the requested mesh
  18929. * @param mesh Define the mesh to render
  18930. * @param useInstances Define whether or not the material is used with instances
  18931. * @returns true if ready, otherwise false
  18932. */
  18933. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18934. /**
  18935. * Binds the world matrix to the material
  18936. * @param world defines the world transformation matrix
  18937. */
  18938. bindOnlyWorldMatrix(world: Matrix): void;
  18939. /**
  18940. * Binds the material to the mesh
  18941. * @param world defines the world transformation matrix
  18942. * @param mesh defines the mesh to bind the material to
  18943. */
  18944. bind(world: Matrix, mesh?: Mesh): void;
  18945. /**
  18946. * Gets the active textures from the material
  18947. * @returns an array of textures
  18948. */
  18949. getActiveTextures(): BaseTexture[];
  18950. /**
  18951. * Specifies if the material uses a texture
  18952. * @param texture defines the texture to check against the material
  18953. * @returns a boolean specifying if the material uses the texture
  18954. */
  18955. hasTexture(texture: BaseTexture): boolean;
  18956. /**
  18957. * Makes a duplicate of the material, and gives it a new name
  18958. * @param name defines the new name for the duplicated material
  18959. * @returns the cloned material
  18960. */
  18961. clone(name: string): ShaderMaterial;
  18962. /**
  18963. * Disposes the material
  18964. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18965. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18966. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18967. */
  18968. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18969. /**
  18970. * Serializes this material in a JSON representation
  18971. * @returns the serialized material object
  18972. */
  18973. serialize(): any;
  18974. /**
  18975. * Creates a shader material from parsed shader material data
  18976. * @param source defines the JSON represnetation of the material
  18977. * @param scene defines the hosting scene
  18978. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18979. * @returns a new material
  18980. */
  18981. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18982. }
  18983. }
  18984. declare module BABYLON {
  18985. /** @hidden */
  18986. export var colorPixelShader: {
  18987. name: string;
  18988. shader: string;
  18989. };
  18990. }
  18991. declare module BABYLON {
  18992. /** @hidden */
  18993. export var colorVertexShader: {
  18994. name: string;
  18995. shader: string;
  18996. };
  18997. }
  18998. declare module BABYLON {
  18999. /**
  19000. * Line mesh
  19001. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19002. */
  19003. export class LinesMesh extends Mesh {
  19004. /**
  19005. * If vertex color should be applied to the mesh
  19006. */
  19007. readonly useVertexColor?: boolean | undefined;
  19008. /**
  19009. * If vertex alpha should be applied to the mesh
  19010. */
  19011. readonly useVertexAlpha?: boolean | undefined;
  19012. /**
  19013. * Color of the line (Default: White)
  19014. */
  19015. color: Color3;
  19016. /**
  19017. * Alpha of the line (Default: 1)
  19018. */
  19019. alpha: number;
  19020. /**
  19021. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19022. * This margin is expressed in world space coordinates, so its value may vary.
  19023. * Default value is 0.1
  19024. */
  19025. intersectionThreshold: number;
  19026. private _colorShader;
  19027. private color4;
  19028. /**
  19029. * Creates a new LinesMesh
  19030. * @param name defines the name
  19031. * @param scene defines the hosting scene
  19032. * @param parent defines the parent mesh if any
  19033. * @param source defines the optional source LinesMesh used to clone data from
  19034. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19035. * When false, achieved by calling a clone(), also passing False.
  19036. * This will make creation of children, recursive.
  19037. * @param useVertexColor defines if this LinesMesh supports vertex color
  19038. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19039. */
  19040. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19041. /**
  19042. * If vertex color should be applied to the mesh
  19043. */
  19044. useVertexColor?: boolean | undefined,
  19045. /**
  19046. * If vertex alpha should be applied to the mesh
  19047. */
  19048. useVertexAlpha?: boolean | undefined);
  19049. private _addClipPlaneDefine;
  19050. private _removeClipPlaneDefine;
  19051. isReady(): boolean;
  19052. /**
  19053. * Returns the string "LineMesh"
  19054. */
  19055. getClassName(): string;
  19056. /**
  19057. * @hidden
  19058. */
  19059. /**
  19060. * @hidden
  19061. */
  19062. material: Material;
  19063. /**
  19064. * @hidden
  19065. */
  19066. readonly checkCollisions: boolean;
  19067. /** @hidden */
  19068. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19069. /** @hidden */
  19070. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19071. /**
  19072. * Disposes of the line mesh
  19073. * @param doNotRecurse If children should be disposed
  19074. */
  19075. dispose(doNotRecurse?: boolean): void;
  19076. /**
  19077. * Returns a new LineMesh object cloned from the current one.
  19078. */
  19079. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19080. /**
  19081. * Creates a new InstancedLinesMesh object from the mesh model.
  19082. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19083. * @param name defines the name of the new instance
  19084. * @returns a new InstancedLinesMesh
  19085. */
  19086. createInstance(name: string): InstancedLinesMesh;
  19087. }
  19088. /**
  19089. * Creates an instance based on a source LinesMesh
  19090. */
  19091. export class InstancedLinesMesh extends InstancedMesh {
  19092. /**
  19093. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19094. * This margin is expressed in world space coordinates, so its value may vary.
  19095. * Initilized with the intersectionThreshold value of the source LinesMesh
  19096. */
  19097. intersectionThreshold: number;
  19098. constructor(name: string, source: LinesMesh);
  19099. /**
  19100. * Returns the string "InstancedLinesMesh".
  19101. */
  19102. getClassName(): string;
  19103. }
  19104. }
  19105. declare module BABYLON {
  19106. /** @hidden */
  19107. export var linePixelShader: {
  19108. name: string;
  19109. shader: string;
  19110. };
  19111. }
  19112. declare module BABYLON {
  19113. /** @hidden */
  19114. export var lineVertexShader: {
  19115. name: string;
  19116. shader: string;
  19117. };
  19118. }
  19119. declare module BABYLON {
  19120. interface AbstractMesh {
  19121. /**
  19122. * Gets the edgesRenderer associated with the mesh
  19123. */
  19124. edgesRenderer: Nullable<EdgesRenderer>;
  19125. }
  19126. interface LinesMesh {
  19127. /**
  19128. * Enables the edge rendering mode on the mesh.
  19129. * This mode makes the mesh edges visible
  19130. * @param epsilon defines the maximal distance between two angles to detect a face
  19131. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19132. * @returns the currentAbstractMesh
  19133. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19134. */
  19135. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19136. }
  19137. interface InstancedLinesMesh {
  19138. /**
  19139. * Enables the edge rendering mode on the mesh.
  19140. * This mode makes the mesh edges visible
  19141. * @param epsilon defines the maximal distance between two angles to detect a face
  19142. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19143. * @returns the current InstancedLinesMesh
  19144. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19145. */
  19146. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19147. }
  19148. /**
  19149. * Defines the minimum contract an Edges renderer should follow.
  19150. */
  19151. export interface IEdgesRenderer extends IDisposable {
  19152. /**
  19153. * Gets or sets a boolean indicating if the edgesRenderer is active
  19154. */
  19155. isEnabled: boolean;
  19156. /**
  19157. * Renders the edges of the attached mesh,
  19158. */
  19159. render(): void;
  19160. /**
  19161. * Checks wether or not the edges renderer is ready to render.
  19162. * @return true if ready, otherwise false.
  19163. */
  19164. isReady(): boolean;
  19165. }
  19166. /**
  19167. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19168. */
  19169. export class EdgesRenderer implements IEdgesRenderer {
  19170. /**
  19171. * Define the size of the edges with an orthographic camera
  19172. */
  19173. edgesWidthScalerForOrthographic: number;
  19174. /**
  19175. * Define the size of the edges with a perspective camera
  19176. */
  19177. edgesWidthScalerForPerspective: number;
  19178. protected _source: AbstractMesh;
  19179. protected _linesPositions: number[];
  19180. protected _linesNormals: number[];
  19181. protected _linesIndices: number[];
  19182. protected _epsilon: number;
  19183. protected _indicesCount: number;
  19184. protected _lineShader: ShaderMaterial;
  19185. protected _ib: DataBuffer;
  19186. protected _buffers: {
  19187. [key: string]: Nullable<VertexBuffer>;
  19188. };
  19189. protected _checkVerticesInsteadOfIndices: boolean;
  19190. private _meshRebuildObserver;
  19191. private _meshDisposeObserver;
  19192. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19193. isEnabled: boolean;
  19194. /**
  19195. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19196. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19197. * @param source Mesh used to create edges
  19198. * @param epsilon sum of angles in adjacency to check for edge
  19199. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19200. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19201. */
  19202. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19203. protected _prepareRessources(): void;
  19204. /** @hidden */
  19205. _rebuild(): void;
  19206. /**
  19207. * Releases the required resources for the edges renderer
  19208. */
  19209. dispose(): void;
  19210. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19211. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19212. /**
  19213. * Checks if the pair of p0 and p1 is en edge
  19214. * @param faceIndex
  19215. * @param edge
  19216. * @param faceNormals
  19217. * @param p0
  19218. * @param p1
  19219. * @private
  19220. */
  19221. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19222. /**
  19223. * push line into the position, normal and index buffer
  19224. * @protected
  19225. */
  19226. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19227. /**
  19228. * Generates lines edges from adjacencjes
  19229. * @private
  19230. */
  19231. _generateEdgesLines(): void;
  19232. /**
  19233. * Checks wether or not the edges renderer is ready to render.
  19234. * @return true if ready, otherwise false.
  19235. */
  19236. isReady(): boolean;
  19237. /**
  19238. * Renders the edges of the attached mesh,
  19239. */
  19240. render(): void;
  19241. }
  19242. /**
  19243. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19244. */
  19245. export class LineEdgesRenderer extends EdgesRenderer {
  19246. /**
  19247. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19248. * @param source LineMesh used to generate edges
  19249. * @param epsilon not important (specified angle for edge detection)
  19250. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19251. */
  19252. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19253. /**
  19254. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19255. */
  19256. _generateEdgesLines(): void;
  19257. }
  19258. }
  19259. declare module BABYLON {
  19260. /**
  19261. * This represents the object necessary to create a rendering group.
  19262. * This is exclusively used and created by the rendering manager.
  19263. * To modify the behavior, you use the available helpers in your scene or meshes.
  19264. * @hidden
  19265. */
  19266. export class RenderingGroup {
  19267. index: number;
  19268. private static _zeroVector;
  19269. private _scene;
  19270. private _opaqueSubMeshes;
  19271. private _transparentSubMeshes;
  19272. private _alphaTestSubMeshes;
  19273. private _depthOnlySubMeshes;
  19274. private _particleSystems;
  19275. private _spriteManagers;
  19276. private _opaqueSortCompareFn;
  19277. private _alphaTestSortCompareFn;
  19278. private _transparentSortCompareFn;
  19279. private _renderOpaque;
  19280. private _renderAlphaTest;
  19281. private _renderTransparent;
  19282. /** @hidden */
  19283. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19284. onBeforeTransparentRendering: () => void;
  19285. /**
  19286. * Set the opaque sort comparison function.
  19287. * If null the sub meshes will be render in the order they were created
  19288. */
  19289. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19290. /**
  19291. * Set the alpha test sort comparison function.
  19292. * If null the sub meshes will be render in the order they were created
  19293. */
  19294. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19295. /**
  19296. * Set the transparent sort comparison function.
  19297. * If null the sub meshes will be render in the order they were created
  19298. */
  19299. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19300. /**
  19301. * Creates a new rendering group.
  19302. * @param index The rendering group index
  19303. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19304. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19305. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19306. */
  19307. 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>);
  19308. /**
  19309. * Render all the sub meshes contained in the group.
  19310. * @param customRenderFunction Used to override the default render behaviour of the group.
  19311. * @returns true if rendered some submeshes.
  19312. */
  19313. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19314. /**
  19315. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19316. * @param subMeshes The submeshes to render
  19317. */
  19318. private renderOpaqueSorted;
  19319. /**
  19320. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19321. * @param subMeshes The submeshes to render
  19322. */
  19323. private renderAlphaTestSorted;
  19324. /**
  19325. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19326. * @param subMeshes The submeshes to render
  19327. */
  19328. private renderTransparentSorted;
  19329. /**
  19330. * Renders the submeshes in a specified order.
  19331. * @param subMeshes The submeshes to sort before render
  19332. * @param sortCompareFn The comparison function use to sort
  19333. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19334. * @param transparent Specifies to activate blending if true
  19335. */
  19336. private static renderSorted;
  19337. /**
  19338. * Renders the submeshes in the order they were dispatched (no sort applied).
  19339. * @param subMeshes The submeshes to render
  19340. */
  19341. private static renderUnsorted;
  19342. /**
  19343. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19344. * are rendered back to front if in the same alpha index.
  19345. *
  19346. * @param a The first submesh
  19347. * @param b The second submesh
  19348. * @returns The result of the comparison
  19349. */
  19350. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19351. /**
  19352. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19353. * are rendered back to front.
  19354. *
  19355. * @param a The first submesh
  19356. * @param b The second submesh
  19357. * @returns The result of the comparison
  19358. */
  19359. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19360. /**
  19361. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19362. * are rendered front to back (prevent overdraw).
  19363. *
  19364. * @param a The first submesh
  19365. * @param b The second submesh
  19366. * @returns The result of the comparison
  19367. */
  19368. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19369. /**
  19370. * Resets the different lists of submeshes to prepare a new frame.
  19371. */
  19372. prepare(): void;
  19373. dispose(): void;
  19374. /**
  19375. * Inserts the submesh in its correct queue depending on its material.
  19376. * @param subMesh The submesh to dispatch
  19377. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19378. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19379. */
  19380. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19381. dispatchSprites(spriteManager: ISpriteManager): void;
  19382. dispatchParticles(particleSystem: IParticleSystem): void;
  19383. private _renderParticles;
  19384. private _renderSprites;
  19385. }
  19386. }
  19387. declare module BABYLON {
  19388. /**
  19389. * Interface describing the different options available in the rendering manager
  19390. * regarding Auto Clear between groups.
  19391. */
  19392. export interface IRenderingManagerAutoClearSetup {
  19393. /**
  19394. * Defines whether or not autoclear is enable.
  19395. */
  19396. autoClear: boolean;
  19397. /**
  19398. * Defines whether or not to autoclear the depth buffer.
  19399. */
  19400. depth: boolean;
  19401. /**
  19402. * Defines whether or not to autoclear the stencil buffer.
  19403. */
  19404. stencil: boolean;
  19405. }
  19406. /**
  19407. * This class is used by the onRenderingGroupObservable
  19408. */
  19409. export class RenderingGroupInfo {
  19410. /**
  19411. * The Scene that being rendered
  19412. */
  19413. scene: Scene;
  19414. /**
  19415. * The camera currently used for the rendering pass
  19416. */
  19417. camera: Nullable<Camera>;
  19418. /**
  19419. * The ID of the renderingGroup being processed
  19420. */
  19421. renderingGroupId: number;
  19422. }
  19423. /**
  19424. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19425. * It is enable to manage the different groups as well as the different necessary sort functions.
  19426. * This should not be used directly aside of the few static configurations
  19427. */
  19428. export class RenderingManager {
  19429. /**
  19430. * The max id used for rendering groups (not included)
  19431. */
  19432. static MAX_RENDERINGGROUPS: number;
  19433. /**
  19434. * The min id used for rendering groups (included)
  19435. */
  19436. static MIN_RENDERINGGROUPS: number;
  19437. /**
  19438. * Used to globally prevent autoclearing scenes.
  19439. */
  19440. static AUTOCLEAR: boolean;
  19441. /**
  19442. * @hidden
  19443. */
  19444. _useSceneAutoClearSetup: boolean;
  19445. private _scene;
  19446. private _renderingGroups;
  19447. private _depthStencilBufferAlreadyCleaned;
  19448. private _autoClearDepthStencil;
  19449. private _customOpaqueSortCompareFn;
  19450. private _customAlphaTestSortCompareFn;
  19451. private _customTransparentSortCompareFn;
  19452. private _renderingGroupInfo;
  19453. /**
  19454. * Instantiates a new rendering group for a particular scene
  19455. * @param scene Defines the scene the groups belongs to
  19456. */
  19457. constructor(scene: Scene);
  19458. private _clearDepthStencilBuffer;
  19459. /**
  19460. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19461. * @hidden
  19462. */
  19463. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19464. /**
  19465. * Resets the different information of the group to prepare a new frame
  19466. * @hidden
  19467. */
  19468. reset(): void;
  19469. /**
  19470. * Dispose and release the group and its associated resources.
  19471. * @hidden
  19472. */
  19473. dispose(): void;
  19474. /**
  19475. * Clear the info related to rendering groups preventing retention points during dispose.
  19476. */
  19477. freeRenderingGroups(): void;
  19478. private _prepareRenderingGroup;
  19479. /**
  19480. * Add a sprite manager to the rendering manager in order to render it this frame.
  19481. * @param spriteManager Define the sprite manager to render
  19482. */
  19483. dispatchSprites(spriteManager: ISpriteManager): void;
  19484. /**
  19485. * Add a particle system to the rendering manager in order to render it this frame.
  19486. * @param particleSystem Define the particle system to render
  19487. */
  19488. dispatchParticles(particleSystem: IParticleSystem): void;
  19489. /**
  19490. * Add a submesh to the manager in order to render it this frame
  19491. * @param subMesh The submesh to dispatch
  19492. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19493. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19494. */
  19495. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19496. /**
  19497. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19498. * This allowed control for front to back rendering or reversly depending of the special needs.
  19499. *
  19500. * @param renderingGroupId The rendering group id corresponding to its index
  19501. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19502. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19503. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19504. */
  19505. 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;
  19506. /**
  19507. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19508. *
  19509. * @param renderingGroupId The rendering group id corresponding to its index
  19510. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19511. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19512. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19513. */
  19514. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19515. /**
  19516. * Gets the current auto clear configuration for one rendering group of the rendering
  19517. * manager.
  19518. * @param index the rendering group index to get the information for
  19519. * @returns The auto clear setup for the requested rendering group
  19520. */
  19521. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19522. }
  19523. }
  19524. declare module BABYLON {
  19525. /**
  19526. * This Helps creating a texture that will be created from a camera in your scene.
  19527. * It is basically a dynamic texture that could be used to create special effects for instance.
  19528. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19529. */
  19530. export class RenderTargetTexture extends Texture {
  19531. isCube: boolean;
  19532. /**
  19533. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19534. */
  19535. static readonly REFRESHRATE_RENDER_ONCE: number;
  19536. /**
  19537. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19538. */
  19539. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19540. /**
  19541. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19542. * the central point of your effect and can save a lot of performances.
  19543. */
  19544. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19545. /**
  19546. * Use this predicate to dynamically define the list of mesh you want to render.
  19547. * If set, the renderList property will be overwritten.
  19548. */
  19549. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19550. private _renderList;
  19551. /**
  19552. * Use this list to define the list of mesh you want to render.
  19553. */
  19554. renderList: Nullable<Array<AbstractMesh>>;
  19555. private _hookArray;
  19556. /**
  19557. * Define if particles should be rendered in your texture.
  19558. */
  19559. renderParticles: boolean;
  19560. /**
  19561. * Define if sprites should be rendered in your texture.
  19562. */
  19563. renderSprites: boolean;
  19564. /**
  19565. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19566. */
  19567. coordinatesMode: number;
  19568. /**
  19569. * Define the camera used to render the texture.
  19570. */
  19571. activeCamera: Nullable<Camera>;
  19572. /**
  19573. * Override the render function of the texture with your own one.
  19574. */
  19575. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19576. /**
  19577. * Define if camera post processes should be use while rendering the texture.
  19578. */
  19579. useCameraPostProcesses: boolean;
  19580. /**
  19581. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19582. */
  19583. ignoreCameraViewport: boolean;
  19584. private _postProcessManager;
  19585. private _postProcesses;
  19586. private _resizeObserver;
  19587. /**
  19588. * An event triggered when the texture is unbind.
  19589. */
  19590. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19591. /**
  19592. * An event triggered when the texture is unbind.
  19593. */
  19594. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19595. private _onAfterUnbindObserver;
  19596. /**
  19597. * Set a after unbind callback in the texture.
  19598. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19599. */
  19600. onAfterUnbind: () => void;
  19601. /**
  19602. * An event triggered before rendering the texture
  19603. */
  19604. onBeforeRenderObservable: Observable<number>;
  19605. private _onBeforeRenderObserver;
  19606. /**
  19607. * Set a before render callback in the texture.
  19608. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19609. */
  19610. onBeforeRender: (faceIndex: number) => void;
  19611. /**
  19612. * An event triggered after rendering the texture
  19613. */
  19614. onAfterRenderObservable: Observable<number>;
  19615. private _onAfterRenderObserver;
  19616. /**
  19617. * Set a after render callback in the texture.
  19618. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19619. */
  19620. onAfterRender: (faceIndex: number) => void;
  19621. /**
  19622. * An event triggered after the texture clear
  19623. */
  19624. onClearObservable: Observable<Engine>;
  19625. private _onClearObserver;
  19626. /**
  19627. * Set a clear callback in the texture.
  19628. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19629. */
  19630. onClear: (Engine: Engine) => void;
  19631. /**
  19632. * An event triggered when the texture is resized.
  19633. */
  19634. onResizeObservable: Observable<RenderTargetTexture>;
  19635. /**
  19636. * Define the clear color of the Render Target if it should be different from the scene.
  19637. */
  19638. clearColor: Color4;
  19639. protected _size: number | {
  19640. width: number;
  19641. height: number;
  19642. };
  19643. protected _initialSizeParameter: number | {
  19644. width: number;
  19645. height: number;
  19646. } | {
  19647. ratio: number;
  19648. };
  19649. protected _sizeRatio: Nullable<number>;
  19650. /** @hidden */
  19651. _generateMipMaps: boolean;
  19652. protected _renderingManager: RenderingManager;
  19653. /** @hidden */
  19654. _waitingRenderList: string[];
  19655. protected _doNotChangeAspectRatio: boolean;
  19656. protected _currentRefreshId: number;
  19657. protected _refreshRate: number;
  19658. protected _textureMatrix: Matrix;
  19659. protected _samples: number;
  19660. protected _renderTargetOptions: RenderTargetCreationOptions;
  19661. /**
  19662. * Gets render target creation options that were used.
  19663. */
  19664. readonly renderTargetOptions: RenderTargetCreationOptions;
  19665. protected _engine: Engine;
  19666. protected _onRatioRescale(): void;
  19667. /**
  19668. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19669. * It must define where the camera used to render the texture is set
  19670. */
  19671. boundingBoxPosition: Vector3;
  19672. private _boundingBoxSize;
  19673. /**
  19674. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19675. * When defined, the cubemap will switch to local mode
  19676. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19677. * @example https://www.babylonjs-playground.com/#RNASML
  19678. */
  19679. boundingBoxSize: Vector3;
  19680. /**
  19681. * In case the RTT has been created with a depth texture, get the associated
  19682. * depth texture.
  19683. * Otherwise, return null.
  19684. */
  19685. depthStencilTexture: Nullable<InternalTexture>;
  19686. /**
  19687. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19688. * or used a shadow, depth texture...
  19689. * @param name The friendly name of the texture
  19690. * @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)
  19691. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19692. * @param generateMipMaps True if mip maps need to be generated after render.
  19693. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19694. * @param type The type of the buffer in the RTT (int, half float, float...)
  19695. * @param isCube True if a cube texture needs to be created
  19696. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19697. * @param generateDepthBuffer True to generate a depth buffer
  19698. * @param generateStencilBuffer True to generate a stencil buffer
  19699. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19700. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19701. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19702. */
  19703. constructor(name: string, size: number | {
  19704. width: number;
  19705. height: number;
  19706. } | {
  19707. ratio: number;
  19708. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19709. /**
  19710. * Creates a depth stencil texture.
  19711. * This is only available in WebGL 2 or with the depth texture extension available.
  19712. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19713. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19714. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19715. */
  19716. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19717. private _processSizeParameter;
  19718. /**
  19719. * Define the number of samples to use in case of MSAA.
  19720. * It defaults to one meaning no MSAA has been enabled.
  19721. */
  19722. samples: number;
  19723. /**
  19724. * Resets the refresh counter of the texture and start bak from scratch.
  19725. * Could be useful to regenerate the texture if it is setup to render only once.
  19726. */
  19727. resetRefreshCounter(): void;
  19728. /**
  19729. * Define the refresh rate of the texture or the rendering frequency.
  19730. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19731. */
  19732. refreshRate: number;
  19733. /**
  19734. * Adds a post process to the render target rendering passes.
  19735. * @param postProcess define the post process to add
  19736. */
  19737. addPostProcess(postProcess: PostProcess): void;
  19738. /**
  19739. * Clear all the post processes attached to the render target
  19740. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19741. */
  19742. clearPostProcesses(dispose?: boolean): void;
  19743. /**
  19744. * Remove one of the post process from the list of attached post processes to the texture
  19745. * @param postProcess define the post process to remove from the list
  19746. */
  19747. removePostProcess(postProcess: PostProcess): void;
  19748. /** @hidden */
  19749. _shouldRender(): boolean;
  19750. /**
  19751. * Gets the actual render size of the texture.
  19752. * @returns the width of the render size
  19753. */
  19754. getRenderSize(): number;
  19755. /**
  19756. * Gets the actual render width of the texture.
  19757. * @returns the width of the render size
  19758. */
  19759. getRenderWidth(): number;
  19760. /**
  19761. * Gets the actual render height of the texture.
  19762. * @returns the height of the render size
  19763. */
  19764. getRenderHeight(): number;
  19765. /**
  19766. * Get if the texture can be rescaled or not.
  19767. */
  19768. readonly canRescale: boolean;
  19769. /**
  19770. * Resize the texture using a ratio.
  19771. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19772. */
  19773. scale(ratio: number): void;
  19774. /**
  19775. * Get the texture reflection matrix used to rotate/transform the reflection.
  19776. * @returns the reflection matrix
  19777. */
  19778. getReflectionTextureMatrix(): Matrix;
  19779. /**
  19780. * Resize the texture to a new desired size.
  19781. * Be carrefull as it will recreate all the data in the new texture.
  19782. * @param size Define the new size. It can be:
  19783. * - a number for squared texture,
  19784. * - an object containing { width: number, height: number }
  19785. * - or an object containing a ratio { ratio: number }
  19786. */
  19787. resize(size: number | {
  19788. width: number;
  19789. height: number;
  19790. } | {
  19791. ratio: number;
  19792. }): void;
  19793. /**
  19794. * Renders all the objects from the render list into the texture.
  19795. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19796. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19797. */
  19798. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19799. private _bestReflectionRenderTargetDimension;
  19800. /**
  19801. * @hidden
  19802. * @param faceIndex face index to bind to if this is a cubetexture
  19803. */
  19804. _bindFrameBuffer(faceIndex?: number): void;
  19805. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19806. private renderToTarget;
  19807. /**
  19808. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19809. * This allowed control for front to back rendering or reversly depending of the special needs.
  19810. *
  19811. * @param renderingGroupId The rendering group id corresponding to its index
  19812. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19813. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19814. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19815. */
  19816. 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;
  19817. /**
  19818. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19819. *
  19820. * @param renderingGroupId The rendering group id corresponding to its index
  19821. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19822. */
  19823. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19824. /**
  19825. * Clones the texture.
  19826. * @returns the cloned texture
  19827. */
  19828. clone(): RenderTargetTexture;
  19829. /**
  19830. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19831. * @returns The JSON representation of the texture
  19832. */
  19833. serialize(): any;
  19834. /**
  19835. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19836. */
  19837. disposeFramebufferObjects(): void;
  19838. /**
  19839. * Dispose the texture and release its associated resources.
  19840. */
  19841. dispose(): void;
  19842. /** @hidden */
  19843. _rebuild(): void;
  19844. /**
  19845. * Clear the info related to rendering groups preventing retention point in material dispose.
  19846. */
  19847. freeRenderingGroups(): void;
  19848. /**
  19849. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19850. * @returns the view count
  19851. */
  19852. getViewCount(): number;
  19853. }
  19854. }
  19855. declare module BABYLON {
  19856. /**
  19857. * Base class for the main features of a material in Babylon.js
  19858. */
  19859. export class Material implements IAnimatable {
  19860. /**
  19861. * Returns the triangle fill mode
  19862. */
  19863. static readonly TriangleFillMode: number;
  19864. /**
  19865. * Returns the wireframe mode
  19866. */
  19867. static readonly WireFrameFillMode: number;
  19868. /**
  19869. * Returns the point fill mode
  19870. */
  19871. static readonly PointFillMode: number;
  19872. /**
  19873. * Returns the point list draw mode
  19874. */
  19875. static readonly PointListDrawMode: number;
  19876. /**
  19877. * Returns the line list draw mode
  19878. */
  19879. static readonly LineListDrawMode: number;
  19880. /**
  19881. * Returns the line loop draw mode
  19882. */
  19883. static readonly LineLoopDrawMode: number;
  19884. /**
  19885. * Returns the line strip draw mode
  19886. */
  19887. static readonly LineStripDrawMode: number;
  19888. /**
  19889. * Returns the triangle strip draw mode
  19890. */
  19891. static readonly TriangleStripDrawMode: number;
  19892. /**
  19893. * Returns the triangle fan draw mode
  19894. */
  19895. static readonly TriangleFanDrawMode: number;
  19896. /**
  19897. * Stores the clock-wise side orientation
  19898. */
  19899. static readonly ClockWiseSideOrientation: number;
  19900. /**
  19901. * Stores the counter clock-wise side orientation
  19902. */
  19903. static readonly CounterClockWiseSideOrientation: number;
  19904. /**
  19905. * The dirty texture flag value
  19906. */
  19907. static readonly TextureDirtyFlag: number;
  19908. /**
  19909. * The dirty light flag value
  19910. */
  19911. static readonly LightDirtyFlag: number;
  19912. /**
  19913. * The dirty fresnel flag value
  19914. */
  19915. static readonly FresnelDirtyFlag: number;
  19916. /**
  19917. * The dirty attribute flag value
  19918. */
  19919. static readonly AttributesDirtyFlag: number;
  19920. /**
  19921. * The dirty misc flag value
  19922. */
  19923. static readonly MiscDirtyFlag: number;
  19924. /**
  19925. * The all dirty flag value
  19926. */
  19927. static readonly AllDirtyFlag: number;
  19928. /**
  19929. * The ID of the material
  19930. */
  19931. id: string;
  19932. /**
  19933. * Gets or sets the unique id of the material
  19934. */
  19935. uniqueId: number;
  19936. /**
  19937. * The name of the material
  19938. */
  19939. name: string;
  19940. /**
  19941. * Gets or sets user defined metadata
  19942. */
  19943. metadata: any;
  19944. /**
  19945. * For internal use only. Please do not use.
  19946. */
  19947. reservedDataStore: any;
  19948. /**
  19949. * Specifies if the ready state should be checked on each call
  19950. */
  19951. checkReadyOnEveryCall: boolean;
  19952. /**
  19953. * Specifies if the ready state should be checked once
  19954. */
  19955. checkReadyOnlyOnce: boolean;
  19956. /**
  19957. * The state of the material
  19958. */
  19959. state: string;
  19960. /**
  19961. * The alpha value of the material
  19962. */
  19963. protected _alpha: number;
  19964. /**
  19965. * List of inspectable custom properties (used by the Inspector)
  19966. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19967. */
  19968. inspectableCustomProperties: IInspectable[];
  19969. /**
  19970. * Sets the alpha value of the material
  19971. */
  19972. /**
  19973. * Gets the alpha value of the material
  19974. */
  19975. alpha: number;
  19976. /**
  19977. * Specifies if back face culling is enabled
  19978. */
  19979. protected _backFaceCulling: boolean;
  19980. /**
  19981. * Sets the back-face culling state
  19982. */
  19983. /**
  19984. * Gets the back-face culling state
  19985. */
  19986. backFaceCulling: boolean;
  19987. /**
  19988. * Stores the value for side orientation
  19989. */
  19990. sideOrientation: number;
  19991. /**
  19992. * Callback triggered when the material is compiled
  19993. */
  19994. onCompiled: Nullable<(effect: Effect) => void>;
  19995. /**
  19996. * Callback triggered when an error occurs
  19997. */
  19998. onError: Nullable<(effect: Effect, errors: string) => void>;
  19999. /**
  20000. * Callback triggered to get the render target textures
  20001. */
  20002. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20003. /**
  20004. * Gets a boolean indicating that current material needs to register RTT
  20005. */
  20006. readonly hasRenderTargetTextures: boolean;
  20007. /**
  20008. * Specifies if the material should be serialized
  20009. */
  20010. doNotSerialize: boolean;
  20011. /**
  20012. * @hidden
  20013. */
  20014. _storeEffectOnSubMeshes: boolean;
  20015. /**
  20016. * Stores the animations for the material
  20017. */
  20018. animations: Nullable<Array<Animation>>;
  20019. /**
  20020. * An event triggered when the material is disposed
  20021. */
  20022. onDisposeObservable: Observable<Material>;
  20023. /**
  20024. * An observer which watches for dispose events
  20025. */
  20026. private _onDisposeObserver;
  20027. private _onUnBindObservable;
  20028. /**
  20029. * Called during a dispose event
  20030. */
  20031. onDispose: () => void;
  20032. private _onBindObservable;
  20033. /**
  20034. * An event triggered when the material is bound
  20035. */
  20036. readonly onBindObservable: Observable<AbstractMesh>;
  20037. /**
  20038. * An observer which watches for bind events
  20039. */
  20040. private _onBindObserver;
  20041. /**
  20042. * Called during a bind event
  20043. */
  20044. onBind: (Mesh: AbstractMesh) => void;
  20045. /**
  20046. * An event triggered when the material is unbound
  20047. */
  20048. readonly onUnBindObservable: Observable<Material>;
  20049. /**
  20050. * Stores the value of the alpha mode
  20051. */
  20052. private _alphaMode;
  20053. /**
  20054. * Sets the value of the alpha mode.
  20055. *
  20056. * | Value | Type | Description |
  20057. * | --- | --- | --- |
  20058. * | 0 | ALPHA_DISABLE | |
  20059. * | 1 | ALPHA_ADD | |
  20060. * | 2 | ALPHA_COMBINE | |
  20061. * | 3 | ALPHA_SUBTRACT | |
  20062. * | 4 | ALPHA_MULTIPLY | |
  20063. * | 5 | ALPHA_MAXIMIZED | |
  20064. * | 6 | ALPHA_ONEONE | |
  20065. * | 7 | ALPHA_PREMULTIPLIED | |
  20066. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20067. * | 9 | ALPHA_INTERPOLATE | |
  20068. * | 10 | ALPHA_SCREENMODE | |
  20069. *
  20070. */
  20071. /**
  20072. * Gets the value of the alpha mode
  20073. */
  20074. alphaMode: number;
  20075. /**
  20076. * Stores the state of the need depth pre-pass value
  20077. */
  20078. private _needDepthPrePass;
  20079. /**
  20080. * Sets the need depth pre-pass value
  20081. */
  20082. /**
  20083. * Gets the depth pre-pass value
  20084. */
  20085. needDepthPrePass: boolean;
  20086. /**
  20087. * Specifies if depth writing should be disabled
  20088. */
  20089. disableDepthWrite: boolean;
  20090. /**
  20091. * Specifies if depth writing should be forced
  20092. */
  20093. forceDepthWrite: boolean;
  20094. /**
  20095. * Specifies if there should be a separate pass for culling
  20096. */
  20097. separateCullingPass: boolean;
  20098. /**
  20099. * Stores the state specifing if fog should be enabled
  20100. */
  20101. private _fogEnabled;
  20102. /**
  20103. * Sets the state for enabling fog
  20104. */
  20105. /**
  20106. * Gets the value of the fog enabled state
  20107. */
  20108. fogEnabled: boolean;
  20109. /**
  20110. * Stores the size of points
  20111. */
  20112. pointSize: number;
  20113. /**
  20114. * Stores the z offset value
  20115. */
  20116. zOffset: number;
  20117. /**
  20118. * Gets a value specifying if wireframe mode is enabled
  20119. */
  20120. /**
  20121. * Sets the state of wireframe mode
  20122. */
  20123. wireframe: boolean;
  20124. /**
  20125. * Gets the value specifying if point clouds are enabled
  20126. */
  20127. /**
  20128. * Sets the state of point cloud mode
  20129. */
  20130. pointsCloud: boolean;
  20131. /**
  20132. * Gets the material fill mode
  20133. */
  20134. /**
  20135. * Sets the material fill mode
  20136. */
  20137. fillMode: number;
  20138. /**
  20139. * @hidden
  20140. * Stores the effects for the material
  20141. */
  20142. _effect: Nullable<Effect>;
  20143. /**
  20144. * @hidden
  20145. * Specifies if the material was previously ready
  20146. */
  20147. _wasPreviouslyReady: boolean;
  20148. /**
  20149. * Specifies if uniform buffers should be used
  20150. */
  20151. private _useUBO;
  20152. /**
  20153. * Stores a reference to the scene
  20154. */
  20155. private _scene;
  20156. /**
  20157. * Stores the fill mode state
  20158. */
  20159. private _fillMode;
  20160. /**
  20161. * Specifies if the depth write state should be cached
  20162. */
  20163. private _cachedDepthWriteState;
  20164. /**
  20165. * Stores the uniform buffer
  20166. */
  20167. protected _uniformBuffer: UniformBuffer;
  20168. /** @hidden */
  20169. _indexInSceneMaterialArray: number;
  20170. /** @hidden */
  20171. meshMap: Nullable<{
  20172. [id: string]: AbstractMesh | undefined;
  20173. }>;
  20174. /**
  20175. * Creates a material instance
  20176. * @param name defines the name of the material
  20177. * @param scene defines the scene to reference
  20178. * @param doNotAdd specifies if the material should be added to the scene
  20179. */
  20180. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20181. /**
  20182. * Returns a string representation of the current material
  20183. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20184. * @returns a string with material information
  20185. */
  20186. toString(fullDetails?: boolean): string;
  20187. /**
  20188. * Gets the class name of the material
  20189. * @returns a string with the class name of the material
  20190. */
  20191. getClassName(): string;
  20192. /**
  20193. * Specifies if updates for the material been locked
  20194. */
  20195. readonly isFrozen: boolean;
  20196. /**
  20197. * Locks updates for the material
  20198. */
  20199. freeze(): void;
  20200. /**
  20201. * Unlocks updates for the material
  20202. */
  20203. unfreeze(): void;
  20204. /**
  20205. * Specifies if the material is ready to be used
  20206. * @param mesh defines the mesh to check
  20207. * @param useInstances specifies if instances should be used
  20208. * @returns a boolean indicating if the material is ready to be used
  20209. */
  20210. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20211. /**
  20212. * Specifies that the submesh is ready to be used
  20213. * @param mesh defines the mesh to check
  20214. * @param subMesh defines which submesh to check
  20215. * @param useInstances specifies that instances should be used
  20216. * @returns a boolean indicating that the submesh is ready or not
  20217. */
  20218. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20219. /**
  20220. * Returns the material effect
  20221. * @returns the effect associated with the material
  20222. */
  20223. getEffect(): Nullable<Effect>;
  20224. /**
  20225. * Returns the current scene
  20226. * @returns a Scene
  20227. */
  20228. getScene(): Scene;
  20229. /**
  20230. * Specifies if the material will require alpha blending
  20231. * @returns a boolean specifying if alpha blending is needed
  20232. */
  20233. needAlphaBlending(): boolean;
  20234. /**
  20235. * Specifies if the mesh will require alpha blending
  20236. * @param mesh defines the mesh to check
  20237. * @returns a boolean specifying if alpha blending is needed for the mesh
  20238. */
  20239. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20240. /**
  20241. * Specifies if this material should be rendered in alpha test mode
  20242. * @returns a boolean specifying if an alpha test is needed.
  20243. */
  20244. needAlphaTesting(): boolean;
  20245. /**
  20246. * Gets the texture used for the alpha test
  20247. * @returns the texture to use for alpha testing
  20248. */
  20249. getAlphaTestTexture(): Nullable<BaseTexture>;
  20250. /**
  20251. * Marks the material to indicate that it needs to be re-calculated
  20252. */
  20253. markDirty(): void;
  20254. /** @hidden */
  20255. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20256. /**
  20257. * Binds the material to the mesh
  20258. * @param world defines the world transformation matrix
  20259. * @param mesh defines the mesh to bind the material to
  20260. */
  20261. bind(world: Matrix, mesh?: Mesh): void;
  20262. /**
  20263. * Binds the submesh to the material
  20264. * @param world defines the world transformation matrix
  20265. * @param mesh defines the mesh containing the submesh
  20266. * @param subMesh defines the submesh to bind the material to
  20267. */
  20268. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20269. /**
  20270. * Binds the world matrix to the material
  20271. * @param world defines the world transformation matrix
  20272. */
  20273. bindOnlyWorldMatrix(world: Matrix): void;
  20274. /**
  20275. * Binds the scene's uniform buffer to the effect.
  20276. * @param effect defines the effect to bind to the scene uniform buffer
  20277. * @param sceneUbo defines the uniform buffer storing scene data
  20278. */
  20279. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20280. /**
  20281. * Binds the view matrix to the effect
  20282. * @param effect defines the effect to bind the view matrix to
  20283. */
  20284. bindView(effect: Effect): void;
  20285. /**
  20286. * Binds the view projection matrix to the effect
  20287. * @param effect defines the effect to bind the view projection matrix to
  20288. */
  20289. bindViewProjection(effect: Effect): void;
  20290. /**
  20291. * Specifies if material alpha testing should be turned on for the mesh
  20292. * @param mesh defines the mesh to check
  20293. */
  20294. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20295. /**
  20296. * Processes to execute after binding the material to a mesh
  20297. * @param mesh defines the rendered mesh
  20298. */
  20299. protected _afterBind(mesh?: Mesh): void;
  20300. /**
  20301. * Unbinds the material from the mesh
  20302. */
  20303. unbind(): void;
  20304. /**
  20305. * Gets the active textures from the material
  20306. * @returns an array of textures
  20307. */
  20308. getActiveTextures(): BaseTexture[];
  20309. /**
  20310. * Specifies if the material uses a texture
  20311. * @param texture defines the texture to check against the material
  20312. * @returns a boolean specifying if the material uses the texture
  20313. */
  20314. hasTexture(texture: BaseTexture): boolean;
  20315. /**
  20316. * Makes a duplicate of the material, and gives it a new name
  20317. * @param name defines the new name for the duplicated material
  20318. * @returns the cloned material
  20319. */
  20320. clone(name: string): Nullable<Material>;
  20321. /**
  20322. * Gets the meshes bound to the material
  20323. * @returns an array of meshes bound to the material
  20324. */
  20325. getBindedMeshes(): AbstractMesh[];
  20326. /**
  20327. * Force shader compilation
  20328. * @param mesh defines the mesh associated with this material
  20329. * @param onCompiled defines a function to execute once the material is compiled
  20330. * @param options defines the options to configure the compilation
  20331. */
  20332. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20333. clipPlane: boolean;
  20334. }>): void;
  20335. /**
  20336. * Force shader compilation
  20337. * @param mesh defines the mesh that will use this material
  20338. * @param options defines additional options for compiling the shaders
  20339. * @returns a promise that resolves when the compilation completes
  20340. */
  20341. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20342. clipPlane: boolean;
  20343. }>): Promise<void>;
  20344. private static readonly _AllDirtyCallBack;
  20345. private static readonly _ImageProcessingDirtyCallBack;
  20346. private static readonly _TextureDirtyCallBack;
  20347. private static readonly _FresnelDirtyCallBack;
  20348. private static readonly _MiscDirtyCallBack;
  20349. private static readonly _LightsDirtyCallBack;
  20350. private static readonly _AttributeDirtyCallBack;
  20351. private static _FresnelAndMiscDirtyCallBack;
  20352. private static _TextureAndMiscDirtyCallBack;
  20353. private static readonly _DirtyCallbackArray;
  20354. private static readonly _RunDirtyCallBacks;
  20355. /**
  20356. * Marks a define in the material to indicate that it needs to be re-computed
  20357. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20358. */
  20359. markAsDirty(flag: number): void;
  20360. /**
  20361. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20362. * @param func defines a function which checks material defines against the submeshes
  20363. */
  20364. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20365. /**
  20366. * Indicates that we need to re-calculated for all submeshes
  20367. */
  20368. protected _markAllSubMeshesAsAllDirty(): void;
  20369. /**
  20370. * Indicates that image processing needs to be re-calculated for all submeshes
  20371. */
  20372. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20373. /**
  20374. * Indicates that textures need to be re-calculated for all submeshes
  20375. */
  20376. protected _markAllSubMeshesAsTexturesDirty(): void;
  20377. /**
  20378. * Indicates that fresnel needs to be re-calculated for all submeshes
  20379. */
  20380. protected _markAllSubMeshesAsFresnelDirty(): void;
  20381. /**
  20382. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20383. */
  20384. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20385. /**
  20386. * Indicates that lights need to be re-calculated for all submeshes
  20387. */
  20388. protected _markAllSubMeshesAsLightsDirty(): void;
  20389. /**
  20390. * Indicates that attributes need to be re-calculated for all submeshes
  20391. */
  20392. protected _markAllSubMeshesAsAttributesDirty(): void;
  20393. /**
  20394. * Indicates that misc needs to be re-calculated for all submeshes
  20395. */
  20396. protected _markAllSubMeshesAsMiscDirty(): void;
  20397. /**
  20398. * Indicates that textures and misc need to be re-calculated for all submeshes
  20399. */
  20400. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20401. /**
  20402. * Disposes the material
  20403. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20404. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20405. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20406. */
  20407. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20408. /** @hidden */
  20409. private releaseVertexArrayObject;
  20410. /**
  20411. * Serializes this material
  20412. * @returns the serialized material object
  20413. */
  20414. serialize(): any;
  20415. /**
  20416. * Creates a material from parsed material data
  20417. * @param parsedMaterial defines parsed material data
  20418. * @param scene defines the hosting scene
  20419. * @param rootUrl defines the root URL to use to load textures
  20420. * @returns a new material
  20421. */
  20422. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20423. }
  20424. }
  20425. declare module BABYLON {
  20426. /**
  20427. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20428. * separate meshes. This can be use to improve performances.
  20429. * @see http://doc.babylonjs.com/how_to/multi_materials
  20430. */
  20431. export class MultiMaterial extends Material {
  20432. private _subMaterials;
  20433. /**
  20434. * Gets or Sets the list of Materials used within the multi material.
  20435. * They need to be ordered according to the submeshes order in the associated mesh
  20436. */
  20437. subMaterials: Nullable<Material>[];
  20438. /**
  20439. * Function used to align with Node.getChildren()
  20440. * @returns the list of Materials used within the multi material
  20441. */
  20442. getChildren(): Nullable<Material>[];
  20443. /**
  20444. * Instantiates a new Multi Material
  20445. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20446. * separate meshes. This can be use to improve performances.
  20447. * @see http://doc.babylonjs.com/how_to/multi_materials
  20448. * @param name Define the name in the scene
  20449. * @param scene Define the scene the material belongs to
  20450. */
  20451. constructor(name: string, scene: Scene);
  20452. private _hookArray;
  20453. /**
  20454. * Get one of the submaterial by its index in the submaterials array
  20455. * @param index The index to look the sub material at
  20456. * @returns The Material if the index has been defined
  20457. */
  20458. getSubMaterial(index: number): Nullable<Material>;
  20459. /**
  20460. * Get the list of active textures for the whole sub materials list.
  20461. * @returns All the textures that will be used during the rendering
  20462. */
  20463. getActiveTextures(): BaseTexture[];
  20464. /**
  20465. * Gets the current class name of the material e.g. "MultiMaterial"
  20466. * Mainly use in serialization.
  20467. * @returns the class name
  20468. */
  20469. getClassName(): string;
  20470. /**
  20471. * Checks if the material is ready to render the requested sub mesh
  20472. * @param mesh Define the mesh the submesh belongs to
  20473. * @param subMesh Define the sub mesh to look readyness for
  20474. * @param useInstances Define whether or not the material is used with instances
  20475. * @returns true if ready, otherwise false
  20476. */
  20477. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20478. /**
  20479. * Clones the current material and its related sub materials
  20480. * @param name Define the name of the newly cloned material
  20481. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20482. * @returns the cloned material
  20483. */
  20484. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20485. /**
  20486. * Serializes the materials into a JSON representation.
  20487. * @returns the JSON representation
  20488. */
  20489. serialize(): any;
  20490. /**
  20491. * Dispose the material and release its associated resources
  20492. * @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)
  20493. * @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)
  20494. * @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)
  20495. */
  20496. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20497. /**
  20498. * Creates a MultiMaterial from parsed MultiMaterial data.
  20499. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20500. * @param scene defines the hosting scene
  20501. * @returns a new MultiMaterial
  20502. */
  20503. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20504. }
  20505. }
  20506. declare module BABYLON {
  20507. /**
  20508. * Base class for submeshes
  20509. */
  20510. export class BaseSubMesh {
  20511. /** @hidden */
  20512. _materialDefines: Nullable<MaterialDefines>;
  20513. /** @hidden */
  20514. _materialEffect: Nullable<Effect>;
  20515. /**
  20516. * Gets associated effect
  20517. */
  20518. readonly effect: Nullable<Effect>;
  20519. /**
  20520. * Sets associated effect (effect used to render this submesh)
  20521. * @param effect defines the effect to associate with
  20522. * @param defines defines the set of defines used to compile this effect
  20523. */
  20524. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20525. }
  20526. /**
  20527. * Defines a subdivision inside a mesh
  20528. */
  20529. export class SubMesh extends BaseSubMesh implements ICullable {
  20530. /** the material index to use */
  20531. materialIndex: number;
  20532. /** vertex index start */
  20533. verticesStart: number;
  20534. /** vertices count */
  20535. verticesCount: number;
  20536. /** index start */
  20537. indexStart: number;
  20538. /** indices count */
  20539. indexCount: number;
  20540. /** @hidden */
  20541. _linesIndexCount: number;
  20542. private _mesh;
  20543. private _renderingMesh;
  20544. private _boundingInfo;
  20545. private _linesIndexBuffer;
  20546. /** @hidden */
  20547. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20548. /** @hidden */
  20549. _trianglePlanes: Plane[];
  20550. /** @hidden */
  20551. _lastColliderTransformMatrix: Nullable<Matrix>;
  20552. /** @hidden */
  20553. _renderId: number;
  20554. /** @hidden */
  20555. _alphaIndex: number;
  20556. /** @hidden */
  20557. _distanceToCamera: number;
  20558. /** @hidden */
  20559. _id: number;
  20560. private _currentMaterial;
  20561. /**
  20562. * Add a new submesh to a mesh
  20563. * @param materialIndex defines the material index to use
  20564. * @param verticesStart defines vertex index start
  20565. * @param verticesCount defines vertices count
  20566. * @param indexStart defines index start
  20567. * @param indexCount defines indices count
  20568. * @param mesh defines the parent mesh
  20569. * @param renderingMesh defines an optional rendering mesh
  20570. * @param createBoundingBox defines if bounding box should be created for this submesh
  20571. * @returns the new submesh
  20572. */
  20573. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20574. /**
  20575. * Creates a new submesh
  20576. * @param materialIndex defines the material index to use
  20577. * @param verticesStart defines vertex index start
  20578. * @param verticesCount defines vertices count
  20579. * @param indexStart defines index start
  20580. * @param indexCount defines indices count
  20581. * @param mesh defines the parent mesh
  20582. * @param renderingMesh defines an optional rendering mesh
  20583. * @param createBoundingBox defines if bounding box should be created for this submesh
  20584. */
  20585. constructor(
  20586. /** the material index to use */
  20587. materialIndex: number,
  20588. /** vertex index start */
  20589. verticesStart: number,
  20590. /** vertices count */
  20591. verticesCount: number,
  20592. /** index start */
  20593. indexStart: number,
  20594. /** indices count */
  20595. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20596. /**
  20597. * Returns true if this submesh covers the entire parent mesh
  20598. * @ignorenaming
  20599. */
  20600. readonly IsGlobal: boolean;
  20601. /**
  20602. * Returns the submesh BoudingInfo object
  20603. * @returns current bounding info (or mesh's one if the submesh is global)
  20604. */
  20605. getBoundingInfo(): BoundingInfo;
  20606. /**
  20607. * Sets the submesh BoundingInfo
  20608. * @param boundingInfo defines the new bounding info to use
  20609. * @returns the SubMesh
  20610. */
  20611. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20612. /**
  20613. * Returns the mesh of the current submesh
  20614. * @return the parent mesh
  20615. */
  20616. getMesh(): AbstractMesh;
  20617. /**
  20618. * Returns the rendering mesh of the submesh
  20619. * @returns the rendering mesh (could be different from parent mesh)
  20620. */
  20621. getRenderingMesh(): Mesh;
  20622. /**
  20623. * Returns the submesh material
  20624. * @returns null or the current material
  20625. */
  20626. getMaterial(): Nullable<Material>;
  20627. /**
  20628. * Sets a new updated BoundingInfo object to the submesh
  20629. * @param data defines an optional position array to use to determine the bounding info
  20630. * @returns the SubMesh
  20631. */
  20632. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20633. /** @hidden */
  20634. _checkCollision(collider: Collider): boolean;
  20635. /**
  20636. * Updates the submesh BoundingInfo
  20637. * @param world defines the world matrix to use to update the bounding info
  20638. * @returns the submesh
  20639. */
  20640. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20641. /**
  20642. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20643. * @param frustumPlanes defines the frustum planes
  20644. * @returns true if the submesh is intersecting with the frustum
  20645. */
  20646. isInFrustum(frustumPlanes: Plane[]): boolean;
  20647. /**
  20648. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20649. * @param frustumPlanes defines the frustum planes
  20650. * @returns true if the submesh is inside the frustum
  20651. */
  20652. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20653. /**
  20654. * Renders the submesh
  20655. * @param enableAlphaMode defines if alpha needs to be used
  20656. * @returns the submesh
  20657. */
  20658. render(enableAlphaMode: boolean): SubMesh;
  20659. /**
  20660. * @hidden
  20661. */
  20662. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20663. /**
  20664. * Checks if the submesh intersects with a ray
  20665. * @param ray defines the ray to test
  20666. * @returns true is the passed ray intersects the submesh bounding box
  20667. */
  20668. canIntersects(ray: Ray): boolean;
  20669. /**
  20670. * Intersects current submesh with a ray
  20671. * @param ray defines the ray to test
  20672. * @param positions defines mesh's positions array
  20673. * @param indices defines mesh's indices array
  20674. * @param fastCheck defines if only bounding info should be used
  20675. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20676. * @returns intersection info or null if no intersection
  20677. */
  20678. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20679. /** @hidden */
  20680. private _intersectLines;
  20681. /** @hidden */
  20682. private _intersectUnIndexedLines;
  20683. /** @hidden */
  20684. private _intersectTriangles;
  20685. /** @hidden */
  20686. private _intersectUnIndexedTriangles;
  20687. /** @hidden */
  20688. _rebuild(): void;
  20689. /**
  20690. * Creates a new submesh from the passed mesh
  20691. * @param newMesh defines the new hosting mesh
  20692. * @param newRenderingMesh defines an optional rendering mesh
  20693. * @returns the new submesh
  20694. */
  20695. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20696. /**
  20697. * Release associated resources
  20698. */
  20699. dispose(): void;
  20700. /**
  20701. * Gets the class name
  20702. * @returns the string "SubMesh".
  20703. */
  20704. getClassName(): string;
  20705. /**
  20706. * Creates a new submesh from indices data
  20707. * @param materialIndex the index of the main mesh material
  20708. * @param startIndex the index where to start the copy in the mesh indices array
  20709. * @param indexCount the number of indices to copy then from the startIndex
  20710. * @param mesh the main mesh to create the submesh from
  20711. * @param renderingMesh the optional rendering mesh
  20712. * @returns a new submesh
  20713. */
  20714. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20715. }
  20716. }
  20717. declare module BABYLON {
  20718. /**
  20719. * Class used to represent data loading progression
  20720. */
  20721. export class SceneLoaderFlags {
  20722. private static _ForceFullSceneLoadingForIncremental;
  20723. private static _ShowLoadingScreen;
  20724. private static _CleanBoneMatrixWeights;
  20725. private static _loggingLevel;
  20726. /**
  20727. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20728. */
  20729. static ForceFullSceneLoadingForIncremental: boolean;
  20730. /**
  20731. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20732. */
  20733. static ShowLoadingScreen: boolean;
  20734. /**
  20735. * Defines the current logging level (while loading the scene)
  20736. * @ignorenaming
  20737. */
  20738. static loggingLevel: number;
  20739. /**
  20740. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20741. */
  20742. static CleanBoneMatrixWeights: boolean;
  20743. }
  20744. }
  20745. declare module BABYLON {
  20746. /**
  20747. * Class used to store geometry data (vertex buffers + index buffer)
  20748. */
  20749. export class Geometry implements IGetSetVerticesData {
  20750. /**
  20751. * Gets or sets the ID of the geometry
  20752. */
  20753. id: string;
  20754. /**
  20755. * Gets or sets the unique ID of the geometry
  20756. */
  20757. uniqueId: number;
  20758. /**
  20759. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20760. */
  20761. delayLoadState: number;
  20762. /**
  20763. * Gets the file containing the data to load when running in delay load state
  20764. */
  20765. delayLoadingFile: Nullable<string>;
  20766. /**
  20767. * Callback called when the geometry is updated
  20768. */
  20769. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20770. private _scene;
  20771. private _engine;
  20772. private _meshes;
  20773. private _totalVertices;
  20774. /** @hidden */
  20775. _indices: IndicesArray;
  20776. /** @hidden */
  20777. _vertexBuffers: {
  20778. [key: string]: VertexBuffer;
  20779. };
  20780. private _isDisposed;
  20781. private _extend;
  20782. private _boundingBias;
  20783. /** @hidden */
  20784. _delayInfo: Array<string>;
  20785. private _indexBuffer;
  20786. private _indexBufferIsUpdatable;
  20787. /** @hidden */
  20788. _boundingInfo: Nullable<BoundingInfo>;
  20789. /** @hidden */
  20790. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20791. /** @hidden */
  20792. _softwareSkinningFrameId: number;
  20793. private _vertexArrayObjects;
  20794. private _updatable;
  20795. /** @hidden */
  20796. _positions: Nullable<Vector3[]>;
  20797. /**
  20798. * 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
  20799. */
  20800. /**
  20801. * 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
  20802. */
  20803. boundingBias: Vector2;
  20804. /**
  20805. * Static function used to attach a new empty geometry to a mesh
  20806. * @param mesh defines the mesh to attach the geometry to
  20807. * @returns the new Geometry
  20808. */
  20809. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20810. /**
  20811. * Creates a new geometry
  20812. * @param id defines the unique ID
  20813. * @param scene defines the hosting scene
  20814. * @param vertexData defines the VertexData used to get geometry data
  20815. * @param updatable defines if geometry must be updatable (false by default)
  20816. * @param mesh defines the mesh that will be associated with the geometry
  20817. */
  20818. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20819. /**
  20820. * Gets the current extend of the geometry
  20821. */
  20822. readonly extend: {
  20823. minimum: Vector3;
  20824. maximum: Vector3;
  20825. };
  20826. /**
  20827. * Gets the hosting scene
  20828. * @returns the hosting Scene
  20829. */
  20830. getScene(): Scene;
  20831. /**
  20832. * Gets the hosting engine
  20833. * @returns the hosting Engine
  20834. */
  20835. getEngine(): Engine;
  20836. /**
  20837. * Defines if the geometry is ready to use
  20838. * @returns true if the geometry is ready to be used
  20839. */
  20840. isReady(): boolean;
  20841. /**
  20842. * Gets a value indicating that the geometry should not be serialized
  20843. */
  20844. readonly doNotSerialize: boolean;
  20845. /** @hidden */
  20846. _rebuild(): void;
  20847. /**
  20848. * Affects all geometry data in one call
  20849. * @param vertexData defines the geometry data
  20850. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20851. */
  20852. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20853. /**
  20854. * Set specific vertex data
  20855. * @param kind defines the data kind (Position, normal, etc...)
  20856. * @param data defines the vertex data to use
  20857. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20858. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20859. */
  20860. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20861. /**
  20862. * Removes a specific vertex data
  20863. * @param kind defines the data kind (Position, normal, etc...)
  20864. */
  20865. removeVerticesData(kind: string): void;
  20866. /**
  20867. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20868. * @param buffer defines the vertex buffer to use
  20869. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20870. */
  20871. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20872. /**
  20873. * Update a specific vertex buffer
  20874. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20875. * It will do nothing if the buffer is not updatable
  20876. * @param kind defines the data kind (Position, normal, etc...)
  20877. * @param data defines the data to use
  20878. * @param offset defines the offset in the target buffer where to store the data
  20879. * @param useBytes set to true if the offset is in bytes
  20880. */
  20881. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20882. /**
  20883. * Update a specific vertex buffer
  20884. * This function will create a new buffer if the current one is not updatable
  20885. * @param kind defines the data kind (Position, normal, etc...)
  20886. * @param data defines the data to use
  20887. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20888. */
  20889. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20890. private _updateBoundingInfo;
  20891. /** @hidden */
  20892. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20893. /**
  20894. * Gets total number of vertices
  20895. * @returns the total number of vertices
  20896. */
  20897. getTotalVertices(): number;
  20898. /**
  20899. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20900. * @param kind defines the data kind (Position, normal, etc...)
  20901. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20902. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20903. * @returns a float array containing vertex data
  20904. */
  20905. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20906. /**
  20907. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20908. * @param kind defines the data kind (Position, normal, etc...)
  20909. * @returns true if the vertex buffer with the specified kind is updatable
  20910. */
  20911. isVertexBufferUpdatable(kind: string): boolean;
  20912. /**
  20913. * Gets a specific vertex buffer
  20914. * @param kind defines the data kind (Position, normal, etc...)
  20915. * @returns a VertexBuffer
  20916. */
  20917. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20918. /**
  20919. * Returns all vertex buffers
  20920. * @return an object holding all vertex buffers indexed by kind
  20921. */
  20922. getVertexBuffers(): Nullable<{
  20923. [key: string]: VertexBuffer;
  20924. }>;
  20925. /**
  20926. * Gets a boolean indicating if specific vertex buffer is present
  20927. * @param kind defines the data kind (Position, normal, etc...)
  20928. * @returns true if data is present
  20929. */
  20930. isVerticesDataPresent(kind: string): boolean;
  20931. /**
  20932. * Gets a list of all attached data kinds (Position, normal, etc...)
  20933. * @returns a list of string containing all kinds
  20934. */
  20935. getVerticesDataKinds(): string[];
  20936. /**
  20937. * Update index buffer
  20938. * @param indices defines the indices to store in the index buffer
  20939. * @param offset defines the offset in the target buffer where to store the data
  20940. * @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)
  20941. */
  20942. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  20943. /**
  20944. * Creates a new index buffer
  20945. * @param indices defines the indices to store in the index buffer
  20946. * @param totalVertices defines the total number of vertices (could be null)
  20947. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20948. */
  20949. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20950. /**
  20951. * Return the total number of indices
  20952. * @returns the total number of indices
  20953. */
  20954. getTotalIndices(): number;
  20955. /**
  20956. * Gets the index buffer array
  20957. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20958. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20959. * @returns the index buffer array
  20960. */
  20961. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20962. /**
  20963. * Gets the index buffer
  20964. * @return the index buffer
  20965. */
  20966. getIndexBuffer(): Nullable<DataBuffer>;
  20967. /** @hidden */
  20968. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20969. /**
  20970. * Release the associated resources for a specific mesh
  20971. * @param mesh defines the source mesh
  20972. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20973. */
  20974. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20975. /**
  20976. * Apply current geometry to a given mesh
  20977. * @param mesh defines the mesh to apply geometry to
  20978. */
  20979. applyToMesh(mesh: Mesh): void;
  20980. private _updateExtend;
  20981. private _applyToMesh;
  20982. private notifyUpdate;
  20983. /**
  20984. * Load the geometry if it was flagged as delay loaded
  20985. * @param scene defines the hosting scene
  20986. * @param onLoaded defines a callback called when the geometry is loaded
  20987. */
  20988. load(scene: Scene, onLoaded?: () => void): void;
  20989. private _queueLoad;
  20990. /**
  20991. * Invert the geometry to move from a right handed system to a left handed one.
  20992. */
  20993. toLeftHanded(): void;
  20994. /** @hidden */
  20995. _resetPointsArrayCache(): void;
  20996. /** @hidden */
  20997. _generatePointsArray(): boolean;
  20998. /**
  20999. * Gets a value indicating if the geometry is disposed
  21000. * @returns true if the geometry was disposed
  21001. */
  21002. isDisposed(): boolean;
  21003. private _disposeVertexArrayObjects;
  21004. /**
  21005. * Free all associated resources
  21006. */
  21007. dispose(): void;
  21008. /**
  21009. * Clone the current geometry into a new geometry
  21010. * @param id defines the unique ID of the new geometry
  21011. * @returns a new geometry object
  21012. */
  21013. copy(id: string): Geometry;
  21014. /**
  21015. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21016. * @return a JSON representation of the current geometry data (without the vertices data)
  21017. */
  21018. serialize(): any;
  21019. private toNumberArray;
  21020. /**
  21021. * Serialize all vertices data into a JSON oject
  21022. * @returns a JSON representation of the current geometry data
  21023. */
  21024. serializeVerticeData(): any;
  21025. /**
  21026. * Extracts a clone of a mesh geometry
  21027. * @param mesh defines the source mesh
  21028. * @param id defines the unique ID of the new geometry object
  21029. * @returns the new geometry object
  21030. */
  21031. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21032. /**
  21033. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21034. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21035. * Be aware Math.random() could cause collisions, but:
  21036. * "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"
  21037. * @returns a string containing a new GUID
  21038. */
  21039. static RandomId(): string;
  21040. /** @hidden */
  21041. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21042. private static _CleanMatricesWeights;
  21043. /**
  21044. * Create a new geometry from persisted data (Using .babylon file format)
  21045. * @param parsedVertexData defines the persisted data
  21046. * @param scene defines the hosting scene
  21047. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21048. * @returns the new geometry object
  21049. */
  21050. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21051. }
  21052. }
  21053. declare module BABYLON {
  21054. /**
  21055. * Define an interface for all classes that will get and set the data on vertices
  21056. */
  21057. export interface IGetSetVerticesData {
  21058. /**
  21059. * Gets a boolean indicating if specific vertex data is present
  21060. * @param kind defines the vertex data kind to use
  21061. * @returns true is data kind is present
  21062. */
  21063. isVerticesDataPresent(kind: string): boolean;
  21064. /**
  21065. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21066. * @param kind defines the data kind (Position, normal, etc...)
  21067. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21068. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21069. * @returns a float array containing vertex data
  21070. */
  21071. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21072. /**
  21073. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21074. * @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.
  21075. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21076. * @returns the indices array or an empty array if the mesh has no geometry
  21077. */
  21078. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21079. /**
  21080. * Set specific vertex data
  21081. * @param kind defines the data kind (Position, normal, etc...)
  21082. * @param data defines the vertex data to use
  21083. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21084. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21085. */
  21086. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21087. /**
  21088. * Update a specific associated vertex buffer
  21089. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21090. * - VertexBuffer.PositionKind
  21091. * - VertexBuffer.UVKind
  21092. * - VertexBuffer.UV2Kind
  21093. * - VertexBuffer.UV3Kind
  21094. * - VertexBuffer.UV4Kind
  21095. * - VertexBuffer.UV5Kind
  21096. * - VertexBuffer.UV6Kind
  21097. * - VertexBuffer.ColorKind
  21098. * - VertexBuffer.MatricesIndicesKind
  21099. * - VertexBuffer.MatricesIndicesExtraKind
  21100. * - VertexBuffer.MatricesWeightsKind
  21101. * - VertexBuffer.MatricesWeightsExtraKind
  21102. * @param data defines the data source
  21103. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21104. * @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)
  21105. */
  21106. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21107. /**
  21108. * Creates a new index buffer
  21109. * @param indices defines the indices to store in the index buffer
  21110. * @param totalVertices defines the total number of vertices (could be null)
  21111. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21112. */
  21113. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21114. }
  21115. /**
  21116. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21117. */
  21118. export class VertexData {
  21119. /**
  21120. * Mesh side orientation : usually the external or front surface
  21121. */
  21122. static readonly FRONTSIDE: number;
  21123. /**
  21124. * Mesh side orientation : usually the internal or back surface
  21125. */
  21126. static readonly BACKSIDE: number;
  21127. /**
  21128. * Mesh side orientation : both internal and external or front and back surfaces
  21129. */
  21130. static readonly DOUBLESIDE: number;
  21131. /**
  21132. * Mesh side orientation : by default, `FRONTSIDE`
  21133. */
  21134. static readonly DEFAULTSIDE: number;
  21135. /**
  21136. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21137. */
  21138. positions: Nullable<FloatArray>;
  21139. /**
  21140. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21141. */
  21142. normals: Nullable<FloatArray>;
  21143. /**
  21144. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21145. */
  21146. tangents: Nullable<FloatArray>;
  21147. /**
  21148. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21149. */
  21150. uvs: Nullable<FloatArray>;
  21151. /**
  21152. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21153. */
  21154. uvs2: Nullable<FloatArray>;
  21155. /**
  21156. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21157. */
  21158. uvs3: Nullable<FloatArray>;
  21159. /**
  21160. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21161. */
  21162. uvs4: Nullable<FloatArray>;
  21163. /**
  21164. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21165. */
  21166. uvs5: Nullable<FloatArray>;
  21167. /**
  21168. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21169. */
  21170. uvs6: Nullable<FloatArray>;
  21171. /**
  21172. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21173. */
  21174. colors: Nullable<FloatArray>;
  21175. /**
  21176. * 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).
  21177. */
  21178. matricesIndices: Nullable<FloatArray>;
  21179. /**
  21180. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21181. */
  21182. matricesWeights: Nullable<FloatArray>;
  21183. /**
  21184. * An array extending the number of possible indices
  21185. */
  21186. matricesIndicesExtra: Nullable<FloatArray>;
  21187. /**
  21188. * An array extending the number of possible weights when the number of indices is extended
  21189. */
  21190. matricesWeightsExtra: Nullable<FloatArray>;
  21191. /**
  21192. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21193. */
  21194. indices: Nullable<IndicesArray>;
  21195. /**
  21196. * Uses the passed data array to set the set the values for the specified kind of data
  21197. * @param data a linear array of floating numbers
  21198. * @param kind the type of data that is being set, eg positions, colors etc
  21199. */
  21200. set(data: FloatArray, kind: string): void;
  21201. /**
  21202. * Associates the vertexData to the passed Mesh.
  21203. * Sets it as updatable or not (default `false`)
  21204. * @param mesh the mesh the vertexData is applied to
  21205. * @param updatable when used and having the value true allows new data to update the vertexData
  21206. * @returns the VertexData
  21207. */
  21208. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21209. /**
  21210. * Associates the vertexData to the passed Geometry.
  21211. * Sets it as updatable or not (default `false`)
  21212. * @param geometry the geometry the vertexData is applied to
  21213. * @param updatable when used and having the value true allows new data to update the vertexData
  21214. * @returns VertexData
  21215. */
  21216. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21217. /**
  21218. * Updates the associated mesh
  21219. * @param mesh the mesh to be updated
  21220. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21221. * @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
  21222. * @returns VertexData
  21223. */
  21224. updateMesh(mesh: Mesh): VertexData;
  21225. /**
  21226. * Updates the associated geometry
  21227. * @param geometry the geometry to be updated
  21228. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21229. * @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
  21230. * @returns VertexData.
  21231. */
  21232. updateGeometry(geometry: Geometry): VertexData;
  21233. private _applyTo;
  21234. private _update;
  21235. /**
  21236. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21237. * @param matrix the transforming matrix
  21238. * @returns the VertexData
  21239. */
  21240. transform(matrix: Matrix): VertexData;
  21241. /**
  21242. * Merges the passed VertexData into the current one
  21243. * @param other the VertexData to be merged into the current one
  21244. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21245. * @returns the modified VertexData
  21246. */
  21247. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21248. private _mergeElement;
  21249. private _validate;
  21250. /**
  21251. * Serializes the VertexData
  21252. * @returns a serialized object
  21253. */
  21254. serialize(): any;
  21255. /**
  21256. * Extracts the vertexData from a mesh
  21257. * @param mesh the mesh from which to extract the VertexData
  21258. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21259. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21260. * @returns the object VertexData associated to the passed mesh
  21261. */
  21262. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21263. /**
  21264. * Extracts the vertexData from the geometry
  21265. * @param geometry the geometry from which to extract the VertexData
  21266. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21267. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21268. * @returns the object VertexData associated to the passed mesh
  21269. */
  21270. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21271. private static _ExtractFrom;
  21272. /**
  21273. * Creates the VertexData for a Ribbon
  21274. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21275. * * pathArray array of paths, each of which an array of successive Vector3
  21276. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21277. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21278. * * 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
  21279. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21280. * * 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)
  21281. * * 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)
  21282. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21283. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21284. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21285. * @returns the VertexData of the ribbon
  21286. */
  21287. static CreateRibbon(options: {
  21288. pathArray: Vector3[][];
  21289. closeArray?: boolean;
  21290. closePath?: boolean;
  21291. offset?: number;
  21292. sideOrientation?: number;
  21293. frontUVs?: Vector4;
  21294. backUVs?: Vector4;
  21295. invertUV?: boolean;
  21296. uvs?: Vector2[];
  21297. colors?: Color4[];
  21298. }): VertexData;
  21299. /**
  21300. * Creates the VertexData for a box
  21301. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21302. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21303. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21304. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21305. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21306. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21307. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21308. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21309. * * 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)
  21310. * * 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)
  21311. * @returns the VertexData of the box
  21312. */
  21313. static CreateBox(options: {
  21314. size?: number;
  21315. width?: number;
  21316. height?: number;
  21317. depth?: number;
  21318. faceUV?: Vector4[];
  21319. faceColors?: Color4[];
  21320. sideOrientation?: number;
  21321. frontUVs?: Vector4;
  21322. backUVs?: Vector4;
  21323. }): VertexData;
  21324. /**
  21325. * Creates the VertexData for a tiled box
  21326. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21327. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21328. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21329. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21330. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21331. * @returns the VertexData of the box
  21332. */
  21333. static CreateTiledBox(options: {
  21334. pattern?: number;
  21335. width?: number;
  21336. height?: number;
  21337. depth?: number;
  21338. tileSize?: number;
  21339. tileWidth?: number;
  21340. tileHeight?: number;
  21341. alignHorizontal?: number;
  21342. alignVertical?: number;
  21343. faceUV?: Vector4[];
  21344. faceColors?: Color4[];
  21345. sideOrientation?: number;
  21346. }): VertexData;
  21347. /**
  21348. * Creates the VertexData for a tiled plane
  21349. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21350. * * pattern a limited pattern arrangement depending on the number
  21351. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21352. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21353. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21354. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21355. * * 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)
  21356. * * 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)
  21357. * @returns the VertexData of the tiled plane
  21358. */
  21359. static CreateTiledPlane(options: {
  21360. pattern?: number;
  21361. tileSize?: number;
  21362. tileWidth?: number;
  21363. tileHeight?: number;
  21364. size?: number;
  21365. width?: number;
  21366. height?: number;
  21367. alignHorizontal?: number;
  21368. alignVertical?: number;
  21369. sideOrientation?: number;
  21370. frontUVs?: Vector4;
  21371. backUVs?: Vector4;
  21372. }): VertexData;
  21373. /**
  21374. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21375. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21376. * * segments sets the number of horizontal strips optional, default 32
  21377. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21378. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21379. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21380. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21381. * * 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
  21382. * * 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
  21383. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21384. * * 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)
  21385. * * 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)
  21386. * @returns the VertexData of the ellipsoid
  21387. */
  21388. static CreateSphere(options: {
  21389. segments?: number;
  21390. diameter?: number;
  21391. diameterX?: number;
  21392. diameterY?: number;
  21393. diameterZ?: number;
  21394. arc?: number;
  21395. slice?: number;
  21396. sideOrientation?: number;
  21397. frontUVs?: Vector4;
  21398. backUVs?: Vector4;
  21399. }): VertexData;
  21400. /**
  21401. * Creates the VertexData for a cylinder, cone or prism
  21402. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21403. * * height sets the height (y direction) of the cylinder, optional, default 2
  21404. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21405. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21406. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21407. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21408. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21409. * * 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
  21410. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21411. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21412. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21413. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21414. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21415. * * 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)
  21416. * * 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)
  21417. * @returns the VertexData of the cylinder, cone or prism
  21418. */
  21419. static CreateCylinder(options: {
  21420. height?: number;
  21421. diameterTop?: number;
  21422. diameterBottom?: number;
  21423. diameter?: number;
  21424. tessellation?: number;
  21425. subdivisions?: number;
  21426. arc?: number;
  21427. faceColors?: Color4[];
  21428. faceUV?: Vector4[];
  21429. hasRings?: boolean;
  21430. enclose?: boolean;
  21431. sideOrientation?: number;
  21432. frontUVs?: Vector4;
  21433. backUVs?: Vector4;
  21434. }): VertexData;
  21435. /**
  21436. * Creates the VertexData for a torus
  21437. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21438. * * diameter the diameter of the torus, optional default 1
  21439. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21440. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21441. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21442. * * 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)
  21443. * * 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)
  21444. * @returns the VertexData of the torus
  21445. */
  21446. static CreateTorus(options: {
  21447. diameter?: number;
  21448. thickness?: number;
  21449. tessellation?: number;
  21450. sideOrientation?: number;
  21451. frontUVs?: Vector4;
  21452. backUVs?: Vector4;
  21453. }): VertexData;
  21454. /**
  21455. * Creates the VertexData of the LineSystem
  21456. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21457. * - lines an array of lines, each line being an array of successive Vector3
  21458. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21459. * @returns the VertexData of the LineSystem
  21460. */
  21461. static CreateLineSystem(options: {
  21462. lines: Vector3[][];
  21463. colors?: Nullable<Color4[][]>;
  21464. }): VertexData;
  21465. /**
  21466. * Create the VertexData for a DashedLines
  21467. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21468. * - points an array successive Vector3
  21469. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21470. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21471. * - dashNb the intended total number of dashes, optional, default 200
  21472. * @returns the VertexData for the DashedLines
  21473. */
  21474. static CreateDashedLines(options: {
  21475. points: Vector3[];
  21476. dashSize?: number;
  21477. gapSize?: number;
  21478. dashNb?: number;
  21479. }): VertexData;
  21480. /**
  21481. * Creates the VertexData for a Ground
  21482. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21483. * - width the width (x direction) of the ground, optional, default 1
  21484. * - height the height (z direction) of the ground, optional, default 1
  21485. * - subdivisions the number of subdivisions per side, optional, default 1
  21486. * @returns the VertexData of the Ground
  21487. */
  21488. static CreateGround(options: {
  21489. width?: number;
  21490. height?: number;
  21491. subdivisions?: number;
  21492. subdivisionsX?: number;
  21493. subdivisionsY?: number;
  21494. }): VertexData;
  21495. /**
  21496. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21497. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21498. * * xmin the ground minimum X coordinate, optional, default -1
  21499. * * zmin the ground minimum Z coordinate, optional, default -1
  21500. * * xmax the ground maximum X coordinate, optional, default 1
  21501. * * zmax the ground maximum Z coordinate, optional, default 1
  21502. * * 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}
  21503. * * 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}
  21504. * @returns the VertexData of the TiledGround
  21505. */
  21506. static CreateTiledGround(options: {
  21507. xmin: number;
  21508. zmin: number;
  21509. xmax: number;
  21510. zmax: number;
  21511. subdivisions?: {
  21512. w: number;
  21513. h: number;
  21514. };
  21515. precision?: {
  21516. w: number;
  21517. h: number;
  21518. };
  21519. }): VertexData;
  21520. /**
  21521. * Creates the VertexData of the Ground designed from a heightmap
  21522. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21523. * * width the width (x direction) of the ground
  21524. * * height the height (z direction) of the ground
  21525. * * subdivisions the number of subdivisions per side
  21526. * * minHeight the minimum altitude on the ground, optional, default 0
  21527. * * maxHeight the maximum altitude on the ground, optional default 1
  21528. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21529. * * buffer the array holding the image color data
  21530. * * bufferWidth the width of image
  21531. * * bufferHeight the height of image
  21532. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21533. * @returns the VertexData of the Ground designed from a heightmap
  21534. */
  21535. static CreateGroundFromHeightMap(options: {
  21536. width: number;
  21537. height: number;
  21538. subdivisions: number;
  21539. minHeight: number;
  21540. maxHeight: number;
  21541. colorFilter: Color3;
  21542. buffer: Uint8Array;
  21543. bufferWidth: number;
  21544. bufferHeight: number;
  21545. alphaFilter: number;
  21546. }): VertexData;
  21547. /**
  21548. * Creates the VertexData for a Plane
  21549. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21550. * * size sets the width and height of the plane to the value of size, optional default 1
  21551. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21552. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21553. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21554. * * 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)
  21555. * * 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)
  21556. * @returns the VertexData of the box
  21557. */
  21558. static CreatePlane(options: {
  21559. size?: number;
  21560. width?: number;
  21561. height?: number;
  21562. sideOrientation?: number;
  21563. frontUVs?: Vector4;
  21564. backUVs?: Vector4;
  21565. }): VertexData;
  21566. /**
  21567. * Creates the VertexData of the Disc or regular Polygon
  21568. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21569. * * radius the radius of the disc, optional default 0.5
  21570. * * tessellation the number of polygon sides, optional, default 64
  21571. * * 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
  21572. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21573. * * 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)
  21574. * * 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)
  21575. * @returns the VertexData of the box
  21576. */
  21577. static CreateDisc(options: {
  21578. radius?: number;
  21579. tessellation?: number;
  21580. arc?: number;
  21581. sideOrientation?: number;
  21582. frontUVs?: Vector4;
  21583. backUVs?: Vector4;
  21584. }): VertexData;
  21585. /**
  21586. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21587. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21588. * @param polygon a mesh built from polygonTriangulation.build()
  21589. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21590. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21591. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21592. * @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)
  21593. * @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)
  21594. * @returns the VertexData of the Polygon
  21595. */
  21596. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21597. /**
  21598. * Creates the VertexData of the IcoSphere
  21599. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21600. * * radius the radius of the IcoSphere, optional default 1
  21601. * * radiusX allows stretching in the x direction, optional, default radius
  21602. * * radiusY allows stretching in the y direction, optional, default radius
  21603. * * radiusZ allows stretching in the z direction, optional, default radius
  21604. * * flat when true creates a flat shaded mesh, optional, default true
  21605. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21606. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21607. * * 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)
  21608. * * 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)
  21609. * @returns the VertexData of the IcoSphere
  21610. */
  21611. static CreateIcoSphere(options: {
  21612. radius?: number;
  21613. radiusX?: number;
  21614. radiusY?: number;
  21615. radiusZ?: number;
  21616. flat?: boolean;
  21617. subdivisions?: number;
  21618. sideOrientation?: number;
  21619. frontUVs?: Vector4;
  21620. backUVs?: Vector4;
  21621. }): VertexData;
  21622. /**
  21623. * Creates the VertexData for a Polyhedron
  21624. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21625. * * type provided types are:
  21626. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21627. * * 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)
  21628. * * size the size of the IcoSphere, optional default 1
  21629. * * sizeX allows stretching in the x direction, optional, default size
  21630. * * sizeY allows stretching in the y direction, optional, default size
  21631. * * sizeZ allows stretching in the z direction, optional, default size
  21632. * * 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
  21633. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21634. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21635. * * flat when true creates a flat shaded mesh, optional, default true
  21636. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21637. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21638. * * 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)
  21639. * * 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)
  21640. * @returns the VertexData of the Polyhedron
  21641. */
  21642. static CreatePolyhedron(options: {
  21643. type?: number;
  21644. size?: number;
  21645. sizeX?: number;
  21646. sizeY?: number;
  21647. sizeZ?: number;
  21648. custom?: any;
  21649. faceUV?: Vector4[];
  21650. faceColors?: Color4[];
  21651. flat?: boolean;
  21652. sideOrientation?: number;
  21653. frontUVs?: Vector4;
  21654. backUVs?: Vector4;
  21655. }): VertexData;
  21656. /**
  21657. * Creates the VertexData for a TorusKnot
  21658. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21659. * * radius the radius of the torus knot, optional, default 2
  21660. * * tube the thickness of the tube, optional, default 0.5
  21661. * * radialSegments the number of sides on each tube segments, optional, default 32
  21662. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21663. * * p the number of windings around the z axis, optional, default 2
  21664. * * q the number of windings around the x axis, optional, default 3
  21665. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21666. * * 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)
  21667. * * 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)
  21668. * @returns the VertexData of the Torus Knot
  21669. */
  21670. static CreateTorusKnot(options: {
  21671. radius?: number;
  21672. tube?: number;
  21673. radialSegments?: number;
  21674. tubularSegments?: number;
  21675. p?: number;
  21676. q?: number;
  21677. sideOrientation?: number;
  21678. frontUVs?: Vector4;
  21679. backUVs?: Vector4;
  21680. }): VertexData;
  21681. /**
  21682. * Compute normals for given positions and indices
  21683. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21684. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21685. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21686. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21687. * * facetNormals : optional array of facet normals (vector3)
  21688. * * facetPositions : optional array of facet positions (vector3)
  21689. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21690. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21691. * * bInfo : optional bounding info, required for facetPartitioning computation
  21692. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21693. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21694. * * useRightHandedSystem: optional boolean to for right handed system computation
  21695. * * depthSort : optional boolean to enable the facet depth sort computation
  21696. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21697. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21698. */
  21699. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21700. facetNormals?: any;
  21701. facetPositions?: any;
  21702. facetPartitioning?: any;
  21703. ratio?: number;
  21704. bInfo?: any;
  21705. bbSize?: Vector3;
  21706. subDiv?: any;
  21707. useRightHandedSystem?: boolean;
  21708. depthSort?: boolean;
  21709. distanceTo?: Vector3;
  21710. depthSortedFacets?: any;
  21711. }): void;
  21712. /** @hidden */
  21713. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21714. /**
  21715. * Applies VertexData created from the imported parameters to the geometry
  21716. * @param parsedVertexData the parsed data from an imported file
  21717. * @param geometry the geometry to apply the VertexData to
  21718. */
  21719. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21720. }
  21721. }
  21722. declare module BABYLON {
  21723. /**
  21724. * Defines a target to use with MorphTargetManager
  21725. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21726. */
  21727. export class MorphTarget implements IAnimatable {
  21728. /** defines the name of the target */
  21729. name: string;
  21730. /**
  21731. * Gets or sets the list of animations
  21732. */
  21733. animations: Animation[];
  21734. private _scene;
  21735. private _positions;
  21736. private _normals;
  21737. private _tangents;
  21738. private _uvs;
  21739. private _influence;
  21740. /**
  21741. * Observable raised when the influence changes
  21742. */
  21743. onInfluenceChanged: Observable<boolean>;
  21744. /** @hidden */
  21745. _onDataLayoutChanged: Observable<void>;
  21746. /**
  21747. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21748. */
  21749. influence: number;
  21750. /**
  21751. * Gets or sets the id of the morph Target
  21752. */
  21753. id: string;
  21754. private _animationPropertiesOverride;
  21755. /**
  21756. * Gets or sets the animation properties override
  21757. */
  21758. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21759. /**
  21760. * Creates a new MorphTarget
  21761. * @param name defines the name of the target
  21762. * @param influence defines the influence to use
  21763. * @param scene defines the scene the morphtarget belongs to
  21764. */
  21765. constructor(
  21766. /** defines the name of the target */
  21767. name: string, influence?: number, scene?: Nullable<Scene>);
  21768. /**
  21769. * Gets a boolean defining if the target contains position data
  21770. */
  21771. readonly hasPositions: boolean;
  21772. /**
  21773. * Gets a boolean defining if the target contains normal data
  21774. */
  21775. readonly hasNormals: boolean;
  21776. /**
  21777. * Gets a boolean defining if the target contains tangent data
  21778. */
  21779. readonly hasTangents: boolean;
  21780. /**
  21781. * Gets a boolean defining if the target contains texture coordinates data
  21782. */
  21783. readonly hasUVs: boolean;
  21784. /**
  21785. * Affects position data to this target
  21786. * @param data defines the position data to use
  21787. */
  21788. setPositions(data: Nullable<FloatArray>): void;
  21789. /**
  21790. * Gets the position data stored in this target
  21791. * @returns a FloatArray containing the position data (or null if not present)
  21792. */
  21793. getPositions(): Nullable<FloatArray>;
  21794. /**
  21795. * Affects normal data to this target
  21796. * @param data defines the normal data to use
  21797. */
  21798. setNormals(data: Nullable<FloatArray>): void;
  21799. /**
  21800. * Gets the normal data stored in this target
  21801. * @returns a FloatArray containing the normal data (or null if not present)
  21802. */
  21803. getNormals(): Nullable<FloatArray>;
  21804. /**
  21805. * Affects tangent data to this target
  21806. * @param data defines the tangent data to use
  21807. */
  21808. setTangents(data: Nullable<FloatArray>): void;
  21809. /**
  21810. * Gets the tangent data stored in this target
  21811. * @returns a FloatArray containing the tangent data (or null if not present)
  21812. */
  21813. getTangents(): Nullable<FloatArray>;
  21814. /**
  21815. * Affects texture coordinates data to this target
  21816. * @param data defines the texture coordinates data to use
  21817. */
  21818. setUVs(data: Nullable<FloatArray>): void;
  21819. /**
  21820. * Gets the texture coordinates data stored in this target
  21821. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21822. */
  21823. getUVs(): Nullable<FloatArray>;
  21824. /**
  21825. * Serializes the current target into a Serialization object
  21826. * @returns the serialized object
  21827. */
  21828. serialize(): any;
  21829. /**
  21830. * Returns the string "MorphTarget"
  21831. * @returns "MorphTarget"
  21832. */
  21833. getClassName(): string;
  21834. /**
  21835. * Creates a new target from serialized data
  21836. * @param serializationObject defines the serialized data to use
  21837. * @returns a new MorphTarget
  21838. */
  21839. static Parse(serializationObject: any): MorphTarget;
  21840. /**
  21841. * Creates a MorphTarget from mesh data
  21842. * @param mesh defines the source mesh
  21843. * @param name defines the name to use for the new target
  21844. * @param influence defines the influence to attach to the target
  21845. * @returns a new MorphTarget
  21846. */
  21847. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21848. }
  21849. }
  21850. declare module BABYLON {
  21851. /**
  21852. * This class is used to deform meshes using morphing between different targets
  21853. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21854. */
  21855. export class MorphTargetManager {
  21856. private _targets;
  21857. private _targetInfluenceChangedObservers;
  21858. private _targetDataLayoutChangedObservers;
  21859. private _activeTargets;
  21860. private _scene;
  21861. private _influences;
  21862. private _supportsNormals;
  21863. private _supportsTangents;
  21864. private _supportsUVs;
  21865. private _vertexCount;
  21866. private _uniqueId;
  21867. private _tempInfluences;
  21868. /**
  21869. * Gets or sets a boolean indicating if normals must be morphed
  21870. */
  21871. enableNormalMorphing: boolean;
  21872. /**
  21873. * Gets or sets a boolean indicating if tangents must be morphed
  21874. */
  21875. enableTangentMorphing: boolean;
  21876. /**
  21877. * Gets or sets a boolean indicating if UV must be morphed
  21878. */
  21879. enableUVMorphing: boolean;
  21880. /**
  21881. * Creates a new MorphTargetManager
  21882. * @param scene defines the current scene
  21883. */
  21884. constructor(scene?: Nullable<Scene>);
  21885. /**
  21886. * Gets the unique ID of this manager
  21887. */
  21888. readonly uniqueId: number;
  21889. /**
  21890. * Gets the number of vertices handled by this manager
  21891. */
  21892. readonly vertexCount: number;
  21893. /**
  21894. * Gets a boolean indicating if this manager supports morphing of normals
  21895. */
  21896. readonly supportsNormals: boolean;
  21897. /**
  21898. * Gets a boolean indicating if this manager supports morphing of tangents
  21899. */
  21900. readonly supportsTangents: boolean;
  21901. /**
  21902. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21903. */
  21904. readonly supportsUVs: boolean;
  21905. /**
  21906. * Gets the number of targets stored in this manager
  21907. */
  21908. readonly numTargets: number;
  21909. /**
  21910. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21911. */
  21912. readonly numInfluencers: number;
  21913. /**
  21914. * Gets the list of influences (one per target)
  21915. */
  21916. readonly influences: Float32Array;
  21917. /**
  21918. * Gets the active target at specified index. An active target is a target with an influence > 0
  21919. * @param index defines the index to check
  21920. * @returns the requested target
  21921. */
  21922. getActiveTarget(index: number): MorphTarget;
  21923. /**
  21924. * Gets the target at specified index
  21925. * @param index defines the index to check
  21926. * @returns the requested target
  21927. */
  21928. getTarget(index: number): MorphTarget;
  21929. /**
  21930. * Add a new target to this manager
  21931. * @param target defines the target to add
  21932. */
  21933. addTarget(target: MorphTarget): void;
  21934. /**
  21935. * Removes a target from the manager
  21936. * @param target defines the target to remove
  21937. */
  21938. removeTarget(target: MorphTarget): void;
  21939. /**
  21940. * Serializes the current manager into a Serialization object
  21941. * @returns the serialized object
  21942. */
  21943. serialize(): any;
  21944. private _syncActiveTargets;
  21945. /**
  21946. * Syncrhonize the targets with all the meshes using this morph target manager
  21947. */
  21948. synchronize(): void;
  21949. /**
  21950. * Creates a new MorphTargetManager from serialized data
  21951. * @param serializationObject defines the serialized data
  21952. * @param scene defines the hosting scene
  21953. * @returns the new MorphTargetManager
  21954. */
  21955. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  21956. }
  21957. }
  21958. declare module BABYLON {
  21959. /**
  21960. * Class used to represent a specific level of detail of a mesh
  21961. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21962. */
  21963. export class MeshLODLevel {
  21964. /** Defines the distance where this level should start being displayed */
  21965. distance: number;
  21966. /** Defines the mesh to use to render this level */
  21967. mesh: Nullable<Mesh>;
  21968. /**
  21969. * Creates a new LOD level
  21970. * @param distance defines the distance where this level should star being displayed
  21971. * @param mesh defines the mesh to use to render this level
  21972. */
  21973. constructor(
  21974. /** Defines the distance where this level should start being displayed */
  21975. distance: number,
  21976. /** Defines the mesh to use to render this level */
  21977. mesh: Nullable<Mesh>);
  21978. }
  21979. }
  21980. declare module BABYLON {
  21981. /**
  21982. * Mesh representing the gorund
  21983. */
  21984. export class GroundMesh extends Mesh {
  21985. /** If octree should be generated */
  21986. generateOctree: boolean;
  21987. private _heightQuads;
  21988. /** @hidden */
  21989. _subdivisionsX: number;
  21990. /** @hidden */
  21991. _subdivisionsY: number;
  21992. /** @hidden */
  21993. _width: number;
  21994. /** @hidden */
  21995. _height: number;
  21996. /** @hidden */
  21997. _minX: number;
  21998. /** @hidden */
  21999. _maxX: number;
  22000. /** @hidden */
  22001. _minZ: number;
  22002. /** @hidden */
  22003. _maxZ: number;
  22004. constructor(name: string, scene: Scene);
  22005. /**
  22006. * "GroundMesh"
  22007. * @returns "GroundMesh"
  22008. */
  22009. getClassName(): string;
  22010. /**
  22011. * The minimum of x and y subdivisions
  22012. */
  22013. readonly subdivisions: number;
  22014. /**
  22015. * X subdivisions
  22016. */
  22017. readonly subdivisionsX: number;
  22018. /**
  22019. * Y subdivisions
  22020. */
  22021. readonly subdivisionsY: number;
  22022. /**
  22023. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22024. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22025. * @param chunksCount the number of subdivisions for x and y
  22026. * @param octreeBlocksSize (Default: 32)
  22027. */
  22028. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22029. /**
  22030. * Returns a height (y) value in the Worl system :
  22031. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22032. * @param x x coordinate
  22033. * @param z z coordinate
  22034. * @returns the ground y position if (x, z) are outside the ground surface.
  22035. */
  22036. getHeightAtCoordinates(x: number, z: number): number;
  22037. /**
  22038. * Returns a normalized vector (Vector3) orthogonal to the ground
  22039. * at the ground coordinates (x, z) expressed in the World system.
  22040. * @param x x coordinate
  22041. * @param z z coordinate
  22042. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22043. */
  22044. getNormalAtCoordinates(x: number, z: number): Vector3;
  22045. /**
  22046. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22047. * at the ground coordinates (x, z) expressed in the World system.
  22048. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22049. * @param x x coordinate
  22050. * @param z z coordinate
  22051. * @param ref vector to store the result
  22052. * @returns the GroundMesh.
  22053. */
  22054. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22055. /**
  22056. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22057. * if the ground has been updated.
  22058. * This can be used in the render loop.
  22059. * @returns the GroundMesh.
  22060. */
  22061. updateCoordinateHeights(): GroundMesh;
  22062. private _getFacetAt;
  22063. private _initHeightQuads;
  22064. private _computeHeightQuads;
  22065. /**
  22066. * Serializes this ground mesh
  22067. * @param serializationObject object to write serialization to
  22068. */
  22069. serialize(serializationObject: any): void;
  22070. /**
  22071. * Parses a serialized ground mesh
  22072. * @param parsedMesh the serialized mesh
  22073. * @param scene the scene to create the ground mesh in
  22074. * @returns the created ground mesh
  22075. */
  22076. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22077. }
  22078. }
  22079. declare module BABYLON {
  22080. /**
  22081. * Interface for Physics-Joint data
  22082. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22083. */
  22084. export interface PhysicsJointData {
  22085. /**
  22086. * The main pivot of the joint
  22087. */
  22088. mainPivot?: Vector3;
  22089. /**
  22090. * The connected pivot of the joint
  22091. */
  22092. connectedPivot?: Vector3;
  22093. /**
  22094. * The main axis of the joint
  22095. */
  22096. mainAxis?: Vector3;
  22097. /**
  22098. * The connected axis of the joint
  22099. */
  22100. connectedAxis?: Vector3;
  22101. /**
  22102. * The collision of the joint
  22103. */
  22104. collision?: boolean;
  22105. /**
  22106. * Native Oimo/Cannon/Energy data
  22107. */
  22108. nativeParams?: any;
  22109. }
  22110. /**
  22111. * This is a holder class for the physics joint created by the physics plugin
  22112. * It holds a set of functions to control the underlying joint
  22113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22114. */
  22115. export class PhysicsJoint {
  22116. /**
  22117. * The type of the physics joint
  22118. */
  22119. type: number;
  22120. /**
  22121. * The data for the physics joint
  22122. */
  22123. jointData: PhysicsJointData;
  22124. private _physicsJoint;
  22125. protected _physicsPlugin: IPhysicsEnginePlugin;
  22126. /**
  22127. * Initializes the physics joint
  22128. * @param type The type of the physics joint
  22129. * @param jointData The data for the physics joint
  22130. */
  22131. constructor(
  22132. /**
  22133. * The type of the physics joint
  22134. */
  22135. type: number,
  22136. /**
  22137. * The data for the physics joint
  22138. */
  22139. jointData: PhysicsJointData);
  22140. /**
  22141. * Gets the physics joint
  22142. */
  22143. /**
  22144. * Sets the physics joint
  22145. */
  22146. physicsJoint: any;
  22147. /**
  22148. * Sets the physics plugin
  22149. */
  22150. physicsPlugin: IPhysicsEnginePlugin;
  22151. /**
  22152. * Execute a function that is physics-plugin specific.
  22153. * @param {Function} func the function that will be executed.
  22154. * It accepts two parameters: the physics world and the physics joint
  22155. */
  22156. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22157. /**
  22158. * Distance-Joint type
  22159. */
  22160. static DistanceJoint: number;
  22161. /**
  22162. * Hinge-Joint type
  22163. */
  22164. static HingeJoint: number;
  22165. /**
  22166. * Ball-and-Socket joint type
  22167. */
  22168. static BallAndSocketJoint: number;
  22169. /**
  22170. * Wheel-Joint type
  22171. */
  22172. static WheelJoint: number;
  22173. /**
  22174. * Slider-Joint type
  22175. */
  22176. static SliderJoint: number;
  22177. /**
  22178. * Prismatic-Joint type
  22179. */
  22180. static PrismaticJoint: number;
  22181. /**
  22182. * Universal-Joint type
  22183. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22184. */
  22185. static UniversalJoint: number;
  22186. /**
  22187. * Hinge-Joint 2 type
  22188. */
  22189. static Hinge2Joint: number;
  22190. /**
  22191. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22192. */
  22193. static PointToPointJoint: number;
  22194. /**
  22195. * Spring-Joint type
  22196. */
  22197. static SpringJoint: number;
  22198. /**
  22199. * Lock-Joint type
  22200. */
  22201. static LockJoint: number;
  22202. }
  22203. /**
  22204. * A class representing a physics distance joint
  22205. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22206. */
  22207. export class DistanceJoint extends PhysicsJoint {
  22208. /**
  22209. *
  22210. * @param jointData The data for the Distance-Joint
  22211. */
  22212. constructor(jointData: DistanceJointData);
  22213. /**
  22214. * Update the predefined distance.
  22215. * @param maxDistance The maximum preferred distance
  22216. * @param minDistance The minimum preferred distance
  22217. */
  22218. updateDistance(maxDistance: number, minDistance?: number): void;
  22219. }
  22220. /**
  22221. * Represents a Motor-Enabled Joint
  22222. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22223. */
  22224. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22225. /**
  22226. * Initializes the Motor-Enabled Joint
  22227. * @param type The type of the joint
  22228. * @param jointData The physica joint data for the joint
  22229. */
  22230. constructor(type: number, jointData: PhysicsJointData);
  22231. /**
  22232. * Set the motor values.
  22233. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22234. * @param force the force to apply
  22235. * @param maxForce max force for this motor.
  22236. */
  22237. setMotor(force?: number, maxForce?: number): void;
  22238. /**
  22239. * Set the motor's limits.
  22240. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22241. * @param upperLimit The upper limit of the motor
  22242. * @param lowerLimit The lower limit of the motor
  22243. */
  22244. setLimit(upperLimit: number, lowerLimit?: number): void;
  22245. }
  22246. /**
  22247. * This class represents a single physics Hinge-Joint
  22248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22249. */
  22250. export class HingeJoint extends MotorEnabledJoint {
  22251. /**
  22252. * Initializes the Hinge-Joint
  22253. * @param jointData The joint data for the Hinge-Joint
  22254. */
  22255. constructor(jointData: PhysicsJointData);
  22256. /**
  22257. * Set the motor values.
  22258. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22259. * @param {number} force the force to apply
  22260. * @param {number} maxForce max force for this motor.
  22261. */
  22262. setMotor(force?: number, maxForce?: number): void;
  22263. /**
  22264. * Set the motor's limits.
  22265. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22266. * @param upperLimit The upper limit of the motor
  22267. * @param lowerLimit The lower limit of the motor
  22268. */
  22269. setLimit(upperLimit: number, lowerLimit?: number): void;
  22270. }
  22271. /**
  22272. * This class represents a dual hinge physics joint (same as wheel joint)
  22273. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22274. */
  22275. export class Hinge2Joint extends MotorEnabledJoint {
  22276. /**
  22277. * Initializes the Hinge2-Joint
  22278. * @param jointData The joint data for the Hinge2-Joint
  22279. */
  22280. constructor(jointData: PhysicsJointData);
  22281. /**
  22282. * Set the motor values.
  22283. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22284. * @param {number} targetSpeed the speed the motor is to reach
  22285. * @param {number} maxForce max force for this motor.
  22286. * @param {motorIndex} the motor's index, 0 or 1.
  22287. */
  22288. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22289. /**
  22290. * Set the motor limits.
  22291. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22292. * @param {number} upperLimit the upper limit
  22293. * @param {number} lowerLimit lower limit
  22294. * @param {motorIndex} the motor's index, 0 or 1.
  22295. */
  22296. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22297. }
  22298. /**
  22299. * Interface for a motor enabled joint
  22300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22301. */
  22302. export interface IMotorEnabledJoint {
  22303. /**
  22304. * Physics joint
  22305. */
  22306. physicsJoint: any;
  22307. /**
  22308. * Sets the motor of the motor-enabled joint
  22309. * @param force The force of the motor
  22310. * @param maxForce The maximum force of the motor
  22311. * @param motorIndex The index of the motor
  22312. */
  22313. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22314. /**
  22315. * Sets the limit of the motor
  22316. * @param upperLimit The upper limit of the motor
  22317. * @param lowerLimit The lower limit of the motor
  22318. * @param motorIndex The index of the motor
  22319. */
  22320. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22321. }
  22322. /**
  22323. * Joint data for a Distance-Joint
  22324. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22325. */
  22326. export interface DistanceJointData extends PhysicsJointData {
  22327. /**
  22328. * Max distance the 2 joint objects can be apart
  22329. */
  22330. maxDistance: number;
  22331. }
  22332. /**
  22333. * Joint data from a spring joint
  22334. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22335. */
  22336. export interface SpringJointData extends PhysicsJointData {
  22337. /**
  22338. * Length of the spring
  22339. */
  22340. length: number;
  22341. /**
  22342. * Stiffness of the spring
  22343. */
  22344. stiffness: number;
  22345. /**
  22346. * Damping of the spring
  22347. */
  22348. damping: number;
  22349. /** this callback will be called when applying the force to the impostors. */
  22350. forceApplicationCallback: () => void;
  22351. }
  22352. }
  22353. declare module BABYLON {
  22354. /**
  22355. * Holds the data for the raycast result
  22356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22357. */
  22358. export class PhysicsRaycastResult {
  22359. private _hasHit;
  22360. private _hitDistance;
  22361. private _hitNormalWorld;
  22362. private _hitPointWorld;
  22363. private _rayFromWorld;
  22364. private _rayToWorld;
  22365. /**
  22366. * Gets if there was a hit
  22367. */
  22368. readonly hasHit: boolean;
  22369. /**
  22370. * Gets the distance from the hit
  22371. */
  22372. readonly hitDistance: number;
  22373. /**
  22374. * Gets the hit normal/direction in the world
  22375. */
  22376. readonly hitNormalWorld: Vector3;
  22377. /**
  22378. * Gets the hit point in the world
  22379. */
  22380. readonly hitPointWorld: Vector3;
  22381. /**
  22382. * Gets the ray "start point" of the ray in the world
  22383. */
  22384. readonly rayFromWorld: Vector3;
  22385. /**
  22386. * Gets the ray "end point" of the ray in the world
  22387. */
  22388. readonly rayToWorld: Vector3;
  22389. /**
  22390. * Sets the hit data (normal & point in world space)
  22391. * @param hitNormalWorld defines the normal in world space
  22392. * @param hitPointWorld defines the point in world space
  22393. */
  22394. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22395. /**
  22396. * Sets the distance from the start point to the hit point
  22397. * @param distance
  22398. */
  22399. setHitDistance(distance: number): void;
  22400. /**
  22401. * Calculates the distance manually
  22402. */
  22403. calculateHitDistance(): void;
  22404. /**
  22405. * Resets all the values to default
  22406. * @param from The from point on world space
  22407. * @param to The to point on world space
  22408. */
  22409. reset(from?: Vector3, to?: Vector3): void;
  22410. }
  22411. /**
  22412. * Interface for the size containing width and height
  22413. */
  22414. interface IXYZ {
  22415. /**
  22416. * X
  22417. */
  22418. x: number;
  22419. /**
  22420. * Y
  22421. */
  22422. y: number;
  22423. /**
  22424. * Z
  22425. */
  22426. z: number;
  22427. }
  22428. }
  22429. declare module BABYLON {
  22430. /**
  22431. * Interface used to describe a physics joint
  22432. */
  22433. export interface PhysicsImpostorJoint {
  22434. /** Defines the main impostor to which the joint is linked */
  22435. mainImpostor: PhysicsImpostor;
  22436. /** Defines the impostor that is connected to the main impostor using this joint */
  22437. connectedImpostor: PhysicsImpostor;
  22438. /** Defines the joint itself */
  22439. joint: PhysicsJoint;
  22440. }
  22441. /** @hidden */
  22442. export interface IPhysicsEnginePlugin {
  22443. world: any;
  22444. name: string;
  22445. setGravity(gravity: Vector3): void;
  22446. setTimeStep(timeStep: number): void;
  22447. getTimeStep(): number;
  22448. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22449. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22450. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22451. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22452. removePhysicsBody(impostor: PhysicsImpostor): void;
  22453. generateJoint(joint: PhysicsImpostorJoint): void;
  22454. removeJoint(joint: PhysicsImpostorJoint): void;
  22455. isSupported(): boolean;
  22456. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22457. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22458. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22459. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22460. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22461. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22462. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22463. getBodyMass(impostor: PhysicsImpostor): number;
  22464. getBodyFriction(impostor: PhysicsImpostor): number;
  22465. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22466. getBodyRestitution(impostor: PhysicsImpostor): number;
  22467. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22468. getBodyPressure?(impostor: PhysicsImpostor): number;
  22469. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22470. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22471. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22472. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22473. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22474. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22475. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22476. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22477. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22478. sleepBody(impostor: PhysicsImpostor): void;
  22479. wakeUpBody(impostor: PhysicsImpostor): void;
  22480. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22481. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22482. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22483. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22484. getRadius(impostor: PhysicsImpostor): number;
  22485. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22486. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22487. dispose(): void;
  22488. }
  22489. /**
  22490. * Interface used to define a physics engine
  22491. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22492. */
  22493. export interface IPhysicsEngine {
  22494. /**
  22495. * Gets the gravity vector used by the simulation
  22496. */
  22497. gravity: Vector3;
  22498. /**
  22499. * Sets the gravity vector used by the simulation
  22500. * @param gravity defines the gravity vector to use
  22501. */
  22502. setGravity(gravity: Vector3): void;
  22503. /**
  22504. * Set the time step of the physics engine.
  22505. * Default is 1/60.
  22506. * To slow it down, enter 1/600 for example.
  22507. * To speed it up, 1/30
  22508. * @param newTimeStep the new timestep to apply to this world.
  22509. */
  22510. setTimeStep(newTimeStep: number): void;
  22511. /**
  22512. * Get the time step of the physics engine.
  22513. * @returns the current time step
  22514. */
  22515. getTimeStep(): number;
  22516. /**
  22517. * Release all resources
  22518. */
  22519. dispose(): void;
  22520. /**
  22521. * Gets the name of the current physics plugin
  22522. * @returns the name of the plugin
  22523. */
  22524. getPhysicsPluginName(): string;
  22525. /**
  22526. * Adding a new impostor for the impostor tracking.
  22527. * This will be done by the impostor itself.
  22528. * @param impostor the impostor to add
  22529. */
  22530. addImpostor(impostor: PhysicsImpostor): void;
  22531. /**
  22532. * Remove an impostor from the engine.
  22533. * This impostor and its mesh will not longer be updated by the physics engine.
  22534. * @param impostor the impostor to remove
  22535. */
  22536. removeImpostor(impostor: PhysicsImpostor): void;
  22537. /**
  22538. * Add a joint to the physics engine
  22539. * @param mainImpostor defines the main impostor to which the joint is added.
  22540. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22541. * @param joint defines the joint that will connect both impostors.
  22542. */
  22543. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22544. /**
  22545. * Removes a joint from the simulation
  22546. * @param mainImpostor defines the impostor used with the joint
  22547. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22548. * @param joint defines the joint to remove
  22549. */
  22550. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22551. /**
  22552. * Gets the current plugin used to run the simulation
  22553. * @returns current plugin
  22554. */
  22555. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22556. /**
  22557. * Gets the list of physic impostors
  22558. * @returns an array of PhysicsImpostor
  22559. */
  22560. getImpostors(): Array<PhysicsImpostor>;
  22561. /**
  22562. * Gets the impostor for a physics enabled object
  22563. * @param object defines the object impersonated by the impostor
  22564. * @returns the PhysicsImpostor or null if not found
  22565. */
  22566. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22567. /**
  22568. * Gets the impostor for a physics body object
  22569. * @param body defines physics body used by the impostor
  22570. * @returns the PhysicsImpostor or null if not found
  22571. */
  22572. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22573. /**
  22574. * Does a raycast in the physics world
  22575. * @param from when should the ray start?
  22576. * @param to when should the ray end?
  22577. * @returns PhysicsRaycastResult
  22578. */
  22579. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22580. /**
  22581. * Called by the scene. No need to call it.
  22582. * @param delta defines the timespam between frames
  22583. */
  22584. _step(delta: number): void;
  22585. }
  22586. }
  22587. declare module BABYLON {
  22588. /**
  22589. * The interface for the physics imposter parameters
  22590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22591. */
  22592. export interface PhysicsImpostorParameters {
  22593. /**
  22594. * The mass of the physics imposter
  22595. */
  22596. mass: number;
  22597. /**
  22598. * The friction of the physics imposter
  22599. */
  22600. friction?: number;
  22601. /**
  22602. * The coefficient of restitution of the physics imposter
  22603. */
  22604. restitution?: number;
  22605. /**
  22606. * The native options of the physics imposter
  22607. */
  22608. nativeOptions?: any;
  22609. /**
  22610. * Specifies if the parent should be ignored
  22611. */
  22612. ignoreParent?: boolean;
  22613. /**
  22614. * Specifies if bi-directional transformations should be disabled
  22615. */
  22616. disableBidirectionalTransformation?: boolean;
  22617. /**
  22618. * The pressure inside the physics imposter, soft object only
  22619. */
  22620. pressure?: number;
  22621. /**
  22622. * The stiffness the physics imposter, soft object only
  22623. */
  22624. stiffness?: number;
  22625. /**
  22626. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22627. */
  22628. velocityIterations?: number;
  22629. /**
  22630. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22631. */
  22632. positionIterations?: number;
  22633. /**
  22634. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22635. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22636. * Add to fix multiple points
  22637. */
  22638. fixedPoints?: number;
  22639. /**
  22640. * The collision margin around a soft object
  22641. */
  22642. margin?: number;
  22643. /**
  22644. * The collision margin around a soft object
  22645. */
  22646. damping?: number;
  22647. /**
  22648. * The path for a rope based on an extrusion
  22649. */
  22650. path?: any;
  22651. /**
  22652. * The shape of an extrusion used for a rope based on an extrusion
  22653. */
  22654. shape?: any;
  22655. }
  22656. /**
  22657. * Interface for a physics-enabled object
  22658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22659. */
  22660. export interface IPhysicsEnabledObject {
  22661. /**
  22662. * The position of the physics-enabled object
  22663. */
  22664. position: Vector3;
  22665. /**
  22666. * The rotation of the physics-enabled object
  22667. */
  22668. rotationQuaternion: Nullable<Quaternion>;
  22669. /**
  22670. * The scale of the physics-enabled object
  22671. */
  22672. scaling: Vector3;
  22673. /**
  22674. * The rotation of the physics-enabled object
  22675. */
  22676. rotation?: Vector3;
  22677. /**
  22678. * The parent of the physics-enabled object
  22679. */
  22680. parent?: any;
  22681. /**
  22682. * The bounding info of the physics-enabled object
  22683. * @returns The bounding info of the physics-enabled object
  22684. */
  22685. getBoundingInfo(): BoundingInfo;
  22686. /**
  22687. * Computes the world matrix
  22688. * @param force Specifies if the world matrix should be computed by force
  22689. * @returns A world matrix
  22690. */
  22691. computeWorldMatrix(force: boolean): Matrix;
  22692. /**
  22693. * Gets the world matrix
  22694. * @returns A world matrix
  22695. */
  22696. getWorldMatrix?(): Matrix;
  22697. /**
  22698. * Gets the child meshes
  22699. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22700. * @returns An array of abstract meshes
  22701. */
  22702. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22703. /**
  22704. * Gets the vertex data
  22705. * @param kind The type of vertex data
  22706. * @returns A nullable array of numbers, or a float32 array
  22707. */
  22708. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22709. /**
  22710. * Gets the indices from the mesh
  22711. * @returns A nullable array of index arrays
  22712. */
  22713. getIndices?(): Nullable<IndicesArray>;
  22714. /**
  22715. * Gets the scene from the mesh
  22716. * @returns the indices array or null
  22717. */
  22718. getScene?(): Scene;
  22719. /**
  22720. * Gets the absolute position from the mesh
  22721. * @returns the absolute position
  22722. */
  22723. getAbsolutePosition(): Vector3;
  22724. /**
  22725. * Gets the absolute pivot point from the mesh
  22726. * @returns the absolute pivot point
  22727. */
  22728. getAbsolutePivotPoint(): Vector3;
  22729. /**
  22730. * Rotates the mesh
  22731. * @param axis The axis of rotation
  22732. * @param amount The amount of rotation
  22733. * @param space The space of the rotation
  22734. * @returns The rotation transform node
  22735. */
  22736. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22737. /**
  22738. * Translates the mesh
  22739. * @param axis The axis of translation
  22740. * @param distance The distance of translation
  22741. * @param space The space of the translation
  22742. * @returns The transform node
  22743. */
  22744. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22745. /**
  22746. * Sets the absolute position of the mesh
  22747. * @param absolutePosition The absolute position of the mesh
  22748. * @returns The transform node
  22749. */
  22750. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22751. /**
  22752. * Gets the class name of the mesh
  22753. * @returns The class name
  22754. */
  22755. getClassName(): string;
  22756. }
  22757. /**
  22758. * Represents a physics imposter
  22759. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22760. */
  22761. export class PhysicsImpostor {
  22762. /**
  22763. * The physics-enabled object used as the physics imposter
  22764. */
  22765. object: IPhysicsEnabledObject;
  22766. /**
  22767. * The type of the physics imposter
  22768. */
  22769. type: number;
  22770. private _options;
  22771. private _scene?;
  22772. /**
  22773. * The default object size of the imposter
  22774. */
  22775. static DEFAULT_OBJECT_SIZE: Vector3;
  22776. /**
  22777. * The identity quaternion of the imposter
  22778. */
  22779. static IDENTITY_QUATERNION: Quaternion;
  22780. /** @hidden */
  22781. _pluginData: any;
  22782. private _physicsEngine;
  22783. private _physicsBody;
  22784. private _bodyUpdateRequired;
  22785. private _onBeforePhysicsStepCallbacks;
  22786. private _onAfterPhysicsStepCallbacks;
  22787. /** @hidden */
  22788. _onPhysicsCollideCallbacks: Array<{
  22789. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22790. otherImpostors: Array<PhysicsImpostor>;
  22791. }>;
  22792. private _deltaPosition;
  22793. private _deltaRotation;
  22794. private _deltaRotationConjugated;
  22795. /** @hidden */
  22796. _isFromLine: boolean;
  22797. private _parent;
  22798. private _isDisposed;
  22799. private static _tmpVecs;
  22800. private static _tmpQuat;
  22801. /**
  22802. * Specifies if the physics imposter is disposed
  22803. */
  22804. readonly isDisposed: boolean;
  22805. /**
  22806. * Gets the mass of the physics imposter
  22807. */
  22808. mass: number;
  22809. /**
  22810. * Gets the coefficient of friction
  22811. */
  22812. /**
  22813. * Sets the coefficient of friction
  22814. */
  22815. friction: number;
  22816. /**
  22817. * Gets the coefficient of restitution
  22818. */
  22819. /**
  22820. * Sets the coefficient of restitution
  22821. */
  22822. restitution: number;
  22823. /**
  22824. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22825. */
  22826. /**
  22827. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22828. */
  22829. pressure: number;
  22830. /**
  22831. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22832. */
  22833. /**
  22834. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22835. */
  22836. stiffness: number;
  22837. /**
  22838. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22839. */
  22840. /**
  22841. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22842. */
  22843. velocityIterations: number;
  22844. /**
  22845. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22846. */
  22847. /**
  22848. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22849. */
  22850. positionIterations: number;
  22851. /**
  22852. * The unique id of the physics imposter
  22853. * set by the physics engine when adding this impostor to the array
  22854. */
  22855. uniqueId: number;
  22856. /**
  22857. * @hidden
  22858. */
  22859. soft: boolean;
  22860. /**
  22861. * @hidden
  22862. */
  22863. segments: number;
  22864. private _joints;
  22865. /**
  22866. * Initializes the physics imposter
  22867. * @param object The physics-enabled object used as the physics imposter
  22868. * @param type The type of the physics imposter
  22869. * @param _options The options for the physics imposter
  22870. * @param _scene The Babylon scene
  22871. */
  22872. constructor(
  22873. /**
  22874. * The physics-enabled object used as the physics imposter
  22875. */
  22876. object: IPhysicsEnabledObject,
  22877. /**
  22878. * The type of the physics imposter
  22879. */
  22880. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22881. /**
  22882. * This function will completly initialize this impostor.
  22883. * It will create a new body - but only if this mesh has no parent.
  22884. * If it has, this impostor will not be used other than to define the impostor
  22885. * of the child mesh.
  22886. * @hidden
  22887. */
  22888. _init(): void;
  22889. private _getPhysicsParent;
  22890. /**
  22891. * Should a new body be generated.
  22892. * @returns boolean specifying if body initialization is required
  22893. */
  22894. isBodyInitRequired(): boolean;
  22895. /**
  22896. * Sets the updated scaling
  22897. * @param updated Specifies if the scaling is updated
  22898. */
  22899. setScalingUpdated(): void;
  22900. /**
  22901. * Force a regeneration of this or the parent's impostor's body.
  22902. * Use under cautious - This will remove all joints already implemented.
  22903. */
  22904. forceUpdate(): void;
  22905. /**
  22906. * Gets the body that holds this impostor. Either its own, or its parent.
  22907. */
  22908. /**
  22909. * Set the physics body. Used mainly by the physics engine/plugin
  22910. */
  22911. physicsBody: any;
  22912. /**
  22913. * Get the parent of the physics imposter
  22914. * @returns Physics imposter or null
  22915. */
  22916. /**
  22917. * Sets the parent of the physics imposter
  22918. */
  22919. parent: Nullable<PhysicsImpostor>;
  22920. /**
  22921. * Resets the update flags
  22922. */
  22923. resetUpdateFlags(): void;
  22924. /**
  22925. * Gets the object extend size
  22926. * @returns the object extend size
  22927. */
  22928. getObjectExtendSize(): Vector3;
  22929. /**
  22930. * Gets the object center
  22931. * @returns The object center
  22932. */
  22933. getObjectCenter(): Vector3;
  22934. /**
  22935. * Get a specific parametes from the options parameter
  22936. * @param paramName The object parameter name
  22937. * @returns The object parameter
  22938. */
  22939. getParam(paramName: string): any;
  22940. /**
  22941. * Sets a specific parameter in the options given to the physics plugin
  22942. * @param paramName The parameter name
  22943. * @param value The value of the parameter
  22944. */
  22945. setParam(paramName: string, value: number): void;
  22946. /**
  22947. * Specifically change the body's mass option. Won't recreate the physics body object
  22948. * @param mass The mass of the physics imposter
  22949. */
  22950. setMass(mass: number): void;
  22951. /**
  22952. * Gets the linear velocity
  22953. * @returns linear velocity or null
  22954. */
  22955. getLinearVelocity(): Nullable<Vector3>;
  22956. /**
  22957. * Sets the linear velocity
  22958. * @param velocity linear velocity or null
  22959. */
  22960. setLinearVelocity(velocity: Nullable<Vector3>): void;
  22961. /**
  22962. * Gets the angular velocity
  22963. * @returns angular velocity or null
  22964. */
  22965. getAngularVelocity(): Nullable<Vector3>;
  22966. /**
  22967. * Sets the angular velocity
  22968. * @param velocity The velocity or null
  22969. */
  22970. setAngularVelocity(velocity: Nullable<Vector3>): void;
  22971. /**
  22972. * Execute a function with the physics plugin native code
  22973. * Provide a function the will have two variables - the world object and the physics body object
  22974. * @param func The function to execute with the physics plugin native code
  22975. */
  22976. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  22977. /**
  22978. * Register a function that will be executed before the physics world is stepping forward
  22979. * @param func The function to execute before the physics world is stepped forward
  22980. */
  22981. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22982. /**
  22983. * Unregister a function that will be executed before the physics world is stepping forward
  22984. * @param func The function to execute before the physics world is stepped forward
  22985. */
  22986. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22987. /**
  22988. * Register a function that will be executed after the physics step
  22989. * @param func The function to execute after physics step
  22990. */
  22991. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22992. /**
  22993. * Unregisters a function that will be executed after the physics step
  22994. * @param func The function to execute after physics step
  22995. */
  22996. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22997. /**
  22998. * register a function that will be executed when this impostor collides against a different body
  22999. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23000. * @param func Callback that is executed on collision
  23001. */
  23002. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23003. /**
  23004. * Unregisters the physics imposter on contact
  23005. * @param collideAgainst The physics object to collide against
  23006. * @param func Callback to execute on collision
  23007. */
  23008. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23009. private _tmpQuat;
  23010. private _tmpQuat2;
  23011. /**
  23012. * Get the parent rotation
  23013. * @returns The parent rotation
  23014. */
  23015. getParentsRotation(): Quaternion;
  23016. /**
  23017. * this function is executed by the physics engine.
  23018. */
  23019. beforeStep: () => void;
  23020. /**
  23021. * this function is executed by the physics engine
  23022. */
  23023. afterStep: () => void;
  23024. /**
  23025. * Legacy collision detection event support
  23026. */
  23027. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23028. /**
  23029. * event and body object due to cannon's event-based architecture.
  23030. */
  23031. onCollide: (e: {
  23032. body: any;
  23033. }) => void;
  23034. /**
  23035. * Apply a force
  23036. * @param force The force to apply
  23037. * @param contactPoint The contact point for the force
  23038. * @returns The physics imposter
  23039. */
  23040. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23041. /**
  23042. * Apply an impulse
  23043. * @param force The impulse force
  23044. * @param contactPoint The contact point for the impulse force
  23045. * @returns The physics imposter
  23046. */
  23047. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23048. /**
  23049. * A help function to create a joint
  23050. * @param otherImpostor A physics imposter used to create a joint
  23051. * @param jointType The type of joint
  23052. * @param jointData The data for the joint
  23053. * @returns The physics imposter
  23054. */
  23055. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23056. /**
  23057. * Add a joint to this impostor with a different impostor
  23058. * @param otherImpostor A physics imposter used to add a joint
  23059. * @param joint The joint to add
  23060. * @returns The physics imposter
  23061. */
  23062. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23063. /**
  23064. * Add an anchor to a cloth impostor
  23065. * @param otherImpostor rigid impostor to anchor to
  23066. * @param width ratio across width from 0 to 1
  23067. * @param height ratio up height from 0 to 1
  23068. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23069. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23070. * @returns impostor the soft imposter
  23071. */
  23072. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23073. /**
  23074. * Add a hook to a rope impostor
  23075. * @param otherImpostor rigid impostor to anchor to
  23076. * @param length ratio across rope from 0 to 1
  23077. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23078. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23079. * @returns impostor the rope imposter
  23080. */
  23081. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23082. /**
  23083. * Will keep this body still, in a sleep mode.
  23084. * @returns the physics imposter
  23085. */
  23086. sleep(): PhysicsImpostor;
  23087. /**
  23088. * Wake the body up.
  23089. * @returns The physics imposter
  23090. */
  23091. wakeUp(): PhysicsImpostor;
  23092. /**
  23093. * Clones the physics imposter
  23094. * @param newObject The physics imposter clones to this physics-enabled object
  23095. * @returns A nullable physics imposter
  23096. */
  23097. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23098. /**
  23099. * Disposes the physics imposter
  23100. */
  23101. dispose(): void;
  23102. /**
  23103. * Sets the delta position
  23104. * @param position The delta position amount
  23105. */
  23106. setDeltaPosition(position: Vector3): void;
  23107. /**
  23108. * Sets the delta rotation
  23109. * @param rotation The delta rotation amount
  23110. */
  23111. setDeltaRotation(rotation: Quaternion): void;
  23112. /**
  23113. * Gets the box size of the physics imposter and stores the result in the input parameter
  23114. * @param result Stores the box size
  23115. * @returns The physics imposter
  23116. */
  23117. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23118. /**
  23119. * Gets the radius of the physics imposter
  23120. * @returns Radius of the physics imposter
  23121. */
  23122. getRadius(): number;
  23123. /**
  23124. * Sync a bone with this impostor
  23125. * @param bone The bone to sync to the impostor.
  23126. * @param boneMesh The mesh that the bone is influencing.
  23127. * @param jointPivot The pivot of the joint / bone in local space.
  23128. * @param distToJoint Optional distance from the impostor to the joint.
  23129. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23130. */
  23131. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23132. /**
  23133. * Sync impostor to a bone
  23134. * @param bone The bone that the impostor will be synced to.
  23135. * @param boneMesh The mesh that the bone is influencing.
  23136. * @param jointPivot The pivot of the joint / bone in local space.
  23137. * @param distToJoint Optional distance from the impostor to the joint.
  23138. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23139. * @param boneAxis Optional vector3 axis the bone is aligned with
  23140. */
  23141. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23142. /**
  23143. * No-Imposter type
  23144. */
  23145. static NoImpostor: number;
  23146. /**
  23147. * Sphere-Imposter type
  23148. */
  23149. static SphereImpostor: number;
  23150. /**
  23151. * Box-Imposter type
  23152. */
  23153. static BoxImpostor: number;
  23154. /**
  23155. * Plane-Imposter type
  23156. */
  23157. static PlaneImpostor: number;
  23158. /**
  23159. * Mesh-imposter type
  23160. */
  23161. static MeshImpostor: number;
  23162. /**
  23163. * Capsule-Impostor type (Ammo.js plugin only)
  23164. */
  23165. static CapsuleImpostor: number;
  23166. /**
  23167. * Cylinder-Imposter type
  23168. */
  23169. static CylinderImpostor: number;
  23170. /**
  23171. * Particle-Imposter type
  23172. */
  23173. static ParticleImpostor: number;
  23174. /**
  23175. * Heightmap-Imposter type
  23176. */
  23177. static HeightmapImpostor: number;
  23178. /**
  23179. * ConvexHull-Impostor type (Ammo.js plugin only)
  23180. */
  23181. static ConvexHullImpostor: number;
  23182. /**
  23183. * Rope-Imposter type
  23184. */
  23185. static RopeImpostor: number;
  23186. /**
  23187. * Cloth-Imposter type
  23188. */
  23189. static ClothImpostor: number;
  23190. /**
  23191. * Softbody-Imposter type
  23192. */
  23193. static SoftbodyImpostor: number;
  23194. }
  23195. }
  23196. declare module BABYLON {
  23197. /**
  23198. * @hidden
  23199. **/
  23200. export class _CreationDataStorage {
  23201. closePath?: boolean;
  23202. closeArray?: boolean;
  23203. idx: number[];
  23204. dashSize: number;
  23205. gapSize: number;
  23206. path3D: Path3D;
  23207. pathArray: Vector3[][];
  23208. arc: number;
  23209. radius: number;
  23210. cap: number;
  23211. tessellation: number;
  23212. }
  23213. /**
  23214. * @hidden
  23215. **/
  23216. class _InstanceDataStorage {
  23217. visibleInstances: any;
  23218. batchCache: _InstancesBatch;
  23219. instancesBufferSize: number;
  23220. instancesBuffer: Nullable<Buffer>;
  23221. instancesData: Float32Array;
  23222. overridenInstanceCount: number;
  23223. isFrozen: boolean;
  23224. previousBatch: Nullable<_InstancesBatch>;
  23225. hardwareInstancedRendering: boolean;
  23226. sideOrientation: number;
  23227. }
  23228. /**
  23229. * @hidden
  23230. **/
  23231. export class _InstancesBatch {
  23232. mustReturn: boolean;
  23233. visibleInstances: Nullable<InstancedMesh[]>[];
  23234. renderSelf: boolean[];
  23235. hardwareInstancedRendering: boolean[];
  23236. }
  23237. /**
  23238. * Class used to represent renderable models
  23239. */
  23240. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23241. /**
  23242. * Mesh side orientation : usually the external or front surface
  23243. */
  23244. static readonly FRONTSIDE: number;
  23245. /**
  23246. * Mesh side orientation : usually the internal or back surface
  23247. */
  23248. static readonly BACKSIDE: number;
  23249. /**
  23250. * Mesh side orientation : both internal and external or front and back surfaces
  23251. */
  23252. static readonly DOUBLESIDE: number;
  23253. /**
  23254. * Mesh side orientation : by default, `FRONTSIDE`
  23255. */
  23256. static readonly DEFAULTSIDE: number;
  23257. /**
  23258. * Mesh cap setting : no cap
  23259. */
  23260. static readonly NO_CAP: number;
  23261. /**
  23262. * Mesh cap setting : one cap at the beginning of the mesh
  23263. */
  23264. static readonly CAP_START: number;
  23265. /**
  23266. * Mesh cap setting : one cap at the end of the mesh
  23267. */
  23268. static readonly CAP_END: number;
  23269. /**
  23270. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23271. */
  23272. static readonly CAP_ALL: number;
  23273. /**
  23274. * Mesh pattern setting : no flip or rotate
  23275. */
  23276. static readonly NO_FLIP: number;
  23277. /**
  23278. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23279. */
  23280. static readonly FLIP_TILE: number;
  23281. /**
  23282. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23283. */
  23284. static readonly ROTATE_TILE: number;
  23285. /**
  23286. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23287. */
  23288. static readonly FLIP_ROW: number;
  23289. /**
  23290. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23291. */
  23292. static readonly ROTATE_ROW: number;
  23293. /**
  23294. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23295. */
  23296. static readonly FLIP_N_ROTATE_TILE: number;
  23297. /**
  23298. * Mesh pattern setting : rotate pattern and rotate
  23299. */
  23300. static readonly FLIP_N_ROTATE_ROW: number;
  23301. /**
  23302. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23303. */
  23304. static readonly CENTER: number;
  23305. /**
  23306. * Mesh tile positioning : part tiles on left
  23307. */
  23308. static readonly LEFT: number;
  23309. /**
  23310. * Mesh tile positioning : part tiles on right
  23311. */
  23312. static readonly RIGHT: number;
  23313. /**
  23314. * Mesh tile positioning : part tiles on top
  23315. */
  23316. static readonly TOP: number;
  23317. /**
  23318. * Mesh tile positioning : part tiles on bottom
  23319. */
  23320. static readonly BOTTOM: number;
  23321. /**
  23322. * Gets the default side orientation.
  23323. * @param orientation the orientation to value to attempt to get
  23324. * @returns the default orientation
  23325. * @hidden
  23326. */
  23327. static _GetDefaultSideOrientation(orientation?: number): number;
  23328. private _internalMeshDataInfo;
  23329. /**
  23330. * An event triggered before rendering the mesh
  23331. */
  23332. readonly onBeforeRenderObservable: Observable<Mesh>;
  23333. /**
  23334. * An event triggered before binding the mesh
  23335. */
  23336. readonly onBeforeBindObservable: Observable<Mesh>;
  23337. /**
  23338. * An event triggered after rendering the mesh
  23339. */
  23340. readonly onAfterRenderObservable: Observable<Mesh>;
  23341. /**
  23342. * An event triggered before drawing the mesh
  23343. */
  23344. readonly onBeforeDrawObservable: Observable<Mesh>;
  23345. private _onBeforeDrawObserver;
  23346. /**
  23347. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23348. */
  23349. onBeforeDraw: () => void;
  23350. readonly hasInstances: boolean;
  23351. /**
  23352. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23353. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23354. */
  23355. delayLoadState: number;
  23356. /**
  23357. * Gets the list of instances created from this mesh
  23358. * it is not supposed to be modified manually.
  23359. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23360. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23361. */
  23362. instances: InstancedMesh[];
  23363. /**
  23364. * Gets the file containing delay loading data for this mesh
  23365. */
  23366. delayLoadingFile: string;
  23367. /** @hidden */
  23368. _binaryInfo: any;
  23369. /**
  23370. * User defined function used to change how LOD level selection is done
  23371. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23372. */
  23373. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23374. /**
  23375. * Gets or sets the morph target manager
  23376. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23377. */
  23378. morphTargetManager: Nullable<MorphTargetManager>;
  23379. /** @hidden */
  23380. _creationDataStorage: Nullable<_CreationDataStorage>;
  23381. /** @hidden */
  23382. _geometry: Nullable<Geometry>;
  23383. /** @hidden */
  23384. _delayInfo: Array<string>;
  23385. /** @hidden */
  23386. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23387. /** @hidden */
  23388. _instanceDataStorage: _InstanceDataStorage;
  23389. private _effectiveMaterial;
  23390. /** @hidden */
  23391. _shouldGenerateFlatShading: boolean;
  23392. /** @hidden */
  23393. _originalBuilderSideOrientation: number;
  23394. /**
  23395. * Use this property to change the original side orientation defined at construction time
  23396. */
  23397. overrideMaterialSideOrientation: Nullable<number>;
  23398. /**
  23399. * Gets the source mesh (the one used to clone this one from)
  23400. */
  23401. readonly source: Nullable<Mesh>;
  23402. /**
  23403. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23404. */
  23405. isUnIndexed: boolean;
  23406. /**
  23407. * @constructor
  23408. * @param name The value used by scene.getMeshByName() to do a lookup.
  23409. * @param scene The scene to add this mesh to.
  23410. * @param parent The parent of this mesh, if it has one
  23411. * @param source An optional Mesh from which geometry is shared, cloned.
  23412. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23413. * When false, achieved by calling a clone(), also passing False.
  23414. * This will make creation of children, recursive.
  23415. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23416. */
  23417. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23418. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23419. /**
  23420. * Gets the class name
  23421. * @returns the string "Mesh".
  23422. */
  23423. getClassName(): string;
  23424. /** @hidden */
  23425. readonly _isMesh: boolean;
  23426. /**
  23427. * Returns a description of this mesh
  23428. * @param fullDetails define if full details about this mesh must be used
  23429. * @returns a descriptive string representing this mesh
  23430. */
  23431. toString(fullDetails?: boolean): string;
  23432. /** @hidden */
  23433. _unBindEffect(): void;
  23434. /**
  23435. * Gets a boolean indicating if this mesh has LOD
  23436. */
  23437. readonly hasLODLevels: boolean;
  23438. /**
  23439. * Gets the list of MeshLODLevel associated with the current mesh
  23440. * @returns an array of MeshLODLevel
  23441. */
  23442. getLODLevels(): MeshLODLevel[];
  23443. private _sortLODLevels;
  23444. /**
  23445. * Add a mesh as LOD level triggered at the given distance.
  23446. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23447. * @param distance The distance from the center of the object to show this level
  23448. * @param mesh The mesh to be added as LOD level (can be null)
  23449. * @return This mesh (for chaining)
  23450. */
  23451. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23452. /**
  23453. * Returns the LOD level mesh at the passed distance or null if not found.
  23454. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23455. * @param distance The distance from the center of the object to show this level
  23456. * @returns a Mesh or `null`
  23457. */
  23458. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23459. /**
  23460. * Remove a mesh from the LOD array
  23461. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23462. * @param mesh defines the mesh to be removed
  23463. * @return This mesh (for chaining)
  23464. */
  23465. removeLODLevel(mesh: Mesh): Mesh;
  23466. /**
  23467. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23468. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23469. * @param camera defines the camera to use to compute distance
  23470. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23471. * @return This mesh (for chaining)
  23472. */
  23473. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23474. /**
  23475. * Gets the mesh internal Geometry object
  23476. */
  23477. readonly geometry: Nullable<Geometry>;
  23478. /**
  23479. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23480. * @returns the total number of vertices
  23481. */
  23482. getTotalVertices(): number;
  23483. /**
  23484. * Returns the content of an associated vertex buffer
  23485. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23486. * - VertexBuffer.PositionKind
  23487. * - VertexBuffer.UVKind
  23488. * - VertexBuffer.UV2Kind
  23489. * - VertexBuffer.UV3Kind
  23490. * - VertexBuffer.UV4Kind
  23491. * - VertexBuffer.UV5Kind
  23492. * - VertexBuffer.UV6Kind
  23493. * - VertexBuffer.ColorKind
  23494. * - VertexBuffer.MatricesIndicesKind
  23495. * - VertexBuffer.MatricesIndicesExtraKind
  23496. * - VertexBuffer.MatricesWeightsKind
  23497. * - VertexBuffer.MatricesWeightsExtraKind
  23498. * @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
  23499. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23500. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23501. */
  23502. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23503. /**
  23504. * Returns the mesh VertexBuffer object from the requested `kind`
  23505. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23506. * - VertexBuffer.PositionKind
  23507. * - VertexBuffer.NormalKind
  23508. * - VertexBuffer.UVKind
  23509. * - VertexBuffer.UV2Kind
  23510. * - VertexBuffer.UV3Kind
  23511. * - VertexBuffer.UV4Kind
  23512. * - VertexBuffer.UV5Kind
  23513. * - VertexBuffer.UV6Kind
  23514. * - VertexBuffer.ColorKind
  23515. * - VertexBuffer.MatricesIndicesKind
  23516. * - VertexBuffer.MatricesIndicesExtraKind
  23517. * - VertexBuffer.MatricesWeightsKind
  23518. * - VertexBuffer.MatricesWeightsExtraKind
  23519. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23520. */
  23521. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23522. /**
  23523. * Tests if a specific vertex buffer is associated with this mesh
  23524. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23525. * - VertexBuffer.PositionKind
  23526. * - VertexBuffer.NormalKind
  23527. * - VertexBuffer.UVKind
  23528. * - VertexBuffer.UV2Kind
  23529. * - VertexBuffer.UV3Kind
  23530. * - VertexBuffer.UV4Kind
  23531. * - VertexBuffer.UV5Kind
  23532. * - VertexBuffer.UV6Kind
  23533. * - VertexBuffer.ColorKind
  23534. * - VertexBuffer.MatricesIndicesKind
  23535. * - VertexBuffer.MatricesIndicesExtraKind
  23536. * - VertexBuffer.MatricesWeightsKind
  23537. * - VertexBuffer.MatricesWeightsExtraKind
  23538. * @returns a boolean
  23539. */
  23540. isVerticesDataPresent(kind: string): boolean;
  23541. /**
  23542. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23543. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23544. * - VertexBuffer.PositionKind
  23545. * - VertexBuffer.UVKind
  23546. * - VertexBuffer.UV2Kind
  23547. * - VertexBuffer.UV3Kind
  23548. * - VertexBuffer.UV4Kind
  23549. * - VertexBuffer.UV5Kind
  23550. * - VertexBuffer.UV6Kind
  23551. * - VertexBuffer.ColorKind
  23552. * - VertexBuffer.MatricesIndicesKind
  23553. * - VertexBuffer.MatricesIndicesExtraKind
  23554. * - VertexBuffer.MatricesWeightsKind
  23555. * - VertexBuffer.MatricesWeightsExtraKind
  23556. * @returns a boolean
  23557. */
  23558. isVertexBufferUpdatable(kind: string): boolean;
  23559. /**
  23560. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23561. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23562. * - VertexBuffer.PositionKind
  23563. * - VertexBuffer.NormalKind
  23564. * - VertexBuffer.UVKind
  23565. * - VertexBuffer.UV2Kind
  23566. * - VertexBuffer.UV3Kind
  23567. * - VertexBuffer.UV4Kind
  23568. * - VertexBuffer.UV5Kind
  23569. * - VertexBuffer.UV6Kind
  23570. * - VertexBuffer.ColorKind
  23571. * - VertexBuffer.MatricesIndicesKind
  23572. * - VertexBuffer.MatricesIndicesExtraKind
  23573. * - VertexBuffer.MatricesWeightsKind
  23574. * - VertexBuffer.MatricesWeightsExtraKind
  23575. * @returns an array of strings
  23576. */
  23577. getVerticesDataKinds(): string[];
  23578. /**
  23579. * Returns a positive integer : the total number of indices in this mesh geometry.
  23580. * @returns the numner of indices or zero if the mesh has no geometry.
  23581. */
  23582. getTotalIndices(): number;
  23583. /**
  23584. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23585. * @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.
  23586. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23587. * @returns the indices array or an empty array if the mesh has no geometry
  23588. */
  23589. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23590. readonly isBlocked: boolean;
  23591. /**
  23592. * Determine if the current mesh is ready to be rendered
  23593. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23594. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23595. * @returns true if all associated assets are ready (material, textures, shaders)
  23596. */
  23597. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23598. /**
  23599. * 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.
  23600. */
  23601. readonly areNormalsFrozen: boolean;
  23602. /**
  23603. * 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.
  23604. * @returns the current mesh
  23605. */
  23606. freezeNormals(): Mesh;
  23607. /**
  23608. * 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
  23609. * @returns the current mesh
  23610. */
  23611. unfreezeNormals(): Mesh;
  23612. /**
  23613. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23614. */
  23615. overridenInstanceCount: number;
  23616. /** @hidden */
  23617. _preActivate(): Mesh;
  23618. /** @hidden */
  23619. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23620. /** @hidden */
  23621. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23622. /**
  23623. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23624. * This means the mesh underlying bounding box and sphere are recomputed.
  23625. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23626. * @returns the current mesh
  23627. */
  23628. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23629. /** @hidden */
  23630. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23631. /**
  23632. * This function will subdivide the mesh into multiple submeshes
  23633. * @param count defines the expected number of submeshes
  23634. */
  23635. subdivide(count: number): void;
  23636. /**
  23637. * Copy a FloatArray into a specific associated vertex buffer
  23638. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23639. * - VertexBuffer.PositionKind
  23640. * - VertexBuffer.UVKind
  23641. * - VertexBuffer.UV2Kind
  23642. * - VertexBuffer.UV3Kind
  23643. * - VertexBuffer.UV4Kind
  23644. * - VertexBuffer.UV5Kind
  23645. * - VertexBuffer.UV6Kind
  23646. * - VertexBuffer.ColorKind
  23647. * - VertexBuffer.MatricesIndicesKind
  23648. * - VertexBuffer.MatricesIndicesExtraKind
  23649. * - VertexBuffer.MatricesWeightsKind
  23650. * - VertexBuffer.MatricesWeightsExtraKind
  23651. * @param data defines the data source
  23652. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23653. * @param stride defines the data stride size (can be null)
  23654. * @returns the current mesh
  23655. */
  23656. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23657. /**
  23658. * Flags an associated vertex buffer as updatable
  23659. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23660. * - VertexBuffer.PositionKind
  23661. * - VertexBuffer.UVKind
  23662. * - VertexBuffer.UV2Kind
  23663. * - VertexBuffer.UV3Kind
  23664. * - VertexBuffer.UV4Kind
  23665. * - VertexBuffer.UV5Kind
  23666. * - VertexBuffer.UV6Kind
  23667. * - VertexBuffer.ColorKind
  23668. * - VertexBuffer.MatricesIndicesKind
  23669. * - VertexBuffer.MatricesIndicesExtraKind
  23670. * - VertexBuffer.MatricesWeightsKind
  23671. * - VertexBuffer.MatricesWeightsExtraKind
  23672. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23673. */
  23674. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23675. /**
  23676. * Sets the mesh global Vertex Buffer
  23677. * @param buffer defines the buffer to use
  23678. * @returns the current mesh
  23679. */
  23680. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23681. /**
  23682. * Update a specific associated vertex buffer
  23683. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23684. * - VertexBuffer.PositionKind
  23685. * - VertexBuffer.UVKind
  23686. * - VertexBuffer.UV2Kind
  23687. * - VertexBuffer.UV3Kind
  23688. * - VertexBuffer.UV4Kind
  23689. * - VertexBuffer.UV5Kind
  23690. * - VertexBuffer.UV6Kind
  23691. * - VertexBuffer.ColorKind
  23692. * - VertexBuffer.MatricesIndicesKind
  23693. * - VertexBuffer.MatricesIndicesExtraKind
  23694. * - VertexBuffer.MatricesWeightsKind
  23695. * - VertexBuffer.MatricesWeightsExtraKind
  23696. * @param data defines the data source
  23697. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23698. * @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)
  23699. * @returns the current mesh
  23700. */
  23701. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23702. /**
  23703. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23704. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23705. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23706. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23707. * @returns the current mesh
  23708. */
  23709. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23710. /**
  23711. * Creates a un-shared specific occurence of the geometry for the mesh.
  23712. * @returns the current mesh
  23713. */
  23714. makeGeometryUnique(): Mesh;
  23715. /**
  23716. * Set the index buffer of this mesh
  23717. * @param indices defines the source data
  23718. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23719. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23720. * @returns the current mesh
  23721. */
  23722. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23723. /**
  23724. * Update the current index buffer
  23725. * @param indices defines the source data
  23726. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23727. * @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)
  23728. * @returns the current mesh
  23729. */
  23730. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23731. /**
  23732. * Invert the geometry to move from a right handed system to a left handed one.
  23733. * @returns the current mesh
  23734. */
  23735. toLeftHanded(): Mesh;
  23736. /** @hidden */
  23737. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23738. /** @hidden */
  23739. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23740. /**
  23741. * Registers for this mesh a javascript function called just before the rendering process
  23742. * @param func defines the function to call before rendering this mesh
  23743. * @returns the current mesh
  23744. */
  23745. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23746. /**
  23747. * Disposes a previously registered javascript function called before the rendering
  23748. * @param func defines the function to remove
  23749. * @returns the current mesh
  23750. */
  23751. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23752. /**
  23753. * Registers for this mesh a javascript function called just after the rendering is complete
  23754. * @param func defines the function to call after rendering this mesh
  23755. * @returns the current mesh
  23756. */
  23757. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23758. /**
  23759. * Disposes a previously registered javascript function called after the rendering.
  23760. * @param func defines the function to remove
  23761. * @returns the current mesh
  23762. */
  23763. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23764. /** @hidden */
  23765. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23766. /** @hidden */
  23767. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23768. /** @hidden */
  23769. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23770. /** @hidden */
  23771. _rebuild(): void;
  23772. /** @hidden */
  23773. _freeze(): void;
  23774. /** @hidden */
  23775. _unFreeze(): void;
  23776. /**
  23777. * 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
  23778. * @param subMesh defines the subMesh to render
  23779. * @param enableAlphaMode defines if alpha mode can be changed
  23780. * @returns the current mesh
  23781. */
  23782. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23783. private _onBeforeDraw;
  23784. /**
  23785. * Renormalize the mesh and patch it up if there are no weights
  23786. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23787. * However in the case of zero weights then we set just a single influence to 1.
  23788. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23789. */
  23790. cleanMatrixWeights(): void;
  23791. private normalizeSkinFourWeights;
  23792. private normalizeSkinWeightsAndExtra;
  23793. /**
  23794. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23795. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23796. * the user know there was an issue with importing the mesh
  23797. * @returns a validation object with skinned, valid and report string
  23798. */
  23799. validateSkinning(): {
  23800. skinned: boolean;
  23801. valid: boolean;
  23802. report: string;
  23803. };
  23804. /** @hidden */
  23805. _checkDelayState(): Mesh;
  23806. private _queueLoad;
  23807. /**
  23808. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23809. * A mesh is in the frustum if its bounding box intersects the frustum
  23810. * @param frustumPlanes defines the frustum to test
  23811. * @returns true if the mesh is in the frustum planes
  23812. */
  23813. isInFrustum(frustumPlanes: Plane[]): boolean;
  23814. /**
  23815. * Sets the mesh material by the material or multiMaterial `id` property
  23816. * @param id is a string identifying the material or the multiMaterial
  23817. * @returns the current mesh
  23818. */
  23819. setMaterialByID(id: string): Mesh;
  23820. /**
  23821. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23822. * @returns an array of IAnimatable
  23823. */
  23824. getAnimatables(): IAnimatable[];
  23825. /**
  23826. * Modifies the mesh geometry according to the passed transformation matrix.
  23827. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23828. * The mesh normals are modified using the same transformation.
  23829. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23830. * @param transform defines the transform matrix to use
  23831. * @see http://doc.babylonjs.com/resources/baking_transformations
  23832. * @returns the current mesh
  23833. */
  23834. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23835. /**
  23836. * Modifies the mesh geometry according to its own current World Matrix.
  23837. * The mesh World Matrix is then reset.
  23838. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23839. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23840. * @see http://doc.babylonjs.com/resources/baking_transformations
  23841. * @returns the current mesh
  23842. */
  23843. bakeCurrentTransformIntoVertices(): Mesh;
  23844. /** @hidden */
  23845. readonly _positions: Nullable<Vector3[]>;
  23846. /** @hidden */
  23847. _resetPointsArrayCache(): Mesh;
  23848. /** @hidden */
  23849. _generatePointsArray(): boolean;
  23850. /**
  23851. * Returns a new Mesh object generated from the current mesh properties.
  23852. * This method must not get confused with createInstance()
  23853. * @param name is a string, the name given to the new mesh
  23854. * @param newParent can be any Node object (default `null`)
  23855. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23856. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23857. * @returns a new mesh
  23858. */
  23859. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  23860. /**
  23861. * Releases resources associated with this mesh.
  23862. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23863. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23864. */
  23865. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23866. /**
  23867. * Modifies the mesh geometry according to a displacement map.
  23868. * 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.
  23869. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23870. * @param url is a string, the URL from the image file is to be downloaded.
  23871. * @param minHeight is the lower limit of the displacement.
  23872. * @param maxHeight is the upper limit of the displacement.
  23873. * @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.
  23874. * @param uvOffset is an optional vector2 used to offset UV.
  23875. * @param uvScale is an optional vector2 used to scale UV.
  23876. * @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.
  23877. * @returns the Mesh.
  23878. */
  23879. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23880. /**
  23881. * Modifies the mesh geometry according to a displacementMap buffer.
  23882. * 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.
  23883. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23884. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23885. * @param heightMapWidth is the width of the buffer image.
  23886. * @param heightMapHeight is the height of the buffer image.
  23887. * @param minHeight is the lower limit of the displacement.
  23888. * @param maxHeight is the upper limit of the displacement.
  23889. * @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.
  23890. * @param uvOffset is an optional vector2 used to offset UV.
  23891. * @param uvScale is an optional vector2 used to scale UV.
  23892. * @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.
  23893. * @returns the Mesh.
  23894. */
  23895. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23896. /**
  23897. * Modify the mesh to get a flat shading rendering.
  23898. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23899. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23900. * @returns current mesh
  23901. */
  23902. convertToFlatShadedMesh(): Mesh;
  23903. /**
  23904. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23905. * In other words, more vertices, no more indices and a single bigger VBO.
  23906. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23907. * @returns current mesh
  23908. */
  23909. convertToUnIndexedMesh(): Mesh;
  23910. /**
  23911. * Inverses facet orientations.
  23912. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23913. * @param flipNormals will also inverts the normals
  23914. * @returns current mesh
  23915. */
  23916. flipFaces(flipNormals?: boolean): Mesh;
  23917. /**
  23918. * Increase the number of facets and hence vertices in a mesh
  23919. * Vertex normals are interpolated from existing vertex normals
  23920. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23921. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23922. */
  23923. increaseVertices(numberPerEdge: number): void;
  23924. /**
  23925. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23926. * This will undo any application of covertToFlatShadedMesh
  23927. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23928. */
  23929. forceSharedVertices(): void;
  23930. /** @hidden */
  23931. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23932. /** @hidden */
  23933. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23934. /**
  23935. * Creates a new InstancedMesh object from the mesh model.
  23936. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23937. * @param name defines the name of the new instance
  23938. * @returns a new InstancedMesh
  23939. */
  23940. createInstance(name: string): InstancedMesh;
  23941. /**
  23942. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23943. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23944. * @returns the current mesh
  23945. */
  23946. synchronizeInstances(): Mesh;
  23947. /**
  23948. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23949. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23950. * This should be used together with the simplification to avoid disappearing triangles.
  23951. * @param successCallback an optional success callback to be called after the optimization finished.
  23952. * @returns the current mesh
  23953. */
  23954. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23955. /**
  23956. * Serialize current mesh
  23957. * @param serializationObject defines the object which will receive the serialization data
  23958. */
  23959. serialize(serializationObject: any): void;
  23960. /** @hidden */
  23961. _syncGeometryWithMorphTargetManager(): void;
  23962. /** @hidden */
  23963. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  23964. /**
  23965. * Returns a new Mesh object parsed from the source provided.
  23966. * @param parsedMesh is the source
  23967. * @param scene defines the hosting scene
  23968. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  23969. * @returns a new Mesh
  23970. */
  23971. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23972. /**
  23973. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  23974. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23975. * @param name defines the name of the mesh to create
  23976. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23977. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  23978. * @param closePath creates a seam between the first and the last points of each path of the path array
  23979. * @param offset is taken in account only if the `pathArray` is containing a single path
  23980. * @param scene defines the hosting scene
  23981. * @param updatable defines if the mesh must be flagged as updatable
  23982. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23983. * @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)
  23984. * @returns a new Mesh
  23985. */
  23986. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23987. /**
  23988. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  23989. * @param name defines the name of the mesh to create
  23990. * @param radius sets the radius size (float) of the polygon (default 0.5)
  23991. * @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
  23992. * @param scene defines the hosting scene
  23993. * @param updatable defines if the mesh must be flagged as updatable
  23994. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23995. * @returns a new Mesh
  23996. */
  23997. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23998. /**
  23999. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24000. * @param name defines the name of the mesh to create
  24001. * @param size sets the size (float) of each box side (default 1)
  24002. * @param scene defines the hosting scene
  24003. * @param updatable defines if the mesh must be flagged as updatable
  24004. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24005. * @returns a new Mesh
  24006. */
  24007. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24008. /**
  24009. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24010. * @param name defines the name of the mesh to create
  24011. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24012. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24013. * @param scene defines the hosting scene
  24014. * @param updatable defines if the mesh must be flagged as updatable
  24015. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24016. * @returns a new Mesh
  24017. */
  24018. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24019. /**
  24020. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24021. * @param name defines the name of the mesh to create
  24022. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24023. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24024. * @param scene defines the hosting scene
  24025. * @returns a new Mesh
  24026. */
  24027. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24028. /**
  24029. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24030. * @param name defines the name of the mesh to create
  24031. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24032. * @param diameterTop set the top cap diameter (floats, default 1)
  24033. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24034. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24035. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24036. * @param scene defines the hosting scene
  24037. * @param updatable defines if the mesh must be flagged as updatable
  24038. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24039. * @returns a new Mesh
  24040. */
  24041. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24042. /**
  24043. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24044. * @param name defines the name of the mesh to create
  24045. * @param diameter sets the diameter size (float) of the torus (default 1)
  24046. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24047. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24048. * @param scene defines the hosting scene
  24049. * @param updatable defines if the mesh must be flagged as updatable
  24050. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24051. * @returns a new Mesh
  24052. */
  24053. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24054. /**
  24055. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24056. * @param name defines the name of the mesh to create
  24057. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24058. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24059. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24060. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24061. * @param p the number of windings on X axis (positive integers, default 2)
  24062. * @param q the number of windings on Y axis (positive integers, default 3)
  24063. * @param scene defines the hosting scene
  24064. * @param updatable defines if the mesh must be flagged as updatable
  24065. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24066. * @returns a new Mesh
  24067. */
  24068. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24069. /**
  24070. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24071. * @param name defines the name of the mesh to create
  24072. * @param points is an array successive Vector3
  24073. * @param scene defines the hosting scene
  24074. * @param updatable defines if the mesh must be flagged as updatable
  24075. * @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).
  24076. * @returns a new Mesh
  24077. */
  24078. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24079. /**
  24080. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24081. * @param name defines the name of the mesh to create
  24082. * @param points is an array successive Vector3
  24083. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24084. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24085. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24086. * @param scene defines the hosting scene
  24087. * @param updatable defines if the mesh must be flagged as updatable
  24088. * @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)
  24089. * @returns a new Mesh
  24090. */
  24091. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24092. /**
  24093. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24094. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24095. * 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.
  24096. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24097. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24098. * Remember you can only change the shape positions, not their number when updating a polygon.
  24099. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24100. * @param name defines the name of the mesh to create
  24101. * @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
  24102. * @param scene defines the hosting scene
  24103. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24104. * @param updatable defines if the mesh must be flagged as updatable
  24105. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24106. * @param earcutInjection can be used to inject your own earcut reference
  24107. * @returns a new Mesh
  24108. */
  24109. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24110. /**
  24111. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24112. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24113. * @param name defines the name of the mesh to create
  24114. * @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
  24115. * @param depth defines the height of extrusion
  24116. * @param scene defines the hosting scene
  24117. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24118. * @param updatable defines if the mesh must be flagged as updatable
  24119. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24120. * @param earcutInjection can be used to inject your own earcut reference
  24121. * @returns a new Mesh
  24122. */
  24123. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24124. /**
  24125. * Creates an extruded shape mesh.
  24126. * 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
  24127. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24128. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24129. * @param name defines the name of the mesh to create
  24130. * @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
  24131. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24132. * @param scale is the value to scale the shape
  24133. * @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
  24134. * @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
  24135. * @param scene defines the hosting scene
  24136. * @param updatable defines if the mesh must be flagged as updatable
  24137. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24138. * @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)
  24139. * @returns a new Mesh
  24140. */
  24141. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24142. /**
  24143. * Creates an custom extruded shape mesh.
  24144. * The custom extrusion is a parametric shape.
  24145. * It has no predefined shape. Its final shape will depend on the input parameters.
  24146. * Please consider using the same method from the MeshBuilder class instead
  24147. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24148. * @param name defines the name of the mesh to create
  24149. * @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
  24150. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24151. * @param scaleFunction is a custom Javascript function called on each path point
  24152. * @param rotationFunction is a custom Javascript function called on each path point
  24153. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24154. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24155. * @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
  24156. * @param scene defines the hosting scene
  24157. * @param updatable defines if the mesh must be flagged as updatable
  24158. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24159. * @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)
  24160. * @returns a new Mesh
  24161. */
  24162. 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;
  24163. /**
  24164. * Creates lathe mesh.
  24165. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24166. * Please consider using the same method from the MeshBuilder class instead
  24167. * @param name defines the name of the mesh to create
  24168. * @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
  24169. * @param radius is the radius value of the lathe
  24170. * @param tessellation is the side number of the lathe.
  24171. * @param scene defines the hosting scene
  24172. * @param updatable defines if the mesh must be flagged as updatable
  24173. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24174. * @returns a new Mesh
  24175. */
  24176. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24177. /**
  24178. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24179. * @param name defines the name of the mesh to create
  24180. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24181. * @param scene defines the hosting scene
  24182. * @param updatable defines if the mesh must be flagged as updatable
  24183. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24184. * @returns a new Mesh
  24185. */
  24186. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24187. /**
  24188. * Creates a ground mesh.
  24189. * Please consider using the same method from the MeshBuilder class instead
  24190. * @param name defines the name of the mesh to create
  24191. * @param width set the width of the ground
  24192. * @param height set the height of the ground
  24193. * @param subdivisions sets the number of subdivisions per side
  24194. * @param scene defines the hosting scene
  24195. * @param updatable defines if the mesh must be flagged as updatable
  24196. * @returns a new Mesh
  24197. */
  24198. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24199. /**
  24200. * Creates a tiled ground mesh.
  24201. * Please consider using the same method from the MeshBuilder class instead
  24202. * @param name defines the name of the mesh to create
  24203. * @param xmin set the ground minimum X coordinate
  24204. * @param zmin set the ground minimum Y coordinate
  24205. * @param xmax set the ground maximum X coordinate
  24206. * @param zmax set the ground maximum Z coordinate
  24207. * @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
  24208. * @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
  24209. * @param scene defines the hosting scene
  24210. * @param updatable defines if the mesh must be flagged as updatable
  24211. * @returns a new Mesh
  24212. */
  24213. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24214. w: number;
  24215. h: number;
  24216. }, precision: {
  24217. w: number;
  24218. h: number;
  24219. }, scene: Scene, updatable?: boolean): Mesh;
  24220. /**
  24221. * Creates a ground mesh from a height map.
  24222. * Please consider using the same method from the MeshBuilder class instead
  24223. * @see http://doc.babylonjs.com/babylon101/height_map
  24224. * @param name defines the name of the mesh to create
  24225. * @param url sets the URL of the height map image resource
  24226. * @param width set the ground width size
  24227. * @param height set the ground height size
  24228. * @param subdivisions sets the number of subdivision per side
  24229. * @param minHeight is the minimum altitude on the ground
  24230. * @param maxHeight is the maximum altitude on the ground
  24231. * @param scene defines the hosting scene
  24232. * @param updatable defines if the mesh must be flagged as updatable
  24233. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24234. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24235. * @returns a new Mesh
  24236. */
  24237. 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;
  24238. /**
  24239. * Creates a tube mesh.
  24240. * The tube is a parametric shape.
  24241. * It has no predefined shape. Its final shape will depend on the input parameters.
  24242. * Please consider using the same method from the MeshBuilder class instead
  24243. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24244. * @param name defines the name of the mesh to create
  24245. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24246. * @param radius sets the tube radius size
  24247. * @param tessellation is the number of sides on the tubular surface
  24248. * @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
  24249. * @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
  24250. * @param scene defines the hosting scene
  24251. * @param updatable defines if the mesh must be flagged as updatable
  24252. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24253. * @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)
  24254. * @returns a new Mesh
  24255. */
  24256. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24257. (i: number, distance: number): number;
  24258. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24259. /**
  24260. * Creates a polyhedron mesh.
  24261. * Please consider using the same method from the MeshBuilder class instead.
  24262. * * 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
  24263. * * The parameter `size` (positive float, default 1) sets the polygon size
  24264. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24265. * * 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`
  24266. * * 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
  24267. * * 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)`)
  24268. * * 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
  24269. * * 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
  24270. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24271. * * 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
  24272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24273. * @param name defines the name of the mesh to create
  24274. * @param options defines the options used to create the mesh
  24275. * @param scene defines the hosting scene
  24276. * @returns a new Mesh
  24277. */
  24278. static CreatePolyhedron(name: string, options: {
  24279. type?: number;
  24280. size?: number;
  24281. sizeX?: number;
  24282. sizeY?: number;
  24283. sizeZ?: number;
  24284. custom?: any;
  24285. faceUV?: Vector4[];
  24286. faceColors?: Color4[];
  24287. updatable?: boolean;
  24288. sideOrientation?: number;
  24289. }, scene: Scene): Mesh;
  24290. /**
  24291. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24292. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24293. * * 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`)
  24294. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24295. * * 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
  24296. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24297. * * 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
  24298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24299. * @param name defines the name of the mesh
  24300. * @param options defines the options used to create the mesh
  24301. * @param scene defines the hosting scene
  24302. * @returns a new Mesh
  24303. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24304. */
  24305. static CreateIcoSphere(name: string, options: {
  24306. radius?: number;
  24307. flat?: boolean;
  24308. subdivisions?: number;
  24309. sideOrientation?: number;
  24310. updatable?: boolean;
  24311. }, scene: Scene): Mesh;
  24312. /**
  24313. * Creates a decal mesh.
  24314. * Please consider using the same method from the MeshBuilder class instead.
  24315. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24316. * @param name defines the name of the mesh
  24317. * @param sourceMesh defines the mesh receiving the decal
  24318. * @param position sets the position of the decal in world coordinates
  24319. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24320. * @param size sets the decal scaling
  24321. * @param angle sets the angle to rotate the decal
  24322. * @returns a new Mesh
  24323. */
  24324. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24325. /**
  24326. * Prepare internal position array for software CPU skinning
  24327. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24328. */
  24329. setPositionsForCPUSkinning(): Float32Array;
  24330. /**
  24331. * Prepare internal normal array for software CPU skinning
  24332. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24333. */
  24334. setNormalsForCPUSkinning(): Float32Array;
  24335. /**
  24336. * Updates the vertex buffer by applying transformation from the bones
  24337. * @param skeleton defines the skeleton to apply to current mesh
  24338. * @returns the current mesh
  24339. */
  24340. applySkeleton(skeleton: Skeleton): Mesh;
  24341. /**
  24342. * 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
  24343. * @param meshes defines the list of meshes to scan
  24344. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24345. */
  24346. static MinMax(meshes: AbstractMesh[]): {
  24347. min: Vector3;
  24348. max: Vector3;
  24349. };
  24350. /**
  24351. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24352. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24353. * @returns a vector3
  24354. */
  24355. static Center(meshesOrMinMaxVector: {
  24356. min: Vector3;
  24357. max: Vector3;
  24358. } | AbstractMesh[]): Vector3;
  24359. /**
  24360. * Merge the array of meshes into a single mesh for performance reasons.
  24361. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24362. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24363. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24364. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24365. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24366. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24367. * @returns a new mesh
  24368. */
  24369. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24370. /** @hidden */
  24371. addInstance(instance: InstancedMesh): void;
  24372. /** @hidden */
  24373. removeInstance(instance: InstancedMesh): void;
  24374. }
  24375. }
  24376. declare module BABYLON {
  24377. /**
  24378. * This is the base class of all the camera used in the application.
  24379. * @see http://doc.babylonjs.com/features/cameras
  24380. */
  24381. export class Camera extends Node {
  24382. /** @hidden */
  24383. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24384. /**
  24385. * This is the default projection mode used by the cameras.
  24386. * It helps recreating a feeling of perspective and better appreciate depth.
  24387. * This is the best way to simulate real life cameras.
  24388. */
  24389. static readonly PERSPECTIVE_CAMERA: number;
  24390. /**
  24391. * This helps creating camera with an orthographic mode.
  24392. * 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.
  24393. */
  24394. static readonly ORTHOGRAPHIC_CAMERA: number;
  24395. /**
  24396. * This is the default FOV mode for perspective cameras.
  24397. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24398. */
  24399. static readonly FOVMODE_VERTICAL_FIXED: number;
  24400. /**
  24401. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24402. */
  24403. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24404. /**
  24405. * This specifies ther is no need for a camera rig.
  24406. * Basically only one eye is rendered corresponding to the camera.
  24407. */
  24408. static readonly RIG_MODE_NONE: number;
  24409. /**
  24410. * Simulates a camera Rig with one blue eye and one red eye.
  24411. * This can be use with 3d blue and red glasses.
  24412. */
  24413. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24414. /**
  24415. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24416. */
  24417. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24418. /**
  24419. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24420. */
  24421. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24422. /**
  24423. * Defines that both eyes of the camera will be rendered over under each other.
  24424. */
  24425. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24426. /**
  24427. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24428. */
  24429. static readonly RIG_MODE_VR: number;
  24430. /**
  24431. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24432. */
  24433. static readonly RIG_MODE_WEBVR: number;
  24434. /**
  24435. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24436. */
  24437. static readonly RIG_MODE_CUSTOM: number;
  24438. /**
  24439. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24440. */
  24441. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24442. /**
  24443. * Define the input manager associated with the camera.
  24444. */
  24445. inputs: CameraInputsManager<Camera>;
  24446. /** @hidden */
  24447. _position: Vector3;
  24448. /**
  24449. * Define the current local position of the camera in the scene
  24450. */
  24451. position: Vector3;
  24452. /**
  24453. * The vector the camera should consider as up.
  24454. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24455. */
  24456. upVector: Vector3;
  24457. /**
  24458. * Define the current limit on the left side for an orthographic camera
  24459. * In scene unit
  24460. */
  24461. orthoLeft: Nullable<number>;
  24462. /**
  24463. * Define the current limit on the right side for an orthographic camera
  24464. * In scene unit
  24465. */
  24466. orthoRight: Nullable<number>;
  24467. /**
  24468. * Define the current limit on the bottom side for an orthographic camera
  24469. * In scene unit
  24470. */
  24471. orthoBottom: Nullable<number>;
  24472. /**
  24473. * Define the current limit on the top side for an orthographic camera
  24474. * In scene unit
  24475. */
  24476. orthoTop: Nullable<number>;
  24477. /**
  24478. * Field Of View is set in Radians. (default is 0.8)
  24479. */
  24480. fov: number;
  24481. /**
  24482. * Define the minimum distance the camera can see from.
  24483. * This is important to note that the depth buffer are not infinite and the closer it starts
  24484. * the more your scene might encounter depth fighting issue.
  24485. */
  24486. minZ: number;
  24487. /**
  24488. * Define the maximum distance the camera can see to.
  24489. * This is important to note that the depth buffer are not infinite and the further it end
  24490. * the more your scene might encounter depth fighting issue.
  24491. */
  24492. maxZ: number;
  24493. /**
  24494. * Define the default inertia of the camera.
  24495. * This helps giving a smooth feeling to the camera movement.
  24496. */
  24497. inertia: number;
  24498. /**
  24499. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24500. */
  24501. mode: number;
  24502. /**
  24503. * Define wether the camera is intermediate.
  24504. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24505. */
  24506. isIntermediate: boolean;
  24507. /**
  24508. * Define the viewport of the camera.
  24509. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24510. */
  24511. viewport: Viewport;
  24512. /**
  24513. * Restricts the camera to viewing objects with the same layerMask.
  24514. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24515. */
  24516. layerMask: number;
  24517. /**
  24518. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24519. */
  24520. fovMode: number;
  24521. /**
  24522. * Rig mode of the camera.
  24523. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24524. * This is normally controlled byt the camera themselves as internal use.
  24525. */
  24526. cameraRigMode: number;
  24527. /**
  24528. * Defines the distance between both "eyes" in case of a RIG
  24529. */
  24530. interaxialDistance: number;
  24531. /**
  24532. * Defines if stereoscopic rendering is done side by side or over under.
  24533. */
  24534. isStereoscopicSideBySide: boolean;
  24535. /**
  24536. * 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
  24537. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24538. * else in the scene. (Eg. security camera)
  24539. *
  24540. * 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)
  24541. */
  24542. customRenderTargets: RenderTargetTexture[];
  24543. /**
  24544. * When set, the camera will render to this render target instead of the default canvas
  24545. *
  24546. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24547. */
  24548. outputRenderTarget: Nullable<RenderTargetTexture>;
  24549. /**
  24550. * Observable triggered when the camera view matrix has changed.
  24551. */
  24552. onViewMatrixChangedObservable: Observable<Camera>;
  24553. /**
  24554. * Observable triggered when the camera Projection matrix has changed.
  24555. */
  24556. onProjectionMatrixChangedObservable: Observable<Camera>;
  24557. /**
  24558. * Observable triggered when the inputs have been processed.
  24559. */
  24560. onAfterCheckInputsObservable: Observable<Camera>;
  24561. /**
  24562. * Observable triggered when reset has been called and applied to the camera.
  24563. */
  24564. onRestoreStateObservable: Observable<Camera>;
  24565. /** @hidden */
  24566. _cameraRigParams: any;
  24567. /** @hidden */
  24568. _rigCameras: Camera[];
  24569. /** @hidden */
  24570. _rigPostProcess: Nullable<PostProcess>;
  24571. protected _webvrViewMatrix: Matrix;
  24572. /** @hidden */
  24573. _skipRendering: boolean;
  24574. /** @hidden */
  24575. _projectionMatrix: Matrix;
  24576. /** @hidden */
  24577. _postProcesses: Nullable<PostProcess>[];
  24578. /** @hidden */
  24579. _activeMeshes: SmartArray<AbstractMesh>;
  24580. protected _globalPosition: Vector3;
  24581. /** @hidden */
  24582. _computedViewMatrix: Matrix;
  24583. private _doNotComputeProjectionMatrix;
  24584. private _transformMatrix;
  24585. private _frustumPlanes;
  24586. private _refreshFrustumPlanes;
  24587. private _storedFov;
  24588. private _stateStored;
  24589. /**
  24590. * Instantiates a new camera object.
  24591. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24592. * @see http://doc.babylonjs.com/features/cameras
  24593. * @param name Defines the name of the camera in the scene
  24594. * @param position Defines the position of the camera
  24595. * @param scene Defines the scene the camera belongs too
  24596. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24597. */
  24598. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24599. /**
  24600. * Store current camera state (fov, position, etc..)
  24601. * @returns the camera
  24602. */
  24603. storeState(): Camera;
  24604. /**
  24605. * Restores the camera state values if it has been stored. You must call storeState() first
  24606. */
  24607. protected _restoreStateValues(): boolean;
  24608. /**
  24609. * Restored camera state. You must call storeState() first.
  24610. * @returns true if restored and false otherwise
  24611. */
  24612. restoreState(): boolean;
  24613. /**
  24614. * Gets the class name of the camera.
  24615. * @returns the class name
  24616. */
  24617. getClassName(): string;
  24618. /** @hidden */
  24619. readonly _isCamera: boolean;
  24620. /**
  24621. * Gets a string representation of the camera useful for debug purpose.
  24622. * @param fullDetails Defines that a more verboe level of logging is required
  24623. * @returns the string representation
  24624. */
  24625. toString(fullDetails?: boolean): string;
  24626. /**
  24627. * Gets the current world space position of the camera.
  24628. */
  24629. readonly globalPosition: Vector3;
  24630. /**
  24631. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24632. * @returns the active meshe list
  24633. */
  24634. getActiveMeshes(): SmartArray<AbstractMesh>;
  24635. /**
  24636. * Check wether a mesh is part of the current active mesh list of the camera
  24637. * @param mesh Defines the mesh to check
  24638. * @returns true if active, false otherwise
  24639. */
  24640. isActiveMesh(mesh: Mesh): boolean;
  24641. /**
  24642. * Is this camera ready to be used/rendered
  24643. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24644. * @return true if the camera is ready
  24645. */
  24646. isReady(completeCheck?: boolean): boolean;
  24647. /** @hidden */
  24648. _initCache(): void;
  24649. /** @hidden */
  24650. _updateCache(ignoreParentClass?: boolean): void;
  24651. /** @hidden */
  24652. _isSynchronized(): boolean;
  24653. /** @hidden */
  24654. _isSynchronizedViewMatrix(): boolean;
  24655. /** @hidden */
  24656. _isSynchronizedProjectionMatrix(): boolean;
  24657. /**
  24658. * Attach the input controls to a specific dom element to get the input from.
  24659. * @param element Defines the element the controls should be listened from
  24660. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24661. */
  24662. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24663. /**
  24664. * Detach the current controls from the specified dom element.
  24665. * @param element Defines the element to stop listening the inputs from
  24666. */
  24667. detachControl(element: HTMLElement): void;
  24668. /**
  24669. * Update the camera state according to the different inputs gathered during the frame.
  24670. */
  24671. update(): void;
  24672. /** @hidden */
  24673. _checkInputs(): void;
  24674. /** @hidden */
  24675. readonly rigCameras: Camera[];
  24676. /**
  24677. * Gets the post process used by the rig cameras
  24678. */
  24679. readonly rigPostProcess: Nullable<PostProcess>;
  24680. /**
  24681. * Internal, gets the first post proces.
  24682. * @returns the first post process to be run on this camera.
  24683. */
  24684. _getFirstPostProcess(): Nullable<PostProcess>;
  24685. private _cascadePostProcessesToRigCams;
  24686. /**
  24687. * Attach a post process to the camera.
  24688. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24689. * @param postProcess The post process to attach to the camera
  24690. * @param insertAt The position of the post process in case several of them are in use in the scene
  24691. * @returns the position the post process has been inserted at
  24692. */
  24693. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24694. /**
  24695. * Detach a post process to the camera.
  24696. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24697. * @param postProcess The post process to detach from the camera
  24698. */
  24699. detachPostProcess(postProcess: PostProcess): void;
  24700. /**
  24701. * Gets the current world matrix of the camera
  24702. */
  24703. getWorldMatrix(): Matrix;
  24704. /** @hidden */
  24705. _getViewMatrix(): Matrix;
  24706. /**
  24707. * Gets the current view matrix of the camera.
  24708. * @param force forces the camera to recompute the matrix without looking at the cached state
  24709. * @returns the view matrix
  24710. */
  24711. getViewMatrix(force?: boolean): Matrix;
  24712. /**
  24713. * Freeze the projection matrix.
  24714. * It will prevent the cache check of the camera projection compute and can speed up perf
  24715. * if no parameter of the camera are meant to change
  24716. * @param projection Defines manually a projection if necessary
  24717. */
  24718. freezeProjectionMatrix(projection?: Matrix): void;
  24719. /**
  24720. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24721. */
  24722. unfreezeProjectionMatrix(): void;
  24723. /**
  24724. * Gets the current projection matrix of the camera.
  24725. * @param force forces the camera to recompute the matrix without looking at the cached state
  24726. * @returns the projection matrix
  24727. */
  24728. getProjectionMatrix(force?: boolean): Matrix;
  24729. /**
  24730. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24731. * @returns a Matrix
  24732. */
  24733. getTransformationMatrix(): Matrix;
  24734. private _updateFrustumPlanes;
  24735. /**
  24736. * Checks if a cullable object (mesh...) is in the camera frustum
  24737. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24738. * @param target The object to check
  24739. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24740. * @returns true if the object is in frustum otherwise false
  24741. */
  24742. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24743. /**
  24744. * Checks if a cullable object (mesh...) is in the camera frustum
  24745. * Unlike isInFrustum this cheks the full bounding box
  24746. * @param target The object to check
  24747. * @returns true if the object is in frustum otherwise false
  24748. */
  24749. isCompletelyInFrustum(target: ICullable): boolean;
  24750. /**
  24751. * Gets a ray in the forward direction from the camera.
  24752. * @param length Defines the length of the ray to create
  24753. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24754. * @param origin Defines the start point of the ray which defaults to the camera position
  24755. * @returns the forward ray
  24756. */
  24757. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24758. /**
  24759. * Releases resources associated with this node.
  24760. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24761. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24762. */
  24763. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24764. /** @hidden */
  24765. _isLeftCamera: boolean;
  24766. /**
  24767. * Gets the left camera of a rig setup in case of Rigged Camera
  24768. */
  24769. readonly isLeftCamera: boolean;
  24770. /** @hidden */
  24771. _isRightCamera: boolean;
  24772. /**
  24773. * Gets the right camera of a rig setup in case of Rigged Camera
  24774. */
  24775. readonly isRightCamera: boolean;
  24776. /**
  24777. * Gets the left camera of a rig setup in case of Rigged Camera
  24778. */
  24779. readonly leftCamera: Nullable<FreeCamera>;
  24780. /**
  24781. * Gets the right camera of a rig setup in case of Rigged Camera
  24782. */
  24783. readonly rightCamera: Nullable<FreeCamera>;
  24784. /**
  24785. * Gets the left camera target of a rig setup in case of Rigged Camera
  24786. * @returns the target position
  24787. */
  24788. getLeftTarget(): Nullable<Vector3>;
  24789. /**
  24790. * Gets the right camera target of a rig setup in case of Rigged Camera
  24791. * @returns the target position
  24792. */
  24793. getRightTarget(): Nullable<Vector3>;
  24794. /**
  24795. * @hidden
  24796. */
  24797. setCameraRigMode(mode: number, rigParams: any): void;
  24798. /** @hidden */
  24799. static _setStereoscopicRigMode(camera: Camera): void;
  24800. /** @hidden */
  24801. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24802. /** @hidden */
  24803. static _setVRRigMode(camera: Camera, rigParams: any): void;
  24804. /** @hidden */
  24805. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24806. /** @hidden */
  24807. _getVRProjectionMatrix(): Matrix;
  24808. protected _updateCameraRotationMatrix(): void;
  24809. protected _updateWebVRCameraRotationMatrix(): void;
  24810. /**
  24811. * This function MUST be overwritten by the different WebVR cameras available.
  24812. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24813. * @hidden
  24814. */
  24815. _getWebVRProjectionMatrix(): Matrix;
  24816. /**
  24817. * This function MUST be overwritten by the different WebVR cameras available.
  24818. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24819. * @hidden
  24820. */
  24821. _getWebVRViewMatrix(): Matrix;
  24822. /** @hidden */
  24823. setCameraRigParameter(name: string, value: any): void;
  24824. /**
  24825. * needs to be overridden by children so sub has required properties to be copied
  24826. * @hidden
  24827. */
  24828. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24829. /**
  24830. * May need to be overridden by children
  24831. * @hidden
  24832. */
  24833. _updateRigCameras(): void;
  24834. /** @hidden */
  24835. _setupInputs(): void;
  24836. /**
  24837. * Serialiaze the camera setup to a json represention
  24838. * @returns the JSON representation
  24839. */
  24840. serialize(): any;
  24841. /**
  24842. * Clones the current camera.
  24843. * @param name The cloned camera name
  24844. * @returns the cloned camera
  24845. */
  24846. clone(name: string): Camera;
  24847. /**
  24848. * Gets the direction of the camera relative to a given local axis.
  24849. * @param localAxis Defines the reference axis to provide a relative direction.
  24850. * @return the direction
  24851. */
  24852. getDirection(localAxis: Vector3): Vector3;
  24853. /**
  24854. * Returns the current camera absolute rotation
  24855. */
  24856. readonly absoluteRotation: Quaternion;
  24857. /**
  24858. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24859. * @param localAxis Defines the reference axis to provide a relative direction.
  24860. * @param result Defines the vector to store the result in
  24861. */
  24862. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24863. /**
  24864. * Gets a camera constructor for a given camera type
  24865. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24866. * @param name The name of the camera the result will be able to instantiate
  24867. * @param scene The scene the result will construct the camera in
  24868. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24869. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24870. * @returns a factory method to construc the camera
  24871. */
  24872. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24873. /**
  24874. * Compute the world matrix of the camera.
  24875. * @returns the camera workd matrix
  24876. */
  24877. computeWorldMatrix(): Matrix;
  24878. /**
  24879. * Parse a JSON and creates the camera from the parsed information
  24880. * @param parsedCamera The JSON to parse
  24881. * @param scene The scene to instantiate the camera in
  24882. * @returns the newly constructed camera
  24883. */
  24884. static Parse(parsedCamera: any, scene: Scene): Camera;
  24885. }
  24886. }
  24887. declare module BABYLON {
  24888. /**
  24889. * Class containing static functions to help procedurally build meshes
  24890. */
  24891. export class DiscBuilder {
  24892. /**
  24893. * Creates a plane polygonal mesh. By default, this is a disc
  24894. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24895. * * 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
  24896. * * 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
  24897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24898. * * 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
  24899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24900. * @param name defines the name of the mesh
  24901. * @param options defines the options used to create the mesh
  24902. * @param scene defines the hosting scene
  24903. * @returns the plane polygonal mesh
  24904. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24905. */
  24906. static CreateDisc(name: string, options: {
  24907. radius?: number;
  24908. tessellation?: number;
  24909. arc?: number;
  24910. updatable?: boolean;
  24911. sideOrientation?: number;
  24912. frontUVs?: Vector4;
  24913. backUVs?: Vector4;
  24914. }, scene?: Nullable<Scene>): Mesh;
  24915. }
  24916. }
  24917. declare module BABYLON {
  24918. /**
  24919. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24920. *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.
  24921. * The SPS is also a particle system. It provides some methods to manage the particles.
  24922. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24923. *
  24924. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24925. */
  24926. export class SolidParticleSystem implements IDisposable {
  24927. /**
  24928. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24929. * Example : var p = SPS.particles[i];
  24930. */
  24931. particles: SolidParticle[];
  24932. /**
  24933. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24934. */
  24935. nbParticles: number;
  24936. /**
  24937. * If the particles must ever face the camera (default false). Useful for planar particles.
  24938. */
  24939. billboard: boolean;
  24940. /**
  24941. * Recompute normals when adding a shape
  24942. */
  24943. recomputeNormals: boolean;
  24944. /**
  24945. * This a counter ofr your own usage. It's not set by any SPS functions.
  24946. */
  24947. counter: number;
  24948. /**
  24949. * The SPS name. This name is also given to the underlying mesh.
  24950. */
  24951. name: string;
  24952. /**
  24953. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24954. */
  24955. mesh: Mesh;
  24956. /**
  24957. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24958. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  24959. */
  24960. vars: any;
  24961. /**
  24962. * This array is populated when the SPS is set as 'pickable'.
  24963. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24964. * Each element of this array is an object `{idx: int, faceId: int}`.
  24965. * `idx` is the picked particle index in the `SPS.particles` array
  24966. * `faceId` is the picked face index counted within this particle.
  24967. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  24968. */
  24969. pickedParticles: {
  24970. idx: number;
  24971. faceId: number;
  24972. }[];
  24973. /**
  24974. * This array is populated when `enableDepthSort` is set to true.
  24975. * Each element of this array is an instance of the class DepthSortedParticle.
  24976. */
  24977. depthSortedParticles: DepthSortedParticle[];
  24978. /**
  24979. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24980. * @hidden
  24981. */
  24982. _bSphereOnly: boolean;
  24983. /**
  24984. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24985. * @hidden
  24986. */
  24987. _bSphereRadiusFactor: number;
  24988. private _scene;
  24989. private _positions;
  24990. private _indices;
  24991. private _normals;
  24992. private _colors;
  24993. private _uvs;
  24994. private _indices32;
  24995. private _positions32;
  24996. private _normals32;
  24997. private _fixedNormal32;
  24998. private _colors32;
  24999. private _uvs32;
  25000. private _index;
  25001. private _updatable;
  25002. private _pickable;
  25003. private _isVisibilityBoxLocked;
  25004. private _alwaysVisible;
  25005. private _depthSort;
  25006. private _shapeCounter;
  25007. private _copy;
  25008. private _color;
  25009. private _computeParticleColor;
  25010. private _computeParticleTexture;
  25011. private _computeParticleRotation;
  25012. private _computeParticleVertex;
  25013. private _computeBoundingBox;
  25014. private _depthSortParticles;
  25015. private _camera;
  25016. private _mustUnrotateFixedNormals;
  25017. private _particlesIntersect;
  25018. private _needs32Bits;
  25019. /**
  25020. * Creates a SPS (Solid Particle System) object.
  25021. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25022. * @param scene (Scene) is the scene in which the SPS is added.
  25023. * @param options defines the options of the sps e.g.
  25024. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25025. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25026. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25027. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25028. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25029. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25030. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25031. */
  25032. constructor(name: string, scene: Scene, options?: {
  25033. updatable?: boolean;
  25034. isPickable?: boolean;
  25035. enableDepthSort?: boolean;
  25036. particleIntersection?: boolean;
  25037. boundingSphereOnly?: boolean;
  25038. bSphereRadiusFactor?: number;
  25039. });
  25040. /**
  25041. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25042. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25043. * @returns the created mesh
  25044. */
  25045. buildMesh(): Mesh;
  25046. /**
  25047. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25048. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25049. * Thus the particles generated from `digest()` have their property `position` set yet.
  25050. * @param mesh ( Mesh ) is the mesh to be digested
  25051. * @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
  25052. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25053. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25054. * @returns the current SPS
  25055. */
  25056. digest(mesh: Mesh, options?: {
  25057. facetNb?: number;
  25058. number?: number;
  25059. delta?: number;
  25060. }): SolidParticleSystem;
  25061. private _unrotateFixedNormals;
  25062. private _resetCopy;
  25063. private _meshBuilder;
  25064. private _posToShape;
  25065. private _uvsToShapeUV;
  25066. private _addParticle;
  25067. /**
  25068. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25069. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25070. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25071. * @param nb (positive integer) the number of particles to be created from this model
  25072. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25073. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25074. * @returns the number of shapes in the system
  25075. */
  25076. addShape(mesh: Mesh, nb: number, options?: {
  25077. positionFunction?: any;
  25078. vertexFunction?: any;
  25079. }): number;
  25080. private _rebuildParticle;
  25081. /**
  25082. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25083. * @returns the SPS.
  25084. */
  25085. rebuildMesh(): SolidParticleSystem;
  25086. /**
  25087. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25088. * This method calls `updateParticle()` for each particle of the SPS.
  25089. * For an animated SPS, it is usually called within the render loop.
  25090. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25091. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25092. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25093. * @returns the SPS.
  25094. */
  25095. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25096. /**
  25097. * Disposes the SPS.
  25098. */
  25099. dispose(): void;
  25100. /**
  25101. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25102. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25103. * @returns the SPS.
  25104. */
  25105. refreshVisibleSize(): SolidParticleSystem;
  25106. /**
  25107. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25108. * @param size the size (float) of the visibility box
  25109. * note : this doesn't lock the SPS mesh bounding box.
  25110. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25111. */
  25112. setVisibilityBox(size: number): void;
  25113. /**
  25114. * Gets whether the SPS as always visible or not
  25115. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25116. */
  25117. /**
  25118. * Sets the SPS as always visible or not
  25119. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25120. */
  25121. isAlwaysVisible: boolean;
  25122. /**
  25123. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25124. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25125. */
  25126. /**
  25127. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25128. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25129. */
  25130. isVisibilityBoxLocked: boolean;
  25131. /**
  25132. * Tells to `setParticles()` to compute the particle rotations or not.
  25133. * Default value : true. The SPS is faster when it's set to false.
  25134. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25135. */
  25136. /**
  25137. * Gets if `setParticles()` computes the particle rotations or not.
  25138. * Default value : true. The SPS is faster when it's set to false.
  25139. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25140. */
  25141. computeParticleRotation: boolean;
  25142. /**
  25143. * Tells to `setParticles()` to compute the particle colors or not.
  25144. * Default value : true. The SPS is faster when it's set to false.
  25145. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25146. */
  25147. /**
  25148. * Gets if `setParticles()` computes the particle colors or not.
  25149. * Default value : true. The SPS is faster when it's set to false.
  25150. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25151. */
  25152. computeParticleColor: boolean;
  25153. /**
  25154. * Gets if `setParticles()` computes the particle textures or not.
  25155. * Default value : true. The SPS is faster when it's set to false.
  25156. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25157. */
  25158. computeParticleTexture: boolean;
  25159. /**
  25160. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25161. * Default value : false. The SPS is faster when it's set to false.
  25162. * Note : the particle custom vertex positions aren't stored values.
  25163. */
  25164. /**
  25165. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25166. * Default value : false. The SPS is faster when it's set to false.
  25167. * Note : the particle custom vertex positions aren't stored values.
  25168. */
  25169. computeParticleVertex: boolean;
  25170. /**
  25171. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25172. */
  25173. /**
  25174. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25175. */
  25176. computeBoundingBox: boolean;
  25177. /**
  25178. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25179. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25180. * Default : `true`
  25181. */
  25182. /**
  25183. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25184. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25185. * Default : `true`
  25186. */
  25187. depthSortParticles: boolean;
  25188. /**
  25189. * This function does nothing. It may be overwritten to set all the particle first values.
  25190. * The SPS doesn't call this function, you may have to call it by your own.
  25191. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25192. */
  25193. initParticles(): void;
  25194. /**
  25195. * This function does nothing. It may be overwritten to recycle a particle.
  25196. * The SPS doesn't call this function, you may have to call it by your own.
  25197. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25198. * @param particle The particle to recycle
  25199. * @returns the recycled particle
  25200. */
  25201. recycleParticle(particle: SolidParticle): SolidParticle;
  25202. /**
  25203. * Updates a particle : this function should be overwritten by the user.
  25204. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25205. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25206. * @example : just set a particle position or velocity and recycle conditions
  25207. * @param particle The particle to update
  25208. * @returns the updated particle
  25209. */
  25210. updateParticle(particle: SolidParticle): SolidParticle;
  25211. /**
  25212. * Updates a vertex of a particle : it can be overwritten by the user.
  25213. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25214. * @param particle the current particle
  25215. * @param vertex the current index of the current particle
  25216. * @param pt the index of the current vertex in the particle shape
  25217. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25218. * @example : just set a vertex particle position
  25219. * @returns the updated vertex
  25220. */
  25221. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25222. /**
  25223. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25224. * This does nothing and may be overwritten by the user.
  25225. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25226. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25227. * @param update the boolean update value actually passed to setParticles()
  25228. */
  25229. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25230. /**
  25231. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25232. * This will be passed three parameters.
  25233. * This does nothing and may be overwritten by the user.
  25234. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25235. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25236. * @param update the boolean update value actually passed to setParticles()
  25237. */
  25238. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25239. }
  25240. }
  25241. declare module BABYLON {
  25242. /**
  25243. * Represents one particle of a solid particle system.
  25244. */
  25245. export class SolidParticle {
  25246. /**
  25247. * particle global index
  25248. */
  25249. idx: number;
  25250. /**
  25251. * The color of the particle
  25252. */
  25253. color: Nullable<Color4>;
  25254. /**
  25255. * The world space position of the particle.
  25256. */
  25257. position: Vector3;
  25258. /**
  25259. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25260. */
  25261. rotation: Vector3;
  25262. /**
  25263. * The world space rotation quaternion of the particle.
  25264. */
  25265. rotationQuaternion: Nullable<Quaternion>;
  25266. /**
  25267. * The scaling of the particle.
  25268. */
  25269. scaling: Vector3;
  25270. /**
  25271. * The uvs of the particle.
  25272. */
  25273. uvs: Vector4;
  25274. /**
  25275. * The current speed of the particle.
  25276. */
  25277. velocity: Vector3;
  25278. /**
  25279. * The pivot point in the particle local space.
  25280. */
  25281. pivot: Vector3;
  25282. /**
  25283. * Must the particle be translated from its pivot point in its local space ?
  25284. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25285. * Default : false
  25286. */
  25287. translateFromPivot: boolean;
  25288. /**
  25289. * Is the particle active or not ?
  25290. */
  25291. alive: boolean;
  25292. /**
  25293. * Is the particle visible or not ?
  25294. */
  25295. isVisible: boolean;
  25296. /**
  25297. * Index of this particle in the global "positions" array (Internal use)
  25298. * @hidden
  25299. */
  25300. _pos: number;
  25301. /**
  25302. * @hidden Index of this particle in the global "indices" array (Internal use)
  25303. */
  25304. _ind: number;
  25305. /**
  25306. * @hidden ModelShape of this particle (Internal use)
  25307. */
  25308. _model: ModelShape;
  25309. /**
  25310. * ModelShape id of this particle
  25311. */
  25312. shapeId: number;
  25313. /**
  25314. * Index of the particle in its shape id
  25315. */
  25316. idxInShape: number;
  25317. /**
  25318. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25319. */
  25320. _modelBoundingInfo: BoundingInfo;
  25321. /**
  25322. * @hidden Particle BoundingInfo object (Internal use)
  25323. */
  25324. _boundingInfo: BoundingInfo;
  25325. /**
  25326. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25327. */
  25328. _sps: SolidParticleSystem;
  25329. /**
  25330. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25331. */
  25332. _stillInvisible: boolean;
  25333. /**
  25334. * @hidden Last computed particle rotation matrix
  25335. */
  25336. _rotationMatrix: number[];
  25337. /**
  25338. * Parent particle Id, if any.
  25339. * Default null.
  25340. */
  25341. parentId: Nullable<number>;
  25342. /**
  25343. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25344. * The possible values are :
  25345. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25346. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25347. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25348. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25349. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25350. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25351. * */
  25352. cullingStrategy: number;
  25353. /**
  25354. * @hidden Internal global position in the SPS.
  25355. */
  25356. _globalPosition: Vector3;
  25357. /**
  25358. * Creates a Solid Particle object.
  25359. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25360. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25361. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25362. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25363. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25364. * @param shapeId (integer) is the model shape identifier in the SPS.
  25365. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25366. * @param sps defines the sps it is associated to
  25367. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25368. */
  25369. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25370. /**
  25371. * Legacy support, changed scale to scaling
  25372. */
  25373. /**
  25374. * Legacy support, changed scale to scaling
  25375. */
  25376. scale: Vector3;
  25377. /**
  25378. * Legacy support, changed quaternion to rotationQuaternion
  25379. */
  25380. /**
  25381. * Legacy support, changed quaternion to rotationQuaternion
  25382. */
  25383. quaternion: Nullable<Quaternion>;
  25384. /**
  25385. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25386. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25387. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25388. * @returns true if it intersects
  25389. */
  25390. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25391. /**
  25392. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25393. * A particle is in the frustum if its bounding box intersects the frustum
  25394. * @param frustumPlanes defines the frustum to test
  25395. * @returns true if the particle is in the frustum planes
  25396. */
  25397. isInFrustum(frustumPlanes: Plane[]): boolean;
  25398. /**
  25399. * get the rotation matrix of the particle
  25400. * @hidden
  25401. */
  25402. getRotationMatrix(m: Matrix): void;
  25403. }
  25404. /**
  25405. * Represents the shape of the model used by one particle of a solid particle system.
  25406. * SPS internal tool, don't use it manually.
  25407. */
  25408. export class ModelShape {
  25409. /**
  25410. * The shape id
  25411. * @hidden
  25412. */
  25413. shapeID: number;
  25414. /**
  25415. * flat array of model positions (internal use)
  25416. * @hidden
  25417. */
  25418. _shape: Vector3[];
  25419. /**
  25420. * flat array of model UVs (internal use)
  25421. * @hidden
  25422. */
  25423. _shapeUV: number[];
  25424. /**
  25425. * length of the shape in the model indices array (internal use)
  25426. * @hidden
  25427. */
  25428. _indicesLength: number;
  25429. /**
  25430. * Custom position function (internal use)
  25431. * @hidden
  25432. */
  25433. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25434. /**
  25435. * Custom vertex function (internal use)
  25436. * @hidden
  25437. */
  25438. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25439. /**
  25440. * 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.
  25441. * SPS internal tool, don't use it manually.
  25442. * @hidden
  25443. */
  25444. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25445. }
  25446. /**
  25447. * Represents a Depth Sorted Particle in the solid particle system.
  25448. */
  25449. export class DepthSortedParticle {
  25450. /**
  25451. * Index of the particle in the "indices" array
  25452. */
  25453. ind: number;
  25454. /**
  25455. * Length of the particle shape in the "indices" array
  25456. */
  25457. indicesLength: number;
  25458. /**
  25459. * Squared distance from the particle to the camera
  25460. */
  25461. sqDistance: number;
  25462. }
  25463. }
  25464. declare module BABYLON {
  25465. /**
  25466. * @hidden
  25467. */
  25468. export class _MeshCollisionData {
  25469. _checkCollisions: boolean;
  25470. _collisionMask: number;
  25471. _collisionGroup: number;
  25472. _collider: Nullable<Collider>;
  25473. _oldPositionForCollisions: Vector3;
  25474. _diffPositionForCollisions: Vector3;
  25475. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25476. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25477. }
  25478. }
  25479. declare module BABYLON {
  25480. /** @hidden */
  25481. class _FacetDataStorage {
  25482. facetPositions: Vector3[];
  25483. facetNormals: Vector3[];
  25484. facetPartitioning: number[][];
  25485. facetNb: number;
  25486. partitioningSubdivisions: number;
  25487. partitioningBBoxRatio: number;
  25488. facetDataEnabled: boolean;
  25489. facetParameters: any;
  25490. bbSize: Vector3;
  25491. subDiv: {
  25492. max: number;
  25493. X: number;
  25494. Y: number;
  25495. Z: number;
  25496. };
  25497. facetDepthSort: boolean;
  25498. facetDepthSortEnabled: boolean;
  25499. depthSortedIndices: IndicesArray;
  25500. depthSortedFacets: {
  25501. ind: number;
  25502. sqDistance: number;
  25503. }[];
  25504. facetDepthSortFunction: (f1: {
  25505. ind: number;
  25506. sqDistance: number;
  25507. }, f2: {
  25508. ind: number;
  25509. sqDistance: number;
  25510. }) => number;
  25511. facetDepthSortFrom: Vector3;
  25512. facetDepthSortOrigin: Vector3;
  25513. invertedMatrix: Matrix;
  25514. }
  25515. /**
  25516. * @hidden
  25517. **/
  25518. class _InternalAbstractMeshDataInfo {
  25519. _hasVertexAlpha: boolean;
  25520. _useVertexColors: boolean;
  25521. _numBoneInfluencers: number;
  25522. _applyFog: boolean;
  25523. _receiveShadows: boolean;
  25524. _facetData: _FacetDataStorage;
  25525. _visibility: number;
  25526. _skeleton: Nullable<Skeleton>;
  25527. _layerMask: number;
  25528. _computeBonesUsingShaders: boolean;
  25529. _isActive: boolean;
  25530. _onlyForInstances: boolean;
  25531. _isActiveIntermediate: boolean;
  25532. _onlyForInstancesIntermediate: boolean;
  25533. }
  25534. /**
  25535. * Class used to store all common mesh properties
  25536. */
  25537. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25538. /** No occlusion */
  25539. static OCCLUSION_TYPE_NONE: number;
  25540. /** Occlusion set to optimisitic */
  25541. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25542. /** Occlusion set to strict */
  25543. static OCCLUSION_TYPE_STRICT: number;
  25544. /** Use an accurante occlusion algorithm */
  25545. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25546. /** Use a conservative occlusion algorithm */
  25547. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25548. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25549. * Test order :
  25550. * Is the bounding sphere outside the frustum ?
  25551. * If not, are the bounding box vertices outside the frustum ?
  25552. * It not, then the cullable object is in the frustum.
  25553. */
  25554. static readonly CULLINGSTRATEGY_STANDARD: number;
  25555. /** Culling strategy : Bounding Sphere Only.
  25556. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25557. * It's also less accurate than the standard because some not visible objects can still be selected.
  25558. * Test : is the bounding sphere outside the frustum ?
  25559. * If not, then the cullable object is in the frustum.
  25560. */
  25561. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25562. /** Culling strategy : Optimistic Inclusion.
  25563. * This in an inclusion test first, then the standard exclusion test.
  25564. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25565. * 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.
  25566. * Anyway, it's as accurate as the standard strategy.
  25567. * Test :
  25568. * Is the cullable object bounding sphere center in the frustum ?
  25569. * If not, apply the default culling strategy.
  25570. */
  25571. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25572. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25573. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25574. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25575. * 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.
  25576. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25577. * Test :
  25578. * Is the cullable object bounding sphere center in the frustum ?
  25579. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25580. */
  25581. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25582. /**
  25583. * No billboard
  25584. */
  25585. static readonly BILLBOARDMODE_NONE: number;
  25586. /** Billboard on X axis */
  25587. static readonly BILLBOARDMODE_X: number;
  25588. /** Billboard on Y axis */
  25589. static readonly BILLBOARDMODE_Y: number;
  25590. /** Billboard on Z axis */
  25591. static readonly BILLBOARDMODE_Z: number;
  25592. /** Billboard on all axes */
  25593. static readonly BILLBOARDMODE_ALL: number;
  25594. /** Billboard on using position instead of orientation */
  25595. static readonly BILLBOARDMODE_USE_POSITION: number;
  25596. /** @hidden */
  25597. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25598. /**
  25599. * The culling strategy to use to check whether the mesh must be rendered or not.
  25600. * This value can be changed at any time and will be used on the next render mesh selection.
  25601. * The possible values are :
  25602. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25603. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25604. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25605. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25606. * Please read each static variable documentation to get details about the culling process.
  25607. * */
  25608. cullingStrategy: number;
  25609. /**
  25610. * Gets the number of facets in the mesh
  25611. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25612. */
  25613. readonly facetNb: number;
  25614. /**
  25615. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25616. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25617. */
  25618. partitioningSubdivisions: number;
  25619. /**
  25620. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25621. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25622. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25623. */
  25624. partitioningBBoxRatio: number;
  25625. /**
  25626. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25627. * Works only for updatable meshes.
  25628. * Doesn't work with multi-materials
  25629. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25630. */
  25631. mustDepthSortFacets: boolean;
  25632. /**
  25633. * The location (Vector3) where the facet depth sort must be computed from.
  25634. * By default, the active camera position.
  25635. * Used only when facet depth sort is enabled
  25636. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25637. */
  25638. facetDepthSortFrom: Vector3;
  25639. /**
  25640. * gets a boolean indicating if facetData is enabled
  25641. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25642. */
  25643. readonly isFacetDataEnabled: boolean;
  25644. /** @hidden */
  25645. _updateNonUniformScalingState(value: boolean): boolean;
  25646. /**
  25647. * An event triggered when this mesh collides with another one
  25648. */
  25649. onCollideObservable: Observable<AbstractMesh>;
  25650. /** Set a function to call when this mesh collides with another one */
  25651. onCollide: () => void;
  25652. /**
  25653. * An event triggered when the collision's position changes
  25654. */
  25655. onCollisionPositionChangeObservable: Observable<Vector3>;
  25656. /** Set a function to call when the collision's position changes */
  25657. onCollisionPositionChange: () => void;
  25658. /**
  25659. * An event triggered when material is changed
  25660. */
  25661. onMaterialChangedObservable: Observable<AbstractMesh>;
  25662. /**
  25663. * Gets or sets the orientation for POV movement & rotation
  25664. */
  25665. definedFacingForward: boolean;
  25666. /** @hidden */
  25667. _occlusionQuery: Nullable<WebGLQuery>;
  25668. /** @hidden */
  25669. _renderingGroup: Nullable<RenderingGroup>;
  25670. /**
  25671. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25672. */
  25673. /**
  25674. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25675. */
  25676. visibility: number;
  25677. /** Gets or sets the alpha index used to sort transparent meshes
  25678. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25679. */
  25680. alphaIndex: number;
  25681. /**
  25682. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25683. */
  25684. isVisible: boolean;
  25685. /**
  25686. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25687. */
  25688. isPickable: boolean;
  25689. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25690. showSubMeshesBoundingBox: boolean;
  25691. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25692. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25693. */
  25694. isBlocker: boolean;
  25695. /**
  25696. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25697. */
  25698. enablePointerMoveEvents: boolean;
  25699. /**
  25700. * Specifies the rendering group id for this mesh (0 by default)
  25701. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25702. */
  25703. renderingGroupId: number;
  25704. private _material;
  25705. /** Gets or sets current material */
  25706. material: Nullable<Material>;
  25707. /**
  25708. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25709. * @see http://doc.babylonjs.com/babylon101/shadows
  25710. */
  25711. receiveShadows: boolean;
  25712. /** Defines color to use when rendering outline */
  25713. outlineColor: Color3;
  25714. /** Define width to use when rendering outline */
  25715. outlineWidth: number;
  25716. /** Defines color to use when rendering overlay */
  25717. overlayColor: Color3;
  25718. /** Defines alpha to use when rendering overlay */
  25719. overlayAlpha: number;
  25720. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25721. hasVertexAlpha: boolean;
  25722. /** 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) */
  25723. useVertexColors: boolean;
  25724. /**
  25725. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25726. */
  25727. computeBonesUsingShaders: boolean;
  25728. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25729. numBoneInfluencers: number;
  25730. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25731. applyFog: boolean;
  25732. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25733. useOctreeForRenderingSelection: boolean;
  25734. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25735. useOctreeForPicking: boolean;
  25736. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25737. useOctreeForCollisions: boolean;
  25738. /**
  25739. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25740. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25741. */
  25742. layerMask: number;
  25743. /**
  25744. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25745. */
  25746. alwaysSelectAsActiveMesh: boolean;
  25747. /**
  25748. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25749. */
  25750. doNotSyncBoundingInfo: boolean;
  25751. /**
  25752. * Gets or sets the current action manager
  25753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25754. */
  25755. actionManager: Nullable<AbstractActionManager>;
  25756. private _meshCollisionData;
  25757. /**
  25758. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25759. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25760. */
  25761. ellipsoid: Vector3;
  25762. /**
  25763. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25764. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25765. */
  25766. ellipsoidOffset: Vector3;
  25767. /**
  25768. * Gets or sets a collision mask used to mask collisions (default is -1).
  25769. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25770. */
  25771. collisionMask: number;
  25772. /**
  25773. * Gets or sets the current collision group mask (-1 by default).
  25774. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25775. */
  25776. collisionGroup: number;
  25777. /**
  25778. * Defines edge width used when edgesRenderer is enabled
  25779. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25780. */
  25781. edgesWidth: number;
  25782. /**
  25783. * Defines edge color used when edgesRenderer is enabled
  25784. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25785. */
  25786. edgesColor: Color4;
  25787. /** @hidden */
  25788. _edgesRenderer: Nullable<IEdgesRenderer>;
  25789. /** @hidden */
  25790. _masterMesh: Nullable<AbstractMesh>;
  25791. /** @hidden */
  25792. _boundingInfo: Nullable<BoundingInfo>;
  25793. /** @hidden */
  25794. _renderId: number;
  25795. /**
  25796. * Gets or sets the list of subMeshes
  25797. * @see http://doc.babylonjs.com/how_to/multi_materials
  25798. */
  25799. subMeshes: SubMesh[];
  25800. /** @hidden */
  25801. _intersectionsInProgress: AbstractMesh[];
  25802. /** @hidden */
  25803. _unIndexed: boolean;
  25804. /** @hidden */
  25805. _lightSources: Light[];
  25806. /** Gets the list of lights affecting that mesh */
  25807. readonly lightSources: Light[];
  25808. /** @hidden */
  25809. readonly _positions: Nullable<Vector3[]>;
  25810. /** @hidden */
  25811. _waitingData: {
  25812. lods: Nullable<any>;
  25813. actions: Nullable<any>;
  25814. freezeWorldMatrix: Nullable<boolean>;
  25815. };
  25816. /** @hidden */
  25817. _bonesTransformMatrices: Nullable<Float32Array>;
  25818. /** @hidden */
  25819. _transformMatrixTexture: Nullable<RawTexture>;
  25820. /**
  25821. * Gets or sets a skeleton to apply skining transformations
  25822. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25823. */
  25824. skeleton: Nullable<Skeleton>;
  25825. /**
  25826. * An event triggered when the mesh is rebuilt.
  25827. */
  25828. onRebuildObservable: Observable<AbstractMesh>;
  25829. /**
  25830. * Creates a new AbstractMesh
  25831. * @param name defines the name of the mesh
  25832. * @param scene defines the hosting scene
  25833. */
  25834. constructor(name: string, scene?: Nullable<Scene>);
  25835. /**
  25836. * Returns the string "AbstractMesh"
  25837. * @returns "AbstractMesh"
  25838. */
  25839. getClassName(): string;
  25840. /**
  25841. * Gets a string representation of the current mesh
  25842. * @param fullDetails defines a boolean indicating if full details must be included
  25843. * @returns a string representation of the current mesh
  25844. */
  25845. toString(fullDetails?: boolean): string;
  25846. /**
  25847. * @hidden
  25848. */
  25849. protected _getEffectiveParent(): Nullable<Node>;
  25850. /** @hidden */
  25851. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25852. /** @hidden */
  25853. _rebuild(): void;
  25854. /** @hidden */
  25855. _resyncLightSources(): void;
  25856. /** @hidden */
  25857. _resyncLighSource(light: Light): void;
  25858. /** @hidden */
  25859. _unBindEffect(): void;
  25860. /** @hidden */
  25861. _removeLightSource(light: Light, dispose: boolean): void;
  25862. private _markSubMeshesAsDirty;
  25863. /** @hidden */
  25864. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  25865. /** @hidden */
  25866. _markSubMeshesAsAttributesDirty(): void;
  25867. /** @hidden */
  25868. _markSubMeshesAsMiscDirty(): void;
  25869. /**
  25870. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25871. */
  25872. scaling: Vector3;
  25873. /**
  25874. * Returns true if the mesh is blocked. Implemented by child classes
  25875. */
  25876. readonly isBlocked: boolean;
  25877. /**
  25878. * Returns the mesh itself by default. Implemented by child classes
  25879. * @param camera defines the camera to use to pick the right LOD level
  25880. * @returns the currentAbstractMesh
  25881. */
  25882. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25883. /**
  25884. * Returns 0 by default. Implemented by child classes
  25885. * @returns an integer
  25886. */
  25887. getTotalVertices(): number;
  25888. /**
  25889. * Returns a positive integer : the total number of indices in this mesh geometry.
  25890. * @returns the numner of indices or zero if the mesh has no geometry.
  25891. */
  25892. getTotalIndices(): number;
  25893. /**
  25894. * Returns null by default. Implemented by child classes
  25895. * @returns null
  25896. */
  25897. getIndices(): Nullable<IndicesArray>;
  25898. /**
  25899. * Returns the array of the requested vertex data kind. Implemented by child classes
  25900. * @param kind defines the vertex data kind to use
  25901. * @returns null
  25902. */
  25903. getVerticesData(kind: string): Nullable<FloatArray>;
  25904. /**
  25905. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25906. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25907. * Note that a new underlying VertexBuffer object is created each call.
  25908. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25909. * @param kind defines vertex data kind:
  25910. * * VertexBuffer.PositionKind
  25911. * * VertexBuffer.UVKind
  25912. * * VertexBuffer.UV2Kind
  25913. * * VertexBuffer.UV3Kind
  25914. * * VertexBuffer.UV4Kind
  25915. * * VertexBuffer.UV5Kind
  25916. * * VertexBuffer.UV6Kind
  25917. * * VertexBuffer.ColorKind
  25918. * * VertexBuffer.MatricesIndicesKind
  25919. * * VertexBuffer.MatricesIndicesExtraKind
  25920. * * VertexBuffer.MatricesWeightsKind
  25921. * * VertexBuffer.MatricesWeightsExtraKind
  25922. * @param data defines the data source
  25923. * @param updatable defines if the data must be flagged as updatable (or static)
  25924. * @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
  25925. * @returns the current mesh
  25926. */
  25927. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25928. /**
  25929. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25930. * If the mesh has no geometry, it is simply returned as it is.
  25931. * @param kind defines vertex data kind:
  25932. * * VertexBuffer.PositionKind
  25933. * * VertexBuffer.UVKind
  25934. * * VertexBuffer.UV2Kind
  25935. * * VertexBuffer.UV3Kind
  25936. * * VertexBuffer.UV4Kind
  25937. * * VertexBuffer.UV5Kind
  25938. * * VertexBuffer.UV6Kind
  25939. * * VertexBuffer.ColorKind
  25940. * * VertexBuffer.MatricesIndicesKind
  25941. * * VertexBuffer.MatricesIndicesExtraKind
  25942. * * VertexBuffer.MatricesWeightsKind
  25943. * * VertexBuffer.MatricesWeightsExtraKind
  25944. * @param data defines the data source
  25945. * @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
  25946. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25947. * @returns the current mesh
  25948. */
  25949. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25950. /**
  25951. * Sets the mesh indices,
  25952. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25953. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25954. * @param totalVertices Defines the total number of vertices
  25955. * @returns the current mesh
  25956. */
  25957. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25958. /**
  25959. * Gets a boolean indicating if specific vertex data is present
  25960. * @param kind defines the vertex data kind to use
  25961. * @returns true is data kind is present
  25962. */
  25963. isVerticesDataPresent(kind: string): boolean;
  25964. /**
  25965. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25966. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25967. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25968. * @returns a BoundingInfo
  25969. */
  25970. getBoundingInfo(): BoundingInfo;
  25971. /**
  25972. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25973. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25974. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25975. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25976. * @returns the current mesh
  25977. */
  25978. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25979. /**
  25980. * Overwrite the current bounding info
  25981. * @param boundingInfo defines the new bounding info
  25982. * @returns the current mesh
  25983. */
  25984. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25985. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25986. readonly useBones: boolean;
  25987. /** @hidden */
  25988. _preActivate(): void;
  25989. /** @hidden */
  25990. _preActivateForIntermediateRendering(renderId: number): void;
  25991. /** @hidden */
  25992. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25993. /** @hidden */
  25994. _postActivate(): void;
  25995. /** @hidden */
  25996. _freeze(): void;
  25997. /** @hidden */
  25998. _unFreeze(): void;
  25999. /**
  26000. * Gets the current world matrix
  26001. * @returns a Matrix
  26002. */
  26003. getWorldMatrix(): Matrix;
  26004. /** @hidden */
  26005. _getWorldMatrixDeterminant(): number;
  26006. /**
  26007. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26008. */
  26009. readonly isAnInstance: boolean;
  26010. /**
  26011. * Gets a boolean indicating if this mesh has instances
  26012. */
  26013. readonly hasInstances: boolean;
  26014. /**
  26015. * Perform relative position change from the point of view of behind the front of the mesh.
  26016. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26017. * Supports definition of mesh facing forward or backward
  26018. * @param amountRight defines the distance on the right axis
  26019. * @param amountUp defines the distance on the up axis
  26020. * @param amountForward defines the distance on the forward axis
  26021. * @returns the current mesh
  26022. */
  26023. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26024. /**
  26025. * Calculate relative position change from the point of view of behind the front of the mesh.
  26026. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26027. * Supports definition of mesh facing forward or backward
  26028. * @param amountRight defines the distance on the right axis
  26029. * @param amountUp defines the distance on the up axis
  26030. * @param amountForward defines the distance on the forward axis
  26031. * @returns the new displacement vector
  26032. */
  26033. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26034. /**
  26035. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26036. * Supports definition of mesh facing forward or backward
  26037. * @param flipBack defines the flip
  26038. * @param twirlClockwise defines the twirl
  26039. * @param tiltRight defines the tilt
  26040. * @returns the current mesh
  26041. */
  26042. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26043. /**
  26044. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26045. * Supports definition of mesh facing forward or backward.
  26046. * @param flipBack defines the flip
  26047. * @param twirlClockwise defines the twirl
  26048. * @param tiltRight defines the tilt
  26049. * @returns the new rotation vector
  26050. */
  26051. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26052. /**
  26053. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26054. * This means the mesh underlying bounding box and sphere are recomputed.
  26055. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26056. * @returns the current mesh
  26057. */
  26058. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26059. /** @hidden */
  26060. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26061. /** @hidden */
  26062. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26063. /** @hidden */
  26064. _updateBoundingInfo(): AbstractMesh;
  26065. /** @hidden */
  26066. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26067. /** @hidden */
  26068. protected _afterComputeWorldMatrix(): void;
  26069. /** @hidden */
  26070. readonly _effectiveMesh: AbstractMesh;
  26071. /**
  26072. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26073. * A mesh is in the frustum if its bounding box intersects the frustum
  26074. * @param frustumPlanes defines the frustum to test
  26075. * @returns true if the mesh is in the frustum planes
  26076. */
  26077. isInFrustum(frustumPlanes: Plane[]): boolean;
  26078. /**
  26079. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26080. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26081. * @param frustumPlanes defines the frustum to test
  26082. * @returns true if the mesh is completely in the frustum planes
  26083. */
  26084. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26085. /**
  26086. * True if the mesh intersects another mesh or a SolidParticle object
  26087. * @param mesh defines a target mesh or SolidParticle to test
  26088. * @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)
  26089. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26090. * @returns true if there is an intersection
  26091. */
  26092. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26093. /**
  26094. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26095. * @param point defines the point to test
  26096. * @returns true if there is an intersection
  26097. */
  26098. intersectsPoint(point: Vector3): boolean;
  26099. /**
  26100. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26101. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26102. */
  26103. checkCollisions: boolean;
  26104. /**
  26105. * Gets Collider object used to compute collisions (not physics)
  26106. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26107. */
  26108. readonly collider: Nullable<Collider>;
  26109. /**
  26110. * Move the mesh using collision engine
  26111. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26112. * @param displacement defines the requested displacement vector
  26113. * @returns the current mesh
  26114. */
  26115. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26116. private _onCollisionPositionChange;
  26117. /** @hidden */
  26118. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26119. /** @hidden */
  26120. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26121. /** @hidden */
  26122. _checkCollision(collider: Collider): AbstractMesh;
  26123. /** @hidden */
  26124. _generatePointsArray(): boolean;
  26125. /**
  26126. * Checks if the passed Ray intersects with the mesh
  26127. * @param ray defines the ray to use
  26128. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26129. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26130. * @returns the picking info
  26131. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26132. */
  26133. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26134. /**
  26135. * Clones the current mesh
  26136. * @param name defines the mesh name
  26137. * @param newParent defines the new mesh parent
  26138. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26139. * @returns the new mesh
  26140. */
  26141. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26142. /**
  26143. * Disposes all the submeshes of the current meshnp
  26144. * @returns the current mesh
  26145. */
  26146. releaseSubMeshes(): AbstractMesh;
  26147. /**
  26148. * Releases resources associated with this abstract mesh.
  26149. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26150. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26151. */
  26152. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26153. /**
  26154. * Adds the passed mesh as a child to the current mesh
  26155. * @param mesh defines the child mesh
  26156. * @returns the current mesh
  26157. */
  26158. addChild(mesh: AbstractMesh): AbstractMesh;
  26159. /**
  26160. * Removes the passed mesh from the current mesh children list
  26161. * @param mesh defines the child mesh
  26162. * @returns the current mesh
  26163. */
  26164. removeChild(mesh: AbstractMesh): AbstractMesh;
  26165. /** @hidden */
  26166. private _initFacetData;
  26167. /**
  26168. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26169. * This method can be called within the render loop.
  26170. * 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
  26171. * @returns the current mesh
  26172. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26173. */
  26174. updateFacetData(): AbstractMesh;
  26175. /**
  26176. * Returns the facetLocalNormals array.
  26177. * The normals are expressed in the mesh local spac
  26178. * @returns an array of Vector3
  26179. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26180. */
  26181. getFacetLocalNormals(): Vector3[];
  26182. /**
  26183. * Returns the facetLocalPositions array.
  26184. * The facet positions are expressed in the mesh local space
  26185. * @returns an array of Vector3
  26186. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26187. */
  26188. getFacetLocalPositions(): Vector3[];
  26189. /**
  26190. * Returns the facetLocalPartioning array
  26191. * @returns an array of array of numbers
  26192. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26193. */
  26194. getFacetLocalPartitioning(): number[][];
  26195. /**
  26196. * Returns the i-th facet position in the world system.
  26197. * This method allocates a new Vector3 per call
  26198. * @param i defines the facet index
  26199. * @returns a new Vector3
  26200. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26201. */
  26202. getFacetPosition(i: number): Vector3;
  26203. /**
  26204. * Sets the reference Vector3 with the i-th facet position in the world system
  26205. * @param i defines the facet index
  26206. * @param ref defines the target vector
  26207. * @returns the current mesh
  26208. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26209. */
  26210. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26211. /**
  26212. * Returns the i-th facet normal in the world system.
  26213. * This method allocates a new Vector3 per call
  26214. * @param i defines the facet index
  26215. * @returns a new Vector3
  26216. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26217. */
  26218. getFacetNormal(i: number): Vector3;
  26219. /**
  26220. * Sets the reference Vector3 with the i-th facet normal in the world system
  26221. * @param i defines the facet index
  26222. * @param ref defines the target vector
  26223. * @returns the current mesh
  26224. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26225. */
  26226. getFacetNormalToRef(i: number, ref: Vector3): this;
  26227. /**
  26228. * 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)
  26229. * @param x defines x coordinate
  26230. * @param y defines y coordinate
  26231. * @param z defines z coordinate
  26232. * @returns the array of facet indexes
  26233. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26234. */
  26235. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26236. /**
  26237. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26238. * @param projected sets as the (x,y,z) world projection on the facet
  26239. * @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
  26240. * @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
  26241. * @param x defines x coordinate
  26242. * @param y defines y coordinate
  26243. * @param z defines z coordinate
  26244. * @returns the face index if found (or null instead)
  26245. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26246. */
  26247. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26248. /**
  26249. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26250. * @param projected sets as the (x,y,z) local projection on the facet
  26251. * @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
  26252. * @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
  26253. * @param x defines x coordinate
  26254. * @param y defines y coordinate
  26255. * @param z defines z coordinate
  26256. * @returns the face index if found (or null instead)
  26257. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26258. */
  26259. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26260. /**
  26261. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26262. * @returns the parameters
  26263. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26264. */
  26265. getFacetDataParameters(): any;
  26266. /**
  26267. * Disables the feature FacetData and frees the related memory
  26268. * @returns the current mesh
  26269. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26270. */
  26271. disableFacetData(): AbstractMesh;
  26272. /**
  26273. * Updates the AbstractMesh indices array
  26274. * @param indices defines the data source
  26275. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26276. * @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)
  26277. * @returns the current mesh
  26278. */
  26279. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26280. /**
  26281. * Creates new normals data for the mesh
  26282. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26283. * @returns the current mesh
  26284. */
  26285. createNormals(updatable: boolean): AbstractMesh;
  26286. /**
  26287. * Align the mesh with a normal
  26288. * @param normal defines the normal to use
  26289. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26290. * @returns the current mesh
  26291. */
  26292. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26293. /** @hidden */
  26294. _checkOcclusionQuery(): boolean;
  26295. /**
  26296. * Disables the mesh edge rendering mode
  26297. * @returns the currentAbstractMesh
  26298. */
  26299. disableEdgesRendering(): AbstractMesh;
  26300. /**
  26301. * Enables the edge rendering mode on the mesh.
  26302. * This mode makes the mesh edges visible
  26303. * @param epsilon defines the maximal distance between two angles to detect a face
  26304. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26305. * @returns the currentAbstractMesh
  26306. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26307. */
  26308. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26309. }
  26310. }
  26311. declare module BABYLON {
  26312. /**
  26313. * Interface used to define ActionEvent
  26314. */
  26315. export interface IActionEvent {
  26316. /** The mesh or sprite that triggered the action */
  26317. source: any;
  26318. /** The X mouse cursor position at the time of the event */
  26319. pointerX: number;
  26320. /** The Y mouse cursor position at the time of the event */
  26321. pointerY: number;
  26322. /** The mesh that is currently pointed at (can be null) */
  26323. meshUnderPointer: Nullable<AbstractMesh>;
  26324. /** the original (browser) event that triggered the ActionEvent */
  26325. sourceEvent?: any;
  26326. /** additional data for the event */
  26327. additionalData?: any;
  26328. }
  26329. /**
  26330. * ActionEvent is the event being sent when an action is triggered.
  26331. */
  26332. export class ActionEvent implements IActionEvent {
  26333. /** The mesh or sprite that triggered the action */
  26334. source: any;
  26335. /** The X mouse cursor position at the time of the event */
  26336. pointerX: number;
  26337. /** The Y mouse cursor position at the time of the event */
  26338. pointerY: number;
  26339. /** The mesh that is currently pointed at (can be null) */
  26340. meshUnderPointer: Nullable<AbstractMesh>;
  26341. /** the original (browser) event that triggered the ActionEvent */
  26342. sourceEvent?: any;
  26343. /** additional data for the event */
  26344. additionalData?: any;
  26345. /**
  26346. * Creates a new ActionEvent
  26347. * @param source The mesh or sprite that triggered the action
  26348. * @param pointerX The X mouse cursor position at the time of the event
  26349. * @param pointerY The Y mouse cursor position at the time of the event
  26350. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26351. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26352. * @param additionalData additional data for the event
  26353. */
  26354. constructor(
  26355. /** The mesh or sprite that triggered the action */
  26356. source: any,
  26357. /** The X mouse cursor position at the time of the event */
  26358. pointerX: number,
  26359. /** The Y mouse cursor position at the time of the event */
  26360. pointerY: number,
  26361. /** The mesh that is currently pointed at (can be null) */
  26362. meshUnderPointer: Nullable<AbstractMesh>,
  26363. /** the original (browser) event that triggered the ActionEvent */
  26364. sourceEvent?: any,
  26365. /** additional data for the event */
  26366. additionalData?: any);
  26367. /**
  26368. * Helper function to auto-create an ActionEvent from a source mesh.
  26369. * @param source The source mesh that triggered the event
  26370. * @param evt The original (browser) event
  26371. * @param additionalData additional data for the event
  26372. * @returns the new ActionEvent
  26373. */
  26374. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26375. /**
  26376. * Helper function to auto-create an ActionEvent from a source sprite
  26377. * @param source The source sprite that triggered the event
  26378. * @param scene Scene associated with the sprite
  26379. * @param evt The original (browser) event
  26380. * @param additionalData additional data for the event
  26381. * @returns the new ActionEvent
  26382. */
  26383. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26384. /**
  26385. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26386. * @param scene the scene where the event occurred
  26387. * @param evt The original (browser) event
  26388. * @returns the new ActionEvent
  26389. */
  26390. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26391. /**
  26392. * Helper function to auto-create an ActionEvent from a primitive
  26393. * @param prim defines the target primitive
  26394. * @param pointerPos defines the pointer position
  26395. * @param evt The original (browser) event
  26396. * @param additionalData additional data for the event
  26397. * @returns the new ActionEvent
  26398. */
  26399. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26400. }
  26401. }
  26402. declare module BABYLON {
  26403. /**
  26404. * Abstract class used to decouple action Manager from scene and meshes.
  26405. * Do not instantiate.
  26406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26407. */
  26408. export abstract class AbstractActionManager implements IDisposable {
  26409. /** Gets the list of active triggers */
  26410. static Triggers: {
  26411. [key: string]: number;
  26412. };
  26413. /** Gets the cursor to use when hovering items */
  26414. hoverCursor: string;
  26415. /** Gets the list of actions */
  26416. actions: IAction[];
  26417. /**
  26418. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26419. */
  26420. isRecursive: boolean;
  26421. /**
  26422. * Releases all associated resources
  26423. */
  26424. abstract dispose(): void;
  26425. /**
  26426. * Does this action manager has pointer triggers
  26427. */
  26428. abstract readonly hasPointerTriggers: boolean;
  26429. /**
  26430. * Does this action manager has pick triggers
  26431. */
  26432. abstract readonly hasPickTriggers: boolean;
  26433. /**
  26434. * Process a specific trigger
  26435. * @param trigger defines the trigger to process
  26436. * @param evt defines the event details to be processed
  26437. */
  26438. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26439. /**
  26440. * Does this action manager handles actions of any of the given triggers
  26441. * @param triggers defines the triggers to be tested
  26442. * @return a boolean indicating whether one (or more) of the triggers is handled
  26443. */
  26444. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26445. /**
  26446. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26447. * speed.
  26448. * @param triggerA defines the trigger to be tested
  26449. * @param triggerB defines the trigger to be tested
  26450. * @return a boolean indicating whether one (or more) of the triggers is handled
  26451. */
  26452. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26453. /**
  26454. * Does this action manager handles actions of a given trigger
  26455. * @param trigger defines the trigger to be tested
  26456. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26457. * @return whether the trigger is handled
  26458. */
  26459. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26460. /**
  26461. * Serialize this manager to a JSON object
  26462. * @param name defines the property name to store this manager
  26463. * @returns a JSON representation of this manager
  26464. */
  26465. abstract serialize(name: string): any;
  26466. /**
  26467. * Registers an action to this action manager
  26468. * @param action defines the action to be registered
  26469. * @return the action amended (prepared) after registration
  26470. */
  26471. abstract registerAction(action: IAction): Nullable<IAction>;
  26472. /**
  26473. * Unregisters an action to this action manager
  26474. * @param action defines the action to be unregistered
  26475. * @return a boolean indicating whether the action has been unregistered
  26476. */
  26477. abstract unregisterAction(action: IAction): Boolean;
  26478. /**
  26479. * Does exist one action manager with at least one trigger
  26480. **/
  26481. static readonly HasTriggers: boolean;
  26482. /**
  26483. * Does exist one action manager with at least one pick trigger
  26484. **/
  26485. static readonly HasPickTriggers: boolean;
  26486. /**
  26487. * Does exist one action manager that handles actions of a given trigger
  26488. * @param trigger defines the trigger to be tested
  26489. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26490. **/
  26491. static HasSpecificTrigger(trigger: number): boolean;
  26492. }
  26493. }
  26494. declare module BABYLON {
  26495. /**
  26496. * Defines how a node can be built from a string name.
  26497. */
  26498. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26499. /**
  26500. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26501. */
  26502. export class Node implements IBehaviorAware<Node> {
  26503. /** @hidden */
  26504. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26505. private static _NodeConstructors;
  26506. /**
  26507. * Add a new node constructor
  26508. * @param type defines the type name of the node to construct
  26509. * @param constructorFunc defines the constructor function
  26510. */
  26511. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26512. /**
  26513. * Returns a node constructor based on type name
  26514. * @param type defines the type name
  26515. * @param name defines the new node name
  26516. * @param scene defines the hosting scene
  26517. * @param options defines optional options to transmit to constructors
  26518. * @returns the new constructor or null
  26519. */
  26520. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26521. /**
  26522. * Gets or sets the name of the node
  26523. */
  26524. name: string;
  26525. /**
  26526. * Gets or sets the id of the node
  26527. */
  26528. id: string;
  26529. /**
  26530. * Gets or sets the unique id of the node
  26531. */
  26532. uniqueId: number;
  26533. /**
  26534. * Gets or sets a string used to store user defined state for the node
  26535. */
  26536. state: string;
  26537. /**
  26538. * Gets or sets an object used to store user defined information for the node
  26539. */
  26540. metadata: any;
  26541. /**
  26542. * For internal use only. Please do not use.
  26543. */
  26544. reservedDataStore: any;
  26545. /**
  26546. * List of inspectable custom properties (used by the Inspector)
  26547. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26548. */
  26549. inspectableCustomProperties: IInspectable[];
  26550. /**
  26551. * Gets or sets a boolean used to define if the node must be serialized
  26552. */
  26553. doNotSerialize: boolean;
  26554. /** @hidden */
  26555. _isDisposed: boolean;
  26556. /**
  26557. * Gets a list of Animations associated with the node
  26558. */
  26559. animations: Animation[];
  26560. protected _ranges: {
  26561. [name: string]: Nullable<AnimationRange>;
  26562. };
  26563. /**
  26564. * Callback raised when the node is ready to be used
  26565. */
  26566. onReady: Nullable<(node: Node) => void>;
  26567. private _isEnabled;
  26568. private _isParentEnabled;
  26569. private _isReady;
  26570. /** @hidden */
  26571. _currentRenderId: number;
  26572. private _parentUpdateId;
  26573. /** @hidden */
  26574. _childUpdateId: number;
  26575. /** @hidden */
  26576. _waitingParentId: Nullable<string>;
  26577. /** @hidden */
  26578. _scene: Scene;
  26579. /** @hidden */
  26580. _cache: any;
  26581. private _parentNode;
  26582. private _children;
  26583. /** @hidden */
  26584. _worldMatrix: Matrix;
  26585. /** @hidden */
  26586. _worldMatrixDeterminant: number;
  26587. /** @hidden */
  26588. _worldMatrixDeterminantIsDirty: boolean;
  26589. /** @hidden */
  26590. private _sceneRootNodesIndex;
  26591. /**
  26592. * Gets a boolean indicating if the node has been disposed
  26593. * @returns true if the node was disposed
  26594. */
  26595. isDisposed(): boolean;
  26596. /**
  26597. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26598. * @see https://doc.babylonjs.com/how_to/parenting
  26599. */
  26600. parent: Nullable<Node>;
  26601. private addToSceneRootNodes;
  26602. private removeFromSceneRootNodes;
  26603. private _animationPropertiesOverride;
  26604. /**
  26605. * Gets or sets the animation properties override
  26606. */
  26607. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26608. /**
  26609. * Gets a string idenfifying the name of the class
  26610. * @returns "Node" string
  26611. */
  26612. getClassName(): string;
  26613. /** @hidden */
  26614. readonly _isNode: boolean;
  26615. /**
  26616. * An event triggered when the mesh is disposed
  26617. */
  26618. onDisposeObservable: Observable<Node>;
  26619. private _onDisposeObserver;
  26620. /**
  26621. * Sets a callback that will be raised when the node will be disposed
  26622. */
  26623. onDispose: () => void;
  26624. /**
  26625. * Creates a new Node
  26626. * @param name the name and id to be given to this node
  26627. * @param scene the scene this node will be added to
  26628. * @param addToRootNodes the node will be added to scene.rootNodes
  26629. */
  26630. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26631. /**
  26632. * Gets the scene of the node
  26633. * @returns a scene
  26634. */
  26635. getScene(): Scene;
  26636. /**
  26637. * Gets the engine of the node
  26638. * @returns a Engine
  26639. */
  26640. getEngine(): Engine;
  26641. private _behaviors;
  26642. /**
  26643. * Attach a behavior to the node
  26644. * @see http://doc.babylonjs.com/features/behaviour
  26645. * @param behavior defines the behavior to attach
  26646. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26647. * @returns the current Node
  26648. */
  26649. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26650. /**
  26651. * Remove an attached behavior
  26652. * @see http://doc.babylonjs.com/features/behaviour
  26653. * @param behavior defines the behavior to attach
  26654. * @returns the current Node
  26655. */
  26656. removeBehavior(behavior: Behavior<Node>): Node;
  26657. /**
  26658. * Gets the list of attached behaviors
  26659. * @see http://doc.babylonjs.com/features/behaviour
  26660. */
  26661. readonly behaviors: Behavior<Node>[];
  26662. /**
  26663. * Gets an attached behavior by name
  26664. * @param name defines the name of the behavior to look for
  26665. * @see http://doc.babylonjs.com/features/behaviour
  26666. * @returns null if behavior was not found else the requested behavior
  26667. */
  26668. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26669. /**
  26670. * Returns the latest update of the World matrix
  26671. * @returns a Matrix
  26672. */
  26673. getWorldMatrix(): Matrix;
  26674. /** @hidden */
  26675. _getWorldMatrixDeterminant(): number;
  26676. /**
  26677. * Returns directly the latest state of the mesh World matrix.
  26678. * A Matrix is returned.
  26679. */
  26680. readonly worldMatrixFromCache: Matrix;
  26681. /** @hidden */
  26682. _initCache(): void;
  26683. /** @hidden */
  26684. updateCache(force?: boolean): void;
  26685. /** @hidden */
  26686. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26687. /** @hidden */
  26688. _updateCache(ignoreParentClass?: boolean): void;
  26689. /** @hidden */
  26690. _isSynchronized(): boolean;
  26691. /** @hidden */
  26692. _markSyncedWithParent(): void;
  26693. /** @hidden */
  26694. isSynchronizedWithParent(): boolean;
  26695. /** @hidden */
  26696. isSynchronized(): boolean;
  26697. /**
  26698. * Is this node ready to be used/rendered
  26699. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26700. * @return true if the node is ready
  26701. */
  26702. isReady(completeCheck?: boolean): boolean;
  26703. /**
  26704. * Is this node enabled?
  26705. * 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
  26706. * @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
  26707. * @return whether this node (and its parent) is enabled
  26708. */
  26709. isEnabled(checkAncestors?: boolean): boolean;
  26710. /** @hidden */
  26711. protected _syncParentEnabledState(): void;
  26712. /**
  26713. * Set the enabled state of this node
  26714. * @param value defines the new enabled state
  26715. */
  26716. setEnabled(value: boolean): void;
  26717. /**
  26718. * Is this node a descendant of the given node?
  26719. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26720. * @param ancestor defines the parent node to inspect
  26721. * @returns a boolean indicating if this node is a descendant of the given node
  26722. */
  26723. isDescendantOf(ancestor: Node): boolean;
  26724. /** @hidden */
  26725. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26726. /**
  26727. * Will return all nodes that have this node as ascendant
  26728. * @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
  26729. * @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
  26730. * @return all children nodes of all types
  26731. */
  26732. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26733. /**
  26734. * Get all child-meshes of this node
  26735. * @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)
  26736. * @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
  26737. * @returns an array of AbstractMesh
  26738. */
  26739. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26740. /**
  26741. * Get all direct children of this node
  26742. * @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
  26743. * @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)
  26744. * @returns an array of Node
  26745. */
  26746. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26747. /** @hidden */
  26748. _setReady(state: boolean): void;
  26749. /**
  26750. * Get an animation by name
  26751. * @param name defines the name of the animation to look for
  26752. * @returns null if not found else the requested animation
  26753. */
  26754. getAnimationByName(name: string): Nullable<Animation>;
  26755. /**
  26756. * Creates an animation range for this node
  26757. * @param name defines the name of the range
  26758. * @param from defines the starting key
  26759. * @param to defines the end key
  26760. */
  26761. createAnimationRange(name: string, from: number, to: number): void;
  26762. /**
  26763. * Delete a specific animation range
  26764. * @param name defines the name of the range to delete
  26765. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26766. */
  26767. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26768. /**
  26769. * Get an animation range by name
  26770. * @param name defines the name of the animation range to look for
  26771. * @returns null if not found else the requested animation range
  26772. */
  26773. getAnimationRange(name: string): Nullable<AnimationRange>;
  26774. /**
  26775. * Gets the list of all animation ranges defined on this node
  26776. * @returns an array
  26777. */
  26778. getAnimationRanges(): Nullable<AnimationRange>[];
  26779. /**
  26780. * Will start the animation sequence
  26781. * @param name defines the range frames for animation sequence
  26782. * @param loop defines if the animation should loop (false by default)
  26783. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26784. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26785. * @returns the object created for this animation. If range does not exist, it will return null
  26786. */
  26787. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26788. /**
  26789. * Serialize animation ranges into a JSON compatible object
  26790. * @returns serialization object
  26791. */
  26792. serializeAnimationRanges(): any;
  26793. /**
  26794. * Computes the world matrix of the node
  26795. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26796. * @returns the world matrix
  26797. */
  26798. computeWorldMatrix(force?: boolean): Matrix;
  26799. /**
  26800. * Releases resources associated with this node.
  26801. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26802. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26803. */
  26804. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26805. /**
  26806. * Parse animation range data from a serialization object and store them into a given node
  26807. * @param node defines where to store the animation ranges
  26808. * @param parsedNode defines the serialization object to read data from
  26809. * @param scene defines the hosting scene
  26810. */
  26811. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26812. /**
  26813. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26814. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26815. * @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
  26816. * @returns the new bounding vectors
  26817. */
  26818. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26819. min: Vector3;
  26820. max: Vector3;
  26821. };
  26822. }
  26823. }
  26824. declare module BABYLON {
  26825. /**
  26826. * @hidden
  26827. */
  26828. export class _IAnimationState {
  26829. key: number;
  26830. repeatCount: number;
  26831. workValue?: any;
  26832. loopMode?: number;
  26833. offsetValue?: any;
  26834. highLimitValue?: any;
  26835. }
  26836. /**
  26837. * Class used to store any kind of animation
  26838. */
  26839. export class Animation {
  26840. /**Name of the animation */
  26841. name: string;
  26842. /**Property to animate */
  26843. targetProperty: string;
  26844. /**The frames per second of the animation */
  26845. framePerSecond: number;
  26846. /**The data type of the animation */
  26847. dataType: number;
  26848. /**The loop mode of the animation */
  26849. loopMode?: number | undefined;
  26850. /**Specifies if blending should be enabled */
  26851. enableBlending?: boolean | undefined;
  26852. /**
  26853. * Use matrix interpolation instead of using direct key value when animating matrices
  26854. */
  26855. static AllowMatricesInterpolation: boolean;
  26856. /**
  26857. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26858. */
  26859. static AllowMatrixDecomposeForInterpolation: boolean;
  26860. /**
  26861. * Stores the key frames of the animation
  26862. */
  26863. private _keys;
  26864. /**
  26865. * Stores the easing function of the animation
  26866. */
  26867. private _easingFunction;
  26868. /**
  26869. * @hidden Internal use only
  26870. */
  26871. _runtimeAnimations: RuntimeAnimation[];
  26872. /**
  26873. * The set of event that will be linked to this animation
  26874. */
  26875. private _events;
  26876. /**
  26877. * Stores an array of target property paths
  26878. */
  26879. targetPropertyPath: string[];
  26880. /**
  26881. * Stores the blending speed of the animation
  26882. */
  26883. blendingSpeed: number;
  26884. /**
  26885. * Stores the animation ranges for the animation
  26886. */
  26887. private _ranges;
  26888. /**
  26889. * @hidden Internal use
  26890. */
  26891. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26892. /**
  26893. * Sets up an animation
  26894. * @param property The property to animate
  26895. * @param animationType The animation type to apply
  26896. * @param framePerSecond The frames per second of the animation
  26897. * @param easingFunction The easing function used in the animation
  26898. * @returns The created animation
  26899. */
  26900. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26901. /**
  26902. * Create and start an animation on a node
  26903. * @param name defines the name of the global animation that will be run on all nodes
  26904. * @param node defines the root node where the animation will take place
  26905. * @param targetProperty defines property to animate
  26906. * @param framePerSecond defines the number of frame per second yo use
  26907. * @param totalFrame defines the number of frames in total
  26908. * @param from defines the initial value
  26909. * @param to defines the final value
  26910. * @param loopMode defines which loop mode you want to use (off by default)
  26911. * @param easingFunction defines the easing function to use (linear by default)
  26912. * @param onAnimationEnd defines the callback to call when animation end
  26913. * @returns the animatable created for this animation
  26914. */
  26915. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26916. /**
  26917. * Create and start an animation on a node and its descendants
  26918. * @param name defines the name of the global animation that will be run on all nodes
  26919. * @param node defines the root node where the animation will take place
  26920. * @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
  26921. * @param targetProperty defines property to animate
  26922. * @param framePerSecond defines the number of frame per second to use
  26923. * @param totalFrame defines the number of frames in total
  26924. * @param from defines the initial value
  26925. * @param to defines the final value
  26926. * @param loopMode defines which loop mode you want to use (off by default)
  26927. * @param easingFunction defines the easing function to use (linear by default)
  26928. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26929. * @returns the list of animatables created for all nodes
  26930. * @example https://www.babylonjs-playground.com/#MH0VLI
  26931. */
  26932. 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[]>;
  26933. /**
  26934. * Creates a new animation, merges it with the existing animations and starts it
  26935. * @param name Name of the animation
  26936. * @param node Node which contains the scene that begins the animations
  26937. * @param targetProperty Specifies which property to animate
  26938. * @param framePerSecond The frames per second of the animation
  26939. * @param totalFrame The total number of frames
  26940. * @param from The frame at the beginning of the animation
  26941. * @param to The frame at the end of the animation
  26942. * @param loopMode Specifies the loop mode of the animation
  26943. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26944. * @param onAnimationEnd Callback to run once the animation is complete
  26945. * @returns Nullable animation
  26946. */
  26947. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26948. /**
  26949. * Transition property of an host to the target Value
  26950. * @param property The property to transition
  26951. * @param targetValue The target Value of the property
  26952. * @param host The object where the property to animate belongs
  26953. * @param scene Scene used to run the animation
  26954. * @param frameRate Framerate (in frame/s) to use
  26955. * @param transition The transition type we want to use
  26956. * @param duration The duration of the animation, in milliseconds
  26957. * @param onAnimationEnd Callback trigger at the end of the animation
  26958. * @returns Nullable animation
  26959. */
  26960. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26961. /**
  26962. * Return the array of runtime animations currently using this animation
  26963. */
  26964. readonly runtimeAnimations: RuntimeAnimation[];
  26965. /**
  26966. * Specifies if any of the runtime animations are currently running
  26967. */
  26968. readonly hasRunningRuntimeAnimations: boolean;
  26969. /**
  26970. * Initializes the animation
  26971. * @param name Name of the animation
  26972. * @param targetProperty Property to animate
  26973. * @param framePerSecond The frames per second of the animation
  26974. * @param dataType The data type of the animation
  26975. * @param loopMode The loop mode of the animation
  26976. * @param enableBlending Specifies if blending should be enabled
  26977. */
  26978. constructor(
  26979. /**Name of the animation */
  26980. name: string,
  26981. /**Property to animate */
  26982. targetProperty: string,
  26983. /**The frames per second of the animation */
  26984. framePerSecond: number,
  26985. /**The data type of the animation */
  26986. dataType: number,
  26987. /**The loop mode of the animation */
  26988. loopMode?: number | undefined,
  26989. /**Specifies if blending should be enabled */
  26990. enableBlending?: boolean | undefined);
  26991. /**
  26992. * Converts the animation to a string
  26993. * @param fullDetails support for multiple levels of logging within scene loading
  26994. * @returns String form of the animation
  26995. */
  26996. toString(fullDetails?: boolean): string;
  26997. /**
  26998. * Add an event to this animation
  26999. * @param event Event to add
  27000. */
  27001. addEvent(event: AnimationEvent): void;
  27002. /**
  27003. * Remove all events found at the given frame
  27004. * @param frame The frame to remove events from
  27005. */
  27006. removeEvents(frame: number): void;
  27007. /**
  27008. * Retrieves all the events from the animation
  27009. * @returns Events from the animation
  27010. */
  27011. getEvents(): AnimationEvent[];
  27012. /**
  27013. * Creates an animation range
  27014. * @param name Name of the animation range
  27015. * @param from Starting frame of the animation range
  27016. * @param to Ending frame of the animation
  27017. */
  27018. createRange(name: string, from: number, to: number): void;
  27019. /**
  27020. * Deletes an animation range by name
  27021. * @param name Name of the animation range to delete
  27022. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27023. */
  27024. deleteRange(name: string, deleteFrames?: boolean): void;
  27025. /**
  27026. * Gets the animation range by name, or null if not defined
  27027. * @param name Name of the animation range
  27028. * @returns Nullable animation range
  27029. */
  27030. getRange(name: string): Nullable<AnimationRange>;
  27031. /**
  27032. * Gets the key frames from the animation
  27033. * @returns The key frames of the animation
  27034. */
  27035. getKeys(): Array<IAnimationKey>;
  27036. /**
  27037. * Gets the highest frame rate of the animation
  27038. * @returns Highest frame rate of the animation
  27039. */
  27040. getHighestFrame(): number;
  27041. /**
  27042. * Gets the easing function of the animation
  27043. * @returns Easing function of the animation
  27044. */
  27045. getEasingFunction(): IEasingFunction;
  27046. /**
  27047. * Sets the easing function of the animation
  27048. * @param easingFunction A custom mathematical formula for animation
  27049. */
  27050. setEasingFunction(easingFunction: EasingFunction): void;
  27051. /**
  27052. * Interpolates a scalar linearly
  27053. * @param startValue Start value of the animation curve
  27054. * @param endValue End value of the animation curve
  27055. * @param gradient Scalar amount to interpolate
  27056. * @returns Interpolated scalar value
  27057. */
  27058. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27059. /**
  27060. * Interpolates a scalar cubically
  27061. * @param startValue Start value of the animation curve
  27062. * @param outTangent End tangent of the animation
  27063. * @param endValue End value of the animation curve
  27064. * @param inTangent Start tangent of the animation curve
  27065. * @param gradient Scalar amount to interpolate
  27066. * @returns Interpolated scalar value
  27067. */
  27068. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27069. /**
  27070. * Interpolates a quaternion using a spherical linear interpolation
  27071. * @param startValue Start value of the animation curve
  27072. * @param endValue End value of the animation curve
  27073. * @param gradient Scalar amount to interpolate
  27074. * @returns Interpolated quaternion value
  27075. */
  27076. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27077. /**
  27078. * Interpolates a quaternion cubically
  27079. * @param startValue Start value of the animation curve
  27080. * @param outTangent End tangent of the animation curve
  27081. * @param endValue End value of the animation curve
  27082. * @param inTangent Start tangent of the animation curve
  27083. * @param gradient Scalar amount to interpolate
  27084. * @returns Interpolated quaternion value
  27085. */
  27086. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27087. /**
  27088. * Interpolates a Vector3 linearl
  27089. * @param startValue Start value of the animation curve
  27090. * @param endValue End value of the animation curve
  27091. * @param gradient Scalar amount to interpolate
  27092. * @returns Interpolated scalar value
  27093. */
  27094. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27095. /**
  27096. * Interpolates a Vector3 cubically
  27097. * @param startValue Start value of the animation curve
  27098. * @param outTangent End tangent of the animation
  27099. * @param endValue End value of the animation curve
  27100. * @param inTangent Start tangent of the animation curve
  27101. * @param gradient Scalar amount to interpolate
  27102. * @returns InterpolatedVector3 value
  27103. */
  27104. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27105. /**
  27106. * Interpolates a Vector2 linearly
  27107. * @param startValue Start value of the animation curve
  27108. * @param endValue End value of the animation curve
  27109. * @param gradient Scalar amount to interpolate
  27110. * @returns Interpolated Vector2 value
  27111. */
  27112. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27113. /**
  27114. * Interpolates a Vector2 cubically
  27115. * @param startValue Start value of the animation curve
  27116. * @param outTangent End tangent of the animation
  27117. * @param endValue End value of the animation curve
  27118. * @param inTangent Start tangent of the animation curve
  27119. * @param gradient Scalar amount to interpolate
  27120. * @returns Interpolated Vector2 value
  27121. */
  27122. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27123. /**
  27124. * Interpolates a size linearly
  27125. * @param startValue Start value of the animation curve
  27126. * @param endValue End value of the animation curve
  27127. * @param gradient Scalar amount to interpolate
  27128. * @returns Interpolated Size value
  27129. */
  27130. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27131. /**
  27132. * Interpolates a Color3 linearly
  27133. * @param startValue Start value of the animation curve
  27134. * @param endValue End value of the animation curve
  27135. * @param gradient Scalar amount to interpolate
  27136. * @returns Interpolated Color3 value
  27137. */
  27138. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27139. /**
  27140. * @hidden Internal use only
  27141. */
  27142. _getKeyValue(value: any): any;
  27143. /**
  27144. * @hidden Internal use only
  27145. */
  27146. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27147. /**
  27148. * Defines the function to use to interpolate matrices
  27149. * @param startValue defines the start matrix
  27150. * @param endValue defines the end matrix
  27151. * @param gradient defines the gradient between both matrices
  27152. * @param result defines an optional target matrix where to store the interpolation
  27153. * @returns the interpolated matrix
  27154. */
  27155. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27156. /**
  27157. * Makes a copy of the animation
  27158. * @returns Cloned animation
  27159. */
  27160. clone(): Animation;
  27161. /**
  27162. * Sets the key frames of the animation
  27163. * @param values The animation key frames to set
  27164. */
  27165. setKeys(values: Array<IAnimationKey>): void;
  27166. /**
  27167. * Serializes the animation to an object
  27168. * @returns Serialized object
  27169. */
  27170. serialize(): any;
  27171. /**
  27172. * Float animation type
  27173. */
  27174. private static _ANIMATIONTYPE_FLOAT;
  27175. /**
  27176. * Vector3 animation type
  27177. */
  27178. private static _ANIMATIONTYPE_VECTOR3;
  27179. /**
  27180. * Quaternion animation type
  27181. */
  27182. private static _ANIMATIONTYPE_QUATERNION;
  27183. /**
  27184. * Matrix animation type
  27185. */
  27186. private static _ANIMATIONTYPE_MATRIX;
  27187. /**
  27188. * Color3 animation type
  27189. */
  27190. private static _ANIMATIONTYPE_COLOR3;
  27191. /**
  27192. * Vector2 animation type
  27193. */
  27194. private static _ANIMATIONTYPE_VECTOR2;
  27195. /**
  27196. * Size animation type
  27197. */
  27198. private static _ANIMATIONTYPE_SIZE;
  27199. /**
  27200. * Relative Loop Mode
  27201. */
  27202. private static _ANIMATIONLOOPMODE_RELATIVE;
  27203. /**
  27204. * Cycle Loop Mode
  27205. */
  27206. private static _ANIMATIONLOOPMODE_CYCLE;
  27207. /**
  27208. * Constant Loop Mode
  27209. */
  27210. private static _ANIMATIONLOOPMODE_CONSTANT;
  27211. /**
  27212. * Get the float animation type
  27213. */
  27214. static readonly ANIMATIONTYPE_FLOAT: number;
  27215. /**
  27216. * Get the Vector3 animation type
  27217. */
  27218. static readonly ANIMATIONTYPE_VECTOR3: number;
  27219. /**
  27220. * Get the Vector2 animation type
  27221. */
  27222. static readonly ANIMATIONTYPE_VECTOR2: number;
  27223. /**
  27224. * Get the Size animation type
  27225. */
  27226. static readonly ANIMATIONTYPE_SIZE: number;
  27227. /**
  27228. * Get the Quaternion animation type
  27229. */
  27230. static readonly ANIMATIONTYPE_QUATERNION: number;
  27231. /**
  27232. * Get the Matrix animation type
  27233. */
  27234. static readonly ANIMATIONTYPE_MATRIX: number;
  27235. /**
  27236. * Get the Color3 animation type
  27237. */
  27238. static readonly ANIMATIONTYPE_COLOR3: number;
  27239. /**
  27240. * Get the Relative Loop Mode
  27241. */
  27242. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27243. /**
  27244. * Get the Cycle Loop Mode
  27245. */
  27246. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27247. /**
  27248. * Get the Constant Loop Mode
  27249. */
  27250. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27251. /** @hidden */
  27252. static _UniversalLerp(left: any, right: any, amount: number): any;
  27253. /**
  27254. * Parses an animation object and creates an animation
  27255. * @param parsedAnimation Parsed animation object
  27256. * @returns Animation object
  27257. */
  27258. static Parse(parsedAnimation: any): Animation;
  27259. /**
  27260. * Appends the serialized animations from the source animations
  27261. * @param source Source containing the animations
  27262. * @param destination Target to store the animations
  27263. */
  27264. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27265. }
  27266. }
  27267. declare module BABYLON {
  27268. /**
  27269. * Interface containing an array of animations
  27270. */
  27271. export interface IAnimatable {
  27272. /**
  27273. * Array of animations
  27274. */
  27275. animations: Nullable<Array<Animation>>;
  27276. }
  27277. }
  27278. declare module BABYLON {
  27279. /**
  27280. * This represents all the required information to add a fresnel effect on a material:
  27281. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27282. */
  27283. export class FresnelParameters {
  27284. private _isEnabled;
  27285. /**
  27286. * Define if the fresnel effect is enable or not.
  27287. */
  27288. isEnabled: boolean;
  27289. /**
  27290. * Define the color used on edges (grazing angle)
  27291. */
  27292. leftColor: Color3;
  27293. /**
  27294. * Define the color used on center
  27295. */
  27296. rightColor: Color3;
  27297. /**
  27298. * Define bias applied to computed fresnel term
  27299. */
  27300. bias: number;
  27301. /**
  27302. * Defined the power exponent applied to fresnel term
  27303. */
  27304. power: number;
  27305. /**
  27306. * Clones the current fresnel and its valuues
  27307. * @returns a clone fresnel configuration
  27308. */
  27309. clone(): FresnelParameters;
  27310. /**
  27311. * Serializes the current fresnel parameters to a JSON representation.
  27312. * @return the JSON serialization
  27313. */
  27314. serialize(): any;
  27315. /**
  27316. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27317. * @param parsedFresnelParameters Define the JSON representation
  27318. * @returns the parsed parameters
  27319. */
  27320. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27321. }
  27322. }
  27323. declare module BABYLON {
  27324. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27325. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27326. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27327. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27328. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27329. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27330. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27331. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27332. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27333. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27334. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27335. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27336. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27337. /**
  27338. * Decorator used to define property that can be serialized as reference to a camera
  27339. * @param sourceName defines the name of the property to decorate
  27340. */
  27341. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27342. /**
  27343. * Class used to help serialization objects
  27344. */
  27345. export class SerializationHelper {
  27346. /** @hidden */
  27347. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27348. /** @hidden */
  27349. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27350. /** @hidden */
  27351. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27352. /** @hidden */
  27353. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27354. /**
  27355. * Appends the serialized animations from the source animations
  27356. * @param source Source containing the animations
  27357. * @param destination Target to store the animations
  27358. */
  27359. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27360. /**
  27361. * Static function used to serialized a specific entity
  27362. * @param entity defines the entity to serialize
  27363. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27364. * @returns a JSON compatible object representing the serialization of the entity
  27365. */
  27366. static Serialize<T>(entity: T, serializationObject?: any): any;
  27367. /**
  27368. * Creates a new entity from a serialization data object
  27369. * @param creationFunction defines a function used to instanciated the new entity
  27370. * @param source defines the source serialization data
  27371. * @param scene defines the hosting scene
  27372. * @param rootUrl defines the root url for resources
  27373. * @returns a new entity
  27374. */
  27375. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27376. /**
  27377. * Clones an object
  27378. * @param creationFunction defines the function used to instanciate the new object
  27379. * @param source defines the source object
  27380. * @returns the cloned object
  27381. */
  27382. static Clone<T>(creationFunction: () => T, source: T): T;
  27383. /**
  27384. * Instanciates a new object based on a source one (some data will be shared between both object)
  27385. * @param creationFunction defines the function used to instanciate the new object
  27386. * @param source defines the source object
  27387. * @returns the new object
  27388. */
  27389. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27390. }
  27391. }
  27392. declare module BABYLON {
  27393. /**
  27394. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27395. */
  27396. export interface CubeMapInfo {
  27397. /**
  27398. * The pixel array for the front face.
  27399. * This is stored in format, left to right, up to down format.
  27400. */
  27401. front: Nullable<ArrayBufferView>;
  27402. /**
  27403. * The pixel array for the back face.
  27404. * This is stored in format, left to right, up to down format.
  27405. */
  27406. back: Nullable<ArrayBufferView>;
  27407. /**
  27408. * The pixel array for the left face.
  27409. * This is stored in format, left to right, up to down format.
  27410. */
  27411. left: Nullable<ArrayBufferView>;
  27412. /**
  27413. * The pixel array for the right face.
  27414. * This is stored in format, left to right, up to down format.
  27415. */
  27416. right: Nullable<ArrayBufferView>;
  27417. /**
  27418. * The pixel array for the up face.
  27419. * This is stored in format, left to right, up to down format.
  27420. */
  27421. up: Nullable<ArrayBufferView>;
  27422. /**
  27423. * The pixel array for the down face.
  27424. * This is stored in format, left to right, up to down format.
  27425. */
  27426. down: Nullable<ArrayBufferView>;
  27427. /**
  27428. * The size of the cubemap stored.
  27429. *
  27430. * Each faces will be size * size pixels.
  27431. */
  27432. size: number;
  27433. /**
  27434. * The format of the texture.
  27435. *
  27436. * RGBA, RGB.
  27437. */
  27438. format: number;
  27439. /**
  27440. * The type of the texture data.
  27441. *
  27442. * UNSIGNED_INT, FLOAT.
  27443. */
  27444. type: number;
  27445. /**
  27446. * Specifies whether the texture is in gamma space.
  27447. */
  27448. gammaSpace: boolean;
  27449. }
  27450. /**
  27451. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27452. */
  27453. export class PanoramaToCubeMapTools {
  27454. private static FACE_FRONT;
  27455. private static FACE_BACK;
  27456. private static FACE_RIGHT;
  27457. private static FACE_LEFT;
  27458. private static FACE_DOWN;
  27459. private static FACE_UP;
  27460. /**
  27461. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27462. *
  27463. * @param float32Array The source data.
  27464. * @param inputWidth The width of the input panorama.
  27465. * @param inputHeight The height of the input panorama.
  27466. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27467. * @return The cubemap data
  27468. */
  27469. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27470. private static CreateCubemapTexture;
  27471. private static CalcProjectionSpherical;
  27472. }
  27473. }
  27474. declare module BABYLON {
  27475. /**
  27476. * Helper class dealing with the extraction of spherical polynomial dataArray
  27477. * from a cube map.
  27478. */
  27479. export class CubeMapToSphericalPolynomialTools {
  27480. private static FileFaces;
  27481. /**
  27482. * Converts a texture to the according Spherical Polynomial data.
  27483. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27484. *
  27485. * @param texture The texture to extract the information from.
  27486. * @return The Spherical Polynomial data.
  27487. */
  27488. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27489. /**
  27490. * Converts a cubemap to the according Spherical Polynomial data.
  27491. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27492. *
  27493. * @param cubeInfo The Cube map to extract the information from.
  27494. * @return The Spherical Polynomial data.
  27495. */
  27496. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27497. }
  27498. }
  27499. declare module BABYLON {
  27500. /**
  27501. * Class used to manipulate GUIDs
  27502. */
  27503. export class GUID {
  27504. /**
  27505. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27506. * Be aware Math.random() could cause collisions, but:
  27507. * "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"
  27508. * @returns a pseudo random id
  27509. */
  27510. static RandomId(): string;
  27511. }
  27512. }
  27513. declare module BABYLON {
  27514. /**
  27515. * Base class of all the textures in babylon.
  27516. * It groups all the common properties the materials, post process, lights... might need
  27517. * in order to make a correct use of the texture.
  27518. */
  27519. export class BaseTexture implements IAnimatable {
  27520. /**
  27521. * Default anisotropic filtering level for the application.
  27522. * It is set to 4 as a good tradeoff between perf and quality.
  27523. */
  27524. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27525. /**
  27526. * Gets or sets the unique id of the texture
  27527. */
  27528. uniqueId: number;
  27529. /**
  27530. * Define the name of the texture.
  27531. */
  27532. name: string;
  27533. /**
  27534. * Gets or sets an object used to store user defined information.
  27535. */
  27536. metadata: any;
  27537. /**
  27538. * For internal use only. Please do not use.
  27539. */
  27540. reservedDataStore: any;
  27541. private _hasAlpha;
  27542. /**
  27543. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27544. */
  27545. hasAlpha: boolean;
  27546. /**
  27547. * Defines if the alpha value should be determined via the rgb values.
  27548. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27549. */
  27550. getAlphaFromRGB: boolean;
  27551. /**
  27552. * Intensity or strength of the texture.
  27553. * It is commonly used by materials to fine tune the intensity of the texture
  27554. */
  27555. level: number;
  27556. /**
  27557. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27558. * This is part of the texture as textures usually maps to one uv set.
  27559. */
  27560. coordinatesIndex: number;
  27561. private _coordinatesMode;
  27562. /**
  27563. * How a texture is mapped.
  27564. *
  27565. * | Value | Type | Description |
  27566. * | ----- | ----------------------------------- | ----------- |
  27567. * | 0 | EXPLICIT_MODE | |
  27568. * | 1 | SPHERICAL_MODE | |
  27569. * | 2 | PLANAR_MODE | |
  27570. * | 3 | CUBIC_MODE | |
  27571. * | 4 | PROJECTION_MODE | |
  27572. * | 5 | SKYBOX_MODE | |
  27573. * | 6 | INVCUBIC_MODE | |
  27574. * | 7 | EQUIRECTANGULAR_MODE | |
  27575. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27576. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27577. */
  27578. coordinatesMode: number;
  27579. /**
  27580. * | Value | Type | Description |
  27581. * | ----- | ------------------ | ----------- |
  27582. * | 0 | CLAMP_ADDRESSMODE | |
  27583. * | 1 | WRAP_ADDRESSMODE | |
  27584. * | 2 | MIRROR_ADDRESSMODE | |
  27585. */
  27586. wrapU: number;
  27587. /**
  27588. * | Value | Type | Description |
  27589. * | ----- | ------------------ | ----------- |
  27590. * | 0 | CLAMP_ADDRESSMODE | |
  27591. * | 1 | WRAP_ADDRESSMODE | |
  27592. * | 2 | MIRROR_ADDRESSMODE | |
  27593. */
  27594. wrapV: number;
  27595. /**
  27596. * | Value | Type | Description |
  27597. * | ----- | ------------------ | ----------- |
  27598. * | 0 | CLAMP_ADDRESSMODE | |
  27599. * | 1 | WRAP_ADDRESSMODE | |
  27600. * | 2 | MIRROR_ADDRESSMODE | |
  27601. */
  27602. wrapR: number;
  27603. /**
  27604. * With compliant hardware and browser (supporting anisotropic filtering)
  27605. * this defines the level of anisotropic filtering in the texture.
  27606. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27607. */
  27608. anisotropicFilteringLevel: number;
  27609. /**
  27610. * Define if the texture is a cube texture or if false a 2d texture.
  27611. */
  27612. isCube: boolean;
  27613. /**
  27614. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27615. */
  27616. is3D: boolean;
  27617. /**
  27618. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27619. * HDR texture are usually stored in linear space.
  27620. * This only impacts the PBR and Background materials
  27621. */
  27622. gammaSpace: boolean;
  27623. /**
  27624. * Gets or sets whether or not the texture contains RGBD data.
  27625. */
  27626. isRGBD: boolean;
  27627. /**
  27628. * Is Z inverted in the texture (useful in a cube texture).
  27629. */
  27630. invertZ: boolean;
  27631. /**
  27632. * Are mip maps generated for this texture or not.
  27633. */
  27634. readonly noMipmap: boolean;
  27635. /**
  27636. * @hidden
  27637. */
  27638. lodLevelInAlpha: boolean;
  27639. /**
  27640. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27641. */
  27642. lodGenerationOffset: number;
  27643. /**
  27644. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27645. */
  27646. lodGenerationScale: number;
  27647. /**
  27648. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27649. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27650. * average roughness values.
  27651. */
  27652. linearSpecularLOD: boolean;
  27653. /**
  27654. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27655. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27656. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27657. */
  27658. irradianceTexture: Nullable<BaseTexture>;
  27659. /**
  27660. * Define if the texture is a render target.
  27661. */
  27662. isRenderTarget: boolean;
  27663. /**
  27664. * Define the unique id of the texture in the scene.
  27665. */
  27666. readonly uid: string;
  27667. /**
  27668. * Return a string representation of the texture.
  27669. * @returns the texture as a string
  27670. */
  27671. toString(): string;
  27672. /**
  27673. * Get the class name of the texture.
  27674. * @returns "BaseTexture"
  27675. */
  27676. getClassName(): string;
  27677. /**
  27678. * Define the list of animation attached to the texture.
  27679. */
  27680. animations: Animation[];
  27681. /**
  27682. * An event triggered when the texture is disposed.
  27683. */
  27684. onDisposeObservable: Observable<BaseTexture>;
  27685. private _onDisposeObserver;
  27686. /**
  27687. * Callback triggered when the texture has been disposed.
  27688. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27689. */
  27690. onDispose: () => void;
  27691. /**
  27692. * Define the current state of the loading sequence when in delayed load mode.
  27693. */
  27694. delayLoadState: number;
  27695. private _scene;
  27696. /** @hidden */
  27697. _texture: Nullable<InternalTexture>;
  27698. private _uid;
  27699. /**
  27700. * Define if the texture is preventinga material to render or not.
  27701. * If not and the texture is not ready, the engine will use a default black texture instead.
  27702. */
  27703. readonly isBlocking: boolean;
  27704. /**
  27705. * Instantiates a new BaseTexture.
  27706. * Base class of all the textures in babylon.
  27707. * It groups all the common properties the materials, post process, lights... might need
  27708. * in order to make a correct use of the texture.
  27709. * @param scene Define the scene the texture blongs to
  27710. */
  27711. constructor(scene: Nullable<Scene>);
  27712. /**
  27713. * Get the scene the texture belongs to.
  27714. * @returns the scene or null if undefined
  27715. */
  27716. getScene(): Nullable<Scene>;
  27717. /**
  27718. * Get the texture transform matrix used to offset tile the texture for istance.
  27719. * @returns the transformation matrix
  27720. */
  27721. getTextureMatrix(): Matrix;
  27722. /**
  27723. * Get the texture reflection matrix used to rotate/transform the reflection.
  27724. * @returns the reflection matrix
  27725. */
  27726. getReflectionTextureMatrix(): Matrix;
  27727. /**
  27728. * Get the underlying lower level texture from Babylon.
  27729. * @returns the insternal texture
  27730. */
  27731. getInternalTexture(): Nullable<InternalTexture>;
  27732. /**
  27733. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27734. * @returns true if ready or not blocking
  27735. */
  27736. isReadyOrNotBlocking(): boolean;
  27737. /**
  27738. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27739. * @returns true if fully ready
  27740. */
  27741. isReady(): boolean;
  27742. private _cachedSize;
  27743. /**
  27744. * Get the size of the texture.
  27745. * @returns the texture size.
  27746. */
  27747. getSize(): ISize;
  27748. /**
  27749. * Get the base size of the texture.
  27750. * It can be different from the size if the texture has been resized for POT for instance
  27751. * @returns the base size
  27752. */
  27753. getBaseSize(): ISize;
  27754. /**
  27755. * Update the sampling mode of the texture.
  27756. * Default is Trilinear mode.
  27757. *
  27758. * | Value | Type | Description |
  27759. * | ----- | ------------------ | ----------- |
  27760. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27761. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27762. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27763. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27764. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27765. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27766. * | 7 | NEAREST_LINEAR | |
  27767. * | 8 | NEAREST_NEAREST | |
  27768. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27769. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27770. * | 11 | LINEAR_LINEAR | |
  27771. * | 12 | LINEAR_NEAREST | |
  27772. *
  27773. * > _mag_: magnification filter (close to the viewer)
  27774. * > _min_: minification filter (far from the viewer)
  27775. * > _mip_: filter used between mip map levels
  27776. *@param samplingMode Define the new sampling mode of the texture
  27777. */
  27778. updateSamplingMode(samplingMode: number): void;
  27779. /**
  27780. * Scales the texture if is `canRescale()`
  27781. * @param ratio the resize factor we want to use to rescale
  27782. */
  27783. scale(ratio: number): void;
  27784. /**
  27785. * Get if the texture can rescale.
  27786. */
  27787. readonly canRescale: boolean;
  27788. /** @hidden */
  27789. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27790. /** @hidden */
  27791. _rebuild(): void;
  27792. /**
  27793. * Triggers the load sequence in delayed load mode.
  27794. */
  27795. delayLoad(): void;
  27796. /**
  27797. * Clones the texture.
  27798. * @returns the cloned texture
  27799. */
  27800. clone(): Nullable<BaseTexture>;
  27801. /**
  27802. * Get the texture underlying type (INT, FLOAT...)
  27803. */
  27804. readonly textureType: number;
  27805. /**
  27806. * Get the texture underlying format (RGB, RGBA...)
  27807. */
  27808. readonly textureFormat: number;
  27809. /**
  27810. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27811. * This will returns an RGBA array buffer containing either in values (0-255) or
  27812. * float values (0-1) depending of the underlying buffer type.
  27813. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27814. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27815. * @param buffer defines a user defined buffer to fill with data (can be null)
  27816. * @returns The Array buffer containing the pixels data.
  27817. */
  27818. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27819. /**
  27820. * Release and destroy the underlying lower level texture aka internalTexture.
  27821. */
  27822. releaseInternalTexture(): void;
  27823. /**
  27824. * Get the polynomial representation of the texture data.
  27825. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27826. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27827. */
  27828. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27829. /** @hidden */
  27830. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27831. /** @hidden */
  27832. readonly _lodTextureMid: Nullable<BaseTexture>;
  27833. /** @hidden */
  27834. readonly _lodTextureLow: Nullable<BaseTexture>;
  27835. /**
  27836. * Dispose the texture and release its associated resources.
  27837. */
  27838. dispose(): void;
  27839. /**
  27840. * Serialize the texture into a JSON representation that can be parsed later on.
  27841. * @returns the JSON representation of the texture
  27842. */
  27843. serialize(): any;
  27844. /**
  27845. * Helper function to be called back once a list of texture contains only ready textures.
  27846. * @param textures Define the list of textures to wait for
  27847. * @param callback Define the callback triggered once the entire list will be ready
  27848. */
  27849. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27850. }
  27851. }
  27852. declare module BABYLON {
  27853. /**
  27854. * Class used to store data associated with WebGL texture data for the engine
  27855. * This class should not be used directly
  27856. */
  27857. export class InternalTexture {
  27858. /** @hidden */
  27859. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27860. /**
  27861. * The source of the texture data is unknown
  27862. */
  27863. static DATASOURCE_UNKNOWN: number;
  27864. /**
  27865. * Texture data comes from an URL
  27866. */
  27867. static DATASOURCE_URL: number;
  27868. /**
  27869. * Texture data is only used for temporary storage
  27870. */
  27871. static DATASOURCE_TEMP: number;
  27872. /**
  27873. * Texture data comes from raw data (ArrayBuffer)
  27874. */
  27875. static DATASOURCE_RAW: number;
  27876. /**
  27877. * Texture content is dynamic (video or dynamic texture)
  27878. */
  27879. static DATASOURCE_DYNAMIC: number;
  27880. /**
  27881. * Texture content is generated by rendering to it
  27882. */
  27883. static DATASOURCE_RENDERTARGET: number;
  27884. /**
  27885. * Texture content is part of a multi render target process
  27886. */
  27887. static DATASOURCE_MULTIRENDERTARGET: number;
  27888. /**
  27889. * Texture data comes from a cube data file
  27890. */
  27891. static DATASOURCE_CUBE: number;
  27892. /**
  27893. * Texture data comes from a raw cube data
  27894. */
  27895. static DATASOURCE_CUBERAW: number;
  27896. /**
  27897. * Texture data come from a prefiltered cube data file
  27898. */
  27899. static DATASOURCE_CUBEPREFILTERED: number;
  27900. /**
  27901. * Texture content is raw 3D data
  27902. */
  27903. static DATASOURCE_RAW3D: number;
  27904. /**
  27905. * Texture content is a depth texture
  27906. */
  27907. static DATASOURCE_DEPTHTEXTURE: number;
  27908. /**
  27909. * Texture data comes from a raw cube data encoded with RGBD
  27910. */
  27911. static DATASOURCE_CUBERAW_RGBD: number;
  27912. /**
  27913. * Defines if the texture is ready
  27914. */
  27915. isReady: boolean;
  27916. /**
  27917. * Defines if the texture is a cube texture
  27918. */
  27919. isCube: boolean;
  27920. /**
  27921. * Defines if the texture contains 3D data
  27922. */
  27923. is3D: boolean;
  27924. /**
  27925. * Defines if the texture contains multiview data
  27926. */
  27927. isMultiview: boolean;
  27928. /**
  27929. * Gets the URL used to load this texture
  27930. */
  27931. url: string;
  27932. /**
  27933. * Gets the sampling mode of the texture
  27934. */
  27935. samplingMode: number;
  27936. /**
  27937. * Gets a boolean indicating if the texture needs mipmaps generation
  27938. */
  27939. generateMipMaps: boolean;
  27940. /**
  27941. * Gets the number of samples used by the texture (WebGL2+ only)
  27942. */
  27943. samples: number;
  27944. /**
  27945. * Gets the type of the texture (int, float...)
  27946. */
  27947. type: number;
  27948. /**
  27949. * Gets the format of the texture (RGB, RGBA...)
  27950. */
  27951. format: number;
  27952. /**
  27953. * Observable called when the texture is loaded
  27954. */
  27955. onLoadedObservable: Observable<InternalTexture>;
  27956. /**
  27957. * Gets the width of the texture
  27958. */
  27959. width: number;
  27960. /**
  27961. * Gets the height of the texture
  27962. */
  27963. height: number;
  27964. /**
  27965. * Gets the depth of the texture
  27966. */
  27967. depth: number;
  27968. /**
  27969. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  27970. */
  27971. baseWidth: number;
  27972. /**
  27973. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  27974. */
  27975. baseHeight: number;
  27976. /**
  27977. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  27978. */
  27979. baseDepth: number;
  27980. /**
  27981. * Gets a boolean indicating if the texture is inverted on Y axis
  27982. */
  27983. invertY: boolean;
  27984. /** @hidden */
  27985. _invertVScale: boolean;
  27986. /** @hidden */
  27987. _associatedChannel: number;
  27988. /** @hidden */
  27989. _dataSource: number;
  27990. /** @hidden */
  27991. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  27992. /** @hidden */
  27993. _bufferView: Nullable<ArrayBufferView>;
  27994. /** @hidden */
  27995. _bufferViewArray: Nullable<ArrayBufferView[]>;
  27996. /** @hidden */
  27997. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  27998. /** @hidden */
  27999. _size: number;
  28000. /** @hidden */
  28001. _extension: string;
  28002. /** @hidden */
  28003. _files: Nullable<string[]>;
  28004. /** @hidden */
  28005. _workingCanvas: Nullable<HTMLCanvasElement>;
  28006. /** @hidden */
  28007. _workingContext: Nullable<CanvasRenderingContext2D>;
  28008. /** @hidden */
  28009. _framebuffer: Nullable<WebGLFramebuffer>;
  28010. /** @hidden */
  28011. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28012. /** @hidden */
  28013. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28014. /** @hidden */
  28015. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28016. /** @hidden */
  28017. _attachments: Nullable<number[]>;
  28018. /** @hidden */
  28019. _cachedCoordinatesMode: Nullable<number>;
  28020. /** @hidden */
  28021. _cachedWrapU: Nullable<number>;
  28022. /** @hidden */
  28023. _cachedWrapV: Nullable<number>;
  28024. /** @hidden */
  28025. _cachedWrapR: Nullable<number>;
  28026. /** @hidden */
  28027. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28028. /** @hidden */
  28029. _isDisabled: boolean;
  28030. /** @hidden */
  28031. _compression: Nullable<string>;
  28032. /** @hidden */
  28033. _generateStencilBuffer: boolean;
  28034. /** @hidden */
  28035. _generateDepthBuffer: boolean;
  28036. /** @hidden */
  28037. _comparisonFunction: number;
  28038. /** @hidden */
  28039. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28040. /** @hidden */
  28041. _lodGenerationScale: number;
  28042. /** @hidden */
  28043. _lodGenerationOffset: number;
  28044. /** @hidden */
  28045. _colorTextureArray: Nullable<WebGLTexture>;
  28046. /** @hidden */
  28047. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28048. /** @hidden */
  28049. _lodTextureHigh: Nullable<BaseTexture>;
  28050. /** @hidden */
  28051. _lodTextureMid: Nullable<BaseTexture>;
  28052. /** @hidden */
  28053. _lodTextureLow: Nullable<BaseTexture>;
  28054. /** @hidden */
  28055. _isRGBD: boolean;
  28056. /** @hidden */
  28057. _linearSpecularLOD: boolean;
  28058. /** @hidden */
  28059. _irradianceTexture: Nullable<BaseTexture>;
  28060. /** @hidden */
  28061. _webGLTexture: Nullable<WebGLTexture>;
  28062. /** @hidden */
  28063. _references: number;
  28064. private _engine;
  28065. /**
  28066. * Gets the Engine the texture belongs to.
  28067. * @returns The babylon engine
  28068. */
  28069. getEngine(): Engine;
  28070. /**
  28071. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28072. */
  28073. readonly dataSource: number;
  28074. /**
  28075. * Creates a new InternalTexture
  28076. * @param engine defines the engine to use
  28077. * @param dataSource defines the type of data that will be used
  28078. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28079. */
  28080. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28081. /**
  28082. * Increments the number of references (ie. the number of Texture that point to it)
  28083. */
  28084. incrementReferences(): void;
  28085. /**
  28086. * Change the size of the texture (not the size of the content)
  28087. * @param width defines the new width
  28088. * @param height defines the new height
  28089. * @param depth defines the new depth (1 by default)
  28090. */
  28091. updateSize(width: int, height: int, depth?: int): void;
  28092. /** @hidden */
  28093. _rebuild(): void;
  28094. /** @hidden */
  28095. _swapAndDie(target: InternalTexture): void;
  28096. /**
  28097. * Dispose the current allocated resources
  28098. */
  28099. dispose(): void;
  28100. }
  28101. }
  28102. declare module BABYLON {
  28103. /**
  28104. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28105. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28106. */
  28107. export class EffectFallbacks {
  28108. private _defines;
  28109. private _currentRank;
  28110. private _maxRank;
  28111. private _mesh;
  28112. /**
  28113. * Removes the fallback from the bound mesh.
  28114. */
  28115. unBindMesh(): void;
  28116. /**
  28117. * Adds a fallback on the specified property.
  28118. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28119. * @param define The name of the define in the shader
  28120. */
  28121. addFallback(rank: number, define: string): void;
  28122. /**
  28123. * Sets the mesh to use CPU skinning when needing to fallback.
  28124. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28125. * @param mesh The mesh to use the fallbacks.
  28126. */
  28127. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28128. /**
  28129. * Checks to see if more fallbacks are still availible.
  28130. */
  28131. readonly hasMoreFallbacks: boolean;
  28132. /**
  28133. * Removes the defines that should be removed when falling back.
  28134. * @param currentDefines defines the current define statements for the shader.
  28135. * @param effect defines the current effect we try to compile
  28136. * @returns The resulting defines with defines of the current rank removed.
  28137. */
  28138. reduce(currentDefines: string, effect: Effect): string;
  28139. }
  28140. /**
  28141. * Options to be used when creating an effect.
  28142. */
  28143. export class EffectCreationOptions {
  28144. /**
  28145. * Atrributes that will be used in the shader.
  28146. */
  28147. attributes: string[];
  28148. /**
  28149. * Uniform varible names that will be set in the shader.
  28150. */
  28151. uniformsNames: string[];
  28152. /**
  28153. * Uniform buffer varible names that will be set in the shader.
  28154. */
  28155. uniformBuffersNames: string[];
  28156. /**
  28157. * Sampler texture variable names that will be set in the shader.
  28158. */
  28159. samplers: string[];
  28160. /**
  28161. * Define statements that will be set in the shader.
  28162. */
  28163. defines: any;
  28164. /**
  28165. * Possible fallbacks for this effect to improve performance when needed.
  28166. */
  28167. fallbacks: Nullable<EffectFallbacks>;
  28168. /**
  28169. * Callback that will be called when the shader is compiled.
  28170. */
  28171. onCompiled: Nullable<(effect: Effect) => void>;
  28172. /**
  28173. * Callback that will be called if an error occurs during shader compilation.
  28174. */
  28175. onError: Nullable<(effect: Effect, errors: string) => void>;
  28176. /**
  28177. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28178. */
  28179. indexParameters: any;
  28180. /**
  28181. * Max number of lights that can be used in the shader.
  28182. */
  28183. maxSimultaneousLights: number;
  28184. /**
  28185. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28186. */
  28187. transformFeedbackVaryings: Nullable<string[]>;
  28188. }
  28189. /**
  28190. * Effect containing vertex and fragment shader that can be executed on an object.
  28191. */
  28192. export class Effect implements IDisposable {
  28193. /**
  28194. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28195. */
  28196. static ShadersRepository: string;
  28197. /**
  28198. * Name of the effect.
  28199. */
  28200. name: any;
  28201. /**
  28202. * String container all the define statements that should be set on the shader.
  28203. */
  28204. defines: string;
  28205. /**
  28206. * Callback that will be called when the shader is compiled.
  28207. */
  28208. onCompiled: Nullable<(effect: Effect) => void>;
  28209. /**
  28210. * Callback that will be called if an error occurs during shader compilation.
  28211. */
  28212. onError: Nullable<(effect: Effect, errors: string) => void>;
  28213. /**
  28214. * Callback that will be called when effect is bound.
  28215. */
  28216. onBind: Nullable<(effect: Effect) => void>;
  28217. /**
  28218. * Unique ID of the effect.
  28219. */
  28220. uniqueId: number;
  28221. /**
  28222. * Observable that will be called when the shader is compiled.
  28223. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28224. */
  28225. onCompileObservable: Observable<Effect>;
  28226. /**
  28227. * Observable that will be called if an error occurs during shader compilation.
  28228. */
  28229. onErrorObservable: Observable<Effect>;
  28230. /** @hidden */
  28231. _onBindObservable: Nullable<Observable<Effect>>;
  28232. /**
  28233. * Observable that will be called when effect is bound.
  28234. */
  28235. readonly onBindObservable: Observable<Effect>;
  28236. /** @hidden */
  28237. _bonesComputationForcedToCPU: boolean;
  28238. private static _uniqueIdSeed;
  28239. private _engine;
  28240. private _uniformBuffersNames;
  28241. private _uniformsNames;
  28242. private _samplerList;
  28243. private _samplers;
  28244. private _isReady;
  28245. private _compilationError;
  28246. private _attributesNames;
  28247. private _attributes;
  28248. private _uniforms;
  28249. /**
  28250. * Key for the effect.
  28251. * @hidden
  28252. */
  28253. _key: string;
  28254. private _indexParameters;
  28255. private _fallbacks;
  28256. private _vertexSourceCode;
  28257. private _fragmentSourceCode;
  28258. private _vertexSourceCodeOverride;
  28259. private _fragmentSourceCodeOverride;
  28260. private _transformFeedbackVaryings;
  28261. /**
  28262. * Compiled shader to webGL program.
  28263. * @hidden
  28264. */
  28265. _pipelineContext: Nullable<IPipelineContext>;
  28266. private _valueCache;
  28267. private static _baseCache;
  28268. /**
  28269. * Instantiates an effect.
  28270. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28271. * @param baseName Name of the effect.
  28272. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28273. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28274. * @param samplers List of sampler variables that will be passed to the shader.
  28275. * @param engine Engine to be used to render the effect
  28276. * @param defines Define statements to be added to the shader.
  28277. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28278. * @param onCompiled Callback that will be called when the shader is compiled.
  28279. * @param onError Callback that will be called if an error occurs during shader compilation.
  28280. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28281. */
  28282. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28283. private _useFinalCode;
  28284. /**
  28285. * Unique key for this effect
  28286. */
  28287. readonly key: string;
  28288. /**
  28289. * If the effect has been compiled and prepared.
  28290. * @returns if the effect is compiled and prepared.
  28291. */
  28292. isReady(): boolean;
  28293. private _isReadyInternal;
  28294. /**
  28295. * The engine the effect was initialized with.
  28296. * @returns the engine.
  28297. */
  28298. getEngine(): Engine;
  28299. /**
  28300. * The pipeline context for this effect
  28301. * @returns the associated pipeline context
  28302. */
  28303. getPipelineContext(): Nullable<IPipelineContext>;
  28304. /**
  28305. * The set of names of attribute variables for the shader.
  28306. * @returns An array of attribute names.
  28307. */
  28308. getAttributesNames(): string[];
  28309. /**
  28310. * Returns the attribute at the given index.
  28311. * @param index The index of the attribute.
  28312. * @returns The location of the attribute.
  28313. */
  28314. getAttributeLocation(index: number): number;
  28315. /**
  28316. * Returns the attribute based on the name of the variable.
  28317. * @param name of the attribute to look up.
  28318. * @returns the attribute location.
  28319. */
  28320. getAttributeLocationByName(name: string): number;
  28321. /**
  28322. * The number of attributes.
  28323. * @returns the numnber of attributes.
  28324. */
  28325. getAttributesCount(): number;
  28326. /**
  28327. * Gets the index of a uniform variable.
  28328. * @param uniformName of the uniform to look up.
  28329. * @returns the index.
  28330. */
  28331. getUniformIndex(uniformName: string): number;
  28332. /**
  28333. * Returns the attribute based on the name of the variable.
  28334. * @param uniformName of the uniform to look up.
  28335. * @returns the location of the uniform.
  28336. */
  28337. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28338. /**
  28339. * Returns an array of sampler variable names
  28340. * @returns The array of sampler variable neames.
  28341. */
  28342. getSamplers(): string[];
  28343. /**
  28344. * The error from the last compilation.
  28345. * @returns the error string.
  28346. */
  28347. getCompilationError(): string;
  28348. /**
  28349. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28350. * @param func The callback to be used.
  28351. */
  28352. executeWhenCompiled(func: (effect: Effect) => void): void;
  28353. private _checkIsReady;
  28354. /** @hidden */
  28355. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28356. /** @hidden */
  28357. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28358. /** @hidden */
  28359. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28360. /**
  28361. * Recompiles the webGL program
  28362. * @param vertexSourceCode The source code for the vertex shader.
  28363. * @param fragmentSourceCode The source code for the fragment shader.
  28364. * @param onCompiled Callback called when completed.
  28365. * @param onError Callback called on error.
  28366. * @hidden
  28367. */
  28368. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28369. /**
  28370. * Prepares the effect
  28371. * @hidden
  28372. */
  28373. _prepareEffect(): void;
  28374. private _processCompilationErrors;
  28375. /**
  28376. * Checks if the effect is supported. (Must be called after compilation)
  28377. */
  28378. readonly isSupported: boolean;
  28379. /**
  28380. * Binds a texture to the engine to be used as output of the shader.
  28381. * @param channel Name of the output variable.
  28382. * @param texture Texture to bind.
  28383. * @hidden
  28384. */
  28385. _bindTexture(channel: string, texture: InternalTexture): void;
  28386. /**
  28387. * Sets a texture on the engine to be used in the shader.
  28388. * @param channel Name of the sampler variable.
  28389. * @param texture Texture to set.
  28390. */
  28391. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28392. /**
  28393. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28394. * @param channel Name of the sampler variable.
  28395. * @param texture Texture to set.
  28396. */
  28397. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28398. /**
  28399. * Sets an array of textures on the engine to be used in the shader.
  28400. * @param channel Name of the variable.
  28401. * @param textures Textures to set.
  28402. */
  28403. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28404. /**
  28405. * 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)
  28406. * @param channel Name of the sampler variable.
  28407. * @param postProcess Post process to get the input texture from.
  28408. */
  28409. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28410. /**
  28411. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28412. * 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)
  28413. * @param channel Name of the sampler variable.
  28414. * @param postProcess Post process to get the output texture from.
  28415. */
  28416. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28417. /** @hidden */
  28418. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28419. /** @hidden */
  28420. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28421. /** @hidden */
  28422. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28423. /** @hidden */
  28424. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28425. /**
  28426. * Binds a buffer to a uniform.
  28427. * @param buffer Buffer to bind.
  28428. * @param name Name of the uniform variable to bind to.
  28429. */
  28430. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28431. /**
  28432. * Binds block to a uniform.
  28433. * @param blockName Name of the block to bind.
  28434. * @param index Index to bind.
  28435. */
  28436. bindUniformBlock(blockName: string, index: number): void;
  28437. /**
  28438. * Sets an interger value on a uniform variable.
  28439. * @param uniformName Name of the variable.
  28440. * @param value Value to be set.
  28441. * @returns this effect.
  28442. */
  28443. setInt(uniformName: string, value: number): Effect;
  28444. /**
  28445. * Sets an int array on a uniform variable.
  28446. * @param uniformName Name of the variable.
  28447. * @param array array to be set.
  28448. * @returns this effect.
  28449. */
  28450. setIntArray(uniformName: string, array: Int32Array): Effect;
  28451. /**
  28452. * 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)
  28453. * @param uniformName Name of the variable.
  28454. * @param array array to be set.
  28455. * @returns this effect.
  28456. */
  28457. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28458. /**
  28459. * 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)
  28460. * @param uniformName Name of the variable.
  28461. * @param array array to be set.
  28462. * @returns this effect.
  28463. */
  28464. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28465. /**
  28466. * 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)
  28467. * @param uniformName Name of the variable.
  28468. * @param array array to be set.
  28469. * @returns this effect.
  28470. */
  28471. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28472. /**
  28473. * Sets an float array on a uniform variable.
  28474. * @param uniformName Name of the variable.
  28475. * @param array array to be set.
  28476. * @returns this effect.
  28477. */
  28478. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28479. /**
  28480. * 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)
  28481. * @param uniformName Name of the variable.
  28482. * @param array array to be set.
  28483. * @returns this effect.
  28484. */
  28485. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28486. /**
  28487. * 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)
  28488. * @param uniformName Name of the variable.
  28489. * @param array array to be set.
  28490. * @returns this effect.
  28491. */
  28492. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28493. /**
  28494. * 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)
  28495. * @param uniformName Name of the variable.
  28496. * @param array array to be set.
  28497. * @returns this effect.
  28498. */
  28499. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28500. /**
  28501. * Sets an array on a uniform variable.
  28502. * @param uniformName Name of the variable.
  28503. * @param array array to be set.
  28504. * @returns this effect.
  28505. */
  28506. setArray(uniformName: string, array: number[]): Effect;
  28507. /**
  28508. * 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)
  28509. * @param uniformName Name of the variable.
  28510. * @param array array to be set.
  28511. * @returns this effect.
  28512. */
  28513. setArray2(uniformName: string, array: number[]): Effect;
  28514. /**
  28515. * 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)
  28516. * @param uniformName Name of the variable.
  28517. * @param array array to be set.
  28518. * @returns this effect.
  28519. */
  28520. setArray3(uniformName: string, array: number[]): Effect;
  28521. /**
  28522. * 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)
  28523. * @param uniformName Name of the variable.
  28524. * @param array array to be set.
  28525. * @returns this effect.
  28526. */
  28527. setArray4(uniformName: string, array: number[]): Effect;
  28528. /**
  28529. * Sets matrices on a uniform variable.
  28530. * @param uniformName Name of the variable.
  28531. * @param matrices matrices to be set.
  28532. * @returns this effect.
  28533. */
  28534. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28535. /**
  28536. * Sets matrix on a uniform variable.
  28537. * @param uniformName Name of the variable.
  28538. * @param matrix matrix to be set.
  28539. * @returns this effect.
  28540. */
  28541. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28542. /**
  28543. * 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)
  28544. * @param uniformName Name of the variable.
  28545. * @param matrix matrix to be set.
  28546. * @returns this effect.
  28547. */
  28548. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28549. /**
  28550. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28551. * @param uniformName Name of the variable.
  28552. * @param matrix matrix to be set.
  28553. * @returns this effect.
  28554. */
  28555. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28556. /**
  28557. * Sets a float on a uniform variable.
  28558. * @param uniformName Name of the variable.
  28559. * @param value value to be set.
  28560. * @returns this effect.
  28561. */
  28562. setFloat(uniformName: string, value: number): Effect;
  28563. /**
  28564. * Sets a boolean on a uniform variable.
  28565. * @param uniformName Name of the variable.
  28566. * @param bool value to be set.
  28567. * @returns this effect.
  28568. */
  28569. setBool(uniformName: string, bool: boolean): Effect;
  28570. /**
  28571. * Sets a Vector2 on a uniform variable.
  28572. * @param uniformName Name of the variable.
  28573. * @param vector2 vector2 to be set.
  28574. * @returns this effect.
  28575. */
  28576. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28577. /**
  28578. * Sets a float2 on a uniform variable.
  28579. * @param uniformName Name of the variable.
  28580. * @param x First float in float2.
  28581. * @param y Second float in float2.
  28582. * @returns this effect.
  28583. */
  28584. setFloat2(uniformName: string, x: number, y: number): Effect;
  28585. /**
  28586. * Sets a Vector3 on a uniform variable.
  28587. * @param uniformName Name of the variable.
  28588. * @param vector3 Value to be set.
  28589. * @returns this effect.
  28590. */
  28591. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28592. /**
  28593. * Sets a float3 on a uniform variable.
  28594. * @param uniformName Name of the variable.
  28595. * @param x First float in float3.
  28596. * @param y Second float in float3.
  28597. * @param z Third float in float3.
  28598. * @returns this effect.
  28599. */
  28600. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28601. /**
  28602. * Sets a Vector4 on a uniform variable.
  28603. * @param uniformName Name of the variable.
  28604. * @param vector4 Value to be set.
  28605. * @returns this effect.
  28606. */
  28607. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28608. /**
  28609. * Sets a float4 on a uniform variable.
  28610. * @param uniformName Name of the variable.
  28611. * @param x First float in float4.
  28612. * @param y Second float in float4.
  28613. * @param z Third float in float4.
  28614. * @param w Fourth float in float4.
  28615. * @returns this effect.
  28616. */
  28617. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28618. /**
  28619. * Sets a Color3 on a uniform variable.
  28620. * @param uniformName Name of the variable.
  28621. * @param color3 Value to be set.
  28622. * @returns this effect.
  28623. */
  28624. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28625. /**
  28626. * Sets a Color4 on a uniform variable.
  28627. * @param uniformName Name of the variable.
  28628. * @param color3 Value to be set.
  28629. * @param alpha Alpha value to be set.
  28630. * @returns this effect.
  28631. */
  28632. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28633. /**
  28634. * Sets a Color4 on a uniform variable
  28635. * @param uniformName defines the name of the variable
  28636. * @param color4 defines the value to be set
  28637. * @returns this effect.
  28638. */
  28639. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28640. /** Release all associated resources */
  28641. dispose(): void;
  28642. /**
  28643. * This function will add a new shader to the shader store
  28644. * @param name the name of the shader
  28645. * @param pixelShader optional pixel shader content
  28646. * @param vertexShader optional vertex shader content
  28647. */
  28648. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28649. /**
  28650. * Store of each shader (The can be looked up using effect.key)
  28651. */
  28652. static ShadersStore: {
  28653. [key: string]: string;
  28654. };
  28655. /**
  28656. * Store of each included file for a shader (The can be looked up using effect.key)
  28657. */
  28658. static IncludesShadersStore: {
  28659. [key: string]: string;
  28660. };
  28661. /**
  28662. * Resets the cache of effects.
  28663. */
  28664. static ResetCache(): void;
  28665. }
  28666. }
  28667. declare module BABYLON {
  28668. /**
  28669. * Uniform buffer objects.
  28670. *
  28671. * Handles blocks of uniform on the GPU.
  28672. *
  28673. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28674. *
  28675. * For more information, please refer to :
  28676. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28677. */
  28678. export class UniformBuffer {
  28679. private _engine;
  28680. private _buffer;
  28681. private _data;
  28682. private _bufferData;
  28683. private _dynamic?;
  28684. private _uniformLocations;
  28685. private _uniformSizes;
  28686. private _uniformLocationPointer;
  28687. private _needSync;
  28688. private _noUBO;
  28689. private _currentEffect;
  28690. private static _MAX_UNIFORM_SIZE;
  28691. private static _tempBuffer;
  28692. /**
  28693. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28694. * This is dynamic to allow compat with webgl 1 and 2.
  28695. * You will need to pass the name of the uniform as well as the value.
  28696. */
  28697. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28698. /**
  28699. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28700. * This is dynamic to allow compat with webgl 1 and 2.
  28701. * You will need to pass the name of the uniform as well as the value.
  28702. */
  28703. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28704. /**
  28705. * Lambda to Update a single float in a uniform buffer.
  28706. * This is dynamic to allow compat with webgl 1 and 2.
  28707. * You will need to pass the name of the uniform as well as the value.
  28708. */
  28709. updateFloat: (name: string, x: number) => void;
  28710. /**
  28711. * Lambda to Update a vec2 of float in a uniform buffer.
  28712. * This is dynamic to allow compat with webgl 1 and 2.
  28713. * You will need to pass the name of the uniform as well as the value.
  28714. */
  28715. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28716. /**
  28717. * Lambda to Update a vec3 of float in a uniform buffer.
  28718. * This is dynamic to allow compat with webgl 1 and 2.
  28719. * You will need to pass the name of the uniform as well as the value.
  28720. */
  28721. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28722. /**
  28723. * Lambda to Update a vec4 of float in a uniform buffer.
  28724. * This is dynamic to allow compat with webgl 1 and 2.
  28725. * You will need to pass the name of the uniform as well as the value.
  28726. */
  28727. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28728. /**
  28729. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28730. * This is dynamic to allow compat with webgl 1 and 2.
  28731. * You will need to pass the name of the uniform as well as the value.
  28732. */
  28733. updateMatrix: (name: string, mat: Matrix) => void;
  28734. /**
  28735. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28736. * This is dynamic to allow compat with webgl 1 and 2.
  28737. * You will need to pass the name of the uniform as well as the value.
  28738. */
  28739. updateVector3: (name: string, vector: Vector3) => void;
  28740. /**
  28741. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28742. * This is dynamic to allow compat with webgl 1 and 2.
  28743. * You will need to pass the name of the uniform as well as the value.
  28744. */
  28745. updateVector4: (name: string, vector: Vector4) => void;
  28746. /**
  28747. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28748. * This is dynamic to allow compat with webgl 1 and 2.
  28749. * You will need to pass the name of the uniform as well as the value.
  28750. */
  28751. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28752. /**
  28753. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28754. * This is dynamic to allow compat with webgl 1 and 2.
  28755. * You will need to pass the name of the uniform as well as the value.
  28756. */
  28757. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28758. /**
  28759. * Instantiates a new Uniform buffer objects.
  28760. *
  28761. * Handles blocks of uniform on the GPU.
  28762. *
  28763. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28764. *
  28765. * For more information, please refer to :
  28766. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28767. * @param engine Define the engine the buffer is associated with
  28768. * @param data Define the data contained in the buffer
  28769. * @param dynamic Define if the buffer is updatable
  28770. */
  28771. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28772. /**
  28773. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28774. * or just falling back on setUniformXXX calls.
  28775. */
  28776. readonly useUbo: boolean;
  28777. /**
  28778. * Indicates if the WebGL underlying uniform buffer is in sync
  28779. * with the javascript cache data.
  28780. */
  28781. readonly isSync: boolean;
  28782. /**
  28783. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28784. * Also, a dynamic UniformBuffer will disable cache verification and always
  28785. * update the underlying WebGL uniform buffer to the GPU.
  28786. * @returns if Dynamic, otherwise false
  28787. */
  28788. isDynamic(): boolean;
  28789. /**
  28790. * The data cache on JS side.
  28791. * @returns the underlying data as a float array
  28792. */
  28793. getData(): Float32Array;
  28794. /**
  28795. * The underlying WebGL Uniform buffer.
  28796. * @returns the webgl buffer
  28797. */
  28798. getBuffer(): Nullable<DataBuffer>;
  28799. /**
  28800. * std140 layout specifies how to align data within an UBO structure.
  28801. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28802. * for specs.
  28803. */
  28804. private _fillAlignment;
  28805. /**
  28806. * Adds an uniform in the buffer.
  28807. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28808. * for the layout to be correct !
  28809. * @param name Name of the uniform, as used in the uniform block in the shader.
  28810. * @param size Data size, or data directly.
  28811. */
  28812. addUniform(name: string, size: number | number[]): void;
  28813. /**
  28814. * Adds a Matrix 4x4 to the uniform buffer.
  28815. * @param name Name of the uniform, as used in the uniform block in the shader.
  28816. * @param mat A 4x4 matrix.
  28817. */
  28818. addMatrix(name: string, mat: Matrix): void;
  28819. /**
  28820. * Adds a vec2 to the uniform buffer.
  28821. * @param name Name of the uniform, as used in the uniform block in the shader.
  28822. * @param x Define the x component value of the vec2
  28823. * @param y Define the y component value of the vec2
  28824. */
  28825. addFloat2(name: string, x: number, y: number): void;
  28826. /**
  28827. * Adds a vec3 to the uniform buffer.
  28828. * @param name Name of the uniform, as used in the uniform block in the shader.
  28829. * @param x Define the x component value of the vec3
  28830. * @param y Define the y component value of the vec3
  28831. * @param z Define the z component value of the vec3
  28832. */
  28833. addFloat3(name: string, x: number, y: number, z: number): void;
  28834. /**
  28835. * Adds a vec3 to the uniform buffer.
  28836. * @param name Name of the uniform, as used in the uniform block in the shader.
  28837. * @param color Define the vec3 from a Color
  28838. */
  28839. addColor3(name: string, color: Color3): void;
  28840. /**
  28841. * Adds a vec4 to the uniform buffer.
  28842. * @param name Name of the uniform, as used in the uniform block in the shader.
  28843. * @param color Define the rgb components from a Color
  28844. * @param alpha Define the a component of the vec4
  28845. */
  28846. addColor4(name: string, color: Color3, alpha: number): void;
  28847. /**
  28848. * Adds a vec3 to the uniform buffer.
  28849. * @param name Name of the uniform, as used in the uniform block in the shader.
  28850. * @param vector Define the vec3 components from a Vector
  28851. */
  28852. addVector3(name: string, vector: Vector3): void;
  28853. /**
  28854. * Adds a Matrix 3x3 to the uniform buffer.
  28855. * @param name Name of the uniform, as used in the uniform block in the shader.
  28856. */
  28857. addMatrix3x3(name: string): void;
  28858. /**
  28859. * Adds a Matrix 2x2 to the uniform buffer.
  28860. * @param name Name of the uniform, as used in the uniform block in the shader.
  28861. */
  28862. addMatrix2x2(name: string): void;
  28863. /**
  28864. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28865. */
  28866. create(): void;
  28867. /** @hidden */
  28868. _rebuild(): void;
  28869. /**
  28870. * Updates the WebGL Uniform Buffer on the GPU.
  28871. * If the `dynamic` flag is set to true, no cache comparison is done.
  28872. * Otherwise, the buffer will be updated only if the cache differs.
  28873. */
  28874. update(): void;
  28875. /**
  28876. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28877. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28878. * @param data Define the flattened data
  28879. * @param size Define the size of the data.
  28880. */
  28881. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28882. private _valueCache;
  28883. private _cacheMatrix;
  28884. private _updateMatrix3x3ForUniform;
  28885. private _updateMatrix3x3ForEffect;
  28886. private _updateMatrix2x2ForEffect;
  28887. private _updateMatrix2x2ForUniform;
  28888. private _updateFloatForEffect;
  28889. private _updateFloatForUniform;
  28890. private _updateFloat2ForEffect;
  28891. private _updateFloat2ForUniform;
  28892. private _updateFloat3ForEffect;
  28893. private _updateFloat3ForUniform;
  28894. private _updateFloat4ForEffect;
  28895. private _updateFloat4ForUniform;
  28896. private _updateMatrixForEffect;
  28897. private _updateMatrixForUniform;
  28898. private _updateVector3ForEffect;
  28899. private _updateVector3ForUniform;
  28900. private _updateVector4ForEffect;
  28901. private _updateVector4ForUniform;
  28902. private _updateColor3ForEffect;
  28903. private _updateColor3ForUniform;
  28904. private _updateColor4ForEffect;
  28905. private _updateColor4ForUniform;
  28906. /**
  28907. * Sets a sampler uniform on the effect.
  28908. * @param name Define the name of the sampler.
  28909. * @param texture Define the texture to set in the sampler
  28910. */
  28911. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28912. /**
  28913. * Directly updates the value of the uniform in the cache AND on the GPU.
  28914. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28915. * @param data Define the flattened data
  28916. */
  28917. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28918. /**
  28919. * Binds this uniform buffer to an effect.
  28920. * @param effect Define the effect to bind the buffer to
  28921. * @param name Name of the uniform block in the shader.
  28922. */
  28923. bindToEffect(effect: Effect, name: string): void;
  28924. /**
  28925. * Disposes the uniform buffer.
  28926. */
  28927. dispose(): void;
  28928. }
  28929. }
  28930. declare module BABYLON {
  28931. /**
  28932. * Class used to work with sound analyzer using fast fourier transform (FFT)
  28933. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28934. */
  28935. export class Analyser {
  28936. /**
  28937. * Gets or sets the smoothing
  28938. * @ignorenaming
  28939. */
  28940. SMOOTHING: number;
  28941. /**
  28942. * Gets or sets the FFT table size
  28943. * @ignorenaming
  28944. */
  28945. FFT_SIZE: number;
  28946. /**
  28947. * Gets or sets the bar graph amplitude
  28948. * @ignorenaming
  28949. */
  28950. BARGRAPHAMPLITUDE: number;
  28951. /**
  28952. * Gets or sets the position of the debug canvas
  28953. * @ignorenaming
  28954. */
  28955. DEBUGCANVASPOS: {
  28956. x: number;
  28957. y: number;
  28958. };
  28959. /**
  28960. * Gets or sets the debug canvas size
  28961. * @ignorenaming
  28962. */
  28963. DEBUGCANVASSIZE: {
  28964. width: number;
  28965. height: number;
  28966. };
  28967. private _byteFreqs;
  28968. private _byteTime;
  28969. private _floatFreqs;
  28970. private _webAudioAnalyser;
  28971. private _debugCanvas;
  28972. private _debugCanvasContext;
  28973. private _scene;
  28974. private _registerFunc;
  28975. private _audioEngine;
  28976. /**
  28977. * Creates a new analyser
  28978. * @param scene defines hosting scene
  28979. */
  28980. constructor(scene: Scene);
  28981. /**
  28982. * Get the number of data values you will have to play with for the visualization
  28983. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  28984. * @returns a number
  28985. */
  28986. getFrequencyBinCount(): number;
  28987. /**
  28988. * Gets the current frequency data as a byte array
  28989. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28990. * @returns a Uint8Array
  28991. */
  28992. getByteFrequencyData(): Uint8Array;
  28993. /**
  28994. * Gets the current waveform as a byte array
  28995. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  28996. * @returns a Uint8Array
  28997. */
  28998. getByteTimeDomainData(): Uint8Array;
  28999. /**
  29000. * Gets the current frequency data as a float array
  29001. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29002. * @returns a Float32Array
  29003. */
  29004. getFloatFrequencyData(): Float32Array;
  29005. /**
  29006. * Renders the debug canvas
  29007. */
  29008. drawDebugCanvas(): void;
  29009. /**
  29010. * Stops rendering the debug canvas and removes it
  29011. */
  29012. stopDebugCanvas(): void;
  29013. /**
  29014. * Connects two audio nodes
  29015. * @param inputAudioNode defines first node to connect
  29016. * @param outputAudioNode defines second node to connect
  29017. */
  29018. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29019. /**
  29020. * Releases all associated resources
  29021. */
  29022. dispose(): void;
  29023. }
  29024. }
  29025. declare module BABYLON {
  29026. /**
  29027. * This represents an audio engine and it is responsible
  29028. * to play, synchronize and analyse sounds throughout the application.
  29029. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29030. */
  29031. export interface IAudioEngine extends IDisposable {
  29032. /**
  29033. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29034. */
  29035. readonly canUseWebAudio: boolean;
  29036. /**
  29037. * Gets the current AudioContext if available.
  29038. */
  29039. readonly audioContext: Nullable<AudioContext>;
  29040. /**
  29041. * The master gain node defines the global audio volume of your audio engine.
  29042. */
  29043. readonly masterGain: GainNode;
  29044. /**
  29045. * Gets whether or not mp3 are supported by your browser.
  29046. */
  29047. readonly isMP3supported: boolean;
  29048. /**
  29049. * Gets whether or not ogg are supported by your browser.
  29050. */
  29051. readonly isOGGsupported: boolean;
  29052. /**
  29053. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29054. * @ignoreNaming
  29055. */
  29056. WarnedWebAudioUnsupported: boolean;
  29057. /**
  29058. * Defines if the audio engine relies on a custom unlocked button.
  29059. * In this case, the embedded button will not be displayed.
  29060. */
  29061. useCustomUnlockedButton: boolean;
  29062. /**
  29063. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29064. */
  29065. readonly unlocked: boolean;
  29066. /**
  29067. * Event raised when audio has been unlocked on the browser.
  29068. */
  29069. onAudioUnlockedObservable: Observable<AudioEngine>;
  29070. /**
  29071. * Event raised when audio has been locked on the browser.
  29072. */
  29073. onAudioLockedObservable: Observable<AudioEngine>;
  29074. /**
  29075. * Flags the audio engine in Locked state.
  29076. * This happens due to new browser policies preventing audio to autoplay.
  29077. */
  29078. lock(): void;
  29079. /**
  29080. * Unlocks the audio engine once a user action has been done on the dom.
  29081. * This is helpful to resume play once browser policies have been satisfied.
  29082. */
  29083. unlock(): void;
  29084. }
  29085. /**
  29086. * This represents the default audio engine used in babylon.
  29087. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29088. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29089. */
  29090. export class AudioEngine implements IAudioEngine {
  29091. private _audioContext;
  29092. private _audioContextInitialized;
  29093. private _muteButton;
  29094. private _hostElement;
  29095. /**
  29096. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29097. */
  29098. canUseWebAudio: boolean;
  29099. /**
  29100. * The master gain node defines the global audio volume of your audio engine.
  29101. */
  29102. masterGain: GainNode;
  29103. /**
  29104. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29105. * @ignoreNaming
  29106. */
  29107. WarnedWebAudioUnsupported: boolean;
  29108. /**
  29109. * Gets whether or not mp3 are supported by your browser.
  29110. */
  29111. isMP3supported: boolean;
  29112. /**
  29113. * Gets whether or not ogg are supported by your browser.
  29114. */
  29115. isOGGsupported: boolean;
  29116. /**
  29117. * Gets whether audio has been unlocked on the device.
  29118. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29119. * a user interaction has happened.
  29120. */
  29121. unlocked: boolean;
  29122. /**
  29123. * Defines if the audio engine relies on a custom unlocked button.
  29124. * In this case, the embedded button will not be displayed.
  29125. */
  29126. useCustomUnlockedButton: boolean;
  29127. /**
  29128. * Event raised when audio has been unlocked on the browser.
  29129. */
  29130. onAudioUnlockedObservable: Observable<AudioEngine>;
  29131. /**
  29132. * Event raised when audio has been locked on the browser.
  29133. */
  29134. onAudioLockedObservable: Observable<AudioEngine>;
  29135. /**
  29136. * Gets the current AudioContext if available.
  29137. */
  29138. readonly audioContext: Nullable<AudioContext>;
  29139. private _connectedAnalyser;
  29140. /**
  29141. * Instantiates a new audio engine.
  29142. *
  29143. * There should be only one per page as some browsers restrict the number
  29144. * of audio contexts you can create.
  29145. * @param hostElement defines the host element where to display the mute icon if necessary
  29146. */
  29147. constructor(hostElement?: Nullable<HTMLElement>);
  29148. /**
  29149. * Flags the audio engine in Locked state.
  29150. * This happens due to new browser policies preventing audio to autoplay.
  29151. */
  29152. lock(): void;
  29153. /**
  29154. * Unlocks the audio engine once a user action has been done on the dom.
  29155. * This is helpful to resume play once browser policies have been satisfied.
  29156. */
  29157. unlock(): void;
  29158. private _resumeAudioContext;
  29159. private _initializeAudioContext;
  29160. private _tryToRun;
  29161. private _triggerRunningState;
  29162. private _triggerSuspendedState;
  29163. private _displayMuteButton;
  29164. private _moveButtonToTopLeft;
  29165. private _onResize;
  29166. private _hideMuteButton;
  29167. /**
  29168. * Destroy and release the resources associated with the audio ccontext.
  29169. */
  29170. dispose(): void;
  29171. /**
  29172. * Gets the global volume sets on the master gain.
  29173. * @returns the global volume if set or -1 otherwise
  29174. */
  29175. getGlobalVolume(): number;
  29176. /**
  29177. * Sets the global volume of your experience (sets on the master gain).
  29178. * @param newVolume Defines the new global volume of the application
  29179. */
  29180. setGlobalVolume(newVolume: number): void;
  29181. /**
  29182. * Connect the audio engine to an audio analyser allowing some amazing
  29183. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29185. * @param analyser The analyser to connect to the engine
  29186. */
  29187. connectToAnalyser(analyser: Analyser): void;
  29188. }
  29189. }
  29190. declare module BABYLON {
  29191. /**
  29192. * Interface used to present a loading screen while loading a scene
  29193. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29194. */
  29195. export interface ILoadingScreen {
  29196. /**
  29197. * Function called to display the loading screen
  29198. */
  29199. displayLoadingUI: () => void;
  29200. /**
  29201. * Function called to hide the loading screen
  29202. */
  29203. hideLoadingUI: () => void;
  29204. /**
  29205. * Gets or sets the color to use for the background
  29206. */
  29207. loadingUIBackgroundColor: string;
  29208. /**
  29209. * Gets or sets the text to display while loading
  29210. */
  29211. loadingUIText: string;
  29212. }
  29213. /**
  29214. * Class used for the default loading screen
  29215. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29216. */
  29217. export class DefaultLoadingScreen implements ILoadingScreen {
  29218. private _renderingCanvas;
  29219. private _loadingText;
  29220. private _loadingDivBackgroundColor;
  29221. private _loadingDiv;
  29222. private _loadingTextDiv;
  29223. /** Gets or sets the logo url to use for the default loading screen */
  29224. static DefaultLogoUrl: string;
  29225. /** Gets or sets the spinner url to use for the default loading screen */
  29226. static DefaultSpinnerUrl: string;
  29227. /**
  29228. * Creates a new default loading screen
  29229. * @param _renderingCanvas defines the canvas used to render the scene
  29230. * @param _loadingText defines the default text to display
  29231. * @param _loadingDivBackgroundColor defines the default background color
  29232. */
  29233. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  29234. /**
  29235. * Function called to display the loading screen
  29236. */
  29237. displayLoadingUI(): void;
  29238. /**
  29239. * Function called to hide the loading screen
  29240. */
  29241. hideLoadingUI(): void;
  29242. /**
  29243. * Gets or sets the text to display while loading
  29244. */
  29245. loadingUIText: string;
  29246. /**
  29247. * Gets or sets the color to use for the background
  29248. */
  29249. loadingUIBackgroundColor: string;
  29250. private _resizeLoadingUI;
  29251. }
  29252. }
  29253. declare module BABYLON {
  29254. /** @hidden */
  29255. export class WebGLPipelineContext implements IPipelineContext {
  29256. engine: Engine;
  29257. program: Nullable<WebGLProgram>;
  29258. context?: WebGLRenderingContext;
  29259. vertexShader?: WebGLShader;
  29260. fragmentShader?: WebGLShader;
  29261. isParallelCompiled: boolean;
  29262. onCompiled?: () => void;
  29263. transformFeedback?: WebGLTransformFeedback | null;
  29264. readonly isAsync: boolean;
  29265. readonly isReady: boolean;
  29266. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  29267. }
  29268. }
  29269. declare module BABYLON {
  29270. /** @hidden */
  29271. export class WebGLDataBuffer extends DataBuffer {
  29272. private _buffer;
  29273. constructor(resource: WebGLBuffer);
  29274. readonly underlyingResource: any;
  29275. }
  29276. }
  29277. declare module BABYLON {
  29278. /** @hidden */
  29279. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29280. attributeProcessor(attribute: string): string;
  29281. varyingProcessor(varying: string, isFragment: boolean): string;
  29282. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29283. }
  29284. }
  29285. declare module BABYLON {
  29286. /**
  29287. * This class is used to track a performance counter which is number based.
  29288. * The user has access to many properties which give statistics of different nature.
  29289. *
  29290. * The implementer can track two kinds of Performance Counter: time and count.
  29291. * 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.
  29292. * 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.
  29293. */
  29294. export class PerfCounter {
  29295. /**
  29296. * Gets or sets a global boolean to turn on and off all the counters
  29297. */
  29298. static Enabled: boolean;
  29299. /**
  29300. * Returns the smallest value ever
  29301. */
  29302. readonly min: number;
  29303. /**
  29304. * Returns the biggest value ever
  29305. */
  29306. readonly max: number;
  29307. /**
  29308. * Returns the average value since the performance counter is running
  29309. */
  29310. readonly average: number;
  29311. /**
  29312. * Returns the average value of the last second the counter was monitored
  29313. */
  29314. readonly lastSecAverage: number;
  29315. /**
  29316. * Returns the current value
  29317. */
  29318. readonly current: number;
  29319. /**
  29320. * Gets the accumulated total
  29321. */
  29322. readonly total: number;
  29323. /**
  29324. * Gets the total value count
  29325. */
  29326. readonly count: number;
  29327. /**
  29328. * Creates a new counter
  29329. */
  29330. constructor();
  29331. /**
  29332. * Call this method to start monitoring a new frame.
  29333. * 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.
  29334. */
  29335. fetchNewFrame(): void;
  29336. /**
  29337. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29338. * @param newCount the count value to add to the monitored count
  29339. * @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.
  29340. */
  29341. addCount(newCount: number, fetchResult: boolean): void;
  29342. /**
  29343. * Start monitoring this performance counter
  29344. */
  29345. beginMonitoring(): void;
  29346. /**
  29347. * Compute the time lapsed since the previous beginMonitoring() call.
  29348. * @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
  29349. */
  29350. endMonitoring(newFrame?: boolean): void;
  29351. private _fetchResult;
  29352. private _startMonitoringTime;
  29353. private _min;
  29354. private _max;
  29355. private _average;
  29356. private _current;
  29357. private _totalValueCount;
  29358. private _totalAccumulated;
  29359. private _lastSecAverage;
  29360. private _lastSecAccumulated;
  29361. private _lastSecTime;
  29362. private _lastSecValueCount;
  29363. }
  29364. }
  29365. declare module BABYLON {
  29366. /**
  29367. * Interface for any object that can request an animation frame
  29368. */
  29369. export interface ICustomAnimationFrameRequester {
  29370. /**
  29371. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29372. */
  29373. renderFunction?: Function;
  29374. /**
  29375. * Called to request the next frame to render to
  29376. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29377. */
  29378. requestAnimationFrame: Function;
  29379. /**
  29380. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29381. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29382. */
  29383. requestID?: number;
  29384. }
  29385. }
  29386. declare module BABYLON {
  29387. /**
  29388. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  29389. */
  29390. export class PerformanceMonitor {
  29391. private _enabled;
  29392. private _rollingFrameTime;
  29393. private _lastFrameTimeMs;
  29394. /**
  29395. * constructor
  29396. * @param frameSampleSize The number of samples required to saturate the sliding window
  29397. */
  29398. constructor(frameSampleSize?: number);
  29399. /**
  29400. * Samples current frame
  29401. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  29402. */
  29403. sampleFrame(timeMs?: number): void;
  29404. /**
  29405. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  29406. */
  29407. readonly averageFrameTime: number;
  29408. /**
  29409. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  29410. */
  29411. readonly averageFrameTimeVariance: number;
  29412. /**
  29413. * Returns the frame time of the most recent frame
  29414. */
  29415. readonly instantaneousFrameTime: number;
  29416. /**
  29417. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  29418. */
  29419. readonly averageFPS: number;
  29420. /**
  29421. * Returns the average framerate in frames per second using the most recent frame time
  29422. */
  29423. readonly instantaneousFPS: number;
  29424. /**
  29425. * Returns true if enough samples have been taken to completely fill the sliding window
  29426. */
  29427. readonly isSaturated: boolean;
  29428. /**
  29429. * Enables contributions to the sliding window sample set
  29430. */
  29431. enable(): void;
  29432. /**
  29433. * Disables contributions to the sliding window sample set
  29434. * Samples will not be interpolated over the disabled period
  29435. */
  29436. disable(): void;
  29437. /**
  29438. * Returns true if sampling is enabled
  29439. */
  29440. readonly isEnabled: boolean;
  29441. /**
  29442. * Resets performance monitor
  29443. */
  29444. reset(): void;
  29445. }
  29446. /**
  29447. * RollingAverage
  29448. *
  29449. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  29450. */
  29451. export class RollingAverage {
  29452. /**
  29453. * Current average
  29454. */
  29455. average: number;
  29456. /**
  29457. * Current variance
  29458. */
  29459. variance: number;
  29460. protected _samples: Array<number>;
  29461. protected _sampleCount: number;
  29462. protected _pos: number;
  29463. protected _m2: number;
  29464. /**
  29465. * constructor
  29466. * @param length The number of samples required to saturate the sliding window
  29467. */
  29468. constructor(length: number);
  29469. /**
  29470. * Adds a sample to the sample set
  29471. * @param v The sample value
  29472. */
  29473. add(v: number): void;
  29474. /**
  29475. * Returns previously added values or null if outside of history or outside the sliding window domain
  29476. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  29477. * @return Value previously recorded with add() or null if outside of range
  29478. */
  29479. history(i: number): number;
  29480. /**
  29481. * Returns true if enough samples have been taken to completely fill the sliding window
  29482. * @return true if sample-set saturated
  29483. */
  29484. isSaturated(): boolean;
  29485. /**
  29486. * Resets the rolling average (equivalent to 0 samples taken so far)
  29487. */
  29488. reset(): void;
  29489. /**
  29490. * Wraps a value around the sample range boundaries
  29491. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  29492. * @return Wrapped position in sample range
  29493. */
  29494. protected _wrapPosition(i: number): number;
  29495. }
  29496. }
  29497. declare module BABYLON {
  29498. /**
  29499. * Settings for finer control over video usage
  29500. */
  29501. export interface VideoTextureSettings {
  29502. /**
  29503. * Applies `autoplay` to video, if specified
  29504. */
  29505. autoPlay?: boolean;
  29506. /**
  29507. * Applies `loop` to video, if specified
  29508. */
  29509. loop?: boolean;
  29510. /**
  29511. * Automatically updates internal texture from video at every frame in the render loop
  29512. */
  29513. autoUpdateTexture: boolean;
  29514. /**
  29515. * Image src displayed during the video loading or until the user interacts with the video.
  29516. */
  29517. poster?: string;
  29518. }
  29519. /**
  29520. * If you want to display a video in your scene, this is the special texture for that.
  29521. * This special texture works similar to other textures, with the exception of a few parameters.
  29522. * @see https://doc.babylonjs.com/how_to/video_texture
  29523. */
  29524. export class VideoTexture extends Texture {
  29525. /**
  29526. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29527. */
  29528. readonly autoUpdateTexture: boolean;
  29529. /**
  29530. * The video instance used by the texture internally
  29531. */
  29532. readonly video: HTMLVideoElement;
  29533. private _onUserActionRequestedObservable;
  29534. /**
  29535. * Event triggerd when a dom action is required by the user to play the video.
  29536. * This happens due to recent changes in browser policies preventing video to auto start.
  29537. */
  29538. readonly onUserActionRequestedObservable: Observable<Texture>;
  29539. private _generateMipMaps;
  29540. private _engine;
  29541. private _stillImageCaptured;
  29542. private _displayingPosterTexture;
  29543. private _settings;
  29544. private _createInternalTextureOnEvent;
  29545. private _frameId;
  29546. /**
  29547. * Creates a video texture.
  29548. * If you want to display a video in your scene, this is the special texture for that.
  29549. * This special texture works similar to other textures, with the exception of a few parameters.
  29550. * @see https://doc.babylonjs.com/how_to/video_texture
  29551. * @param name optional name, will detect from video source, if not defined
  29552. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29553. * @param scene is obviously the current scene.
  29554. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29555. * @param invertY is false by default but can be used to invert video on Y axis
  29556. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29557. * @param settings allows finer control over video usage
  29558. */
  29559. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29560. private _getName;
  29561. private _getVideo;
  29562. private _createInternalTexture;
  29563. private reset;
  29564. /**
  29565. * @hidden Internal method to initiate `update`.
  29566. */
  29567. _rebuild(): void;
  29568. /**
  29569. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29570. */
  29571. update(): void;
  29572. /**
  29573. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29574. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29575. */
  29576. updateTexture(isVisible: boolean): void;
  29577. protected _updateInternalTexture: () => void;
  29578. /**
  29579. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29580. * @param url New url.
  29581. */
  29582. updateURL(url: string): void;
  29583. /**
  29584. * Dispose the texture and release its associated resources.
  29585. */
  29586. dispose(): void;
  29587. /**
  29588. * Creates a video texture straight from a stream.
  29589. * @param scene Define the scene the texture should be created in
  29590. * @param stream Define the stream the texture should be created from
  29591. * @returns The created video texture as a promise
  29592. */
  29593. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29594. /**
  29595. * Creates a video texture straight from your WebCam video feed.
  29596. * @param scene Define the scene the texture should be created in
  29597. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29598. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29599. * @returns The created video texture as a promise
  29600. */
  29601. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29602. minWidth: number;
  29603. maxWidth: number;
  29604. minHeight: number;
  29605. maxHeight: number;
  29606. deviceId: string;
  29607. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29608. /**
  29609. * Creates a video texture straight from your WebCam video feed.
  29610. * @param scene Define the scene the texture should be created in
  29611. * @param onReady Define a callback to triggered once the texture will be ready
  29612. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29613. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29614. */
  29615. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29616. minWidth: number;
  29617. maxWidth: number;
  29618. minHeight: number;
  29619. maxHeight: number;
  29620. deviceId: string;
  29621. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29622. }
  29623. }
  29624. declare module BABYLON {
  29625. /**
  29626. * Defines the interface used by objects containing a viewport (like a camera)
  29627. */
  29628. interface IViewportOwnerLike {
  29629. /**
  29630. * Gets or sets the viewport
  29631. */
  29632. viewport: IViewportLike;
  29633. }
  29634. /**
  29635. * Interface for attribute information associated with buffer instanciation
  29636. */
  29637. export class InstancingAttributeInfo {
  29638. /**
  29639. * Index/offset of the attribute in the vertex shader
  29640. */
  29641. index: number;
  29642. /**
  29643. * size of the attribute, 1, 2, 3 or 4
  29644. */
  29645. attributeSize: number;
  29646. /**
  29647. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29648. * default is FLOAT
  29649. */
  29650. attribyteType: number;
  29651. /**
  29652. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29653. */
  29654. normalized: boolean;
  29655. /**
  29656. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29657. */
  29658. offset: number;
  29659. /**
  29660. * Name of the GLSL attribute, for debugging purpose only
  29661. */
  29662. attributeName: string;
  29663. }
  29664. /**
  29665. * Define options used to create a depth texture
  29666. */
  29667. export class DepthTextureCreationOptions {
  29668. /** Specifies whether or not a stencil should be allocated in the texture */
  29669. generateStencil?: boolean;
  29670. /** Specifies whether or not bilinear filtering is enable on the texture */
  29671. bilinearFiltering?: boolean;
  29672. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29673. comparisonFunction?: number;
  29674. /** Specifies if the created texture is a cube texture */
  29675. isCube?: boolean;
  29676. }
  29677. /**
  29678. * Class used to describe the capabilities of the engine relatively to the current browser
  29679. */
  29680. export class EngineCapabilities {
  29681. /** Maximum textures units per fragment shader */
  29682. maxTexturesImageUnits: number;
  29683. /** Maximum texture units per vertex shader */
  29684. maxVertexTextureImageUnits: number;
  29685. /** Maximum textures units in the entire pipeline */
  29686. maxCombinedTexturesImageUnits: number;
  29687. /** Maximum texture size */
  29688. maxTextureSize: number;
  29689. /** Maximum cube texture size */
  29690. maxCubemapTextureSize: number;
  29691. /** Maximum render texture size */
  29692. maxRenderTextureSize: number;
  29693. /** Maximum number of vertex attributes */
  29694. maxVertexAttribs: number;
  29695. /** Maximum number of varyings */
  29696. maxVaryingVectors: number;
  29697. /** Maximum number of uniforms per vertex shader */
  29698. maxVertexUniformVectors: number;
  29699. /** Maximum number of uniforms per fragment shader */
  29700. maxFragmentUniformVectors: number;
  29701. /** Defines if standard derivates (dx/dy) are supported */
  29702. standardDerivatives: boolean;
  29703. /** Defines if s3tc texture compression is supported */
  29704. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29705. /** Defines if pvrtc texture compression is supported */
  29706. pvrtc: any;
  29707. /** Defines if etc1 texture compression is supported */
  29708. etc1: any;
  29709. /** Defines if etc2 texture compression is supported */
  29710. etc2: any;
  29711. /** Defines if astc texture compression is supported */
  29712. astc: any;
  29713. /** Defines if float textures are supported */
  29714. textureFloat: boolean;
  29715. /** Defines if vertex array objects are supported */
  29716. vertexArrayObject: boolean;
  29717. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29718. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29719. /** Gets the maximum level of anisotropy supported */
  29720. maxAnisotropy: number;
  29721. /** Defines if instancing is supported */
  29722. instancedArrays: boolean;
  29723. /** Defines if 32 bits indices are supported */
  29724. uintIndices: boolean;
  29725. /** Defines if high precision shaders are supported */
  29726. highPrecisionShaderSupported: boolean;
  29727. /** Defines if depth reading in the fragment shader is supported */
  29728. fragmentDepthSupported: boolean;
  29729. /** Defines if float texture linear filtering is supported*/
  29730. textureFloatLinearFiltering: boolean;
  29731. /** Defines if rendering to float textures is supported */
  29732. textureFloatRender: boolean;
  29733. /** Defines if half float textures are supported*/
  29734. textureHalfFloat: boolean;
  29735. /** Defines if half float texture linear filtering is supported*/
  29736. textureHalfFloatLinearFiltering: boolean;
  29737. /** Defines if rendering to half float textures is supported */
  29738. textureHalfFloatRender: boolean;
  29739. /** Defines if textureLOD shader command is supported */
  29740. textureLOD: boolean;
  29741. /** Defines if draw buffers extension is supported */
  29742. drawBuffersExtension: boolean;
  29743. /** Defines if depth textures are supported */
  29744. depthTextureExtension: boolean;
  29745. /** Defines if float color buffer are supported */
  29746. colorBufferFloat: boolean;
  29747. /** Gets disjoint timer query extension (null if not supported) */
  29748. timerQuery: EXT_disjoint_timer_query;
  29749. /** Defines if timestamp can be used with timer query */
  29750. canUseTimestampForTimerQuery: boolean;
  29751. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29752. multiview: any;
  29753. /** Function used to let the system compiles shaders in background */
  29754. parallelShaderCompile: {
  29755. COMPLETION_STATUS_KHR: number;
  29756. };
  29757. /** Max number of texture samples for MSAA */
  29758. maxMSAASamples: number;
  29759. /** Defines if the blend min max extension is supported */
  29760. blendMinMax: boolean;
  29761. }
  29762. /** Interface defining initialization parameters for Engine class */
  29763. export interface EngineOptions extends WebGLContextAttributes {
  29764. /**
  29765. * Defines if the engine should no exceed a specified device ratio
  29766. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29767. */
  29768. limitDeviceRatio?: number;
  29769. /**
  29770. * Defines if webvr should be enabled automatically
  29771. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29772. */
  29773. autoEnableWebVR?: boolean;
  29774. /**
  29775. * Defines if webgl2 should be turned off even if supported
  29776. * @see http://doc.babylonjs.com/features/webgl2
  29777. */
  29778. disableWebGL2Support?: boolean;
  29779. /**
  29780. * Defines if webaudio should be initialized as well
  29781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29782. */
  29783. audioEngine?: boolean;
  29784. /**
  29785. * Defines if animations should run using a deterministic lock step
  29786. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29787. */
  29788. deterministicLockstep?: boolean;
  29789. /** Defines the maximum steps to use with deterministic lock step mode */
  29790. lockstepMaxSteps?: number;
  29791. /**
  29792. * Defines that engine should ignore context lost events
  29793. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29794. */
  29795. doNotHandleContextLost?: boolean;
  29796. /**
  29797. * Defines that engine should ignore modifying touch action attribute and style
  29798. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29799. */
  29800. doNotHandleTouchAction?: boolean;
  29801. /**
  29802. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29803. */
  29804. useHighPrecisionFloats?: boolean;
  29805. }
  29806. /**
  29807. * Defines the interface used by display changed events
  29808. */
  29809. export interface IDisplayChangedEventArgs {
  29810. /** Gets the vrDisplay object (if any) */
  29811. vrDisplay: Nullable<any>;
  29812. /** Gets a boolean indicating if webVR is supported */
  29813. vrSupported: boolean;
  29814. }
  29815. /**
  29816. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29817. */
  29818. export class Engine {
  29819. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29820. static ExceptionList: ({
  29821. key: string;
  29822. capture: string;
  29823. captureConstraint: number;
  29824. targets: string[];
  29825. } | {
  29826. key: string;
  29827. capture: null;
  29828. captureConstraint: null;
  29829. targets: string[];
  29830. })[];
  29831. /** Gets the list of created engines */
  29832. static readonly Instances: Engine[];
  29833. /**
  29834. * Gets the latest created engine
  29835. */
  29836. static readonly LastCreatedEngine: Nullable<Engine>;
  29837. /**
  29838. * Gets the latest created scene
  29839. */
  29840. static readonly LastCreatedScene: Nullable<Scene>;
  29841. /**
  29842. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29843. * @param flag defines which part of the materials must be marked as dirty
  29844. * @param predicate defines a predicate used to filter which materials should be affected
  29845. */
  29846. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29847. /** Defines that alpha blending is disabled */
  29848. static readonly ALPHA_DISABLE: number;
  29849. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29850. static readonly ALPHA_ADD: number;
  29851. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29852. static readonly ALPHA_COMBINE: number;
  29853. /** Defines that alpha blending to DEST - SRC * DEST */
  29854. static readonly ALPHA_SUBTRACT: number;
  29855. /** Defines that alpha blending to SRC * DEST */
  29856. static readonly ALPHA_MULTIPLY: number;
  29857. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29858. static readonly ALPHA_MAXIMIZED: number;
  29859. /** Defines that alpha blending to SRC + DEST */
  29860. static readonly ALPHA_ONEONE: number;
  29861. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29862. static readonly ALPHA_PREMULTIPLIED: number;
  29863. /**
  29864. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29865. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29866. */
  29867. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29868. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29869. static readonly ALPHA_INTERPOLATE: number;
  29870. /**
  29871. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29872. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29873. */
  29874. static readonly ALPHA_SCREENMODE: number;
  29875. /** Defines that the ressource is not delayed*/
  29876. static readonly DELAYLOADSTATE_NONE: number;
  29877. /** Defines that the ressource was successfully delay loaded */
  29878. static readonly DELAYLOADSTATE_LOADED: number;
  29879. /** Defines that the ressource is currently delay loading */
  29880. static readonly DELAYLOADSTATE_LOADING: number;
  29881. /** Defines that the ressource is delayed and has not started loading */
  29882. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29883. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29884. static readonly NEVER: number;
  29885. /** 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 */
  29886. static readonly ALWAYS: number;
  29887. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29888. static readonly LESS: number;
  29889. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29890. static readonly EQUAL: number;
  29891. /** 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 */
  29892. static readonly LEQUAL: number;
  29893. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29894. static readonly GREATER: number;
  29895. /** 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 */
  29896. static readonly GEQUAL: number;
  29897. /** 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 */
  29898. static readonly NOTEQUAL: number;
  29899. /** Passed to stencilOperation to specify that stencil value must be kept */
  29900. static readonly KEEP: number;
  29901. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29902. static readonly REPLACE: number;
  29903. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29904. static readonly INCR: number;
  29905. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29906. static readonly DECR: number;
  29907. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29908. static readonly INVERT: number;
  29909. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29910. static readonly INCR_WRAP: number;
  29911. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29912. static readonly DECR_WRAP: number;
  29913. /** Texture is not repeating outside of 0..1 UVs */
  29914. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29915. /** Texture is repeating outside of 0..1 UVs */
  29916. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29917. /** Texture is repeating and mirrored */
  29918. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29919. /** ALPHA */
  29920. static readonly TEXTUREFORMAT_ALPHA: number;
  29921. /** LUMINANCE */
  29922. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29923. /** LUMINANCE_ALPHA */
  29924. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29925. /** RGB */
  29926. static readonly TEXTUREFORMAT_RGB: number;
  29927. /** RGBA */
  29928. static readonly TEXTUREFORMAT_RGBA: number;
  29929. /** RED */
  29930. static readonly TEXTUREFORMAT_RED: number;
  29931. /** RED (2nd reference) */
  29932. static readonly TEXTUREFORMAT_R: number;
  29933. /** RG */
  29934. static readonly TEXTUREFORMAT_RG: number;
  29935. /** RED_INTEGER */
  29936. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29937. /** RED_INTEGER (2nd reference) */
  29938. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29939. /** RG_INTEGER */
  29940. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29941. /** RGB_INTEGER */
  29942. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29943. /** RGBA_INTEGER */
  29944. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29945. /** UNSIGNED_BYTE */
  29946. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29947. /** UNSIGNED_BYTE (2nd reference) */
  29948. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29949. /** FLOAT */
  29950. static readonly TEXTURETYPE_FLOAT: number;
  29951. /** HALF_FLOAT */
  29952. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29953. /** BYTE */
  29954. static readonly TEXTURETYPE_BYTE: number;
  29955. /** SHORT */
  29956. static readonly TEXTURETYPE_SHORT: number;
  29957. /** UNSIGNED_SHORT */
  29958. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29959. /** INT */
  29960. static readonly TEXTURETYPE_INT: number;
  29961. /** UNSIGNED_INT */
  29962. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29963. /** UNSIGNED_SHORT_4_4_4_4 */
  29964. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29965. /** UNSIGNED_SHORT_5_5_5_1 */
  29966. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29967. /** UNSIGNED_SHORT_5_6_5 */
  29968. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29969. /** UNSIGNED_INT_2_10_10_10_REV */
  29970. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29971. /** UNSIGNED_INT_24_8 */
  29972. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29973. /** UNSIGNED_INT_10F_11F_11F_REV */
  29974. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29975. /** UNSIGNED_INT_5_9_9_9_REV */
  29976. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29977. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29978. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29979. /** nearest is mag = nearest and min = nearest and mip = linear */
  29980. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29981. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29982. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29983. /** Trilinear is mag = linear and min = linear and mip = linear */
  29984. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29985. /** nearest is mag = nearest and min = nearest and mip = linear */
  29986. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29987. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29988. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29989. /** Trilinear is mag = linear and min = linear and mip = linear */
  29990. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29991. /** mag = nearest and min = nearest and mip = nearest */
  29992. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29993. /** mag = nearest and min = linear and mip = nearest */
  29994. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29995. /** mag = nearest and min = linear and mip = linear */
  29996. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29997. /** mag = nearest and min = linear and mip = none */
  29998. static readonly TEXTURE_NEAREST_LINEAR: number;
  29999. /** mag = nearest and min = nearest and mip = none */
  30000. static readonly TEXTURE_NEAREST_NEAREST: number;
  30001. /** mag = linear and min = nearest and mip = nearest */
  30002. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30003. /** mag = linear and min = nearest and mip = linear */
  30004. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30005. /** mag = linear and min = linear and mip = none */
  30006. static readonly TEXTURE_LINEAR_LINEAR: number;
  30007. /** mag = linear and min = nearest and mip = none */
  30008. static readonly TEXTURE_LINEAR_NEAREST: number;
  30009. /** Explicit coordinates mode */
  30010. static readonly TEXTURE_EXPLICIT_MODE: number;
  30011. /** Spherical coordinates mode */
  30012. static readonly TEXTURE_SPHERICAL_MODE: number;
  30013. /** Planar coordinates mode */
  30014. static readonly TEXTURE_PLANAR_MODE: number;
  30015. /** Cubic coordinates mode */
  30016. static readonly TEXTURE_CUBIC_MODE: number;
  30017. /** Projection coordinates mode */
  30018. static readonly TEXTURE_PROJECTION_MODE: number;
  30019. /** Skybox coordinates mode */
  30020. static readonly TEXTURE_SKYBOX_MODE: number;
  30021. /** Inverse Cubic coordinates mode */
  30022. static readonly TEXTURE_INVCUBIC_MODE: number;
  30023. /** Equirectangular coordinates mode */
  30024. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30025. /** Equirectangular Fixed coordinates mode */
  30026. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30027. /** Equirectangular Fixed Mirrored coordinates mode */
  30028. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30029. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30030. static readonly SCALEMODE_FLOOR: number;
  30031. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30032. static readonly SCALEMODE_NEAREST: number;
  30033. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30034. static readonly SCALEMODE_CEILING: number;
  30035. /** @hidden */
  30036. static _TextureLoaders: IInternalTextureLoader[];
  30037. /**
  30038. * Returns the current npm package of the sdk
  30039. */
  30040. static readonly NpmPackage: string;
  30041. /**
  30042. * Returns the current version of the framework
  30043. */
  30044. static readonly Version: string;
  30045. /**
  30046. * Returns a string describing the current engine
  30047. */
  30048. readonly description: string;
  30049. /**
  30050. * Gets or sets the epsilon value used by collision engine
  30051. */
  30052. static CollisionsEpsilon: number;
  30053. /**
  30054. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30055. */
  30056. static ShadersRepository: string;
  30057. /**
  30058. * Method called to create the default loading screen.
  30059. * This can be overriden in your own app.
  30060. * @param canvas The rendering canvas element
  30061. * @returns The loading screen
  30062. */
  30063. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30064. /**
  30065. * Method called to create the default rescale post process on each engine.
  30066. */
  30067. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30068. /** @hidden */
  30069. _shaderProcessor: IShaderProcessor;
  30070. /**
  30071. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30072. */
  30073. forcePOTTextures: boolean;
  30074. /**
  30075. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30076. */
  30077. isFullscreen: boolean;
  30078. /**
  30079. * Gets a boolean indicating if the pointer is currently locked
  30080. */
  30081. isPointerLock: boolean;
  30082. /**
  30083. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30084. */
  30085. cullBackFaces: boolean;
  30086. /**
  30087. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30088. */
  30089. renderEvenInBackground: boolean;
  30090. /**
  30091. * Gets or sets a boolean indicating that cache can be kept between frames
  30092. */
  30093. preventCacheWipeBetweenFrames: boolean;
  30094. /**
  30095. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30096. **/
  30097. enableOfflineSupport: boolean;
  30098. /**
  30099. * 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)
  30100. **/
  30101. disableManifestCheck: boolean;
  30102. /**
  30103. * Gets the list of created scenes
  30104. */
  30105. scenes: Scene[];
  30106. /**
  30107. * Event raised when a new scene is created
  30108. */
  30109. onNewSceneAddedObservable: Observable<Scene>;
  30110. /**
  30111. * Gets the list of created postprocesses
  30112. */
  30113. postProcesses: PostProcess[];
  30114. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30115. validateShaderPrograms: boolean;
  30116. /**
  30117. * Observable event triggered each time the rendering canvas is resized
  30118. */
  30119. onResizeObservable: Observable<Engine>;
  30120. /**
  30121. * Observable event triggered each time the canvas loses focus
  30122. */
  30123. onCanvasBlurObservable: Observable<Engine>;
  30124. /**
  30125. * Observable event triggered each time the canvas gains focus
  30126. */
  30127. onCanvasFocusObservable: Observable<Engine>;
  30128. /**
  30129. * Observable event triggered each time the canvas receives pointerout event
  30130. */
  30131. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30132. /**
  30133. * Observable event triggered before each texture is initialized
  30134. */
  30135. onBeforeTextureInitObservable: Observable<Texture>;
  30136. /**
  30137. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30138. */
  30139. disableUniformBuffers: boolean;
  30140. /** @hidden */
  30141. _uniformBuffers: UniformBuffer[];
  30142. /**
  30143. * Gets a boolean indicating that the engine supports uniform buffers
  30144. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30145. */
  30146. readonly supportsUniformBuffers: boolean;
  30147. /**
  30148. * Observable raised when the engine begins a new frame
  30149. */
  30150. onBeginFrameObservable: Observable<Engine>;
  30151. /**
  30152. * If set, will be used to request the next animation frame for the render loop
  30153. */
  30154. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30155. /**
  30156. * Observable raised when the engine ends the current frame
  30157. */
  30158. onEndFrameObservable: Observable<Engine>;
  30159. /**
  30160. * Observable raised when the engine is about to compile a shader
  30161. */
  30162. onBeforeShaderCompilationObservable: Observable<Engine>;
  30163. /**
  30164. * Observable raised when the engine has jsut compiled a shader
  30165. */
  30166. onAfterShaderCompilationObservable: Observable<Engine>;
  30167. /** @hidden */
  30168. _gl: WebGLRenderingContext;
  30169. private _renderingCanvas;
  30170. private _windowIsBackground;
  30171. protected _webGLVersion: number;
  30172. protected _highPrecisionShadersAllowed: boolean;
  30173. /** @hidden */
  30174. readonly _shouldUseHighPrecisionShader: boolean;
  30175. /**
  30176. * Gets a boolean indicating that only power of 2 textures are supported
  30177. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30178. */
  30179. readonly needPOTTextures: boolean;
  30180. /** @hidden */
  30181. _badOS: boolean;
  30182. /** @hidden */
  30183. _badDesktopOS: boolean;
  30184. /**
  30185. * Gets the audio engine
  30186. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30187. * @ignorenaming
  30188. */
  30189. static audioEngine: IAudioEngine;
  30190. /**
  30191. * Default AudioEngine factory responsible of creating the Audio Engine.
  30192. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30193. */
  30194. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30195. /**
  30196. * Default offline support factory responsible of creating a tool used to store data locally.
  30197. * By default, this will create a Database object if the workload has been embedded.
  30198. */
  30199. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30200. private _onFocus;
  30201. private _onBlur;
  30202. private _onCanvasPointerOut;
  30203. private _onCanvasBlur;
  30204. private _onCanvasFocus;
  30205. private _onFullscreenChange;
  30206. private _onPointerLockChange;
  30207. private _hardwareScalingLevel;
  30208. /** @hidden */
  30209. _caps: EngineCapabilities;
  30210. private _pointerLockRequested;
  30211. private _isStencilEnable;
  30212. protected _colorWrite: boolean;
  30213. private _loadingScreen;
  30214. /** @hidden */
  30215. _drawCalls: PerfCounter;
  30216. private _glVersion;
  30217. private _glRenderer;
  30218. private _glVendor;
  30219. private _videoTextureSupported;
  30220. private _renderingQueueLaunched;
  30221. private _activeRenderLoops;
  30222. private _deterministicLockstep;
  30223. private _lockstepMaxSteps;
  30224. /**
  30225. * Observable signaled when a context lost event is raised
  30226. */
  30227. onContextLostObservable: Observable<Engine>;
  30228. /**
  30229. * Observable signaled when a context restored event is raised
  30230. */
  30231. onContextRestoredObservable: Observable<Engine>;
  30232. private _onContextLost;
  30233. private _onContextRestored;
  30234. private _contextWasLost;
  30235. /** @hidden */
  30236. _doNotHandleContextLost: boolean;
  30237. /**
  30238. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30239. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30240. */
  30241. doNotHandleContextLost: boolean;
  30242. private _fps;
  30243. private _deltaTime;
  30244. /**
  30245. * Turn this value on if you want to pause FPS computation when in background
  30246. */
  30247. disablePerformanceMonitorInBackground: boolean;
  30248. private _performanceMonitor;
  30249. /**
  30250. * Gets the performance monitor attached to this engine
  30251. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30252. */
  30253. readonly performanceMonitor: PerformanceMonitor;
  30254. /**
  30255. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30256. */
  30257. disableVertexArrayObjects: boolean;
  30258. /** @hidden */
  30259. protected _depthCullingState: _DepthCullingState;
  30260. /** @hidden */
  30261. protected _stencilState: _StencilState;
  30262. /** @hidden */
  30263. protected _alphaState: _AlphaState;
  30264. /** @hidden */
  30265. protected _alphaMode: number;
  30266. /** @hidden */
  30267. protected _alphaEquation: number;
  30268. /** @hidden */
  30269. _internalTexturesCache: InternalTexture[];
  30270. /** @hidden */
  30271. protected _activeChannel: number;
  30272. private _currentTextureChannel;
  30273. /** @hidden */
  30274. protected _boundTexturesCache: {
  30275. [key: string]: Nullable<InternalTexture>;
  30276. };
  30277. /** @hidden */
  30278. protected _currentEffect: Nullable<Effect>;
  30279. /** @hidden */
  30280. protected _currentProgram: Nullable<WebGLProgram>;
  30281. private _compiledEffects;
  30282. private _vertexAttribArraysEnabled;
  30283. /** @hidden */
  30284. protected _cachedViewport: Nullable<IViewportLike>;
  30285. private _cachedVertexArrayObject;
  30286. /** @hidden */
  30287. protected _cachedVertexBuffers: any;
  30288. /** @hidden */
  30289. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30290. /** @hidden */
  30291. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30292. /** @hidden */
  30293. _currentRenderTarget: Nullable<InternalTexture>;
  30294. private _uintIndicesCurrentlySet;
  30295. private _currentBoundBuffer;
  30296. /** @hidden */
  30297. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30298. private _currentBufferPointers;
  30299. private _currentInstanceLocations;
  30300. private _currentInstanceBuffers;
  30301. private _textureUnits;
  30302. /** @hidden */
  30303. _workingCanvas: Nullable<HTMLCanvasElement>;
  30304. /** @hidden */
  30305. _workingContext: Nullable<CanvasRenderingContext2D>;
  30306. private _rescalePostProcess;
  30307. private _dummyFramebuffer;
  30308. /** @hidden */
  30309. _bindedRenderFunction: any;
  30310. private _vaoRecordInProgress;
  30311. private _mustWipeVertexAttributes;
  30312. private _emptyTexture;
  30313. private _emptyCubeTexture;
  30314. private _emptyTexture3D;
  30315. /** @hidden */
  30316. _frameHandler: number;
  30317. private _nextFreeTextureSlots;
  30318. private _maxSimultaneousTextures;
  30319. private _activeRequests;
  30320. private _texturesSupported;
  30321. /** @hidden */
  30322. _textureFormatInUse: Nullable<string>;
  30323. /**
  30324. * Gets the list of texture formats supported
  30325. */
  30326. readonly texturesSupported: Array<string>;
  30327. /**
  30328. * Gets the list of texture formats in use
  30329. */
  30330. readonly textureFormatInUse: Nullable<string>;
  30331. /**
  30332. * Gets the current viewport
  30333. */
  30334. readonly currentViewport: Nullable<IViewportLike>;
  30335. /**
  30336. * Gets the default empty texture
  30337. */
  30338. readonly emptyTexture: InternalTexture;
  30339. /**
  30340. * Gets the default empty 3D texture
  30341. */
  30342. readonly emptyTexture3D: InternalTexture;
  30343. /**
  30344. * Gets the default empty cube texture
  30345. */
  30346. readonly emptyCubeTexture: InternalTexture;
  30347. /**
  30348. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30349. */
  30350. readonly premultipliedAlpha: boolean;
  30351. /**
  30352. * Creates a new engine
  30353. * @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
  30354. * @param antialias defines enable antialiasing (default: false)
  30355. * @param options defines further options to be sent to the getContext() function
  30356. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30357. */
  30358. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30359. /**
  30360. * Initializes a webVR display and starts listening to display change events
  30361. * The onVRDisplayChangedObservable will be notified upon these changes
  30362. * @returns The onVRDisplayChangedObservable
  30363. */
  30364. initWebVR(): Observable<IDisplayChangedEventArgs>;
  30365. /** @hidden */
  30366. _prepareVRComponent(): void;
  30367. /** @hidden */
  30368. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  30369. /** @hidden */
  30370. _submitVRFrame(): void;
  30371. /**
  30372. * Call this function to leave webVR mode
  30373. * Will do nothing if webVR is not supported or if there is no webVR device
  30374. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30375. */
  30376. disableVR(): void;
  30377. /**
  30378. * Gets a boolean indicating that the system is in VR mode and is presenting
  30379. * @returns true if VR mode is engaged
  30380. */
  30381. isVRPresenting(): boolean;
  30382. /** @hidden */
  30383. _requestVRFrame(): void;
  30384. private _disableTouchAction;
  30385. private _rebuildInternalTextures;
  30386. private _rebuildEffects;
  30387. /**
  30388. * Gets a boolean indicating if all created effects are ready
  30389. * @returns true if all effects are ready
  30390. */
  30391. areAllEffectsReady(): boolean;
  30392. private _rebuildBuffers;
  30393. private _initGLContext;
  30394. /**
  30395. * Gets version of the current webGL context
  30396. */
  30397. readonly webGLVersion: number;
  30398. /**
  30399. * Gets a string idenfifying the name of the class
  30400. * @returns "Engine" string
  30401. */
  30402. getClassName(): string;
  30403. /**
  30404. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30405. */
  30406. readonly isStencilEnable: boolean;
  30407. /** @hidden */
  30408. _prepareWorkingCanvas(): void;
  30409. /**
  30410. * Reset the texture cache to empty state
  30411. */
  30412. resetTextureCache(): void;
  30413. /**
  30414. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30415. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30416. * @returns true if engine is in deterministic lock step mode
  30417. */
  30418. isDeterministicLockStep(): boolean;
  30419. /**
  30420. * Gets the max steps when engine is running in deterministic lock step
  30421. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30422. * @returns the max steps
  30423. */
  30424. getLockstepMaxSteps(): number;
  30425. /**
  30426. * Gets an object containing information about the current webGL context
  30427. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30428. */
  30429. getGlInfo(): {
  30430. vendor: string;
  30431. renderer: string;
  30432. version: string;
  30433. };
  30434. /**
  30435. * Gets current aspect ratio
  30436. * @param viewportOwner defines the camera to use to get the aspect ratio
  30437. * @param useScreen defines if screen size must be used (or the current render target if any)
  30438. * @returns a number defining the aspect ratio
  30439. */
  30440. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30441. /**
  30442. * Gets current screen aspect ratio
  30443. * @returns a number defining the aspect ratio
  30444. */
  30445. getScreenAspectRatio(): number;
  30446. /**
  30447. * Gets the current render width
  30448. * @param useScreen defines if screen size must be used (or the current render target if any)
  30449. * @returns a number defining the current render width
  30450. */
  30451. getRenderWidth(useScreen?: boolean): number;
  30452. /**
  30453. * Gets the current render height
  30454. * @param useScreen defines if screen size must be used (or the current render target if any)
  30455. * @returns a number defining the current render height
  30456. */
  30457. getRenderHeight(useScreen?: boolean): number;
  30458. /**
  30459. * Gets the HTML canvas attached with the current webGL context
  30460. * @returns a HTML canvas
  30461. */
  30462. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30463. /**
  30464. * Gets host window
  30465. * @returns the host window object
  30466. */
  30467. getHostWindow(): Window;
  30468. /**
  30469. * Gets host document
  30470. * @returns the host document object
  30471. */
  30472. getHostDocument(): Document;
  30473. /**
  30474. * Gets the client rect of the HTML canvas attached with the current webGL context
  30475. * @returns a client rectanglee
  30476. */
  30477. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30478. /**
  30479. * Defines the hardware scaling level.
  30480. * By default the hardware scaling level is computed from the window device ratio.
  30481. * 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.
  30482. * @param level defines the level to use
  30483. */
  30484. setHardwareScalingLevel(level: number): void;
  30485. /**
  30486. * Gets the current hardware scaling level.
  30487. * By default the hardware scaling level is computed from the window device ratio.
  30488. * 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.
  30489. * @returns a number indicating the current hardware scaling level
  30490. */
  30491. getHardwareScalingLevel(): number;
  30492. /**
  30493. * Gets the list of loaded textures
  30494. * @returns an array containing all loaded textures
  30495. */
  30496. getLoadedTexturesCache(): InternalTexture[];
  30497. /**
  30498. * Gets the object containing all engine capabilities
  30499. * @returns the EngineCapabilities object
  30500. */
  30501. getCaps(): EngineCapabilities;
  30502. /**
  30503. * Gets the current depth function
  30504. * @returns a number defining the depth function
  30505. */
  30506. getDepthFunction(): Nullable<number>;
  30507. /**
  30508. * Sets the current depth function
  30509. * @param depthFunc defines the function to use
  30510. */
  30511. setDepthFunction(depthFunc: number): void;
  30512. /**
  30513. * Sets the current depth function to GREATER
  30514. */
  30515. setDepthFunctionToGreater(): void;
  30516. /**
  30517. * Sets the current depth function to GEQUAL
  30518. */
  30519. setDepthFunctionToGreaterOrEqual(): void;
  30520. /**
  30521. * Sets the current depth function to LESS
  30522. */
  30523. setDepthFunctionToLess(): void;
  30524. private _cachedStencilBuffer;
  30525. private _cachedStencilFunction;
  30526. private _cachedStencilMask;
  30527. private _cachedStencilOperationPass;
  30528. private _cachedStencilOperationFail;
  30529. private _cachedStencilOperationDepthFail;
  30530. private _cachedStencilReference;
  30531. /**
  30532. * Caches the the state of the stencil buffer
  30533. */
  30534. cacheStencilState(): void;
  30535. /**
  30536. * Restores the state of the stencil buffer
  30537. */
  30538. restoreStencilState(): void;
  30539. /**
  30540. * Sets the current depth function to LEQUAL
  30541. */
  30542. setDepthFunctionToLessOrEqual(): void;
  30543. /**
  30544. * Gets a boolean indicating if stencil buffer is enabled
  30545. * @returns the current stencil buffer state
  30546. */
  30547. getStencilBuffer(): boolean;
  30548. /**
  30549. * Enable or disable the stencil buffer
  30550. * @param enable defines if the stencil buffer must be enabled or disabled
  30551. */
  30552. setStencilBuffer(enable: boolean): void;
  30553. /**
  30554. * Gets the current stencil mask
  30555. * @returns a number defining the new stencil mask to use
  30556. */
  30557. getStencilMask(): number;
  30558. /**
  30559. * Sets the current stencil mask
  30560. * @param mask defines the new stencil mask to use
  30561. */
  30562. setStencilMask(mask: number): void;
  30563. /**
  30564. * Gets the current stencil function
  30565. * @returns a number defining the stencil function to use
  30566. */
  30567. getStencilFunction(): number;
  30568. /**
  30569. * Gets the current stencil reference value
  30570. * @returns a number defining the stencil reference value to use
  30571. */
  30572. getStencilFunctionReference(): number;
  30573. /**
  30574. * Gets the current stencil mask
  30575. * @returns a number defining the stencil mask to use
  30576. */
  30577. getStencilFunctionMask(): number;
  30578. /**
  30579. * Sets the current stencil function
  30580. * @param stencilFunc defines the new stencil function to use
  30581. */
  30582. setStencilFunction(stencilFunc: number): void;
  30583. /**
  30584. * Sets the current stencil reference
  30585. * @param reference defines the new stencil reference to use
  30586. */
  30587. setStencilFunctionReference(reference: number): void;
  30588. /**
  30589. * Sets the current stencil mask
  30590. * @param mask defines the new stencil mask to use
  30591. */
  30592. setStencilFunctionMask(mask: number): void;
  30593. /**
  30594. * Gets the current stencil operation when stencil fails
  30595. * @returns a number defining stencil operation to use when stencil fails
  30596. */
  30597. getStencilOperationFail(): number;
  30598. /**
  30599. * Gets the current stencil operation when depth fails
  30600. * @returns a number defining stencil operation to use when depth fails
  30601. */
  30602. getStencilOperationDepthFail(): number;
  30603. /**
  30604. * Gets the current stencil operation when stencil passes
  30605. * @returns a number defining stencil operation to use when stencil passes
  30606. */
  30607. getStencilOperationPass(): number;
  30608. /**
  30609. * Sets the stencil operation to use when stencil fails
  30610. * @param operation defines the stencil operation to use when stencil fails
  30611. */
  30612. setStencilOperationFail(operation: number): void;
  30613. /**
  30614. * Sets the stencil operation to use when depth fails
  30615. * @param operation defines the stencil operation to use when depth fails
  30616. */
  30617. setStencilOperationDepthFail(operation: number): void;
  30618. /**
  30619. * Sets the stencil operation to use when stencil passes
  30620. * @param operation defines the stencil operation to use when stencil passes
  30621. */
  30622. setStencilOperationPass(operation: number): void;
  30623. /**
  30624. * Sets a boolean indicating if the dithering state is enabled or disabled
  30625. * @param value defines the dithering state
  30626. */
  30627. setDitheringState(value: boolean): void;
  30628. /**
  30629. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30630. * @param value defines the rasterizer state
  30631. */
  30632. setRasterizerState(value: boolean): void;
  30633. /**
  30634. * stop executing a render loop function and remove it from the execution array
  30635. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30636. */
  30637. stopRenderLoop(renderFunction?: () => void): void;
  30638. /** @hidden */
  30639. _renderLoop(): void;
  30640. /**
  30641. * Can be used to override the current requestAnimationFrame requester.
  30642. * @hidden
  30643. */
  30644. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30645. /**
  30646. * Register and execute a render loop. The engine can have more than one render function
  30647. * @param renderFunction defines the function to continuously execute
  30648. */
  30649. runRenderLoop(renderFunction: () => void): void;
  30650. /**
  30651. * Toggle full screen mode
  30652. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30653. */
  30654. switchFullscreen(requestPointerLock: boolean): void;
  30655. /**
  30656. * Enters full screen mode
  30657. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30658. */
  30659. enterFullscreen(requestPointerLock: boolean): void;
  30660. /**
  30661. * Exits full screen mode
  30662. */
  30663. exitFullscreen(): void;
  30664. /**
  30665. * Enters Pointerlock mode
  30666. */
  30667. enterPointerlock(): void;
  30668. /**
  30669. * Exits Pointerlock mode
  30670. */
  30671. exitPointerlock(): void;
  30672. /**
  30673. * Clear the current render buffer or the current render target (if any is set up)
  30674. * @param color defines the color to use
  30675. * @param backBuffer defines if the back buffer must be cleared
  30676. * @param depth defines if the depth buffer must be cleared
  30677. * @param stencil defines if the stencil buffer must be cleared
  30678. */
  30679. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30680. /**
  30681. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30682. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30683. * @param y defines the y-coordinate of the corner of the clear rectangle
  30684. * @param width defines the width of the clear rectangle
  30685. * @param height defines the height of the clear rectangle
  30686. * @param clearColor defines the clear color
  30687. */
  30688. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30689. /**
  30690. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30691. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30692. * @param y defines the y-coordinate of the corner of the clear rectangle
  30693. * @param width defines the width of the clear rectangle
  30694. * @param height defines the height of the clear rectangle
  30695. */
  30696. enableScissor(x: number, y: number, width: number, height: number): void;
  30697. /**
  30698. * Disable previously set scissor test rectangle
  30699. */
  30700. disableScissor(): void;
  30701. private _viewportCached;
  30702. /** @hidden */
  30703. _viewport(x: number, y: number, width: number, height: number): void;
  30704. /**
  30705. * Set the WebGL's viewport
  30706. * @param viewport defines the viewport element to be used
  30707. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30708. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30709. */
  30710. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30711. /**
  30712. * Directly set the WebGL Viewport
  30713. * @param x defines the x coordinate of the viewport (in screen space)
  30714. * @param y defines the y coordinate of the viewport (in screen space)
  30715. * @param width defines the width of the viewport (in screen space)
  30716. * @param height defines the height of the viewport (in screen space)
  30717. * @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
  30718. */
  30719. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30720. /**
  30721. * Begin a new frame
  30722. */
  30723. beginFrame(): void;
  30724. /**
  30725. * Enf the current frame
  30726. */
  30727. endFrame(): void;
  30728. /**
  30729. * Resize the view according to the canvas' size
  30730. */
  30731. resize(): void;
  30732. /**
  30733. * Force a specific size of the canvas
  30734. * @param width defines the new canvas' width
  30735. * @param height defines the new canvas' height
  30736. */
  30737. setSize(width: number, height: number): void;
  30738. /**
  30739. * Binds the frame buffer to the specified texture.
  30740. * @param texture The texture to render to or null for the default canvas
  30741. * @param faceIndex The face of the texture to render to in case of cube texture
  30742. * @param requiredWidth The width of the target to render to
  30743. * @param requiredHeight The height of the target to render to
  30744. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30745. * @param depthStencilTexture The depth stencil texture to use to render
  30746. * @param lodLevel defines le lod level to bind to the frame buffer
  30747. */
  30748. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30749. /** @hidden */
  30750. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30751. /**
  30752. * Unbind the current render target texture from the webGL context
  30753. * @param texture defines the render target texture to unbind
  30754. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30755. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30756. */
  30757. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30758. /**
  30759. * Force the mipmap generation for the given render target texture
  30760. * @param texture defines the render target texture to use
  30761. */
  30762. generateMipMapsForCubemap(texture: InternalTexture): void;
  30763. /**
  30764. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30765. */
  30766. flushFramebuffer(): void;
  30767. /**
  30768. * Unbind the current render target and bind the default framebuffer
  30769. */
  30770. restoreDefaultFramebuffer(): void;
  30771. /**
  30772. * Create an uniform buffer
  30773. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30774. * @param elements defines the content of the uniform buffer
  30775. * @returns the webGL uniform buffer
  30776. */
  30777. createUniformBuffer(elements: FloatArray): DataBuffer;
  30778. /**
  30779. * Create a dynamic uniform buffer
  30780. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30781. * @param elements defines the content of the uniform buffer
  30782. * @returns the webGL uniform buffer
  30783. */
  30784. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30785. /**
  30786. * Update an existing uniform buffer
  30787. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30788. * @param uniformBuffer defines the target uniform buffer
  30789. * @param elements defines the content to update
  30790. * @param offset defines the offset in the uniform buffer where update should start
  30791. * @param count defines the size of the data to update
  30792. */
  30793. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30794. private _resetVertexBufferBinding;
  30795. /**
  30796. * Creates a vertex buffer
  30797. * @param data the data for the vertex buffer
  30798. * @returns the new WebGL static buffer
  30799. */
  30800. createVertexBuffer(data: DataArray): DataBuffer;
  30801. private _createVertexBuffer;
  30802. /**
  30803. * Creates a dynamic vertex buffer
  30804. * @param data the data for the dynamic vertex buffer
  30805. * @returns the new WebGL dynamic buffer
  30806. */
  30807. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30808. /**
  30809. * Update a dynamic index buffer
  30810. * @param indexBuffer defines the target index buffer
  30811. * @param indices defines the data to update
  30812. * @param offset defines the offset in the target index buffer where update should start
  30813. */
  30814. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30815. /**
  30816. * Updates a dynamic vertex buffer.
  30817. * @param vertexBuffer the vertex buffer to update
  30818. * @param data the data used to update the vertex buffer
  30819. * @param byteOffset the byte offset of the data
  30820. * @param byteLength the byte length of the data
  30821. */
  30822. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30823. private _resetIndexBufferBinding;
  30824. /**
  30825. * Creates a new index buffer
  30826. * @param indices defines the content of the index buffer
  30827. * @param updatable defines if the index buffer must be updatable
  30828. * @returns a new webGL buffer
  30829. */
  30830. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30831. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30832. /**
  30833. * Bind a webGL buffer to the webGL context
  30834. * @param buffer defines the buffer to bind
  30835. */
  30836. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30837. /**
  30838. * Bind an uniform buffer to the current webGL context
  30839. * @param buffer defines the buffer to bind
  30840. */
  30841. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30842. /**
  30843. * Bind a buffer to the current webGL context at a given location
  30844. * @param buffer defines the buffer to bind
  30845. * @param location defines the index where to bind the buffer
  30846. */
  30847. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30848. /**
  30849. * Bind a specific block at a given index in a specific shader program
  30850. * @param pipelineContext defines the pipeline context to use
  30851. * @param blockName defines the block name
  30852. * @param index defines the index where to bind the block
  30853. */
  30854. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30855. private bindIndexBuffer;
  30856. private bindBuffer;
  30857. /**
  30858. * update the bound buffer with the given data
  30859. * @param data defines the data to update
  30860. */
  30861. updateArrayBuffer(data: Float32Array): void;
  30862. private _vertexAttribPointer;
  30863. private _bindIndexBufferWithCache;
  30864. private _bindVertexBuffersAttributes;
  30865. /**
  30866. * Records a vertex array object
  30867. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30868. * @param vertexBuffers defines the list of vertex buffers to store
  30869. * @param indexBuffer defines the index buffer to store
  30870. * @param effect defines the effect to store
  30871. * @returns the new vertex array object
  30872. */
  30873. recordVertexArrayObject(vertexBuffers: {
  30874. [key: string]: VertexBuffer;
  30875. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30876. /**
  30877. * Bind a specific vertex array object
  30878. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30879. * @param vertexArrayObject defines the vertex array object to bind
  30880. * @param indexBuffer defines the index buffer to bind
  30881. */
  30882. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30883. /**
  30884. * Bind webGl buffers directly to the webGL context
  30885. * @param vertexBuffer defines the vertex buffer to bind
  30886. * @param indexBuffer defines the index buffer to bind
  30887. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30888. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30889. * @param effect defines the effect associated with the vertex buffer
  30890. */
  30891. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30892. private _unbindVertexArrayObject;
  30893. /**
  30894. * Bind a list of vertex buffers to the webGL context
  30895. * @param vertexBuffers defines the list of vertex buffers to bind
  30896. * @param indexBuffer defines the index buffer to bind
  30897. * @param effect defines the effect associated with the vertex buffers
  30898. */
  30899. bindBuffers(vertexBuffers: {
  30900. [key: string]: Nullable<VertexBuffer>;
  30901. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30902. /**
  30903. * Unbind all instance attributes
  30904. */
  30905. unbindInstanceAttributes(): void;
  30906. /**
  30907. * Release and free the memory of a vertex array object
  30908. * @param vao defines the vertex array object to delete
  30909. */
  30910. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30911. /** @hidden */
  30912. _releaseBuffer(buffer: DataBuffer): boolean;
  30913. protected _deleteBuffer(buffer: DataBuffer): void;
  30914. /**
  30915. * Creates a webGL buffer to use with instanciation
  30916. * @param capacity defines the size of the buffer
  30917. * @returns the webGL buffer
  30918. */
  30919. createInstancesBuffer(capacity: number): DataBuffer;
  30920. /**
  30921. * Delete a webGL buffer used with instanciation
  30922. * @param buffer defines the webGL buffer to delete
  30923. */
  30924. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30925. /**
  30926. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30927. * @param instancesBuffer defines the webGL buffer to update and bind
  30928. * @param data defines the data to store in the buffer
  30929. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30930. */
  30931. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30932. /**
  30933. * Apply all cached states (depth, culling, stencil and alpha)
  30934. */
  30935. applyStates(): void;
  30936. /**
  30937. * Send a draw order
  30938. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30939. * @param indexStart defines the starting index
  30940. * @param indexCount defines the number of index to draw
  30941. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30942. */
  30943. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30944. /**
  30945. * Draw a list of points
  30946. * @param verticesStart defines the index of first vertex to draw
  30947. * @param verticesCount defines the count of vertices to draw
  30948. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30949. */
  30950. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30951. /**
  30952. * Draw a list of unindexed primitives
  30953. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30954. * @param verticesStart defines the index of first vertex to draw
  30955. * @param verticesCount defines the count of vertices to draw
  30956. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30957. */
  30958. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30959. /**
  30960. * Draw a list of indexed primitives
  30961. * @param fillMode defines the primitive to use
  30962. * @param indexStart defines the starting index
  30963. * @param indexCount defines the number of index to draw
  30964. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30965. */
  30966. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30967. /**
  30968. * Draw a list of unindexed primitives
  30969. * @param fillMode defines the primitive to use
  30970. * @param verticesStart defines the index of first vertex to draw
  30971. * @param verticesCount defines the count of vertices to draw
  30972. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30973. */
  30974. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30975. private _drawMode;
  30976. /** @hidden */
  30977. _releaseEffect(effect: Effect): void;
  30978. /** @hidden */
  30979. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30980. /**
  30981. * Create a new effect (used to store vertex/fragment shaders)
  30982. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30983. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30984. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30985. * @param samplers defines an array of string used to represent textures
  30986. * @param defines defines the string containing the defines to use to compile the shaders
  30987. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30988. * @param onCompiled defines a function to call when the effect creation is successful
  30989. * @param onError defines a function to call when the effect creation has failed
  30990. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30991. * @returns the new Effect
  30992. */
  30993. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30994. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30995. private _compileShader;
  30996. private _compileRawShader;
  30997. /**
  30998. * Directly creates a webGL program
  30999. * @param pipelineContext defines the pipeline context to attach to
  31000. * @param vertexCode defines the vertex shader code to use
  31001. * @param fragmentCode defines the fragment shader code to use
  31002. * @param context defines the webGL context to use (if not set, the current one will be used)
  31003. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31004. * @returns the new webGL program
  31005. */
  31006. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31007. /**
  31008. * Creates a webGL program
  31009. * @param pipelineContext defines the pipeline context to attach to
  31010. * @param vertexCode defines the vertex shader code to use
  31011. * @param fragmentCode defines the fragment shader code to use
  31012. * @param defines defines the string containing the defines to use to compile the shaders
  31013. * @param context defines the webGL context to use (if not set, the current one will be used)
  31014. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31015. * @returns the new webGL program
  31016. */
  31017. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31018. /**
  31019. * Creates a new pipeline context
  31020. * @returns the new pipeline
  31021. */
  31022. createPipelineContext(): IPipelineContext;
  31023. private _createShaderProgram;
  31024. private _finalizePipelineContext;
  31025. /** @hidden */
  31026. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31027. /** @hidden */
  31028. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31029. /** @hidden */
  31030. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31031. /**
  31032. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31033. * @param pipelineContext defines the pipeline context to use
  31034. * @param uniformsNames defines the list of uniform names
  31035. * @returns an array of webGL uniform locations
  31036. */
  31037. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31038. /**
  31039. * Gets the lsit of active attributes for a given webGL program
  31040. * @param pipelineContext defines the pipeline context to use
  31041. * @param attributesNames defines the list of attribute names to get
  31042. * @returns an array of indices indicating the offset of each attribute
  31043. */
  31044. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31045. /**
  31046. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31047. * @param effect defines the effect to activate
  31048. */
  31049. enableEffect(effect: Nullable<Effect>): void;
  31050. /**
  31051. * Set the value of an uniform to an array of int32
  31052. * @param uniform defines the webGL uniform location where to store the value
  31053. * @param array defines the array of int32 to store
  31054. */
  31055. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31056. /**
  31057. * Set the value of an uniform to an array of int32 (stored as vec2)
  31058. * @param uniform defines the webGL uniform location where to store the value
  31059. * @param array defines the array of int32 to store
  31060. */
  31061. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31062. /**
  31063. * Set the value of an uniform to an array of int32 (stored as vec3)
  31064. * @param uniform defines the webGL uniform location where to store the value
  31065. * @param array defines the array of int32 to store
  31066. */
  31067. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31068. /**
  31069. * Set the value of an uniform to an array of int32 (stored as vec4)
  31070. * @param uniform defines the webGL uniform location where to store the value
  31071. * @param array defines the array of int32 to store
  31072. */
  31073. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31074. /**
  31075. * Set the value of an uniform to an array of float32
  31076. * @param uniform defines the webGL uniform location where to store the value
  31077. * @param array defines the array of float32 to store
  31078. */
  31079. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31080. /**
  31081. * Set the value of an uniform to an array of float32 (stored as vec2)
  31082. * @param uniform defines the webGL uniform location where to store the value
  31083. * @param array defines the array of float32 to store
  31084. */
  31085. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31086. /**
  31087. * Set the value of an uniform to an array of float32 (stored as vec3)
  31088. * @param uniform defines the webGL uniform location where to store the value
  31089. * @param array defines the array of float32 to store
  31090. */
  31091. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31092. /**
  31093. * Set the value of an uniform to an array of float32 (stored as vec4)
  31094. * @param uniform defines the webGL uniform location where to store the value
  31095. * @param array defines the array of float32 to store
  31096. */
  31097. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31098. /**
  31099. * Set the value of an uniform to an array of number
  31100. * @param uniform defines the webGL uniform location where to store the value
  31101. * @param array defines the array of number to store
  31102. */
  31103. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31104. /**
  31105. * Set the value of an uniform to an array of number (stored as vec2)
  31106. * @param uniform defines the webGL uniform location where to store the value
  31107. * @param array defines the array of number to store
  31108. */
  31109. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31110. /**
  31111. * Set the value of an uniform to an array of number (stored as vec3)
  31112. * @param uniform defines the webGL uniform location where to store the value
  31113. * @param array defines the array of number to store
  31114. */
  31115. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31116. /**
  31117. * Set the value of an uniform to an array of number (stored as vec4)
  31118. * @param uniform defines the webGL uniform location where to store the value
  31119. * @param array defines the array of number to store
  31120. */
  31121. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31122. /**
  31123. * Set the value of an uniform to an array of float32 (stored as matrices)
  31124. * @param uniform defines the webGL uniform location where to store the value
  31125. * @param matrices defines the array of float32 to store
  31126. */
  31127. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31128. /**
  31129. * Set the value of an uniform to a matrix (3x3)
  31130. * @param uniform defines the webGL uniform location where to store the value
  31131. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31132. */
  31133. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31134. /**
  31135. * Set the value of an uniform to a matrix (2x2)
  31136. * @param uniform defines the webGL uniform location where to store the value
  31137. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31138. */
  31139. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31140. /**
  31141. * Set the value of an uniform to a number (int)
  31142. * @param uniform defines the webGL uniform location where to store the value
  31143. * @param value defines the int number to store
  31144. */
  31145. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31146. /**
  31147. * Set the value of an uniform to a number (float)
  31148. * @param uniform defines the webGL uniform location where to store the value
  31149. * @param value defines the float number to store
  31150. */
  31151. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31152. /**
  31153. * Set the value of an uniform to a vec2
  31154. * @param uniform defines the webGL uniform location where to store the value
  31155. * @param x defines the 1st component of the value
  31156. * @param y defines the 2nd component of the value
  31157. */
  31158. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31159. /**
  31160. * Set the value of an uniform to a vec3
  31161. * @param uniform defines the webGL uniform location where to store the value
  31162. * @param x defines the 1st component of the value
  31163. * @param y defines the 2nd component of the value
  31164. * @param z defines the 3rd component of the value
  31165. */
  31166. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31167. /**
  31168. * Set the value of an uniform to a boolean
  31169. * @param uniform defines the webGL uniform location where to store the value
  31170. * @param bool defines the boolean to store
  31171. */
  31172. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31173. /**
  31174. * Set the value of an uniform to a vec4
  31175. * @param uniform defines the webGL uniform location where to store the value
  31176. * @param x defines the 1st component of the value
  31177. * @param y defines the 2nd component of the value
  31178. * @param z defines the 3rd component of the value
  31179. * @param w defines the 4th component of the value
  31180. */
  31181. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31182. /**
  31183. * Sets a Color4 on a uniform variable
  31184. * @param uniform defines the uniform location
  31185. * @param color4 defines the value to be set
  31186. */
  31187. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31188. /**
  31189. * Set various states to the webGL context
  31190. * @param culling defines backface culling state
  31191. * @param zOffset defines the value to apply to zOffset (0 by default)
  31192. * @param force defines if states must be applied even if cache is up to date
  31193. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31194. */
  31195. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31196. /**
  31197. * Set the z offset to apply to current rendering
  31198. * @param value defines the offset to apply
  31199. */
  31200. setZOffset(value: number): void;
  31201. /**
  31202. * Gets the current value of the zOffset
  31203. * @returns the current zOffset state
  31204. */
  31205. getZOffset(): number;
  31206. /**
  31207. * Enable or disable depth buffering
  31208. * @param enable defines the state to set
  31209. */
  31210. setDepthBuffer(enable: boolean): void;
  31211. /**
  31212. * Gets a boolean indicating if depth writing is enabled
  31213. * @returns the current depth writing state
  31214. */
  31215. getDepthWrite(): boolean;
  31216. /**
  31217. * Enable or disable depth writing
  31218. * @param enable defines the state to set
  31219. */
  31220. setDepthWrite(enable: boolean): void;
  31221. /**
  31222. * Enable or disable color writing
  31223. * @param enable defines the state to set
  31224. */
  31225. setColorWrite(enable: boolean): void;
  31226. /**
  31227. * Gets a boolean indicating if color writing is enabled
  31228. * @returns the current color writing state
  31229. */
  31230. getColorWrite(): boolean;
  31231. /**
  31232. * Sets alpha constants used by some alpha blending modes
  31233. * @param r defines the red component
  31234. * @param g defines the green component
  31235. * @param b defines the blue component
  31236. * @param a defines the alpha component
  31237. */
  31238. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31239. /**
  31240. * Sets the current alpha mode
  31241. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31242. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31243. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31244. */
  31245. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31246. /**
  31247. * Gets the current alpha mode
  31248. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31249. * @returns the current alpha mode
  31250. */
  31251. getAlphaMode(): number;
  31252. /**
  31253. * Sets the current alpha equation
  31254. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31255. */
  31256. setAlphaEquation(equation: number): void;
  31257. /**
  31258. * Gets the current alpha equation.
  31259. * @returns the current alpha equation
  31260. */
  31261. getAlphaEquation(): number;
  31262. /**
  31263. * Clears the list of texture accessible through engine.
  31264. * This can help preventing texture load conflict due to name collision.
  31265. */
  31266. clearInternalTexturesCache(): void;
  31267. /**
  31268. * Force the entire cache to be cleared
  31269. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31270. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31271. */
  31272. wipeCaches(bruteForce?: boolean): void;
  31273. /**
  31274. * Set the compressed texture format to use, based on the formats you have, and the formats
  31275. * supported by the hardware / browser.
  31276. *
  31277. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31278. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31279. * to API arguments needed to compressed textures. This puts the burden on the container
  31280. * generator to house the arcane code for determining these for current & future formats.
  31281. *
  31282. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31283. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31284. *
  31285. * Note: The result of this call is not taken into account when a texture is base64.
  31286. *
  31287. * @param formatsAvailable defines the list of those format families you have created
  31288. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31289. *
  31290. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31291. * @returns The extension selected.
  31292. */
  31293. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31294. /** @hidden */
  31295. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31296. min: number;
  31297. mag: number;
  31298. };
  31299. /** @hidden */
  31300. _createTexture(): WebGLTexture;
  31301. /**
  31302. * Usually called from Texture.ts.
  31303. * Passed information to create a WebGLTexture
  31304. * @param urlArg defines a value which contains one of the following:
  31305. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31306. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31307. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31308. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31309. * @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)
  31310. * @param scene needed for loading to the correct scene
  31311. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31312. * @param onLoad optional callback to be called upon successful completion
  31313. * @param onError optional callback to be called upon failure
  31314. * @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
  31315. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31316. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31317. * @param forcedExtension defines the extension to use to pick the right loader
  31318. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31319. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31320. */
  31321. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  31322. /**
  31323. * @hidden
  31324. * Rescales a texture
  31325. * @param source input texutre
  31326. * @param destination destination texture
  31327. * @param scene scene to use to render the resize
  31328. * @param internalFormat format to use when resizing
  31329. * @param onComplete callback to be called when resize has completed
  31330. */
  31331. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  31332. private _unpackFlipYCached;
  31333. /**
  31334. * In case you are sharing the context with other applications, it might
  31335. * be interested to not cache the unpack flip y state to ensure a consistent
  31336. * value would be set.
  31337. */
  31338. enableUnpackFlipYCached: boolean;
  31339. /** @hidden */
  31340. _unpackFlipY(value: boolean): void;
  31341. /** @hidden */
  31342. _getUnpackAlignement(): number;
  31343. /**
  31344. * Creates a dynamic texture
  31345. * @param width defines the width of the texture
  31346. * @param height defines the height of the texture
  31347. * @param generateMipMaps defines if the engine should generate the mip levels
  31348. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31349. * @returns the dynamic texture inside an InternalTexture
  31350. */
  31351. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  31352. /**
  31353. * Update the sampling mode of a given texture
  31354. * @param samplingMode defines the required sampling mode
  31355. * @param texture defines the texture to update
  31356. */
  31357. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31358. /**
  31359. * Update the content of a dynamic texture
  31360. * @param texture defines the texture to update
  31361. * @param canvas defines the canvas containing the source
  31362. * @param invertY defines if data must be stored with Y axis inverted
  31363. * @param premulAlpha defines if alpha is stored as premultiplied
  31364. * @param format defines the format of the data
  31365. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31366. */
  31367. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  31368. /**
  31369. * Update a video texture
  31370. * @param texture defines the texture to update
  31371. * @param video defines the video element to use
  31372. * @param invertY defines if data must be stored with Y axis inverted
  31373. */
  31374. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31375. /**
  31376. * Updates a depth texture Comparison Mode and Function.
  31377. * If the comparison Function is equal to 0, the mode will be set to none.
  31378. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31379. * @param texture The texture to set the comparison function for
  31380. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31381. */
  31382. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31383. /** @hidden */
  31384. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31385. width: number;
  31386. height: number;
  31387. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31388. /**
  31389. * Creates a depth stencil texture.
  31390. * This is only available in WebGL 2 or with the depth texture extension available.
  31391. * @param size The size of face edge in the texture.
  31392. * @param options The options defining the texture.
  31393. * @returns The texture
  31394. */
  31395. createDepthStencilTexture(size: number | {
  31396. width: number;
  31397. height: number;
  31398. }, options: DepthTextureCreationOptions): InternalTexture;
  31399. /**
  31400. * Creates a depth stencil texture.
  31401. * This is only available in WebGL 2 or with the depth texture extension available.
  31402. * @param size The size of face edge in the texture.
  31403. * @param options The options defining the texture.
  31404. * @returns The texture
  31405. */
  31406. private _createDepthStencilTexture;
  31407. /**
  31408. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31409. * @param renderTarget The render target to set the frame buffer for
  31410. */
  31411. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31412. /**
  31413. * Creates a new render target texture
  31414. * @param size defines the size of the texture
  31415. * @param options defines the options used to create the texture
  31416. * @returns a new render target texture stored in an InternalTexture
  31417. */
  31418. createRenderTargetTexture(size: number | {
  31419. width: number;
  31420. height: number;
  31421. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31422. /** @hidden */
  31423. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31424. /**
  31425. * Updates the sample count of a render target texture
  31426. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31427. * @param texture defines the texture to update
  31428. * @param samples defines the sample count to set
  31429. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31430. */
  31431. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31432. /** @hidden */
  31433. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31434. /** @hidden */
  31435. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31436. /** @hidden */
  31437. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31438. /** @hidden */
  31439. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31440. /**
  31441. * @hidden
  31442. */
  31443. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31444. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31445. private _prepareWebGLTexture;
  31446. /** @hidden */
  31447. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31448. /** @hidden */
  31449. _releaseFramebufferObjects(texture: InternalTexture): void;
  31450. /** @hidden */
  31451. _releaseTexture(texture: InternalTexture): void;
  31452. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31453. protected _setProgram(program: WebGLProgram): void;
  31454. protected _boundUniforms: {
  31455. [key: number]: WebGLUniformLocation;
  31456. };
  31457. /**
  31458. * Binds an effect to the webGL context
  31459. * @param effect defines the effect to bind
  31460. */
  31461. bindSamplers(effect: Effect): void;
  31462. private _activateCurrentTexture;
  31463. /** @hidden */
  31464. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31465. /** @hidden */
  31466. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31467. /**
  31468. * Sets a texture to the webGL context from a postprocess
  31469. * @param channel defines the channel to use
  31470. * @param postProcess defines the source postprocess
  31471. */
  31472. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31473. /**
  31474. * Binds the output of the passed in post process to the texture channel specified
  31475. * @param channel The channel the texture should be bound to
  31476. * @param postProcess The post process which's output should be bound
  31477. */
  31478. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31479. /**
  31480. * Unbind all textures from the webGL context
  31481. */
  31482. unbindAllTextures(): void;
  31483. /**
  31484. * Sets a texture to the according uniform.
  31485. * @param channel The texture channel
  31486. * @param uniform The uniform to set
  31487. * @param texture The texture to apply
  31488. */
  31489. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31490. /**
  31491. * Sets a depth stencil texture from a render target to the according uniform.
  31492. * @param channel The texture channel
  31493. * @param uniform The uniform to set
  31494. * @param texture The render target texture containing the depth stencil texture to apply
  31495. */
  31496. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31497. private _bindSamplerUniformToChannel;
  31498. private _getTextureWrapMode;
  31499. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31500. /**
  31501. * Sets an array of texture to the webGL context
  31502. * @param channel defines the channel where the texture array must be set
  31503. * @param uniform defines the associated uniform location
  31504. * @param textures defines the array of textures to bind
  31505. */
  31506. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31507. /** @hidden */
  31508. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31509. private _setTextureParameterFloat;
  31510. private _setTextureParameterInteger;
  31511. /**
  31512. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31513. * @param x defines the x coordinate of the rectangle where pixels must be read
  31514. * @param y defines the y coordinate of the rectangle where pixels must be read
  31515. * @param width defines the width of the rectangle where pixels must be read
  31516. * @param height defines the height of the rectangle where pixels must be read
  31517. * @returns a Uint8Array containing RGBA colors
  31518. */
  31519. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31520. /**
  31521. * Unbind all vertex attributes from the webGL context
  31522. */
  31523. unbindAllAttributes(): void;
  31524. /**
  31525. * 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
  31526. */
  31527. releaseEffects(): void;
  31528. /**
  31529. * Dispose and release all associated resources
  31530. */
  31531. dispose(): void;
  31532. /**
  31533. * Display the loading screen
  31534. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31535. */
  31536. displayLoadingUI(): void;
  31537. /**
  31538. * Hide the loading screen
  31539. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31540. */
  31541. hideLoadingUI(): void;
  31542. /**
  31543. * Gets the current loading screen object
  31544. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31545. */
  31546. /**
  31547. * Sets the current loading screen object
  31548. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31549. */
  31550. loadingScreen: ILoadingScreen;
  31551. /**
  31552. * Sets the current loading screen text
  31553. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31554. */
  31555. loadingUIText: string;
  31556. /**
  31557. * Sets the current loading screen background color
  31558. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31559. */
  31560. loadingUIBackgroundColor: string;
  31561. /**
  31562. * Attach a new callback raised when context lost event is fired
  31563. * @param callback defines the callback to call
  31564. */
  31565. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31566. /**
  31567. * Attach a new callback raised when context restored event is fired
  31568. * @param callback defines the callback to call
  31569. */
  31570. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31571. /**
  31572. * Gets the source code of the vertex shader associated with a specific webGL program
  31573. * @param program defines the program to use
  31574. * @returns a string containing the source code of the vertex shader associated with the program
  31575. */
  31576. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31577. /**
  31578. * Gets the source code of the fragment shader associated with a specific webGL program
  31579. * @param program defines the program to use
  31580. * @returns a string containing the source code of the fragment shader associated with the program
  31581. */
  31582. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31583. /**
  31584. * Get the current error code of the webGL context
  31585. * @returns the error code
  31586. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31587. */
  31588. getError(): number;
  31589. /**
  31590. * Gets the current framerate
  31591. * @returns a number representing the framerate
  31592. */
  31593. getFps(): number;
  31594. /**
  31595. * Gets the time spent between current and previous frame
  31596. * @returns a number representing the delta time in ms
  31597. */
  31598. getDeltaTime(): number;
  31599. private _measureFps;
  31600. /** @hidden */
  31601. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31602. private _canRenderToFloatFramebuffer;
  31603. private _canRenderToHalfFloatFramebuffer;
  31604. private _canRenderToFramebuffer;
  31605. /** @hidden */
  31606. _getWebGLTextureType(type: number): number;
  31607. /** @hidden */
  31608. _getInternalFormat(format: number): number;
  31609. /** @hidden */
  31610. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31611. /** @hidden */
  31612. _getRGBAMultiSampleBufferFormat(type: number): number;
  31613. /** @hidden */
  31614. _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;
  31615. /** @hidden */
  31616. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31617. /**
  31618. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31619. * @returns true if the engine can be created
  31620. * @ignorenaming
  31621. */
  31622. static isSupported(): boolean;
  31623. /**
  31624. * Find the next highest power of two.
  31625. * @param x Number to start search from.
  31626. * @return Next highest power of two.
  31627. */
  31628. static CeilingPOT(x: number): number;
  31629. /**
  31630. * Find the next lowest power of two.
  31631. * @param x Number to start search from.
  31632. * @return Next lowest power of two.
  31633. */
  31634. static FloorPOT(x: number): number;
  31635. /**
  31636. * Find the nearest power of two.
  31637. * @param x Number to start search from.
  31638. * @return Next nearest power of two.
  31639. */
  31640. static NearestPOT(x: number): number;
  31641. /**
  31642. * Get the closest exponent of two
  31643. * @param value defines the value to approximate
  31644. * @param max defines the maximum value to return
  31645. * @param mode defines how to define the closest value
  31646. * @returns closest exponent of two of the given value
  31647. */
  31648. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31649. /**
  31650. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31651. * @param func - the function to be called
  31652. * @param requester - the object that will request the next frame. Falls back to window.
  31653. * @returns frame number
  31654. */
  31655. static QueueNewFrame(func: () => void, requester?: any): number;
  31656. /**
  31657. * Ask the browser to promote the current element to pointerlock mode
  31658. * @param element defines the DOM element to promote
  31659. */
  31660. static _RequestPointerlock(element: HTMLElement): void;
  31661. /**
  31662. * Asks the browser to exit pointerlock mode
  31663. */
  31664. static _ExitPointerlock(): void;
  31665. /**
  31666. * Ask the browser to promote the current element to fullscreen rendering mode
  31667. * @param element defines the DOM element to promote
  31668. */
  31669. static _RequestFullscreen(element: HTMLElement): void;
  31670. /**
  31671. * Asks the browser to exit fullscreen mode
  31672. */
  31673. static _ExitFullscreen(): void;
  31674. }
  31675. }
  31676. declare module BABYLON {
  31677. /**
  31678. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31679. * during the life time of the application.
  31680. */
  31681. export class EngineStore {
  31682. /** Gets the list of created engines */
  31683. static Instances: Engine[];
  31684. /** @hidden */
  31685. static _LastCreatedScene: Nullable<Scene>;
  31686. /**
  31687. * Gets the latest created engine
  31688. */
  31689. static readonly LastCreatedEngine: Nullable<Engine>;
  31690. /**
  31691. * Gets the latest created scene
  31692. */
  31693. static readonly LastCreatedScene: Nullable<Scene>;
  31694. /**
  31695. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31696. * @ignorenaming
  31697. */
  31698. static UseFallbackTexture: boolean;
  31699. /**
  31700. * Texture content used if a texture cannot loaded
  31701. * @ignorenaming
  31702. */
  31703. static FallbackTexture: string;
  31704. }
  31705. }
  31706. declare module BABYLON {
  31707. /**
  31708. * Helper class that provides a small promise polyfill
  31709. */
  31710. export class PromisePolyfill {
  31711. /**
  31712. * Static function used to check if the polyfill is required
  31713. * If this is the case then the function will inject the polyfill to window.Promise
  31714. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31715. */
  31716. static Apply(force?: boolean): void;
  31717. }
  31718. }
  31719. declare module BABYLON {
  31720. /**
  31721. * Interface for screenshot methods with describe argument called `size` as object with options
  31722. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31723. */
  31724. export interface IScreenshotSize {
  31725. /**
  31726. * number in pixels for canvas height
  31727. */
  31728. height?: number;
  31729. /**
  31730. * multiplier allowing render at a higher or lower resolution
  31731. * If value is defined then height and width will be ignored and taken from camera
  31732. */
  31733. precision?: number;
  31734. /**
  31735. * number in pixels for canvas width
  31736. */
  31737. width?: number;
  31738. }
  31739. }
  31740. declare module BABYLON {
  31741. interface IColor4Like {
  31742. r: float;
  31743. g: float;
  31744. b: float;
  31745. a: float;
  31746. }
  31747. /**
  31748. * Class containing a set of static utilities functions
  31749. */
  31750. export class Tools {
  31751. /**
  31752. * Gets or sets the base URL to use to load assets
  31753. */
  31754. static BaseUrl: string;
  31755. /**
  31756. * Enable/Disable Custom HTTP Request Headers globally.
  31757. * default = false
  31758. * @see CustomRequestHeaders
  31759. */
  31760. static UseCustomRequestHeaders: boolean;
  31761. /**
  31762. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31763. * i.e. when loading files, where the server/service expects an Authorization header
  31764. */
  31765. static CustomRequestHeaders: {
  31766. [key: string]: string;
  31767. };
  31768. /**
  31769. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31770. */
  31771. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31772. /**
  31773. * Default behaviour for cors in the application.
  31774. * It can be a string if the expected behavior is identical in the entire app.
  31775. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31776. */
  31777. static CorsBehavior: string | ((url: string | string[]) => string);
  31778. /**
  31779. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31780. * @ignorenaming
  31781. */
  31782. static UseFallbackTexture: boolean;
  31783. /**
  31784. * Use this object to register external classes like custom textures or material
  31785. * to allow the laoders to instantiate them
  31786. */
  31787. static RegisteredExternalClasses: {
  31788. [key: string]: Object;
  31789. };
  31790. /**
  31791. * Texture content used if a texture cannot loaded
  31792. * @ignorenaming
  31793. */
  31794. static fallbackTexture: string;
  31795. /**
  31796. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31797. * @param u defines the coordinate on X axis
  31798. * @param v defines the coordinate on Y axis
  31799. * @param width defines the width of the source data
  31800. * @param height defines the height of the source data
  31801. * @param pixels defines the source byte array
  31802. * @param color defines the output color
  31803. */
  31804. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31805. /**
  31806. * Interpolates between a and b via alpha
  31807. * @param a The lower value (returned when alpha = 0)
  31808. * @param b The upper value (returned when alpha = 1)
  31809. * @param alpha The interpolation-factor
  31810. * @return The mixed value
  31811. */
  31812. static Mix(a: number, b: number, alpha: number): number;
  31813. /**
  31814. * Tries to instantiate a new object from a given class name
  31815. * @param className defines the class name to instantiate
  31816. * @returns the new object or null if the system was not able to do the instantiation
  31817. */
  31818. static Instantiate(className: string): any;
  31819. /**
  31820. * Provides a slice function that will work even on IE
  31821. * @param data defines the array to slice
  31822. * @param start defines the start of the data (optional)
  31823. * @param end defines the end of the data (optional)
  31824. * @returns the new sliced array
  31825. */
  31826. static Slice<T>(data: T, start?: number, end?: number): T;
  31827. /**
  31828. * Polyfill for setImmediate
  31829. * @param action defines the action to execute after the current execution block
  31830. */
  31831. static SetImmediate(action: () => void): void;
  31832. /**
  31833. * Function indicating if a number is an exponent of 2
  31834. * @param value defines the value to test
  31835. * @returns true if the value is an exponent of 2
  31836. */
  31837. static IsExponentOfTwo(value: number): boolean;
  31838. private static _tmpFloatArray;
  31839. /**
  31840. * Returns the nearest 32-bit single precision float representation of a Number
  31841. * @param value A Number. If the parameter is of a different type, it will get converted
  31842. * to a number or to NaN if it cannot be converted
  31843. * @returns number
  31844. */
  31845. static FloatRound(value: number): number;
  31846. /**
  31847. * Extracts the filename from a path
  31848. * @param path defines the path to use
  31849. * @returns the filename
  31850. */
  31851. static GetFilename(path: string): string;
  31852. /**
  31853. * Extracts the "folder" part of a path (everything before the filename).
  31854. * @param uri The URI to extract the info from
  31855. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31856. * @returns The "folder" part of the path
  31857. */
  31858. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31859. /**
  31860. * Extracts text content from a DOM element hierarchy
  31861. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31862. */
  31863. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31864. /**
  31865. * Convert an angle in radians to degrees
  31866. * @param angle defines the angle to convert
  31867. * @returns the angle in degrees
  31868. */
  31869. static ToDegrees(angle: number): number;
  31870. /**
  31871. * Convert an angle in degrees to radians
  31872. * @param angle defines the angle to convert
  31873. * @returns the angle in radians
  31874. */
  31875. static ToRadians(angle: number): number;
  31876. /**
  31877. * Encode a buffer to a base64 string
  31878. * @param buffer defines the buffer to encode
  31879. * @returns the encoded string
  31880. */
  31881. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31882. /**
  31883. * Returns an array if obj is not an array
  31884. * @param obj defines the object to evaluate as an array
  31885. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31886. * @returns either obj directly if obj is an array or a new array containing obj
  31887. */
  31888. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31889. /**
  31890. * Gets the pointer prefix to use
  31891. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31892. */
  31893. static GetPointerPrefix(): string;
  31894. /**
  31895. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31896. * @param url define the url we are trying
  31897. * @param element define the dom element where to configure the cors policy
  31898. */
  31899. static SetCorsBehavior(url: string | string[], element: {
  31900. crossOrigin: string | null;
  31901. }): void;
  31902. /**
  31903. * Removes unwanted characters from an url
  31904. * @param url defines the url to clean
  31905. * @returns the cleaned url
  31906. */
  31907. static CleanUrl(url: string): string;
  31908. /**
  31909. * Gets or sets a function used to pre-process url before using them to load assets
  31910. */
  31911. static PreprocessUrl: (url: string) => string;
  31912. /**
  31913. * Loads an image as an HTMLImageElement.
  31914. * @param input url string, ArrayBuffer, or Blob to load
  31915. * @param onLoad callback called when the image successfully loads
  31916. * @param onError callback called when the image fails to load
  31917. * @param offlineProvider offline provider for caching
  31918. * @returns the HTMLImageElement of the loaded image
  31919. */
  31920. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31921. /**
  31922. * Loads a file
  31923. * @param url url string, ArrayBuffer, or Blob to load
  31924. * @param onSuccess callback called when the file successfully loads
  31925. * @param onProgress callback called while file is loading (if the server supports this mode)
  31926. * @param offlineProvider defines the offline provider for caching
  31927. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31928. * @param onError callback called when the file fails to load
  31929. * @returns a file request object
  31930. */
  31931. 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;
  31932. /**
  31933. * Loads a file from a url
  31934. * @param url the file url to load
  31935. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31936. */
  31937. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31938. /**
  31939. * Load a script (identified by an url). When the url returns, the
  31940. * content of this file is added into a new script element, attached to the DOM (body element)
  31941. * @param scriptUrl defines the url of the script to laod
  31942. * @param onSuccess defines the callback called when the script is loaded
  31943. * @param onError defines the callback to call if an error occurs
  31944. * @param scriptId defines the id of the script element
  31945. */
  31946. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31947. /**
  31948. * Load an asynchronous script (identified by an url). When the url returns, the
  31949. * content of this file is added into a new script element, attached to the DOM (body element)
  31950. * @param scriptUrl defines the url of the script to laod
  31951. * @param scriptId defines the id of the script element
  31952. * @returns a promise request object
  31953. */
  31954. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31955. /**
  31956. * Loads a file from a blob
  31957. * @param fileToLoad defines the blob to use
  31958. * @param callback defines the callback to call when data is loaded
  31959. * @param progressCallback defines the callback to call during loading process
  31960. * @returns a file request object
  31961. */
  31962. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31963. /**
  31964. * Loads a file
  31965. * @param fileToLoad defines the file to load
  31966. * @param callback defines the callback to call when data is loaded
  31967. * @param progressCallBack defines the callback to call during loading process
  31968. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31969. * @returns a file request object
  31970. */
  31971. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31972. /**
  31973. * Creates a data url from a given string content
  31974. * @param content defines the content to convert
  31975. * @returns the new data url link
  31976. */
  31977. static FileAsURL(content: string): string;
  31978. /**
  31979. * Format the given number to a specific decimal format
  31980. * @param value defines the number to format
  31981. * @param decimals defines the number of decimals to use
  31982. * @returns the formatted string
  31983. */
  31984. static Format(value: number, decimals?: number): string;
  31985. /**
  31986. * Tries to copy an object by duplicating every property
  31987. * @param source defines the source object
  31988. * @param destination defines the target object
  31989. * @param doNotCopyList defines a list of properties to avoid
  31990. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31991. */
  31992. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31993. /**
  31994. * Gets a boolean indicating if the given object has no own property
  31995. * @param obj defines the object to test
  31996. * @returns true if object has no own property
  31997. */
  31998. static IsEmpty(obj: any): boolean;
  31999. /**
  32000. * Function used to register events at window level
  32001. * @param windowElement defines the Window object to use
  32002. * @param events defines the events to register
  32003. */
  32004. static RegisterTopRootEvents(windowElement: Window, events: {
  32005. name: string;
  32006. handler: Nullable<(e: FocusEvent) => any>;
  32007. }[]): void;
  32008. /**
  32009. * Function used to unregister events from window level
  32010. * @param windowElement defines the Window object to use
  32011. * @param events defines the events to unregister
  32012. */
  32013. static UnregisterTopRootEvents(windowElement: Window, events: {
  32014. name: string;
  32015. handler: Nullable<(e: FocusEvent) => any>;
  32016. }[]): void;
  32017. /**
  32018. * @ignore
  32019. */
  32020. static _ScreenshotCanvas: HTMLCanvasElement;
  32021. /**
  32022. * Dumps the current bound framebuffer
  32023. * @param width defines the rendering width
  32024. * @param height defines the rendering height
  32025. * @param engine defines the hosting engine
  32026. * @param successCallback defines the callback triggered once the data are available
  32027. * @param mimeType defines the mime type of the result
  32028. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32029. */
  32030. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32031. /**
  32032. * Converts the canvas data to blob.
  32033. * This acts as a polyfill for browsers not supporting the to blob function.
  32034. * @param canvas Defines the canvas to extract the data from
  32035. * @param successCallback Defines the callback triggered once the data are available
  32036. * @param mimeType Defines the mime type of the result
  32037. */
  32038. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32039. /**
  32040. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32041. * @param successCallback defines the callback triggered once the data are available
  32042. * @param mimeType defines the mime type of the result
  32043. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32044. */
  32045. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32046. /**
  32047. * Downloads a blob in the browser
  32048. * @param blob defines the blob to download
  32049. * @param fileName defines the name of the downloaded file
  32050. */
  32051. static Download(blob: Blob, fileName: string): void;
  32052. /**
  32053. * Captures a screenshot of the current rendering
  32054. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32055. * @param engine defines the rendering engine
  32056. * @param camera defines the source camera
  32057. * @param size This parameter can be set to a single number or to an object with the
  32058. * following (optional) properties: precision, width, height. If a single number is passed,
  32059. * it will be used for both width and height. If an object is passed, the screenshot size
  32060. * will be derived from the parameters. The precision property is a multiplier allowing
  32061. * rendering at a higher or lower resolution
  32062. * @param successCallback defines the callback receives a single parameter which contains the
  32063. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32064. * src parameter of an <img> to display it
  32065. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32066. * Check your browser for supported MIME types
  32067. */
  32068. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32069. /**
  32070. * Captures a screenshot of the current rendering
  32071. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32072. * @param engine defines the rendering engine
  32073. * @param camera defines the source camera
  32074. * @param size This parameter can be set to a single number or to an object with the
  32075. * following (optional) properties: precision, width, height. If a single number is passed,
  32076. * it will be used for both width and height. If an object is passed, the screenshot size
  32077. * will be derived from the parameters. The precision property is a multiplier allowing
  32078. * rendering at a higher or lower resolution
  32079. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32080. * Check your browser for supported MIME types
  32081. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32082. * to the src parameter of an <img> to display it
  32083. */
  32084. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32085. /**
  32086. * Generates an image screenshot from the specified camera.
  32087. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32088. * @param engine The engine to use for rendering
  32089. * @param camera The camera to use for rendering
  32090. * @param size This parameter can be set to a single number or to an object with the
  32091. * following (optional) properties: precision, width, height. If a single number is passed,
  32092. * it will be used for both width and height. If an object is passed, the screenshot size
  32093. * will be derived from the parameters. The precision property is a multiplier allowing
  32094. * rendering at a higher or lower resolution
  32095. * @param successCallback The callback receives a single parameter which contains the
  32096. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32097. * src parameter of an <img> to display it
  32098. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32099. * Check your browser for supported MIME types
  32100. * @param samples Texture samples (default: 1)
  32101. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32102. * @param fileName A name for for the downloaded file.
  32103. */
  32104. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32105. /**
  32106. * Generates an image screenshot from the specified camera.
  32107. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32108. * @param engine The engine to use for rendering
  32109. * @param camera The camera to use for rendering
  32110. * @param size This parameter can be set to a single number or to an object with the
  32111. * following (optional) properties: precision, width, height. If a single number is passed,
  32112. * it will be used for both width and height. If an object is passed, the screenshot size
  32113. * will be derived from the parameters. The precision property is a multiplier allowing
  32114. * rendering at a higher or lower resolution
  32115. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32116. * Check your browser for supported MIME types
  32117. * @param samples Texture samples (default: 1)
  32118. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32119. * @param fileName A name for for the downloaded file.
  32120. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32121. * to the src parameter of an <img> to display it
  32122. */
  32123. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32124. /**
  32125. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32126. * Be aware Math.random() could cause collisions, but:
  32127. * "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"
  32128. * @returns a pseudo random id
  32129. */
  32130. static RandomId(): string;
  32131. /**
  32132. * Test if the given uri is a base64 string
  32133. * @param uri The uri to test
  32134. * @return True if the uri is a base64 string or false otherwise
  32135. */
  32136. static IsBase64(uri: string): boolean;
  32137. /**
  32138. * Decode the given base64 uri.
  32139. * @param uri The uri to decode
  32140. * @return The decoded base64 data.
  32141. */
  32142. static DecodeBase64(uri: string): ArrayBuffer;
  32143. /**
  32144. * Gets the absolute url.
  32145. * @param url the input url
  32146. * @return the absolute url
  32147. */
  32148. static GetAbsoluteUrl(url: string): string;
  32149. /**
  32150. * No log
  32151. */
  32152. static readonly NoneLogLevel: number;
  32153. /**
  32154. * Only message logs
  32155. */
  32156. static readonly MessageLogLevel: number;
  32157. /**
  32158. * Only warning logs
  32159. */
  32160. static readonly WarningLogLevel: number;
  32161. /**
  32162. * Only error logs
  32163. */
  32164. static readonly ErrorLogLevel: number;
  32165. /**
  32166. * All logs
  32167. */
  32168. static readonly AllLogLevel: number;
  32169. /**
  32170. * Gets a value indicating the number of loading errors
  32171. * @ignorenaming
  32172. */
  32173. static readonly errorsCount: number;
  32174. /**
  32175. * Callback called when a new log is added
  32176. */
  32177. static OnNewCacheEntry: (entry: string) => void;
  32178. /**
  32179. * Log a message to the console
  32180. * @param message defines the message to log
  32181. */
  32182. static Log(message: string): void;
  32183. /**
  32184. * Write a warning message to the console
  32185. * @param message defines the message to log
  32186. */
  32187. static Warn(message: string): void;
  32188. /**
  32189. * Write an error message to the console
  32190. * @param message defines the message to log
  32191. */
  32192. static Error(message: string): void;
  32193. /**
  32194. * Gets current log cache (list of logs)
  32195. */
  32196. static readonly LogCache: string;
  32197. /**
  32198. * Clears the log cache
  32199. */
  32200. static ClearLogCache(): void;
  32201. /**
  32202. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32203. */
  32204. static LogLevels: number;
  32205. /**
  32206. * Checks if the window object exists
  32207. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32208. */
  32209. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32210. /**
  32211. * No performance log
  32212. */
  32213. static readonly PerformanceNoneLogLevel: number;
  32214. /**
  32215. * Use user marks to log performance
  32216. */
  32217. static readonly PerformanceUserMarkLogLevel: number;
  32218. /**
  32219. * Log performance to the console
  32220. */
  32221. static readonly PerformanceConsoleLogLevel: number;
  32222. private static _performance;
  32223. /**
  32224. * Sets the current performance log level
  32225. */
  32226. static PerformanceLogLevel: number;
  32227. private static _StartPerformanceCounterDisabled;
  32228. private static _EndPerformanceCounterDisabled;
  32229. private static _StartUserMark;
  32230. private static _EndUserMark;
  32231. private static _StartPerformanceConsole;
  32232. private static _EndPerformanceConsole;
  32233. /**
  32234. * Starts a performance counter
  32235. */
  32236. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32237. /**
  32238. * Ends a specific performance coutner
  32239. */
  32240. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32241. /**
  32242. * Gets either window.performance.now() if supported or Date.now() else
  32243. */
  32244. static readonly Now: number;
  32245. /**
  32246. * This method will return the name of the class used to create the instance of the given object.
  32247. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32248. * @param object the object to get the class name from
  32249. * @param isType defines if the object is actually a type
  32250. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32251. */
  32252. static GetClassName(object: any, isType?: boolean): string;
  32253. /**
  32254. * Gets the first element of an array satisfying a given predicate
  32255. * @param array defines the array to browse
  32256. * @param predicate defines the predicate to use
  32257. * @returns null if not found or the element
  32258. */
  32259. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32260. /**
  32261. * This method will return the name of the full name of the class, including its owning module (if any).
  32262. * 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).
  32263. * @param object the object to get the class name from
  32264. * @param isType defines if the object is actually a type
  32265. * @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.
  32266. * @ignorenaming
  32267. */
  32268. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32269. /**
  32270. * Returns a promise that resolves after the given amount of time.
  32271. * @param delay Number of milliseconds to delay
  32272. * @returns Promise that resolves after the given amount of time
  32273. */
  32274. static DelayAsync(delay: number): Promise<void>;
  32275. }
  32276. /**
  32277. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32278. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32279. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32280. * @param name The name of the class, case should be preserved
  32281. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32282. */
  32283. export function className(name: string, module?: string): (target: Object) => void;
  32284. /**
  32285. * An implementation of a loop for asynchronous functions.
  32286. */
  32287. export class AsyncLoop {
  32288. /**
  32289. * Defines the number of iterations for the loop
  32290. */
  32291. iterations: number;
  32292. /**
  32293. * Defines the current index of the loop.
  32294. */
  32295. index: number;
  32296. private _done;
  32297. private _fn;
  32298. private _successCallback;
  32299. /**
  32300. * Constructor.
  32301. * @param iterations the number of iterations.
  32302. * @param func the function to run each iteration
  32303. * @param successCallback the callback that will be called upon succesful execution
  32304. * @param offset starting offset.
  32305. */
  32306. constructor(
  32307. /**
  32308. * Defines the number of iterations for the loop
  32309. */
  32310. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32311. /**
  32312. * Execute the next iteration. Must be called after the last iteration was finished.
  32313. */
  32314. executeNext(): void;
  32315. /**
  32316. * Break the loop and run the success callback.
  32317. */
  32318. breakLoop(): void;
  32319. /**
  32320. * Create and run an async loop.
  32321. * @param iterations the number of iterations.
  32322. * @param fn the function to run each iteration
  32323. * @param successCallback the callback that will be called upon succesful execution
  32324. * @param offset starting offset.
  32325. * @returns the created async loop object
  32326. */
  32327. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32328. /**
  32329. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32330. * @param iterations total number of iterations
  32331. * @param syncedIterations number of synchronous iterations in each async iteration.
  32332. * @param fn the function to call each iteration.
  32333. * @param callback a success call back that will be called when iterating stops.
  32334. * @param breakFunction a break condition (optional)
  32335. * @param timeout timeout settings for the setTimeout function. default - 0.
  32336. * @returns the created async loop object
  32337. */
  32338. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32339. }
  32340. }
  32341. declare module BABYLON {
  32342. /**
  32343. * This class implement a typical dictionary using a string as key and the generic type T as value.
  32344. * The underlying implementation relies on an associative array to ensure the best performances.
  32345. * The value can be anything including 'null' but except 'undefined'
  32346. */
  32347. export class StringDictionary<T> {
  32348. /**
  32349. * This will clear this dictionary and copy the content from the 'source' one.
  32350. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  32351. * @param source the dictionary to take the content from and copy to this dictionary
  32352. */
  32353. copyFrom(source: StringDictionary<T>): void;
  32354. /**
  32355. * Get a value based from its key
  32356. * @param key the given key to get the matching value from
  32357. * @return the value if found, otherwise undefined is returned
  32358. */
  32359. get(key: string): T | undefined;
  32360. /**
  32361. * Get a value from its key or add it if it doesn't exist.
  32362. * This method will ensure you that a given key/data will be present in the dictionary.
  32363. * @param key the given key to get the matching value from
  32364. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32365. * The factory will only be invoked if there's no data for the given key.
  32366. * @return the value corresponding to the key.
  32367. */
  32368. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32369. /**
  32370. * Get a value from its key if present in the dictionary otherwise add it
  32371. * @param key the key to get the value from
  32372. * @param val if there's no such key/value pair in the dictionary add it with this value
  32373. * @return the value corresponding to the key
  32374. */
  32375. getOrAdd(key: string, val: T): T;
  32376. /**
  32377. * Check if there's a given key in the dictionary
  32378. * @param key the key to check for
  32379. * @return true if the key is present, false otherwise
  32380. */
  32381. contains(key: string): boolean;
  32382. /**
  32383. * Add a new key and its corresponding value
  32384. * @param key the key to add
  32385. * @param value the value corresponding to the key
  32386. * @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
  32387. */
  32388. add(key: string, value: T): boolean;
  32389. /**
  32390. * Update a specific value associated to a key
  32391. * @param key defines the key to use
  32392. * @param value defines the value to store
  32393. * @returns true if the value was updated (or false if the key was not found)
  32394. */
  32395. set(key: string, value: T): boolean;
  32396. /**
  32397. * Get the element of the given key and remove it from the dictionary
  32398. * @param key defines the key to search
  32399. * @returns the value associated with the key or null if not found
  32400. */
  32401. getAndRemove(key: string): Nullable<T>;
  32402. /**
  32403. * Remove a key/value from the dictionary.
  32404. * @param key the key to remove
  32405. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32406. */
  32407. remove(key: string): boolean;
  32408. /**
  32409. * Clear the whole content of the dictionary
  32410. */
  32411. clear(): void;
  32412. /**
  32413. * Gets the current count
  32414. */
  32415. readonly count: number;
  32416. /**
  32417. * Execute a callback on each key/val of the dictionary.
  32418. * Note that you can remove any element in this dictionary in the callback implementation
  32419. * @param callback the callback to execute on a given key/value pair
  32420. */
  32421. forEach(callback: (key: string, val: T) => void): void;
  32422. /**
  32423. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32424. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32425. * Note that you can remove any element in this dictionary in the callback implementation
  32426. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32427. * @returns the first item
  32428. */
  32429. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32430. private _count;
  32431. private _data;
  32432. }
  32433. }
  32434. declare module BABYLON {
  32435. /** @hidden */
  32436. export interface ICollisionCoordinator {
  32437. createCollider(): Collider;
  32438. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32439. init(scene: Scene): void;
  32440. }
  32441. /** @hidden */
  32442. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32443. private _scene;
  32444. private _scaledPosition;
  32445. private _scaledVelocity;
  32446. private _finalPosition;
  32447. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32448. createCollider(): Collider;
  32449. init(scene: Scene): void;
  32450. private _collideWithWorld;
  32451. }
  32452. }
  32453. declare module BABYLON {
  32454. /**
  32455. * Class used to manage all inputs for the scene.
  32456. */
  32457. export class InputManager {
  32458. /** The distance in pixel that you have to move to prevent some events */
  32459. static DragMovementThreshold: number;
  32460. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32461. static LongPressDelay: number;
  32462. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32463. static DoubleClickDelay: number;
  32464. /** If you need to check double click without raising a single click at first click, enable this flag */
  32465. static ExclusiveDoubleClickMode: boolean;
  32466. private _wheelEventName;
  32467. private _onPointerMove;
  32468. private _onPointerDown;
  32469. private _onPointerUp;
  32470. private _initClickEvent;
  32471. private _initActionManager;
  32472. private _delayedSimpleClick;
  32473. private _delayedSimpleClickTimeout;
  32474. private _previousDelayedSimpleClickTimeout;
  32475. private _meshPickProceed;
  32476. private _previousButtonPressed;
  32477. private _currentPickResult;
  32478. private _previousPickResult;
  32479. private _totalPointersPressed;
  32480. private _doubleClickOccured;
  32481. private _pointerOverMesh;
  32482. private _pickedDownMesh;
  32483. private _pickedUpMesh;
  32484. private _pointerX;
  32485. private _pointerY;
  32486. private _unTranslatedPointerX;
  32487. private _unTranslatedPointerY;
  32488. private _startingPointerPosition;
  32489. private _previousStartingPointerPosition;
  32490. private _startingPointerTime;
  32491. private _previousStartingPointerTime;
  32492. private _pointerCaptures;
  32493. private _onKeyDown;
  32494. private _onKeyUp;
  32495. private _onCanvasFocusObserver;
  32496. private _onCanvasBlurObserver;
  32497. private _scene;
  32498. /**
  32499. * Creates a new InputManager
  32500. * @param scene defines the hosting scene
  32501. */
  32502. constructor(scene: Scene);
  32503. /**
  32504. * Gets the mesh that is currently under the pointer
  32505. */
  32506. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32507. /**
  32508. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32509. */
  32510. readonly unTranslatedPointer: Vector2;
  32511. /**
  32512. * Gets or sets the current on-screen X position of the pointer
  32513. */
  32514. pointerX: number;
  32515. /**
  32516. * Gets or sets the current on-screen Y position of the pointer
  32517. */
  32518. pointerY: number;
  32519. private _updatePointerPosition;
  32520. private _processPointerMove;
  32521. private _setRayOnPointerInfo;
  32522. private _checkPrePointerObservable;
  32523. /**
  32524. * Use this method to simulate a pointer move on a mesh
  32525. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32526. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32527. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32528. */
  32529. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32530. /**
  32531. * Use this method to simulate a pointer down on a mesh
  32532. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32533. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32534. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32535. */
  32536. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32537. private _processPointerDown;
  32538. /** @hidden */
  32539. _isPointerSwiping(): boolean;
  32540. /**
  32541. * Use this method to simulate a pointer up on a mesh
  32542. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32543. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32544. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32545. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32546. */
  32547. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32548. private _processPointerUp;
  32549. /**
  32550. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32551. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32552. * @returns true if the pointer was captured
  32553. */
  32554. isPointerCaptured(pointerId?: number): boolean;
  32555. /**
  32556. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32557. * @param attachUp defines if you want to attach events to pointerup
  32558. * @param attachDown defines if you want to attach events to pointerdown
  32559. * @param attachMove defines if you want to attach events to pointermove
  32560. */
  32561. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32562. /**
  32563. * Detaches all event handlers
  32564. */
  32565. detachControl(): void;
  32566. /**
  32567. * Force the value of meshUnderPointer
  32568. * @param mesh defines the mesh to use
  32569. */
  32570. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32571. /**
  32572. * Gets the mesh under the pointer
  32573. * @returns a Mesh or null if no mesh is under the pointer
  32574. */
  32575. getPointerOverMesh(): Nullable<AbstractMesh>;
  32576. }
  32577. }
  32578. declare module BABYLON {
  32579. /**
  32580. * Helper class used to generate session unique ID
  32581. */
  32582. export class UniqueIdGenerator {
  32583. private static _UniqueIdCounter;
  32584. /**
  32585. * Gets an unique (relatively to the current scene) Id
  32586. */
  32587. static readonly UniqueId: number;
  32588. }
  32589. }
  32590. declare module BABYLON {
  32591. /**
  32592. * This class defines the direct association between an animation and a target
  32593. */
  32594. export class TargetedAnimation {
  32595. /**
  32596. * Animation to perform
  32597. */
  32598. animation: Animation;
  32599. /**
  32600. * Target to animate
  32601. */
  32602. target: any;
  32603. /**
  32604. * Serialize the object
  32605. * @returns the JSON object representing the current entity
  32606. */
  32607. serialize(): any;
  32608. }
  32609. /**
  32610. * Use this class to create coordinated animations on multiple targets
  32611. */
  32612. export class AnimationGroup implements IDisposable {
  32613. /** The name of the animation group */
  32614. name: string;
  32615. private _scene;
  32616. private _targetedAnimations;
  32617. private _animatables;
  32618. private _from;
  32619. private _to;
  32620. private _isStarted;
  32621. private _isPaused;
  32622. private _speedRatio;
  32623. private _loopAnimation;
  32624. /**
  32625. * Gets or sets the unique id of the node
  32626. */
  32627. uniqueId: number;
  32628. /**
  32629. * This observable will notify when one animation have ended
  32630. */
  32631. onAnimationEndObservable: Observable<TargetedAnimation>;
  32632. /**
  32633. * Observer raised when one animation loops
  32634. */
  32635. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32636. /**
  32637. * This observable will notify when all animations have ended.
  32638. */
  32639. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32640. /**
  32641. * This observable will notify when all animations have paused.
  32642. */
  32643. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32644. /**
  32645. * This observable will notify when all animations are playing.
  32646. */
  32647. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32648. /**
  32649. * Gets the first frame
  32650. */
  32651. readonly from: number;
  32652. /**
  32653. * Gets the last frame
  32654. */
  32655. readonly to: number;
  32656. /**
  32657. * Define if the animations are started
  32658. */
  32659. readonly isStarted: boolean;
  32660. /**
  32661. * Gets a value indicating that the current group is playing
  32662. */
  32663. readonly isPlaying: boolean;
  32664. /**
  32665. * Gets or sets the speed ratio to use for all animations
  32666. */
  32667. /**
  32668. * Gets or sets the speed ratio to use for all animations
  32669. */
  32670. speedRatio: number;
  32671. /**
  32672. * Gets or sets if all animations should loop or not
  32673. */
  32674. loopAnimation: boolean;
  32675. /**
  32676. * Gets the targeted animations for this animation group
  32677. */
  32678. readonly targetedAnimations: Array<TargetedAnimation>;
  32679. /**
  32680. * returning the list of animatables controlled by this animation group.
  32681. */
  32682. readonly animatables: Array<Animatable>;
  32683. /**
  32684. * Instantiates a new Animation Group.
  32685. * This helps managing several animations at once.
  32686. * @see http://doc.babylonjs.com/how_to/group
  32687. * @param name Defines the name of the group
  32688. * @param scene Defines the scene the group belongs to
  32689. */
  32690. constructor(
  32691. /** The name of the animation group */
  32692. name: string, scene?: Nullable<Scene>);
  32693. /**
  32694. * Add an animation (with its target) in the group
  32695. * @param animation defines the animation we want to add
  32696. * @param target defines the target of the animation
  32697. * @returns the TargetedAnimation object
  32698. */
  32699. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32700. /**
  32701. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32702. * It can add constant keys at begin or end
  32703. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32704. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32705. * @returns the animation group
  32706. */
  32707. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32708. /**
  32709. * Start all animations on given targets
  32710. * @param loop defines if animations must loop
  32711. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32712. * @param from defines the from key (optional)
  32713. * @param to defines the to key (optional)
  32714. * @returns the current animation group
  32715. */
  32716. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32717. /**
  32718. * Pause all animations
  32719. * @returns the animation group
  32720. */
  32721. pause(): AnimationGroup;
  32722. /**
  32723. * Play all animations to initial state
  32724. * This function will start() the animations if they were not started or will restart() them if they were paused
  32725. * @param loop defines if animations must loop
  32726. * @returns the animation group
  32727. */
  32728. play(loop?: boolean): AnimationGroup;
  32729. /**
  32730. * Reset all animations to initial state
  32731. * @returns the animation group
  32732. */
  32733. reset(): AnimationGroup;
  32734. /**
  32735. * Restart animations from key 0
  32736. * @returns the animation group
  32737. */
  32738. restart(): AnimationGroup;
  32739. /**
  32740. * Stop all animations
  32741. * @returns the animation group
  32742. */
  32743. stop(): AnimationGroup;
  32744. /**
  32745. * Set animation weight for all animatables
  32746. * @param weight defines the weight to use
  32747. * @return the animationGroup
  32748. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32749. */
  32750. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32751. /**
  32752. * Synchronize and normalize all animatables with a source animatable
  32753. * @param root defines the root animatable to synchronize with
  32754. * @return the animationGroup
  32755. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32756. */
  32757. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32758. /**
  32759. * Goes to a specific frame in this animation group
  32760. * @param frame the frame number to go to
  32761. * @return the animationGroup
  32762. */
  32763. goToFrame(frame: number): AnimationGroup;
  32764. /**
  32765. * Dispose all associated resources
  32766. */
  32767. dispose(): void;
  32768. private _checkAnimationGroupEnded;
  32769. /**
  32770. * Clone the current animation group and returns a copy
  32771. * @param newName defines the name of the new group
  32772. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32773. * @returns the new aniamtion group
  32774. */
  32775. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32776. /**
  32777. * Serializes the animationGroup to an object
  32778. * @returns Serialized object
  32779. */
  32780. serialize(): any;
  32781. /**
  32782. * Returns a new AnimationGroup object parsed from the source provided.
  32783. * @param parsedAnimationGroup defines the source
  32784. * @param scene defines the scene that will receive the animationGroup
  32785. * @returns a new AnimationGroup
  32786. */
  32787. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32788. /**
  32789. * Returns the string "AnimationGroup"
  32790. * @returns "AnimationGroup"
  32791. */
  32792. getClassName(): string;
  32793. /**
  32794. * Creates a detailled string about the object
  32795. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32796. * @returns a string representing the object
  32797. */
  32798. toString(fullDetails?: boolean): string;
  32799. }
  32800. }
  32801. declare module BABYLON {
  32802. /**
  32803. * Define an interface for all classes that will hold resources
  32804. */
  32805. export interface IDisposable {
  32806. /**
  32807. * Releases all held resources
  32808. */
  32809. dispose(): void;
  32810. }
  32811. /** Interface defining initialization parameters for Scene class */
  32812. export interface SceneOptions {
  32813. /**
  32814. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32815. * It will improve performance when the number of geometries becomes important.
  32816. */
  32817. useGeometryUniqueIdsMap?: boolean;
  32818. /**
  32819. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32820. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32821. */
  32822. useMaterialMeshMap?: boolean;
  32823. /**
  32824. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32825. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32826. */
  32827. useClonedMeshhMap?: boolean;
  32828. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32829. virtual?: boolean;
  32830. }
  32831. /**
  32832. * Represents a scene to be rendered by the engine.
  32833. * @see http://doc.babylonjs.com/features/scene
  32834. */
  32835. export class Scene extends AbstractScene implements IAnimatable {
  32836. /** The fog is deactivated */
  32837. static readonly FOGMODE_NONE: number;
  32838. /** The fog density is following an exponential function */
  32839. static readonly FOGMODE_EXP: number;
  32840. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32841. static readonly FOGMODE_EXP2: number;
  32842. /** The fog density is following a linear function. */
  32843. static readonly FOGMODE_LINEAR: number;
  32844. /**
  32845. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32846. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32847. */
  32848. static MinDeltaTime: number;
  32849. /**
  32850. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32851. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32852. */
  32853. static MaxDeltaTime: number;
  32854. /**
  32855. * Factory used to create the default material.
  32856. * @param name The name of the material to create
  32857. * @param scene The scene to create the material for
  32858. * @returns The default material
  32859. */
  32860. static DefaultMaterialFactory(scene: Scene): Material;
  32861. /**
  32862. * Factory used to create the a collision coordinator.
  32863. * @returns The collision coordinator
  32864. */
  32865. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32866. /** @hidden */
  32867. _inputManager: InputManager;
  32868. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32869. cameraToUseForPointers: Nullable<Camera>;
  32870. /** @hidden */
  32871. readonly _isScene: boolean;
  32872. /**
  32873. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32874. */
  32875. autoClear: boolean;
  32876. /**
  32877. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32878. */
  32879. autoClearDepthAndStencil: boolean;
  32880. /**
  32881. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32882. */
  32883. clearColor: Color4;
  32884. /**
  32885. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32886. */
  32887. ambientColor: Color3;
  32888. /**
  32889. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32890. * It should only be one of the following (if not the default embedded one):
  32891. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32892. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32893. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32894. * The material properties need to be setup according to the type of texture in use.
  32895. */
  32896. environmentBRDFTexture: BaseTexture;
  32897. /** @hidden */
  32898. protected _environmentTexture: Nullable<BaseTexture>;
  32899. /**
  32900. * Texture used in all pbr material as the reflection texture.
  32901. * As in the majority of the scene they are the same (exception for multi room and so on),
  32902. * this is easier to reference from here than from all the materials.
  32903. */
  32904. /**
  32905. * Texture used in all pbr material as the reflection texture.
  32906. * As in the majority of the scene they are the same (exception for multi room and so on),
  32907. * this is easier to set here than in all the materials.
  32908. */
  32909. environmentTexture: Nullable<BaseTexture>;
  32910. /** @hidden */
  32911. protected _environmentIntensity: number;
  32912. /**
  32913. * Intensity of the environment in all pbr material.
  32914. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32915. * As in the majority of the scene they are the same (exception for multi room and so on),
  32916. * this is easier to reference from here than from all the materials.
  32917. */
  32918. /**
  32919. * Intensity of the environment in all pbr material.
  32920. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32921. * As in the majority of the scene they are the same (exception for multi room and so on),
  32922. * this is easier to set here than in all the materials.
  32923. */
  32924. environmentIntensity: number;
  32925. /** @hidden */
  32926. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32927. /**
  32928. * Default image processing configuration used either in the rendering
  32929. * Forward main pass or through the imageProcessingPostProcess if present.
  32930. * As in the majority of the scene they are the same (exception for multi camera),
  32931. * this is easier to reference from here than from all the materials and post process.
  32932. *
  32933. * No setter as we it is a shared configuration, you can set the values instead.
  32934. */
  32935. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32936. private _forceWireframe;
  32937. /**
  32938. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32939. */
  32940. forceWireframe: boolean;
  32941. private _forcePointsCloud;
  32942. /**
  32943. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32944. */
  32945. forcePointsCloud: boolean;
  32946. /**
  32947. * Gets or sets the active clipplane 1
  32948. */
  32949. clipPlane: Nullable<Plane>;
  32950. /**
  32951. * Gets or sets the active clipplane 2
  32952. */
  32953. clipPlane2: Nullable<Plane>;
  32954. /**
  32955. * Gets or sets the active clipplane 3
  32956. */
  32957. clipPlane3: Nullable<Plane>;
  32958. /**
  32959. * Gets or sets the active clipplane 4
  32960. */
  32961. clipPlane4: Nullable<Plane>;
  32962. /**
  32963. * Gets or sets a boolean indicating if animations are enabled
  32964. */
  32965. animationsEnabled: boolean;
  32966. private _animationPropertiesOverride;
  32967. /**
  32968. * Gets or sets the animation properties override
  32969. */
  32970. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32971. /**
  32972. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32973. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32974. */
  32975. useConstantAnimationDeltaTime: boolean;
  32976. /**
  32977. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32978. * Please note that it requires to run a ray cast through the scene on every frame
  32979. */
  32980. constantlyUpdateMeshUnderPointer: boolean;
  32981. /**
  32982. * Defines the HTML cursor to use when hovering over interactive elements
  32983. */
  32984. hoverCursor: string;
  32985. /**
  32986. * Defines the HTML default cursor to use (empty by default)
  32987. */
  32988. defaultCursor: string;
  32989. /**
  32990. * This is used to call preventDefault() on pointer down
  32991. * in order to block unwanted artifacts like system double clicks
  32992. */
  32993. preventDefaultOnPointerDown: boolean;
  32994. /**
  32995. * This is used to call preventDefault() on pointer up
  32996. * in order to block unwanted artifacts like system double clicks
  32997. */
  32998. preventDefaultOnPointerUp: boolean;
  32999. /**
  33000. * Gets or sets user defined metadata
  33001. */
  33002. metadata: any;
  33003. /**
  33004. * For internal use only. Please do not use.
  33005. */
  33006. reservedDataStore: any;
  33007. /**
  33008. * Gets the name of the plugin used to load this scene (null by default)
  33009. */
  33010. loadingPluginName: string;
  33011. /**
  33012. * Use this array to add regular expressions used to disable offline support for specific urls
  33013. */
  33014. disableOfflineSupportExceptionRules: RegExp[];
  33015. /**
  33016. * An event triggered when the scene is disposed.
  33017. */
  33018. onDisposeObservable: Observable<Scene>;
  33019. private _onDisposeObserver;
  33020. /** Sets a function to be executed when this scene is disposed. */
  33021. onDispose: () => void;
  33022. /**
  33023. * An event triggered before rendering the scene (right after animations and physics)
  33024. */
  33025. onBeforeRenderObservable: Observable<Scene>;
  33026. private _onBeforeRenderObserver;
  33027. /** Sets a function to be executed before rendering this scene */
  33028. beforeRender: Nullable<() => void>;
  33029. /**
  33030. * An event triggered after rendering the scene
  33031. */
  33032. onAfterRenderObservable: Observable<Scene>;
  33033. /**
  33034. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33035. */
  33036. onAfterRenderCameraObservable: Observable<Camera>;
  33037. private _onAfterRenderObserver;
  33038. /** Sets a function to be executed after rendering this scene */
  33039. afterRender: Nullable<() => void>;
  33040. /**
  33041. * An event triggered before animating the scene
  33042. */
  33043. onBeforeAnimationsObservable: Observable<Scene>;
  33044. /**
  33045. * An event triggered after animations processing
  33046. */
  33047. onAfterAnimationsObservable: Observable<Scene>;
  33048. /**
  33049. * An event triggered before draw calls are ready to be sent
  33050. */
  33051. onBeforeDrawPhaseObservable: Observable<Scene>;
  33052. /**
  33053. * An event triggered after draw calls have been sent
  33054. */
  33055. onAfterDrawPhaseObservable: Observable<Scene>;
  33056. /**
  33057. * An event triggered when the scene is ready
  33058. */
  33059. onReadyObservable: Observable<Scene>;
  33060. /**
  33061. * An event triggered before rendering a camera
  33062. */
  33063. onBeforeCameraRenderObservable: Observable<Camera>;
  33064. private _onBeforeCameraRenderObserver;
  33065. /** Sets a function to be executed before rendering a camera*/
  33066. beforeCameraRender: () => void;
  33067. /**
  33068. * An event triggered after rendering a camera
  33069. */
  33070. onAfterCameraRenderObservable: Observable<Camera>;
  33071. private _onAfterCameraRenderObserver;
  33072. /** Sets a function to be executed after rendering a camera*/
  33073. afterCameraRender: () => void;
  33074. /**
  33075. * An event triggered when active meshes evaluation is about to start
  33076. */
  33077. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33078. /**
  33079. * An event triggered when active meshes evaluation is done
  33080. */
  33081. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33082. /**
  33083. * An event triggered when particles rendering is about to start
  33084. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33085. */
  33086. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33087. /**
  33088. * An event triggered when particles rendering is done
  33089. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33090. */
  33091. onAfterParticlesRenderingObservable: Observable<Scene>;
  33092. /**
  33093. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33094. */
  33095. onDataLoadedObservable: Observable<Scene>;
  33096. /**
  33097. * An event triggered when a camera is created
  33098. */
  33099. onNewCameraAddedObservable: Observable<Camera>;
  33100. /**
  33101. * An event triggered when a camera is removed
  33102. */
  33103. onCameraRemovedObservable: Observable<Camera>;
  33104. /**
  33105. * An event triggered when a light is created
  33106. */
  33107. onNewLightAddedObservable: Observable<Light>;
  33108. /**
  33109. * An event triggered when a light is removed
  33110. */
  33111. onLightRemovedObservable: Observable<Light>;
  33112. /**
  33113. * An event triggered when a geometry is created
  33114. */
  33115. onNewGeometryAddedObservable: Observable<Geometry>;
  33116. /**
  33117. * An event triggered when a geometry is removed
  33118. */
  33119. onGeometryRemovedObservable: Observable<Geometry>;
  33120. /**
  33121. * An event triggered when a transform node is created
  33122. */
  33123. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33124. /**
  33125. * An event triggered when a transform node is removed
  33126. */
  33127. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33128. /**
  33129. * An event triggered when a mesh is created
  33130. */
  33131. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33132. /**
  33133. * An event triggered when a mesh is removed
  33134. */
  33135. onMeshRemovedObservable: Observable<AbstractMesh>;
  33136. /**
  33137. * An event triggered when a skeleton is created
  33138. */
  33139. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33140. /**
  33141. * An event triggered when a skeleton is removed
  33142. */
  33143. onSkeletonRemovedObservable: Observable<Skeleton>;
  33144. /**
  33145. * An event triggered when a material is created
  33146. */
  33147. onNewMaterialAddedObservable: Observable<Material>;
  33148. /**
  33149. * An event triggered when a material is removed
  33150. */
  33151. onMaterialRemovedObservable: Observable<Material>;
  33152. /**
  33153. * An event triggered when a texture is created
  33154. */
  33155. onNewTextureAddedObservable: Observable<BaseTexture>;
  33156. /**
  33157. * An event triggered when a texture is removed
  33158. */
  33159. onTextureRemovedObservable: Observable<BaseTexture>;
  33160. /**
  33161. * An event triggered when render targets are about to be rendered
  33162. * Can happen multiple times per frame.
  33163. */
  33164. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33165. /**
  33166. * An event triggered when render targets were rendered.
  33167. * Can happen multiple times per frame.
  33168. */
  33169. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33170. /**
  33171. * An event triggered before calculating deterministic simulation step
  33172. */
  33173. onBeforeStepObservable: Observable<Scene>;
  33174. /**
  33175. * An event triggered after calculating deterministic simulation step
  33176. */
  33177. onAfterStepObservable: Observable<Scene>;
  33178. /**
  33179. * An event triggered when the activeCamera property is updated
  33180. */
  33181. onActiveCameraChanged: Observable<Scene>;
  33182. /**
  33183. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33184. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33185. * 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)
  33186. */
  33187. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33188. /**
  33189. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33190. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33191. * 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)
  33192. */
  33193. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33194. /**
  33195. * This Observable will when a mesh has been imported into the scene.
  33196. */
  33197. onMeshImportedObservable: Observable<AbstractMesh>;
  33198. /**
  33199. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33200. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33201. */
  33202. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33203. /** @hidden */
  33204. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33205. /**
  33206. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33207. */
  33208. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33209. /**
  33210. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33211. */
  33212. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33213. /**
  33214. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33215. */
  33216. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33217. /** Callback called when a pointer move is detected */
  33218. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33219. /** Callback called when a pointer down is detected */
  33220. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33221. /** Callback called when a pointer up is detected */
  33222. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33223. /** Callback called when a pointer pick is detected */
  33224. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33225. /**
  33226. * 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).
  33227. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33228. */
  33229. onPrePointerObservable: Observable<PointerInfoPre>;
  33230. /**
  33231. * Observable event triggered each time an input event is received from the rendering canvas
  33232. */
  33233. onPointerObservable: Observable<PointerInfo>;
  33234. /**
  33235. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33236. */
  33237. readonly unTranslatedPointer: Vector2;
  33238. /**
  33239. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33240. */
  33241. static DragMovementThreshold: number;
  33242. /**
  33243. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33244. */
  33245. static LongPressDelay: number;
  33246. /**
  33247. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33248. */
  33249. static DoubleClickDelay: number;
  33250. /** If you need to check double click without raising a single click at first click, enable this flag */
  33251. static ExclusiveDoubleClickMode: boolean;
  33252. /** @hidden */
  33253. _mirroredCameraPosition: Nullable<Vector3>;
  33254. /**
  33255. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33256. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33257. */
  33258. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33259. /**
  33260. * Observable event triggered each time an keyboard event is received from the hosting window
  33261. */
  33262. onKeyboardObservable: Observable<KeyboardInfo>;
  33263. private _useRightHandedSystem;
  33264. /**
  33265. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33266. */
  33267. useRightHandedSystem: boolean;
  33268. private _timeAccumulator;
  33269. private _currentStepId;
  33270. private _currentInternalStep;
  33271. /**
  33272. * Sets the step Id used by deterministic lock step
  33273. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33274. * @param newStepId defines the step Id
  33275. */
  33276. setStepId(newStepId: number): void;
  33277. /**
  33278. * Gets the step Id used by deterministic lock step
  33279. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33280. * @returns the step Id
  33281. */
  33282. getStepId(): number;
  33283. /**
  33284. * Gets the internal step used by deterministic lock step
  33285. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33286. * @returns the internal step
  33287. */
  33288. getInternalStep(): number;
  33289. private _fogEnabled;
  33290. /**
  33291. * Gets or sets a boolean indicating if fog is enabled on this scene
  33292. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33293. * (Default is true)
  33294. */
  33295. fogEnabled: boolean;
  33296. private _fogMode;
  33297. /**
  33298. * Gets or sets the fog mode to use
  33299. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33300. * | mode | value |
  33301. * | --- | --- |
  33302. * | FOGMODE_NONE | 0 |
  33303. * | FOGMODE_EXP | 1 |
  33304. * | FOGMODE_EXP2 | 2 |
  33305. * | FOGMODE_LINEAR | 3 |
  33306. */
  33307. fogMode: number;
  33308. /**
  33309. * Gets or sets the fog color to use
  33310. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33311. * (Default is Color3(0.2, 0.2, 0.3))
  33312. */
  33313. fogColor: Color3;
  33314. /**
  33315. * Gets or sets the fog density to use
  33316. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33317. * (Default is 0.1)
  33318. */
  33319. fogDensity: number;
  33320. /**
  33321. * Gets or sets the fog start distance to use
  33322. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33323. * (Default is 0)
  33324. */
  33325. fogStart: number;
  33326. /**
  33327. * Gets or sets the fog end distance to use
  33328. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33329. * (Default is 1000)
  33330. */
  33331. fogEnd: number;
  33332. private _shadowsEnabled;
  33333. /**
  33334. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33335. */
  33336. shadowsEnabled: boolean;
  33337. private _lightsEnabled;
  33338. /**
  33339. * Gets or sets a boolean indicating if lights are enabled on this scene
  33340. */
  33341. lightsEnabled: boolean;
  33342. /** All of the active cameras added to this scene. */
  33343. activeCameras: Camera[];
  33344. /** @hidden */
  33345. _activeCamera: Nullable<Camera>;
  33346. /** Gets or sets the current active camera */
  33347. activeCamera: Nullable<Camera>;
  33348. private _defaultMaterial;
  33349. /** The default material used on meshes when no material is affected */
  33350. /** The default material used on meshes when no material is affected */
  33351. defaultMaterial: Material;
  33352. private _texturesEnabled;
  33353. /**
  33354. * Gets or sets a boolean indicating if textures are enabled on this scene
  33355. */
  33356. texturesEnabled: boolean;
  33357. /**
  33358. * Gets or sets a boolean indicating if particles are enabled on this scene
  33359. */
  33360. particlesEnabled: boolean;
  33361. /**
  33362. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33363. */
  33364. spritesEnabled: boolean;
  33365. private _skeletonsEnabled;
  33366. /**
  33367. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33368. */
  33369. skeletonsEnabled: boolean;
  33370. /**
  33371. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33372. */
  33373. lensFlaresEnabled: boolean;
  33374. /**
  33375. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33376. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33377. */
  33378. collisionsEnabled: boolean;
  33379. private _collisionCoordinator;
  33380. /** @hidden */
  33381. readonly collisionCoordinator: ICollisionCoordinator;
  33382. /**
  33383. * Defines the gravity applied to this scene (used only for collisions)
  33384. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33385. */
  33386. gravity: Vector3;
  33387. /**
  33388. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33389. */
  33390. postProcessesEnabled: boolean;
  33391. /**
  33392. * The list of postprocesses added to the scene
  33393. */
  33394. postProcesses: PostProcess[];
  33395. /**
  33396. * Gets the current postprocess manager
  33397. */
  33398. postProcessManager: PostProcessManager;
  33399. /**
  33400. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33401. */
  33402. renderTargetsEnabled: boolean;
  33403. /**
  33404. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33405. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33406. */
  33407. dumpNextRenderTargets: boolean;
  33408. /**
  33409. * The list of user defined render targets added to the scene
  33410. */
  33411. customRenderTargets: RenderTargetTexture[];
  33412. /**
  33413. * Defines if texture loading must be delayed
  33414. * If true, textures will only be loaded when they need to be rendered
  33415. */
  33416. useDelayedTextureLoading: boolean;
  33417. /**
  33418. * Gets the list of meshes imported to the scene through SceneLoader
  33419. */
  33420. importedMeshesFiles: String[];
  33421. /**
  33422. * Gets or sets a boolean indicating if probes are enabled on this scene
  33423. */
  33424. probesEnabled: boolean;
  33425. /**
  33426. * Gets or sets the current offline provider to use to store scene data
  33427. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33428. */
  33429. offlineProvider: IOfflineProvider;
  33430. /**
  33431. * Gets or sets the action manager associated with the scene
  33432. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33433. */
  33434. actionManager: AbstractActionManager;
  33435. private _meshesForIntersections;
  33436. /**
  33437. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33438. */
  33439. proceduralTexturesEnabled: boolean;
  33440. private _engine;
  33441. private _totalVertices;
  33442. /** @hidden */
  33443. _activeIndices: PerfCounter;
  33444. /** @hidden */
  33445. _activeParticles: PerfCounter;
  33446. /** @hidden */
  33447. _activeBones: PerfCounter;
  33448. private _animationRatio;
  33449. /** @hidden */
  33450. _animationTimeLast: number;
  33451. /** @hidden */
  33452. _animationTime: number;
  33453. /**
  33454. * Gets or sets a general scale for animation speed
  33455. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33456. */
  33457. animationTimeScale: number;
  33458. /** @hidden */
  33459. _cachedMaterial: Nullable<Material>;
  33460. /** @hidden */
  33461. _cachedEffect: Nullable<Effect>;
  33462. /** @hidden */
  33463. _cachedVisibility: Nullable<number>;
  33464. private _renderId;
  33465. private _frameId;
  33466. private _executeWhenReadyTimeoutId;
  33467. private _intermediateRendering;
  33468. private _viewUpdateFlag;
  33469. private _projectionUpdateFlag;
  33470. /** @hidden */
  33471. _toBeDisposed: Nullable<IDisposable>[];
  33472. private _activeRequests;
  33473. /** @hidden */
  33474. _pendingData: any[];
  33475. private _isDisposed;
  33476. /**
  33477. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33478. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33479. */
  33480. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33481. private _activeMeshes;
  33482. private _processedMaterials;
  33483. private _renderTargets;
  33484. /** @hidden */
  33485. _activeParticleSystems: SmartArray<IParticleSystem>;
  33486. private _activeSkeletons;
  33487. private _softwareSkinnedMeshes;
  33488. private _renderingManager;
  33489. /** @hidden */
  33490. _activeAnimatables: Animatable[];
  33491. private _transformMatrix;
  33492. private _sceneUbo;
  33493. /** @hidden */
  33494. _viewMatrix: Matrix;
  33495. private _projectionMatrix;
  33496. /** @hidden */
  33497. _forcedViewPosition: Nullable<Vector3>;
  33498. /** @hidden */
  33499. _frustumPlanes: Plane[];
  33500. /**
  33501. * Gets the list of frustum planes (built from the active camera)
  33502. */
  33503. readonly frustumPlanes: Plane[];
  33504. /**
  33505. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33506. * This is useful if there are more lights that the maximum simulteanous authorized
  33507. */
  33508. requireLightSorting: boolean;
  33509. /** @hidden */
  33510. readonly useMaterialMeshMap: boolean;
  33511. /** @hidden */
  33512. readonly useClonedMeshhMap: boolean;
  33513. private _externalData;
  33514. private _uid;
  33515. /**
  33516. * @hidden
  33517. * Backing store of defined scene components.
  33518. */
  33519. _components: ISceneComponent[];
  33520. /**
  33521. * @hidden
  33522. * Backing store of defined scene components.
  33523. */
  33524. _serializableComponents: ISceneSerializableComponent[];
  33525. /**
  33526. * List of components to register on the next registration step.
  33527. */
  33528. private _transientComponents;
  33529. /**
  33530. * Registers the transient components if needed.
  33531. */
  33532. private _registerTransientComponents;
  33533. /**
  33534. * @hidden
  33535. * Add a component to the scene.
  33536. * Note that the ccomponent could be registered on th next frame if this is called after
  33537. * the register component stage.
  33538. * @param component Defines the component to add to the scene
  33539. */
  33540. _addComponent(component: ISceneComponent): void;
  33541. /**
  33542. * @hidden
  33543. * Gets a component from the scene.
  33544. * @param name defines the name of the component to retrieve
  33545. * @returns the component or null if not present
  33546. */
  33547. _getComponent(name: string): Nullable<ISceneComponent>;
  33548. /**
  33549. * @hidden
  33550. * Defines the actions happening before camera updates.
  33551. */
  33552. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33553. /**
  33554. * @hidden
  33555. * Defines the actions happening before clear the canvas.
  33556. */
  33557. _beforeClearStage: Stage<SimpleStageAction>;
  33558. /**
  33559. * @hidden
  33560. * Defines the actions when collecting render targets for the frame.
  33561. */
  33562. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33563. /**
  33564. * @hidden
  33565. * Defines the actions happening for one camera in the frame.
  33566. */
  33567. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33568. /**
  33569. * @hidden
  33570. * Defines the actions happening during the per mesh ready checks.
  33571. */
  33572. _isReadyForMeshStage: Stage<MeshStageAction>;
  33573. /**
  33574. * @hidden
  33575. * Defines the actions happening before evaluate active mesh checks.
  33576. */
  33577. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33578. /**
  33579. * @hidden
  33580. * Defines the actions happening during the evaluate sub mesh checks.
  33581. */
  33582. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33583. /**
  33584. * @hidden
  33585. * Defines the actions happening during the active mesh stage.
  33586. */
  33587. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33588. /**
  33589. * @hidden
  33590. * Defines the actions happening during the per camera render target step.
  33591. */
  33592. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33593. /**
  33594. * @hidden
  33595. * Defines the actions happening just before the active camera is drawing.
  33596. */
  33597. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33598. /**
  33599. * @hidden
  33600. * Defines the actions happening just before a render target is drawing.
  33601. */
  33602. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33603. /**
  33604. * @hidden
  33605. * Defines the actions happening just before a rendering group is drawing.
  33606. */
  33607. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33608. /**
  33609. * @hidden
  33610. * Defines the actions happening just before a mesh is drawing.
  33611. */
  33612. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33613. /**
  33614. * @hidden
  33615. * Defines the actions happening just after a mesh has been drawn.
  33616. */
  33617. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33618. /**
  33619. * @hidden
  33620. * Defines the actions happening just after a rendering group has been drawn.
  33621. */
  33622. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33623. /**
  33624. * @hidden
  33625. * Defines the actions happening just after the active camera has been drawn.
  33626. */
  33627. _afterCameraDrawStage: Stage<CameraStageAction>;
  33628. /**
  33629. * @hidden
  33630. * Defines the actions happening just after a render target has been drawn.
  33631. */
  33632. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33633. /**
  33634. * @hidden
  33635. * Defines the actions happening just after rendering all cameras and computing intersections.
  33636. */
  33637. _afterRenderStage: Stage<SimpleStageAction>;
  33638. /**
  33639. * @hidden
  33640. * Defines the actions happening when a pointer move event happens.
  33641. */
  33642. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33643. /**
  33644. * @hidden
  33645. * Defines the actions happening when a pointer down event happens.
  33646. */
  33647. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33648. /**
  33649. * @hidden
  33650. * Defines the actions happening when a pointer up event happens.
  33651. */
  33652. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33653. /**
  33654. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33655. */
  33656. private geometriesByUniqueId;
  33657. /**
  33658. * Creates a new Scene
  33659. * @param engine defines the engine to use to render this scene
  33660. * @param options defines the scene options
  33661. */
  33662. constructor(engine: Engine, options?: SceneOptions);
  33663. /**
  33664. * Gets a string idenfifying the name of the class
  33665. * @returns "Scene" string
  33666. */
  33667. getClassName(): string;
  33668. private _defaultMeshCandidates;
  33669. /**
  33670. * @hidden
  33671. */
  33672. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33673. private _defaultSubMeshCandidates;
  33674. /**
  33675. * @hidden
  33676. */
  33677. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33678. /**
  33679. * Sets the default candidate providers for the scene.
  33680. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33681. * and getCollidingSubMeshCandidates to their default function
  33682. */
  33683. setDefaultCandidateProviders(): void;
  33684. /**
  33685. * Gets the mesh that is currently under the pointer
  33686. */
  33687. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33688. /**
  33689. * Gets or sets the current on-screen X position of the pointer
  33690. */
  33691. pointerX: number;
  33692. /**
  33693. * Gets or sets the current on-screen Y position of the pointer
  33694. */
  33695. pointerY: number;
  33696. /**
  33697. * Gets the cached material (ie. the latest rendered one)
  33698. * @returns the cached material
  33699. */
  33700. getCachedMaterial(): Nullable<Material>;
  33701. /**
  33702. * Gets the cached effect (ie. the latest rendered one)
  33703. * @returns the cached effect
  33704. */
  33705. getCachedEffect(): Nullable<Effect>;
  33706. /**
  33707. * Gets the cached visibility state (ie. the latest rendered one)
  33708. * @returns the cached visibility state
  33709. */
  33710. getCachedVisibility(): Nullable<number>;
  33711. /**
  33712. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33713. * @param material defines the current material
  33714. * @param effect defines the current effect
  33715. * @param visibility defines the current visibility state
  33716. * @returns true if one parameter is not cached
  33717. */
  33718. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33719. /**
  33720. * Gets the engine associated with the scene
  33721. * @returns an Engine
  33722. */
  33723. getEngine(): Engine;
  33724. /**
  33725. * Gets the total number of vertices rendered per frame
  33726. * @returns the total number of vertices rendered per frame
  33727. */
  33728. getTotalVertices(): number;
  33729. /**
  33730. * Gets the performance counter for total vertices
  33731. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33732. */
  33733. readonly totalVerticesPerfCounter: PerfCounter;
  33734. /**
  33735. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33736. * @returns the total number of active indices rendered per frame
  33737. */
  33738. getActiveIndices(): number;
  33739. /**
  33740. * Gets the performance counter for active indices
  33741. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33742. */
  33743. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33744. /**
  33745. * Gets the total number of active particles rendered per frame
  33746. * @returns the total number of active particles rendered per frame
  33747. */
  33748. getActiveParticles(): number;
  33749. /**
  33750. * Gets the performance counter for active particles
  33751. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33752. */
  33753. readonly activeParticlesPerfCounter: PerfCounter;
  33754. /**
  33755. * Gets the total number of active bones rendered per frame
  33756. * @returns the total number of active bones rendered per frame
  33757. */
  33758. getActiveBones(): number;
  33759. /**
  33760. * Gets the performance counter for active bones
  33761. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33762. */
  33763. readonly activeBonesPerfCounter: PerfCounter;
  33764. /**
  33765. * Gets the array of active meshes
  33766. * @returns an array of AbstractMesh
  33767. */
  33768. getActiveMeshes(): SmartArray<AbstractMesh>;
  33769. /**
  33770. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33771. * @returns a number
  33772. */
  33773. getAnimationRatio(): number;
  33774. /**
  33775. * Gets an unique Id for the current render phase
  33776. * @returns a number
  33777. */
  33778. getRenderId(): number;
  33779. /**
  33780. * Gets an unique Id for the current frame
  33781. * @returns a number
  33782. */
  33783. getFrameId(): number;
  33784. /** Call this function if you want to manually increment the render Id*/
  33785. incrementRenderId(): void;
  33786. private _createUbo;
  33787. /**
  33788. * Use this method to simulate a pointer move on a mesh
  33789. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33790. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33791. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33792. * @returns the current scene
  33793. */
  33794. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33795. /**
  33796. * Use this method to simulate a pointer down on a mesh
  33797. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33798. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33799. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33800. * @returns the current scene
  33801. */
  33802. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33803. /**
  33804. * Use this method to simulate a pointer up on a mesh
  33805. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33806. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33807. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33808. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33809. * @returns the current scene
  33810. */
  33811. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33812. /**
  33813. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33814. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33815. * @returns true if the pointer was captured
  33816. */
  33817. isPointerCaptured(pointerId?: number): boolean;
  33818. /**
  33819. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33820. * @param attachUp defines if you want to attach events to pointerup
  33821. * @param attachDown defines if you want to attach events to pointerdown
  33822. * @param attachMove defines if you want to attach events to pointermove
  33823. */
  33824. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33825. /** Detaches all event handlers*/
  33826. detachControl(): void;
  33827. /**
  33828. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33829. * Delay loaded resources are not taking in account
  33830. * @return true if all required resources are ready
  33831. */
  33832. isReady(): boolean;
  33833. /** Resets all cached information relative to material (including effect and visibility) */
  33834. resetCachedMaterial(): void;
  33835. /**
  33836. * Registers a function to be called before every frame render
  33837. * @param func defines the function to register
  33838. */
  33839. registerBeforeRender(func: () => void): void;
  33840. /**
  33841. * Unregisters a function called before every frame render
  33842. * @param func defines the function to unregister
  33843. */
  33844. unregisterBeforeRender(func: () => void): void;
  33845. /**
  33846. * Registers a function to be called after every frame render
  33847. * @param func defines the function to register
  33848. */
  33849. registerAfterRender(func: () => void): void;
  33850. /**
  33851. * Unregisters a function called after every frame render
  33852. * @param func defines the function to unregister
  33853. */
  33854. unregisterAfterRender(func: () => void): void;
  33855. private _executeOnceBeforeRender;
  33856. /**
  33857. * The provided function will run before render once and will be disposed afterwards.
  33858. * A timeout delay can be provided so that the function will be executed in N ms.
  33859. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33860. * @param func The function to be executed.
  33861. * @param timeout optional delay in ms
  33862. */
  33863. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33864. /** @hidden */
  33865. _addPendingData(data: any): void;
  33866. /** @hidden */
  33867. _removePendingData(data: any): void;
  33868. /**
  33869. * Returns the number of items waiting to be loaded
  33870. * @returns the number of items waiting to be loaded
  33871. */
  33872. getWaitingItemsCount(): number;
  33873. /**
  33874. * Returns a boolean indicating if the scene is still loading data
  33875. */
  33876. readonly isLoading: boolean;
  33877. /**
  33878. * Registers a function to be executed when the scene is ready
  33879. * @param {Function} func - the function to be executed
  33880. */
  33881. executeWhenReady(func: () => void): void;
  33882. /**
  33883. * Returns a promise that resolves when the scene is ready
  33884. * @returns A promise that resolves when the scene is ready
  33885. */
  33886. whenReadyAsync(): Promise<void>;
  33887. /** @hidden */
  33888. _checkIsReady(): void;
  33889. /**
  33890. * Gets all animatable attached to the scene
  33891. */
  33892. readonly animatables: Animatable[];
  33893. /**
  33894. * Resets the last animation time frame.
  33895. * Useful to override when animations start running when loading a scene for the first time.
  33896. */
  33897. resetLastAnimationTimeFrame(): void;
  33898. /**
  33899. * Gets the current view matrix
  33900. * @returns a Matrix
  33901. */
  33902. getViewMatrix(): Matrix;
  33903. /**
  33904. * Gets the current projection matrix
  33905. * @returns a Matrix
  33906. */
  33907. getProjectionMatrix(): Matrix;
  33908. /**
  33909. * Gets the current transform matrix
  33910. * @returns a Matrix made of View * Projection
  33911. */
  33912. getTransformMatrix(): Matrix;
  33913. /**
  33914. * Sets the current transform matrix
  33915. * @param viewL defines the View matrix to use
  33916. * @param projectionL defines the Projection matrix to use
  33917. * @param viewR defines the right View matrix to use (if provided)
  33918. * @param projectionR defines the right Projection matrix to use (if provided)
  33919. */
  33920. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33921. /**
  33922. * Gets the uniform buffer used to store scene data
  33923. * @returns a UniformBuffer
  33924. */
  33925. getSceneUniformBuffer(): UniformBuffer;
  33926. /**
  33927. * Gets an unique (relatively to the current scene) Id
  33928. * @returns an unique number for the scene
  33929. */
  33930. getUniqueId(): number;
  33931. /**
  33932. * Add a mesh to the list of scene's meshes
  33933. * @param newMesh defines the mesh to add
  33934. * @param recursive if all child meshes should also be added to the scene
  33935. */
  33936. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33937. /**
  33938. * Remove a mesh for the list of scene's meshes
  33939. * @param toRemove defines the mesh to remove
  33940. * @param recursive if all child meshes should also be removed from the scene
  33941. * @returns the index where the mesh was in the mesh list
  33942. */
  33943. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33944. /**
  33945. * Add a transform node to the list of scene's transform nodes
  33946. * @param newTransformNode defines the transform node to add
  33947. */
  33948. addTransformNode(newTransformNode: TransformNode): void;
  33949. /**
  33950. * Remove a transform node for the list of scene's transform nodes
  33951. * @param toRemove defines the transform node to remove
  33952. * @returns the index where the transform node was in the transform node list
  33953. */
  33954. removeTransformNode(toRemove: TransformNode): number;
  33955. /**
  33956. * Remove a skeleton for the list of scene's skeletons
  33957. * @param toRemove defines the skeleton to remove
  33958. * @returns the index where the skeleton was in the skeleton list
  33959. */
  33960. removeSkeleton(toRemove: Skeleton): number;
  33961. /**
  33962. * Remove a morph target for the list of scene's morph targets
  33963. * @param toRemove defines the morph target to remove
  33964. * @returns the index where the morph target was in the morph target list
  33965. */
  33966. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33967. /**
  33968. * Remove a light for the list of scene's lights
  33969. * @param toRemove defines the light to remove
  33970. * @returns the index where the light was in the light list
  33971. */
  33972. removeLight(toRemove: Light): number;
  33973. /**
  33974. * Remove a camera for the list of scene's cameras
  33975. * @param toRemove defines the camera to remove
  33976. * @returns the index where the camera was in the camera list
  33977. */
  33978. removeCamera(toRemove: Camera): number;
  33979. /**
  33980. * Remove a particle system for the list of scene's particle systems
  33981. * @param toRemove defines the particle system to remove
  33982. * @returns the index where the particle system was in the particle system list
  33983. */
  33984. removeParticleSystem(toRemove: IParticleSystem): number;
  33985. /**
  33986. * Remove a animation for the list of scene's animations
  33987. * @param toRemove defines the animation to remove
  33988. * @returns the index where the animation was in the animation list
  33989. */
  33990. removeAnimation(toRemove: Animation): number;
  33991. /**
  33992. * Will stop the animation of the given target
  33993. * @param target - the target
  33994. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33995. * @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)
  33996. */
  33997. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33998. /**
  33999. * Removes the given animation group from this scene.
  34000. * @param toRemove The animation group to remove
  34001. * @returns The index of the removed animation group
  34002. */
  34003. removeAnimationGroup(toRemove: AnimationGroup): number;
  34004. /**
  34005. * Removes the given multi-material from this scene.
  34006. * @param toRemove The multi-material to remove
  34007. * @returns The index of the removed multi-material
  34008. */
  34009. removeMultiMaterial(toRemove: MultiMaterial): number;
  34010. /**
  34011. * Removes the given material from this scene.
  34012. * @param toRemove The material to remove
  34013. * @returns The index of the removed material
  34014. */
  34015. removeMaterial(toRemove: Material): number;
  34016. /**
  34017. * Removes the given action manager from this scene.
  34018. * @param toRemove The action manager to remove
  34019. * @returns The index of the removed action manager
  34020. */
  34021. removeActionManager(toRemove: AbstractActionManager): number;
  34022. /**
  34023. * Removes the given texture from this scene.
  34024. * @param toRemove The texture to remove
  34025. * @returns The index of the removed texture
  34026. */
  34027. removeTexture(toRemove: BaseTexture): number;
  34028. /**
  34029. * Adds the given light to this scene
  34030. * @param newLight The light to add
  34031. */
  34032. addLight(newLight: Light): void;
  34033. /**
  34034. * Sorts the list list based on light priorities
  34035. */
  34036. sortLightsByPriority(): void;
  34037. /**
  34038. * Adds the given camera to this scene
  34039. * @param newCamera The camera to add
  34040. */
  34041. addCamera(newCamera: Camera): void;
  34042. /**
  34043. * Adds the given skeleton to this scene
  34044. * @param newSkeleton The skeleton to add
  34045. */
  34046. addSkeleton(newSkeleton: Skeleton): void;
  34047. /**
  34048. * Adds the given particle system to this scene
  34049. * @param newParticleSystem The particle system to add
  34050. */
  34051. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34052. /**
  34053. * Adds the given animation to this scene
  34054. * @param newAnimation The animation to add
  34055. */
  34056. addAnimation(newAnimation: Animation): void;
  34057. /**
  34058. * Adds the given animation group to this scene.
  34059. * @param newAnimationGroup The animation group to add
  34060. */
  34061. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34062. /**
  34063. * Adds the given multi-material to this scene
  34064. * @param newMultiMaterial The multi-material to add
  34065. */
  34066. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34067. /**
  34068. * Adds the given material to this scene
  34069. * @param newMaterial The material to add
  34070. */
  34071. addMaterial(newMaterial: Material): void;
  34072. /**
  34073. * Adds the given morph target to this scene
  34074. * @param newMorphTargetManager The morph target to add
  34075. */
  34076. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34077. /**
  34078. * Adds the given geometry to this scene
  34079. * @param newGeometry The geometry to add
  34080. */
  34081. addGeometry(newGeometry: Geometry): void;
  34082. /**
  34083. * Adds the given action manager to this scene
  34084. * @param newActionManager The action manager to add
  34085. */
  34086. addActionManager(newActionManager: AbstractActionManager): void;
  34087. /**
  34088. * Adds the given texture to this scene.
  34089. * @param newTexture The texture to add
  34090. */
  34091. addTexture(newTexture: BaseTexture): void;
  34092. /**
  34093. * Switch active camera
  34094. * @param newCamera defines the new active camera
  34095. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34096. */
  34097. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34098. /**
  34099. * sets the active camera of the scene using its ID
  34100. * @param id defines the camera's ID
  34101. * @return the new active camera or null if none found.
  34102. */
  34103. setActiveCameraByID(id: string): Nullable<Camera>;
  34104. /**
  34105. * sets the active camera of the scene using its name
  34106. * @param name defines the camera's name
  34107. * @returns the new active camera or null if none found.
  34108. */
  34109. setActiveCameraByName(name: string): Nullable<Camera>;
  34110. /**
  34111. * get an animation group using its name
  34112. * @param name defines the material's name
  34113. * @return the animation group or null if none found.
  34114. */
  34115. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34116. /**
  34117. * Get a material using its unique id
  34118. * @param uniqueId defines the material's unique id
  34119. * @return the material or null if none found.
  34120. */
  34121. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34122. /**
  34123. * get a material using its id
  34124. * @param id defines the material's ID
  34125. * @return the material or null if none found.
  34126. */
  34127. getMaterialByID(id: string): Nullable<Material>;
  34128. /**
  34129. * Gets a the last added material using a given id
  34130. * @param id defines the material's ID
  34131. * @return the last material with the given id or null if none found.
  34132. */
  34133. getLastMaterialByID(id: string): Nullable<Material>;
  34134. /**
  34135. * Gets a material using its name
  34136. * @param name defines the material's name
  34137. * @return the material or null if none found.
  34138. */
  34139. getMaterialByName(name: string): Nullable<Material>;
  34140. /**
  34141. * Get a texture using its unique id
  34142. * @param uniqueId defines the texture's unique id
  34143. * @return the texture or null if none found.
  34144. */
  34145. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34146. /**
  34147. * Gets a camera using its id
  34148. * @param id defines the id to look for
  34149. * @returns the camera or null if not found
  34150. */
  34151. getCameraByID(id: string): Nullable<Camera>;
  34152. /**
  34153. * Gets a camera using its unique id
  34154. * @param uniqueId defines the unique id to look for
  34155. * @returns the camera or null if not found
  34156. */
  34157. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34158. /**
  34159. * Gets a camera using its name
  34160. * @param name defines the camera's name
  34161. * @return the camera or null if none found.
  34162. */
  34163. getCameraByName(name: string): Nullable<Camera>;
  34164. /**
  34165. * Gets a bone using its id
  34166. * @param id defines the bone's id
  34167. * @return the bone or null if not found
  34168. */
  34169. getBoneByID(id: string): Nullable<Bone>;
  34170. /**
  34171. * Gets a bone using its id
  34172. * @param name defines the bone's name
  34173. * @return the bone or null if not found
  34174. */
  34175. getBoneByName(name: string): Nullable<Bone>;
  34176. /**
  34177. * Gets a light node using its name
  34178. * @param name defines the the light's name
  34179. * @return the light or null if none found.
  34180. */
  34181. getLightByName(name: string): Nullable<Light>;
  34182. /**
  34183. * Gets a light node using its id
  34184. * @param id defines the light's id
  34185. * @return the light or null if none found.
  34186. */
  34187. getLightByID(id: string): Nullable<Light>;
  34188. /**
  34189. * Gets a light node using its scene-generated unique ID
  34190. * @param uniqueId defines the light's unique id
  34191. * @return the light or null if none found.
  34192. */
  34193. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34194. /**
  34195. * Gets a particle system by id
  34196. * @param id defines the particle system id
  34197. * @return the corresponding system or null if none found
  34198. */
  34199. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34200. /**
  34201. * Gets a geometry using its ID
  34202. * @param id defines the geometry's id
  34203. * @return the geometry or null if none found.
  34204. */
  34205. getGeometryByID(id: string): Nullable<Geometry>;
  34206. private _getGeometryByUniqueID;
  34207. /**
  34208. * Add a new geometry to this scene
  34209. * @param geometry defines the geometry to be added to the scene.
  34210. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34211. * @return a boolean defining if the geometry was added or not
  34212. */
  34213. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34214. /**
  34215. * Removes an existing geometry
  34216. * @param geometry defines the geometry to be removed from the scene
  34217. * @return a boolean defining if the geometry was removed or not
  34218. */
  34219. removeGeometry(geometry: Geometry): boolean;
  34220. /**
  34221. * Gets the list of geometries attached to the scene
  34222. * @returns an array of Geometry
  34223. */
  34224. getGeometries(): Geometry[];
  34225. /**
  34226. * Gets the first added mesh found of a given ID
  34227. * @param id defines the id to search for
  34228. * @return the mesh found or null if not found at all
  34229. */
  34230. getMeshByID(id: string): Nullable<AbstractMesh>;
  34231. /**
  34232. * Gets a list of meshes using their id
  34233. * @param id defines the id to search for
  34234. * @returns a list of meshes
  34235. */
  34236. getMeshesByID(id: string): Array<AbstractMesh>;
  34237. /**
  34238. * Gets the first added transform node found of a given ID
  34239. * @param id defines the id to search for
  34240. * @return the found transform node or null if not found at all.
  34241. */
  34242. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34243. /**
  34244. * Gets a transform node with its auto-generated unique id
  34245. * @param uniqueId efines the unique id to search for
  34246. * @return the found transform node or null if not found at all.
  34247. */
  34248. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34249. /**
  34250. * Gets a list of transform nodes using their id
  34251. * @param id defines the id to search for
  34252. * @returns a list of transform nodes
  34253. */
  34254. getTransformNodesByID(id: string): Array<TransformNode>;
  34255. /**
  34256. * Gets a mesh with its auto-generated unique id
  34257. * @param uniqueId defines the unique id to search for
  34258. * @return the found mesh or null if not found at all.
  34259. */
  34260. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34261. /**
  34262. * Gets a the last added mesh using a given id
  34263. * @param id defines the id to search for
  34264. * @return the found mesh or null if not found at all.
  34265. */
  34266. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34267. /**
  34268. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34269. * @param id defines the id to search for
  34270. * @return the found node or null if not found at all
  34271. */
  34272. getLastEntryByID(id: string): Nullable<Node>;
  34273. /**
  34274. * Gets a node (Mesh, Camera, Light) using a given id
  34275. * @param id defines the id to search for
  34276. * @return the found node or null if not found at all
  34277. */
  34278. getNodeByID(id: string): Nullable<Node>;
  34279. /**
  34280. * Gets a node (Mesh, Camera, Light) using a given name
  34281. * @param name defines the name to search for
  34282. * @return the found node or null if not found at all.
  34283. */
  34284. getNodeByName(name: string): Nullable<Node>;
  34285. /**
  34286. * Gets a mesh using a given name
  34287. * @param name defines the name to search for
  34288. * @return the found mesh or null if not found at all.
  34289. */
  34290. getMeshByName(name: string): Nullable<AbstractMesh>;
  34291. /**
  34292. * Gets a transform node using a given name
  34293. * @param name defines the name to search for
  34294. * @return the found transform node or null if not found at all.
  34295. */
  34296. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34297. /**
  34298. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34299. * @param id defines the id to search for
  34300. * @return the found skeleton or null if not found at all.
  34301. */
  34302. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34303. /**
  34304. * Gets a skeleton using a given auto generated unique id
  34305. * @param uniqueId defines the unique id to search for
  34306. * @return the found skeleton or null if not found at all.
  34307. */
  34308. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34309. /**
  34310. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34311. * @param id defines the id to search for
  34312. * @return the found skeleton or null if not found at all.
  34313. */
  34314. getSkeletonById(id: string): Nullable<Skeleton>;
  34315. /**
  34316. * Gets a skeleton using a given name
  34317. * @param name defines the name to search for
  34318. * @return the found skeleton or null if not found at all.
  34319. */
  34320. getSkeletonByName(name: string): Nullable<Skeleton>;
  34321. /**
  34322. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34323. * @param id defines the id to search for
  34324. * @return the found morph target manager or null if not found at all.
  34325. */
  34326. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34327. /**
  34328. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34329. * @param id defines the id to search for
  34330. * @return the found morph target or null if not found at all.
  34331. */
  34332. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34333. /**
  34334. * Gets a boolean indicating if the given mesh is active
  34335. * @param mesh defines the mesh to look for
  34336. * @returns true if the mesh is in the active list
  34337. */
  34338. isActiveMesh(mesh: AbstractMesh): boolean;
  34339. /**
  34340. * Return a unique id as a string which can serve as an identifier for the scene
  34341. */
  34342. readonly uid: string;
  34343. /**
  34344. * Add an externaly attached data from its key.
  34345. * This method call will fail and return false, if such key already exists.
  34346. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34347. * @param key the unique key that identifies the data
  34348. * @param data the data object to associate to the key for this Engine instance
  34349. * @return true if no such key were already present and the data was added successfully, false otherwise
  34350. */
  34351. addExternalData<T>(key: string, data: T): boolean;
  34352. /**
  34353. * Get an externaly attached data from its key
  34354. * @param key the unique key that identifies the data
  34355. * @return the associated data, if present (can be null), or undefined if not present
  34356. */
  34357. getExternalData<T>(key: string): Nullable<T>;
  34358. /**
  34359. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34360. * @param key the unique key that identifies the data
  34361. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34362. * @return the associated data, can be null if the factory returned null.
  34363. */
  34364. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34365. /**
  34366. * Remove an externaly attached data from the Engine instance
  34367. * @param key the unique key that identifies the data
  34368. * @return true if the data was successfully removed, false if it doesn't exist
  34369. */
  34370. removeExternalData(key: string): boolean;
  34371. private _evaluateSubMesh;
  34372. /**
  34373. * Clear the processed materials smart array preventing retention point in material dispose.
  34374. */
  34375. freeProcessedMaterials(): void;
  34376. private _preventFreeActiveMeshesAndRenderingGroups;
  34377. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34378. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34379. * when disposing several meshes in a row or a hierarchy of meshes.
  34380. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34381. */
  34382. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34383. /**
  34384. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34385. */
  34386. freeActiveMeshes(): void;
  34387. /**
  34388. * Clear the info related to rendering groups preventing retention points during dispose.
  34389. */
  34390. freeRenderingGroups(): void;
  34391. /** @hidden */
  34392. _isInIntermediateRendering(): boolean;
  34393. /**
  34394. * Lambda returning the list of potentially active meshes.
  34395. */
  34396. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34397. /**
  34398. * Lambda returning the list of potentially active sub meshes.
  34399. */
  34400. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34401. /**
  34402. * Lambda returning the list of potentially intersecting sub meshes.
  34403. */
  34404. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34405. /**
  34406. * Lambda returning the list of potentially colliding sub meshes.
  34407. */
  34408. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34409. private _activeMeshesFrozen;
  34410. /**
  34411. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34412. * @returns the current scene
  34413. */
  34414. freezeActiveMeshes(): Scene;
  34415. /**
  34416. * Use this function to restart evaluating active meshes on every frame
  34417. * @returns the current scene
  34418. */
  34419. unfreezeActiveMeshes(): Scene;
  34420. private _evaluateActiveMeshes;
  34421. private _activeMesh;
  34422. /**
  34423. * Update the transform matrix to update from the current active camera
  34424. * @param force defines a boolean used to force the update even if cache is up to date
  34425. */
  34426. updateTransformMatrix(force?: boolean): void;
  34427. private _bindFrameBuffer;
  34428. /** @hidden */
  34429. _allowPostProcessClearColor: boolean;
  34430. /** @hidden */
  34431. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34432. private _processSubCameras;
  34433. private _checkIntersections;
  34434. /** @hidden */
  34435. _advancePhysicsEngineStep(step: number): void;
  34436. /**
  34437. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34438. */
  34439. getDeterministicFrameTime: () => number;
  34440. /** @hidden */
  34441. _animate(): void;
  34442. /** Execute all animations (for a frame) */
  34443. animate(): void;
  34444. /**
  34445. * Render the scene
  34446. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34447. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34448. */
  34449. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34450. /**
  34451. * Freeze all materials
  34452. * A frozen material will not be updatable but should be faster to render
  34453. */
  34454. freezeMaterials(): void;
  34455. /**
  34456. * Unfreeze all materials
  34457. * A frozen material will not be updatable but should be faster to render
  34458. */
  34459. unfreezeMaterials(): void;
  34460. /**
  34461. * Releases all held ressources
  34462. */
  34463. dispose(): void;
  34464. /**
  34465. * Gets if the scene is already disposed
  34466. */
  34467. readonly isDisposed: boolean;
  34468. /**
  34469. * Call this function to reduce memory footprint of the scene.
  34470. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34471. */
  34472. clearCachedVertexData(): void;
  34473. /**
  34474. * This function will remove the local cached buffer data from texture.
  34475. * It will save memory but will prevent the texture from being rebuilt
  34476. */
  34477. cleanCachedTextureBuffer(): void;
  34478. /**
  34479. * Get the world extend vectors with an optional filter
  34480. *
  34481. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34482. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34483. */
  34484. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34485. min: Vector3;
  34486. max: Vector3;
  34487. };
  34488. /**
  34489. * Creates a ray that can be used to pick in the scene
  34490. * @param x defines the x coordinate of the origin (on-screen)
  34491. * @param y defines the y coordinate of the origin (on-screen)
  34492. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34493. * @param camera defines the camera to use for the picking
  34494. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34495. * @returns a Ray
  34496. */
  34497. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34498. /**
  34499. * Creates a ray that can be used to pick in the scene
  34500. * @param x defines the x coordinate of the origin (on-screen)
  34501. * @param y defines the y coordinate of the origin (on-screen)
  34502. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34503. * @param result defines the ray where to store the picking ray
  34504. * @param camera defines the camera to use for the picking
  34505. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34506. * @returns the current scene
  34507. */
  34508. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34509. /**
  34510. * Creates a ray that can be used to pick in the scene
  34511. * @param x defines the x coordinate of the origin (on-screen)
  34512. * @param y defines the y coordinate of the origin (on-screen)
  34513. * @param camera defines the camera to use for the picking
  34514. * @returns a Ray
  34515. */
  34516. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34517. /**
  34518. * Creates a ray that can be used to pick in the scene
  34519. * @param x defines the x coordinate of the origin (on-screen)
  34520. * @param y defines the y coordinate of the origin (on-screen)
  34521. * @param result defines the ray where to store the picking ray
  34522. * @param camera defines the camera to use for the picking
  34523. * @returns the current scene
  34524. */
  34525. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34526. /** Launch a ray to try to pick a mesh in the scene
  34527. * @param x position on screen
  34528. * @param y position on screen
  34529. * @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
  34530. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34531. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34532. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34533. * @returns a PickingInfo
  34534. */
  34535. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34536. /** Use the given ray to pick a mesh in the scene
  34537. * @param ray The ray to use to pick meshes
  34538. * @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
  34539. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34540. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34541. * @returns a PickingInfo
  34542. */
  34543. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34544. /**
  34545. * Launch a ray to try to pick a mesh in the scene
  34546. * @param x X position on screen
  34547. * @param y Y position on screen
  34548. * @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
  34549. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34550. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34551. * @returns an array of PickingInfo
  34552. */
  34553. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34554. /**
  34555. * Launch a ray to try to pick a mesh in the scene
  34556. * @param ray Ray to use
  34557. * @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
  34558. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34559. * @returns an array of PickingInfo
  34560. */
  34561. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34562. /**
  34563. * Force the value of meshUnderPointer
  34564. * @param mesh defines the mesh to use
  34565. */
  34566. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34567. /**
  34568. * Gets the mesh under the pointer
  34569. * @returns a Mesh or null if no mesh is under the pointer
  34570. */
  34571. getPointerOverMesh(): Nullable<AbstractMesh>;
  34572. /** @hidden */
  34573. _rebuildGeometries(): void;
  34574. /** @hidden */
  34575. _rebuildTextures(): void;
  34576. private _getByTags;
  34577. /**
  34578. * Get a list of meshes by tags
  34579. * @param tagsQuery defines the tags query to use
  34580. * @param forEach defines a predicate used to filter results
  34581. * @returns an array of Mesh
  34582. */
  34583. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34584. /**
  34585. * Get a list of cameras by tags
  34586. * @param tagsQuery defines the tags query to use
  34587. * @param forEach defines a predicate used to filter results
  34588. * @returns an array of Camera
  34589. */
  34590. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34591. /**
  34592. * Get a list of lights by tags
  34593. * @param tagsQuery defines the tags query to use
  34594. * @param forEach defines a predicate used to filter results
  34595. * @returns an array of Light
  34596. */
  34597. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34598. /**
  34599. * Get a list of materials by tags
  34600. * @param tagsQuery defines the tags query to use
  34601. * @param forEach defines a predicate used to filter results
  34602. * @returns an array of Material
  34603. */
  34604. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34605. /**
  34606. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34607. * This allowed control for front to back rendering or reversly depending of the special needs.
  34608. *
  34609. * @param renderingGroupId The rendering group id corresponding to its index
  34610. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34611. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34612. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34613. */
  34614. 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;
  34615. /**
  34616. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34617. *
  34618. * @param renderingGroupId The rendering group id corresponding to its index
  34619. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34620. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34621. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34622. */
  34623. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34624. /**
  34625. * Gets the current auto clear configuration for one rendering group of the rendering
  34626. * manager.
  34627. * @param index the rendering group index to get the information for
  34628. * @returns The auto clear setup for the requested rendering group
  34629. */
  34630. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34631. private _blockMaterialDirtyMechanism;
  34632. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34633. blockMaterialDirtyMechanism: boolean;
  34634. /**
  34635. * Will flag all materials as dirty to trigger new shader compilation
  34636. * @param flag defines the flag used to specify which material part must be marked as dirty
  34637. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34638. */
  34639. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34640. /** @hidden */
  34641. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34642. /** @hidden */
  34643. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34644. }
  34645. }
  34646. declare module BABYLON {
  34647. /**
  34648. * Set of assets to keep when moving a scene into an asset container.
  34649. */
  34650. export class KeepAssets extends AbstractScene {
  34651. }
  34652. /**
  34653. * Container with a set of assets that can be added or removed from a scene.
  34654. */
  34655. export class AssetContainer extends AbstractScene {
  34656. /**
  34657. * The scene the AssetContainer belongs to.
  34658. */
  34659. scene: Scene;
  34660. /**
  34661. * Instantiates an AssetContainer.
  34662. * @param scene The scene the AssetContainer belongs to.
  34663. */
  34664. constructor(scene: Scene);
  34665. /**
  34666. * Adds all the assets from the container to the scene.
  34667. */
  34668. addAllToScene(): void;
  34669. /**
  34670. * Removes all the assets in the container from the scene
  34671. */
  34672. removeAllFromScene(): void;
  34673. /**
  34674. * Disposes all the assets in the container
  34675. */
  34676. dispose(): void;
  34677. private _moveAssets;
  34678. /**
  34679. * Removes all the assets contained in the scene and adds them to the container.
  34680. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34681. */
  34682. moveAllFromScene(keepAssets?: KeepAssets): void;
  34683. /**
  34684. * 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.
  34685. * @returns the root mesh
  34686. */
  34687. createRootMesh(): Mesh;
  34688. }
  34689. }
  34690. declare module BABYLON {
  34691. /**
  34692. * Defines how the parser contract is defined.
  34693. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34694. */
  34695. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34696. /**
  34697. * Defines how the individual parser contract is defined.
  34698. * These parser can parse an individual asset
  34699. */
  34700. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34701. /**
  34702. * Base class of the scene acting as a container for the different elements composing a scene.
  34703. * This class is dynamically extended by the different components of the scene increasing
  34704. * flexibility and reducing coupling
  34705. */
  34706. export abstract class AbstractScene {
  34707. /**
  34708. * Stores the list of available parsers in the application.
  34709. */
  34710. private static _BabylonFileParsers;
  34711. /**
  34712. * Stores the list of available individual parsers in the application.
  34713. */
  34714. private static _IndividualBabylonFileParsers;
  34715. /**
  34716. * Adds a parser in the list of available ones
  34717. * @param name Defines the name of the parser
  34718. * @param parser Defines the parser to add
  34719. */
  34720. static AddParser(name: string, parser: BabylonFileParser): void;
  34721. /**
  34722. * Gets a general parser from the list of avaialble ones
  34723. * @param name Defines the name of the parser
  34724. * @returns the requested parser or null
  34725. */
  34726. static GetParser(name: string): Nullable<BabylonFileParser>;
  34727. /**
  34728. * Adds n individual parser in the list of available ones
  34729. * @param name Defines the name of the parser
  34730. * @param parser Defines the parser to add
  34731. */
  34732. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34733. /**
  34734. * Gets an individual parser from the list of avaialble ones
  34735. * @param name Defines the name of the parser
  34736. * @returns the requested parser or null
  34737. */
  34738. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34739. /**
  34740. * Parser json data and populate both a scene and its associated container object
  34741. * @param jsonData Defines the data to parse
  34742. * @param scene Defines the scene to parse the data for
  34743. * @param container Defines the container attached to the parsing sequence
  34744. * @param rootUrl Defines the root url of the data
  34745. */
  34746. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34747. /**
  34748. * Gets the list of root nodes (ie. nodes with no parent)
  34749. */
  34750. rootNodes: Node[];
  34751. /** All of the cameras added to this scene
  34752. * @see http://doc.babylonjs.com/babylon101/cameras
  34753. */
  34754. cameras: Camera[];
  34755. /**
  34756. * All of the lights added to this scene
  34757. * @see http://doc.babylonjs.com/babylon101/lights
  34758. */
  34759. lights: Light[];
  34760. /**
  34761. * All of the (abstract) meshes added to this scene
  34762. */
  34763. meshes: AbstractMesh[];
  34764. /**
  34765. * The list of skeletons added to the scene
  34766. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34767. */
  34768. skeletons: Skeleton[];
  34769. /**
  34770. * All of the particle systems added to this scene
  34771. * @see http://doc.babylonjs.com/babylon101/particles
  34772. */
  34773. particleSystems: IParticleSystem[];
  34774. /**
  34775. * Gets a list of Animations associated with the scene
  34776. */
  34777. animations: Animation[];
  34778. /**
  34779. * All of the animation groups added to this scene
  34780. * @see http://doc.babylonjs.com/how_to/group
  34781. */
  34782. animationGroups: AnimationGroup[];
  34783. /**
  34784. * All of the multi-materials added to this scene
  34785. * @see http://doc.babylonjs.com/how_to/multi_materials
  34786. */
  34787. multiMaterials: MultiMaterial[];
  34788. /**
  34789. * All of the materials added to this scene
  34790. * In the context of a Scene, it is not supposed to be modified manually.
  34791. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34792. * Note also that the order of the Material wihin the array is not significant and might change.
  34793. * @see http://doc.babylonjs.com/babylon101/materials
  34794. */
  34795. materials: Material[];
  34796. /**
  34797. * The list of morph target managers added to the scene
  34798. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34799. */
  34800. morphTargetManagers: MorphTargetManager[];
  34801. /**
  34802. * The list of geometries used in the scene.
  34803. */
  34804. geometries: Geometry[];
  34805. /**
  34806. * All of the tranform nodes added to this scene
  34807. * In the context of a Scene, it is not supposed to be modified manually.
  34808. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34809. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34810. * @see http://doc.babylonjs.com/how_to/transformnode
  34811. */
  34812. transformNodes: TransformNode[];
  34813. /**
  34814. * ActionManagers available on the scene.
  34815. */
  34816. actionManagers: AbstractActionManager[];
  34817. /**
  34818. * Textures to keep.
  34819. */
  34820. textures: BaseTexture[];
  34821. /**
  34822. * Environment texture for the scene
  34823. */
  34824. environmentTexture: Nullable<BaseTexture>;
  34825. }
  34826. }
  34827. declare module BABYLON {
  34828. /**
  34829. * Interface used to define options for Sound class
  34830. */
  34831. export interface ISoundOptions {
  34832. /**
  34833. * Does the sound autoplay once loaded.
  34834. */
  34835. autoplay?: boolean;
  34836. /**
  34837. * Does the sound loop after it finishes playing once.
  34838. */
  34839. loop?: boolean;
  34840. /**
  34841. * Sound's volume
  34842. */
  34843. volume?: number;
  34844. /**
  34845. * Is it a spatial sound?
  34846. */
  34847. spatialSound?: boolean;
  34848. /**
  34849. * Maximum distance to hear that sound
  34850. */
  34851. maxDistance?: number;
  34852. /**
  34853. * Uses user defined attenuation function
  34854. */
  34855. useCustomAttenuation?: boolean;
  34856. /**
  34857. * Define the roll off factor of spatial sounds.
  34858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34859. */
  34860. rolloffFactor?: number;
  34861. /**
  34862. * Define the reference distance the sound should be heard perfectly.
  34863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34864. */
  34865. refDistance?: number;
  34866. /**
  34867. * Define the distance attenuation model the sound will follow.
  34868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34869. */
  34870. distanceModel?: string;
  34871. /**
  34872. * Defines the playback speed (1 by default)
  34873. */
  34874. playbackRate?: number;
  34875. /**
  34876. * Defines if the sound is from a streaming source
  34877. */
  34878. streaming?: boolean;
  34879. /**
  34880. * Defines an optional length (in seconds) inside the sound file
  34881. */
  34882. length?: number;
  34883. /**
  34884. * Defines an optional offset (in seconds) inside the sound file
  34885. */
  34886. offset?: number;
  34887. /**
  34888. * If true, URLs will not be required to state the audio file codec to use.
  34889. */
  34890. skipCodecCheck?: boolean;
  34891. }
  34892. /**
  34893. * Defines a sound that can be played in the application.
  34894. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34895. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34896. */
  34897. export class Sound {
  34898. /**
  34899. * The name of the sound in the scene.
  34900. */
  34901. name: string;
  34902. /**
  34903. * Does the sound autoplay once loaded.
  34904. */
  34905. autoplay: boolean;
  34906. /**
  34907. * Does the sound loop after it finishes playing once.
  34908. */
  34909. loop: boolean;
  34910. /**
  34911. * Does the sound use a custom attenuation curve to simulate the falloff
  34912. * happening when the source gets further away from the camera.
  34913. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34914. */
  34915. useCustomAttenuation: boolean;
  34916. /**
  34917. * The sound track id this sound belongs to.
  34918. */
  34919. soundTrackId: number;
  34920. /**
  34921. * Is this sound currently played.
  34922. */
  34923. isPlaying: boolean;
  34924. /**
  34925. * Is this sound currently paused.
  34926. */
  34927. isPaused: boolean;
  34928. /**
  34929. * Does this sound enables spatial sound.
  34930. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34931. */
  34932. spatialSound: boolean;
  34933. /**
  34934. * Define the reference distance the sound should be heard perfectly.
  34935. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34936. */
  34937. refDistance: number;
  34938. /**
  34939. * Define the roll off factor of spatial sounds.
  34940. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34941. */
  34942. rolloffFactor: number;
  34943. /**
  34944. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34945. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34946. */
  34947. maxDistance: number;
  34948. /**
  34949. * Define the distance attenuation model the sound will follow.
  34950. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34951. */
  34952. distanceModel: string;
  34953. /**
  34954. * @hidden
  34955. * Back Compat
  34956. **/
  34957. onended: () => any;
  34958. /**
  34959. * Observable event when the current playing sound finishes.
  34960. */
  34961. onEndedObservable: Observable<Sound>;
  34962. private _panningModel;
  34963. private _playbackRate;
  34964. private _streaming;
  34965. private _startTime;
  34966. private _startOffset;
  34967. private _position;
  34968. /** @hidden */
  34969. _positionInEmitterSpace: boolean;
  34970. private _localDirection;
  34971. private _volume;
  34972. private _isReadyToPlay;
  34973. private _isDirectional;
  34974. private _readyToPlayCallback;
  34975. private _audioBuffer;
  34976. private _soundSource;
  34977. private _streamingSource;
  34978. private _soundPanner;
  34979. private _soundGain;
  34980. private _inputAudioNode;
  34981. private _outputAudioNode;
  34982. private _coneInnerAngle;
  34983. private _coneOuterAngle;
  34984. private _coneOuterGain;
  34985. private _scene;
  34986. private _connectedTransformNode;
  34987. private _customAttenuationFunction;
  34988. private _registerFunc;
  34989. private _isOutputConnected;
  34990. private _htmlAudioElement;
  34991. private _urlType;
  34992. private _length?;
  34993. private _offset?;
  34994. /** @hidden */
  34995. static _SceneComponentInitialization: (scene: Scene) => void;
  34996. /**
  34997. * Create a sound and attach it to a scene
  34998. * @param name Name of your sound
  34999. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35000. * @param scene defines the scene the sound belongs to
  35001. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35002. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35003. */
  35004. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35005. /**
  35006. * Release the sound and its associated resources
  35007. */
  35008. dispose(): void;
  35009. /**
  35010. * Gets if the sounds is ready to be played or not.
  35011. * @returns true if ready, otherwise false
  35012. */
  35013. isReady(): boolean;
  35014. private _soundLoaded;
  35015. /**
  35016. * Sets the data of the sound from an audiobuffer
  35017. * @param audioBuffer The audioBuffer containing the data
  35018. */
  35019. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35020. /**
  35021. * Updates the current sounds options such as maxdistance, loop...
  35022. * @param options A JSON object containing values named as the object properties
  35023. */
  35024. updateOptions(options: ISoundOptions): void;
  35025. private _createSpatialParameters;
  35026. private _updateSpatialParameters;
  35027. /**
  35028. * Switch the panning model to HRTF:
  35029. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35030. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35031. */
  35032. switchPanningModelToHRTF(): void;
  35033. /**
  35034. * Switch the panning model to Equal Power:
  35035. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35037. */
  35038. switchPanningModelToEqualPower(): void;
  35039. private _switchPanningModel;
  35040. /**
  35041. * Connect this sound to a sound track audio node like gain...
  35042. * @param soundTrackAudioNode the sound track audio node to connect to
  35043. */
  35044. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35045. /**
  35046. * Transform this sound into a directional source
  35047. * @param coneInnerAngle Size of the inner cone in degree
  35048. * @param coneOuterAngle Size of the outer cone in degree
  35049. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35050. */
  35051. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35052. /**
  35053. * Gets or sets the inner angle for the directional cone.
  35054. */
  35055. /**
  35056. * Gets or sets the inner angle for the directional cone.
  35057. */
  35058. directionalConeInnerAngle: number;
  35059. /**
  35060. * Gets or sets the outer angle for the directional cone.
  35061. */
  35062. /**
  35063. * Gets or sets the outer angle for the directional cone.
  35064. */
  35065. directionalConeOuterAngle: number;
  35066. /**
  35067. * Sets the position of the emitter if spatial sound is enabled
  35068. * @param newPosition Defines the new posisiton
  35069. */
  35070. setPosition(newPosition: Vector3): void;
  35071. /**
  35072. * Sets the local direction of the emitter if spatial sound is enabled
  35073. * @param newLocalDirection Defines the new local direction
  35074. */
  35075. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35076. private _updateDirection;
  35077. /** @hidden */
  35078. updateDistanceFromListener(): void;
  35079. /**
  35080. * Sets a new custom attenuation function for the sound.
  35081. * @param callback Defines the function used for the attenuation
  35082. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35083. */
  35084. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35085. /**
  35086. * Play the sound
  35087. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35088. * @param offset (optional) Start the sound at a specific time in seconds
  35089. * @param length (optional) Sound duration (in seconds)
  35090. */
  35091. play(time?: number, offset?: number, length?: number): void;
  35092. private _onended;
  35093. /**
  35094. * Stop the sound
  35095. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35096. */
  35097. stop(time?: number): void;
  35098. /**
  35099. * Put the sound in pause
  35100. */
  35101. pause(): void;
  35102. /**
  35103. * Sets a dedicated volume for this sounds
  35104. * @param newVolume Define the new volume of the sound
  35105. * @param time Define time for gradual change to new volume
  35106. */
  35107. setVolume(newVolume: number, time?: number): void;
  35108. /**
  35109. * Set the sound play back rate
  35110. * @param newPlaybackRate Define the playback rate the sound should be played at
  35111. */
  35112. setPlaybackRate(newPlaybackRate: number): void;
  35113. /**
  35114. * Gets the volume of the sound.
  35115. * @returns the volume of the sound
  35116. */
  35117. getVolume(): number;
  35118. /**
  35119. * Attach the sound to a dedicated mesh
  35120. * @param transformNode The transform node to connect the sound with
  35121. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35122. */
  35123. attachToMesh(transformNode: TransformNode): void;
  35124. /**
  35125. * Detach the sound from the previously attached mesh
  35126. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35127. */
  35128. detachFromMesh(): void;
  35129. private _onRegisterAfterWorldMatrixUpdate;
  35130. /**
  35131. * Clone the current sound in the scene.
  35132. * @returns the new sound clone
  35133. */
  35134. clone(): Nullable<Sound>;
  35135. /**
  35136. * Gets the current underlying audio buffer containing the data
  35137. * @returns the audio buffer
  35138. */
  35139. getAudioBuffer(): Nullable<AudioBuffer>;
  35140. /**
  35141. * Serializes the Sound in a JSON representation
  35142. * @returns the JSON representation of the sound
  35143. */
  35144. serialize(): any;
  35145. /**
  35146. * Parse a JSON representation of a sound to innstantiate in a given scene
  35147. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35148. * @param scene Define the scene the new parsed sound should be created in
  35149. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35150. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35151. * @returns the newly parsed sound
  35152. */
  35153. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35154. }
  35155. }
  35156. declare module BABYLON {
  35157. /**
  35158. * This defines an action helpful to play a defined sound on a triggered action.
  35159. */
  35160. export class PlaySoundAction extends Action {
  35161. private _sound;
  35162. /**
  35163. * Instantiate the action
  35164. * @param triggerOptions defines the trigger options
  35165. * @param sound defines the sound to play
  35166. * @param condition defines the trigger related conditions
  35167. */
  35168. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35169. /** @hidden */
  35170. _prepare(): void;
  35171. /**
  35172. * Execute the action and play the sound.
  35173. */
  35174. execute(): void;
  35175. /**
  35176. * Serializes the actions and its related information.
  35177. * @param parent defines the object to serialize in
  35178. * @returns the serialized object
  35179. */
  35180. serialize(parent: any): any;
  35181. }
  35182. /**
  35183. * This defines an action helpful to stop a defined sound on a triggered action.
  35184. */
  35185. export class StopSoundAction extends Action {
  35186. private _sound;
  35187. /**
  35188. * Instantiate the action
  35189. * @param triggerOptions defines the trigger options
  35190. * @param sound defines the sound to stop
  35191. * @param condition defines the trigger related conditions
  35192. */
  35193. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35194. /** @hidden */
  35195. _prepare(): void;
  35196. /**
  35197. * Execute the action and stop the sound.
  35198. */
  35199. execute(): void;
  35200. /**
  35201. * Serializes the actions and its related information.
  35202. * @param parent defines the object to serialize in
  35203. * @returns the serialized object
  35204. */
  35205. serialize(parent: any): any;
  35206. }
  35207. }
  35208. declare module BABYLON {
  35209. /**
  35210. * This defines an action responsible to change the value of a property
  35211. * by interpolating between its current value and the newly set one once triggered.
  35212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35213. */
  35214. export class InterpolateValueAction extends Action {
  35215. /**
  35216. * Defines the path of the property where the value should be interpolated
  35217. */
  35218. propertyPath: string;
  35219. /**
  35220. * Defines the target value at the end of the interpolation.
  35221. */
  35222. value: any;
  35223. /**
  35224. * Defines the time it will take for the property to interpolate to the value.
  35225. */
  35226. duration: number;
  35227. /**
  35228. * Defines if the other scene animations should be stopped when the action has been triggered
  35229. */
  35230. stopOtherAnimations?: boolean;
  35231. /**
  35232. * Defines a callback raised once the interpolation animation has been done.
  35233. */
  35234. onInterpolationDone?: () => void;
  35235. /**
  35236. * Observable triggered once the interpolation animation has been done.
  35237. */
  35238. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35239. private _target;
  35240. private _effectiveTarget;
  35241. private _property;
  35242. /**
  35243. * Instantiate the action
  35244. * @param triggerOptions defines the trigger options
  35245. * @param target defines the object containing the value to interpolate
  35246. * @param propertyPath defines the path to the property in the target object
  35247. * @param value defines the target value at the end of the interpolation
  35248. * @param duration deines the time it will take for the property to interpolate to the value.
  35249. * @param condition defines the trigger related conditions
  35250. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35251. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35252. */
  35253. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35254. /** @hidden */
  35255. _prepare(): void;
  35256. /**
  35257. * Execute the action starts the value interpolation.
  35258. */
  35259. execute(): void;
  35260. /**
  35261. * Serializes the actions and its related information.
  35262. * @param parent defines the object to serialize in
  35263. * @returns the serialized object
  35264. */
  35265. serialize(parent: any): any;
  35266. }
  35267. }
  35268. declare module BABYLON {
  35269. /**
  35270. * Options allowed during the creation of a sound track.
  35271. */
  35272. export interface ISoundTrackOptions {
  35273. /**
  35274. * The volume the sound track should take during creation
  35275. */
  35276. volume?: number;
  35277. /**
  35278. * Define if the sound track is the main sound track of the scene
  35279. */
  35280. mainTrack?: boolean;
  35281. }
  35282. /**
  35283. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35284. * It will be also used in a future release to apply effects on a specific track.
  35285. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35286. */
  35287. export class SoundTrack {
  35288. /**
  35289. * The unique identifier of the sound track in the scene.
  35290. */
  35291. id: number;
  35292. /**
  35293. * The list of sounds included in the sound track.
  35294. */
  35295. soundCollection: Array<Sound>;
  35296. private _outputAudioNode;
  35297. private _scene;
  35298. private _isMainTrack;
  35299. private _connectedAnalyser;
  35300. private _options;
  35301. private _isInitialized;
  35302. /**
  35303. * Creates a new sound track.
  35304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35305. * @param scene Define the scene the sound track belongs to
  35306. * @param options
  35307. */
  35308. constructor(scene: Scene, options?: ISoundTrackOptions);
  35309. private _initializeSoundTrackAudioGraph;
  35310. /**
  35311. * Release the sound track and its associated resources
  35312. */
  35313. dispose(): void;
  35314. /**
  35315. * Adds a sound to this sound track
  35316. * @param sound define the cound to add
  35317. * @ignoreNaming
  35318. */
  35319. AddSound(sound: Sound): void;
  35320. /**
  35321. * Removes a sound to this sound track
  35322. * @param sound define the cound to remove
  35323. * @ignoreNaming
  35324. */
  35325. RemoveSound(sound: Sound): void;
  35326. /**
  35327. * Set a global volume for the full sound track.
  35328. * @param newVolume Define the new volume of the sound track
  35329. */
  35330. setVolume(newVolume: number): void;
  35331. /**
  35332. * Switch the panning model to HRTF:
  35333. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35334. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35335. */
  35336. switchPanningModelToHRTF(): void;
  35337. /**
  35338. * Switch the panning model to Equal Power:
  35339. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35340. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35341. */
  35342. switchPanningModelToEqualPower(): void;
  35343. /**
  35344. * Connect the sound track to an audio analyser allowing some amazing
  35345. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35346. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35347. * @param analyser The analyser to connect to the engine
  35348. */
  35349. connectToAnalyser(analyser: Analyser): void;
  35350. }
  35351. }
  35352. declare module BABYLON {
  35353. interface AbstractScene {
  35354. /**
  35355. * The list of sounds used in the scene.
  35356. */
  35357. sounds: Nullable<Array<Sound>>;
  35358. }
  35359. interface Scene {
  35360. /**
  35361. * @hidden
  35362. * Backing field
  35363. */
  35364. _mainSoundTrack: SoundTrack;
  35365. /**
  35366. * The main sound track played by the scene.
  35367. * It cotains your primary collection of sounds.
  35368. */
  35369. mainSoundTrack: SoundTrack;
  35370. /**
  35371. * The list of sound tracks added to the scene
  35372. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35373. */
  35374. soundTracks: Nullable<Array<SoundTrack>>;
  35375. /**
  35376. * Gets a sound using a given name
  35377. * @param name defines the name to search for
  35378. * @return the found sound or null if not found at all.
  35379. */
  35380. getSoundByName(name: string): Nullable<Sound>;
  35381. /**
  35382. * Gets or sets if audio support is enabled
  35383. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35384. */
  35385. audioEnabled: boolean;
  35386. /**
  35387. * Gets or sets if audio will be output to headphones
  35388. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35389. */
  35390. headphone: boolean;
  35391. /**
  35392. * Gets or sets custom audio listener position provider
  35393. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35394. */
  35395. audioListenerPositionProvider: Nullable<() => Vector3>;
  35396. }
  35397. /**
  35398. * Defines the sound scene component responsible to manage any sounds
  35399. * in a given scene.
  35400. */
  35401. export class AudioSceneComponent implements ISceneSerializableComponent {
  35402. /**
  35403. * The component name helpfull to identify the component in the list of scene components.
  35404. */
  35405. readonly name: string;
  35406. /**
  35407. * The scene the component belongs to.
  35408. */
  35409. scene: Scene;
  35410. private _audioEnabled;
  35411. /**
  35412. * Gets whether audio is enabled or not.
  35413. * Please use related enable/disable method to switch state.
  35414. */
  35415. readonly audioEnabled: boolean;
  35416. private _headphone;
  35417. /**
  35418. * Gets whether audio is outputing to headphone or not.
  35419. * Please use the according Switch methods to change output.
  35420. */
  35421. readonly headphone: boolean;
  35422. private _audioListenerPositionProvider;
  35423. /**
  35424. * Gets the current audio listener position provider
  35425. */
  35426. /**
  35427. * Sets a custom listener position for all sounds in the scene
  35428. * By default, this is the position of the first active camera
  35429. */
  35430. audioListenerPositionProvider: Nullable<() => Vector3>;
  35431. /**
  35432. * Creates a new instance of the component for the given scene
  35433. * @param scene Defines the scene to register the component in
  35434. */
  35435. constructor(scene: Scene);
  35436. /**
  35437. * Registers the component in a given scene
  35438. */
  35439. register(): void;
  35440. /**
  35441. * Rebuilds the elements related to this component in case of
  35442. * context lost for instance.
  35443. */
  35444. rebuild(): void;
  35445. /**
  35446. * Serializes the component data to the specified json object
  35447. * @param serializationObject The object to serialize to
  35448. */
  35449. serialize(serializationObject: any): void;
  35450. /**
  35451. * Adds all the elements from the container to the scene
  35452. * @param container the container holding the elements
  35453. */
  35454. addFromContainer(container: AbstractScene): void;
  35455. /**
  35456. * Removes all the elements in the container from the scene
  35457. * @param container contains the elements to remove
  35458. * @param dispose if the removed element should be disposed (default: false)
  35459. */
  35460. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35461. /**
  35462. * Disposes the component and the associated ressources.
  35463. */
  35464. dispose(): void;
  35465. /**
  35466. * Disables audio in the associated scene.
  35467. */
  35468. disableAudio(): void;
  35469. /**
  35470. * Enables audio in the associated scene.
  35471. */
  35472. enableAudio(): void;
  35473. /**
  35474. * Switch audio to headphone output.
  35475. */
  35476. switchAudioModeForHeadphones(): void;
  35477. /**
  35478. * Switch audio to normal speakers.
  35479. */
  35480. switchAudioModeForNormalSpeakers(): void;
  35481. private _afterRender;
  35482. }
  35483. }
  35484. declare module BABYLON {
  35485. /**
  35486. * Wraps one or more Sound objects and selects one with random weight for playback.
  35487. */
  35488. export class WeightedSound {
  35489. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35490. loop: boolean;
  35491. private _coneInnerAngle;
  35492. private _coneOuterAngle;
  35493. private _volume;
  35494. /** A Sound is currently playing. */
  35495. isPlaying: boolean;
  35496. /** A Sound is currently paused. */
  35497. isPaused: boolean;
  35498. private _sounds;
  35499. private _weights;
  35500. private _currentIndex?;
  35501. /**
  35502. * Creates a new WeightedSound from the list of sounds given.
  35503. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35504. * @param sounds Array of Sounds that will be selected from.
  35505. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35506. */
  35507. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35508. /**
  35509. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35510. */
  35511. /**
  35512. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35513. */
  35514. directionalConeInnerAngle: number;
  35515. /**
  35516. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35517. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35518. */
  35519. /**
  35520. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35521. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35522. */
  35523. directionalConeOuterAngle: number;
  35524. /**
  35525. * Playback volume.
  35526. */
  35527. /**
  35528. * Playback volume.
  35529. */
  35530. volume: number;
  35531. private _onended;
  35532. /**
  35533. * Suspend playback
  35534. */
  35535. pause(): void;
  35536. /**
  35537. * Stop playback
  35538. */
  35539. stop(): void;
  35540. /**
  35541. * Start playback.
  35542. * @param startOffset Position the clip head at a specific time in seconds.
  35543. */
  35544. play(startOffset?: number): void;
  35545. }
  35546. }
  35547. declare module BABYLON {
  35548. /**
  35549. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35550. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35551. */
  35552. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35553. /**
  35554. * Gets the name of the behavior.
  35555. */
  35556. readonly name: string;
  35557. /**
  35558. * The easing function used by animations
  35559. */
  35560. static EasingFunction: BackEase;
  35561. /**
  35562. * The easing mode used by animations
  35563. */
  35564. static EasingMode: number;
  35565. /**
  35566. * The duration of the animation, in milliseconds
  35567. */
  35568. transitionDuration: number;
  35569. /**
  35570. * Length of the distance animated by the transition when lower radius is reached
  35571. */
  35572. lowerRadiusTransitionRange: number;
  35573. /**
  35574. * Length of the distance animated by the transition when upper radius is reached
  35575. */
  35576. upperRadiusTransitionRange: number;
  35577. private _autoTransitionRange;
  35578. /**
  35579. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35580. */
  35581. /**
  35582. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35583. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35584. */
  35585. autoTransitionRange: boolean;
  35586. private _attachedCamera;
  35587. private _onAfterCheckInputsObserver;
  35588. private _onMeshTargetChangedObserver;
  35589. /**
  35590. * Initializes the behavior.
  35591. */
  35592. init(): void;
  35593. /**
  35594. * Attaches the behavior to its arc rotate camera.
  35595. * @param camera Defines the camera to attach the behavior to
  35596. */
  35597. attach(camera: ArcRotateCamera): void;
  35598. /**
  35599. * Detaches the behavior from its current arc rotate camera.
  35600. */
  35601. detach(): void;
  35602. private _radiusIsAnimating;
  35603. private _radiusBounceTransition;
  35604. private _animatables;
  35605. private _cachedWheelPrecision;
  35606. /**
  35607. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35608. * @param radiusLimit The limit to check against.
  35609. * @return Bool to indicate if at limit.
  35610. */
  35611. private _isRadiusAtLimit;
  35612. /**
  35613. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35614. * @param radiusDelta The delta by which to animate to. Can be negative.
  35615. */
  35616. private _applyBoundRadiusAnimation;
  35617. /**
  35618. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35619. */
  35620. protected _clearAnimationLocks(): void;
  35621. /**
  35622. * Stops and removes all animations that have been applied to the camera
  35623. */
  35624. stopAllAnimations(): void;
  35625. }
  35626. }
  35627. declare module BABYLON {
  35628. /**
  35629. * 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.
  35630. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35631. */
  35632. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35633. /**
  35634. * Gets the name of the behavior.
  35635. */
  35636. readonly name: string;
  35637. private _mode;
  35638. private _radiusScale;
  35639. private _positionScale;
  35640. private _defaultElevation;
  35641. private _elevationReturnTime;
  35642. private _elevationReturnWaitTime;
  35643. private _zoomStopsAnimation;
  35644. private _framingTime;
  35645. /**
  35646. * The easing function used by animations
  35647. */
  35648. static EasingFunction: ExponentialEase;
  35649. /**
  35650. * The easing mode used by animations
  35651. */
  35652. static EasingMode: number;
  35653. /**
  35654. * Sets the current mode used by the behavior
  35655. */
  35656. /**
  35657. * Gets current mode used by the behavior.
  35658. */
  35659. mode: number;
  35660. /**
  35661. * Sets the scale applied to the radius (1 by default)
  35662. */
  35663. /**
  35664. * Gets the scale applied to the radius
  35665. */
  35666. radiusScale: number;
  35667. /**
  35668. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35669. */
  35670. /**
  35671. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35672. */
  35673. positionScale: number;
  35674. /**
  35675. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35676. * behaviour is triggered, in radians.
  35677. */
  35678. /**
  35679. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35680. * behaviour is triggered, in radians.
  35681. */
  35682. defaultElevation: number;
  35683. /**
  35684. * Sets the time (in milliseconds) taken to return to the default beta position.
  35685. * Negative value indicates camera should not return to default.
  35686. */
  35687. /**
  35688. * Gets the time (in milliseconds) taken to return to the default beta position.
  35689. * Negative value indicates camera should not return to default.
  35690. */
  35691. elevationReturnTime: number;
  35692. /**
  35693. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35694. */
  35695. /**
  35696. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35697. */
  35698. elevationReturnWaitTime: number;
  35699. /**
  35700. * Sets the flag that indicates if user zooming should stop animation.
  35701. */
  35702. /**
  35703. * Gets the flag that indicates if user zooming should stop animation.
  35704. */
  35705. zoomStopsAnimation: boolean;
  35706. /**
  35707. * Sets the transition time when framing the mesh, in milliseconds
  35708. */
  35709. /**
  35710. * Gets the transition time when framing the mesh, in milliseconds
  35711. */
  35712. framingTime: number;
  35713. /**
  35714. * Define if the behavior should automatically change the configured
  35715. * camera limits and sensibilities.
  35716. */
  35717. autoCorrectCameraLimitsAndSensibility: boolean;
  35718. private _onPrePointerObservableObserver;
  35719. private _onAfterCheckInputsObserver;
  35720. private _onMeshTargetChangedObserver;
  35721. private _attachedCamera;
  35722. private _isPointerDown;
  35723. private _lastInteractionTime;
  35724. /**
  35725. * Initializes the behavior.
  35726. */
  35727. init(): void;
  35728. /**
  35729. * Attaches the behavior to its arc rotate camera.
  35730. * @param camera Defines the camera to attach the behavior to
  35731. */
  35732. attach(camera: ArcRotateCamera): void;
  35733. /**
  35734. * Detaches the behavior from its current arc rotate camera.
  35735. */
  35736. detach(): void;
  35737. private _animatables;
  35738. private _betaIsAnimating;
  35739. private _betaTransition;
  35740. private _radiusTransition;
  35741. private _vectorTransition;
  35742. /**
  35743. * Targets the given mesh and updates zoom level accordingly.
  35744. * @param mesh The mesh to target.
  35745. * @param radius Optional. If a cached radius position already exists, overrides default.
  35746. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35747. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35748. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35749. */
  35750. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35751. /**
  35752. * Targets the given mesh with its children and updates zoom level accordingly.
  35753. * @param mesh The mesh to target.
  35754. * @param radius Optional. If a cached radius position already exists, overrides default.
  35755. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35756. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35757. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35758. */
  35759. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35760. /**
  35761. * Targets the given meshes with their children and updates zoom level accordingly.
  35762. * @param meshes The mesh to target.
  35763. * @param radius Optional. If a cached radius position already exists, overrides default.
  35764. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35765. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35766. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35767. */
  35768. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35769. /**
  35770. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35771. * @param minimumWorld Determines the smaller position of the bounding box extend
  35772. * @param maximumWorld Determines the bigger position of the bounding box extend
  35773. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35774. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35775. */
  35776. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35777. /**
  35778. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35779. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35780. * frustum width.
  35781. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35782. * to fully enclose the mesh in the viewing frustum.
  35783. */
  35784. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35785. /**
  35786. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35787. * is automatically returned to its default position (expected to be above ground plane).
  35788. */
  35789. private _maintainCameraAboveGround;
  35790. /**
  35791. * Returns the frustum slope based on the canvas ratio and camera FOV
  35792. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35793. */
  35794. private _getFrustumSlope;
  35795. /**
  35796. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35797. */
  35798. private _clearAnimationLocks;
  35799. /**
  35800. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35801. */
  35802. private _applyUserInteraction;
  35803. /**
  35804. * Stops and removes all animations that have been applied to the camera
  35805. */
  35806. stopAllAnimations(): void;
  35807. /**
  35808. * Gets a value indicating if the user is moving the camera
  35809. */
  35810. readonly isUserIsMoving: boolean;
  35811. /**
  35812. * The camera can move all the way towards the mesh.
  35813. */
  35814. static IgnoreBoundsSizeMode: number;
  35815. /**
  35816. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35817. */
  35818. static FitFrustumSidesMode: number;
  35819. }
  35820. }
  35821. declare module BABYLON {
  35822. /**
  35823. * Base class for Camera Pointer Inputs.
  35824. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35825. * for example usage.
  35826. */
  35827. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35828. /**
  35829. * Defines the camera the input is attached to.
  35830. */
  35831. abstract camera: Camera;
  35832. /**
  35833. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35834. */
  35835. protected _altKey: boolean;
  35836. protected _ctrlKey: boolean;
  35837. protected _metaKey: boolean;
  35838. protected _shiftKey: boolean;
  35839. /**
  35840. * Which mouse buttons were pressed at time of last mouse event.
  35841. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35842. */
  35843. protected _buttonsPressed: number;
  35844. /**
  35845. * Defines the buttons associated with the input to handle camera move.
  35846. */
  35847. buttons: number[];
  35848. /**
  35849. * Attach the input controls to a specific dom element to get the input from.
  35850. * @param element Defines the element the controls should be listened from
  35851. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35852. */
  35853. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35854. /**
  35855. * Detach the current controls from the specified dom element.
  35856. * @param element Defines the element to stop listening the inputs from
  35857. */
  35858. detachControl(element: Nullable<HTMLElement>): void;
  35859. /**
  35860. * Gets the class name of the current input.
  35861. * @returns the class name
  35862. */
  35863. getClassName(): string;
  35864. /**
  35865. * Get the friendly name associated with the input class.
  35866. * @returns the input friendly name
  35867. */
  35868. getSimpleName(): string;
  35869. /**
  35870. * Called on pointer POINTERDOUBLETAP event.
  35871. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35872. */
  35873. protected onDoubleTap(type: string): void;
  35874. /**
  35875. * Called on pointer POINTERMOVE event if only a single touch is active.
  35876. * Override this method to provide functionality.
  35877. */
  35878. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35879. /**
  35880. * Called on pointer POINTERMOVE event if multiple touches are active.
  35881. * Override this method to provide functionality.
  35882. */
  35883. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35884. /**
  35885. * Called on JS contextmenu event.
  35886. * Override this method to provide functionality.
  35887. */
  35888. protected onContextMenu(evt: PointerEvent): void;
  35889. /**
  35890. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35891. * press.
  35892. * Override this method to provide functionality.
  35893. */
  35894. protected onButtonDown(evt: PointerEvent): void;
  35895. /**
  35896. * Called each time a new POINTERUP event occurs. Ie, for each button
  35897. * release.
  35898. * Override this method to provide functionality.
  35899. */
  35900. protected onButtonUp(evt: PointerEvent): void;
  35901. /**
  35902. * Called when window becomes inactive.
  35903. * Override this method to provide functionality.
  35904. */
  35905. protected onLostFocus(): void;
  35906. private _pointerInput;
  35907. private _observer;
  35908. private _onLostFocus;
  35909. private pointA;
  35910. private pointB;
  35911. }
  35912. }
  35913. declare module BABYLON {
  35914. /**
  35915. * Manage the pointers inputs to control an arc rotate camera.
  35916. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35917. */
  35918. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35919. /**
  35920. * Defines the camera the input is attached to.
  35921. */
  35922. camera: ArcRotateCamera;
  35923. /**
  35924. * Gets the class name of the current input.
  35925. * @returns the class name
  35926. */
  35927. getClassName(): string;
  35928. /**
  35929. * Defines the buttons associated with the input to handle camera move.
  35930. */
  35931. buttons: number[];
  35932. /**
  35933. * Defines the pointer angular sensibility along the X axis or how fast is
  35934. * the camera rotating.
  35935. */
  35936. angularSensibilityX: number;
  35937. /**
  35938. * Defines the pointer angular sensibility along the Y axis or how fast is
  35939. * the camera rotating.
  35940. */
  35941. angularSensibilityY: number;
  35942. /**
  35943. * Defines the pointer pinch precision or how fast is the camera zooming.
  35944. */
  35945. pinchPrecision: number;
  35946. /**
  35947. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35948. * from 0.
  35949. * It defines the percentage of current camera.radius to use as delta when
  35950. * pinch zoom is used.
  35951. */
  35952. pinchDeltaPercentage: number;
  35953. /**
  35954. * Defines the pointer panning sensibility or how fast is the camera moving.
  35955. */
  35956. panningSensibility: number;
  35957. /**
  35958. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35959. */
  35960. multiTouchPanning: boolean;
  35961. /**
  35962. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35963. * zoom (pinch) through multitouch.
  35964. */
  35965. multiTouchPanAndZoom: boolean;
  35966. /**
  35967. * Revers pinch action direction.
  35968. */
  35969. pinchInwards: boolean;
  35970. private _isPanClick;
  35971. private _twoFingerActivityCount;
  35972. private _isPinching;
  35973. /**
  35974. * Called on pointer POINTERMOVE event if only a single touch is active.
  35975. */
  35976. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35977. /**
  35978. * Called on pointer POINTERDOUBLETAP event.
  35979. */
  35980. protected onDoubleTap(type: string): void;
  35981. /**
  35982. * Called on pointer POINTERMOVE event if multiple touches are active.
  35983. */
  35984. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35985. /**
  35986. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35987. * press.
  35988. */
  35989. protected onButtonDown(evt: PointerEvent): void;
  35990. /**
  35991. * Called each time a new POINTERUP event occurs. Ie, for each button
  35992. * release.
  35993. */
  35994. protected onButtonUp(evt: PointerEvent): void;
  35995. /**
  35996. * Called when window becomes inactive.
  35997. */
  35998. protected onLostFocus(): void;
  35999. }
  36000. }
  36001. declare module BABYLON {
  36002. /**
  36003. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36004. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36005. */
  36006. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36007. /**
  36008. * Defines the camera the input is attached to.
  36009. */
  36010. camera: ArcRotateCamera;
  36011. /**
  36012. * Defines the list of key codes associated with the up action (increase alpha)
  36013. */
  36014. keysUp: number[];
  36015. /**
  36016. * Defines the list of key codes associated with the down action (decrease alpha)
  36017. */
  36018. keysDown: number[];
  36019. /**
  36020. * Defines the list of key codes associated with the left action (increase beta)
  36021. */
  36022. keysLeft: number[];
  36023. /**
  36024. * Defines the list of key codes associated with the right action (decrease beta)
  36025. */
  36026. keysRight: number[];
  36027. /**
  36028. * Defines the list of key codes associated with the reset action.
  36029. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36030. */
  36031. keysReset: number[];
  36032. /**
  36033. * Defines the panning sensibility of the inputs.
  36034. * (How fast is the camera paning)
  36035. */
  36036. panningSensibility: number;
  36037. /**
  36038. * Defines the zooming sensibility of the inputs.
  36039. * (How fast is the camera zooming)
  36040. */
  36041. zoomingSensibility: number;
  36042. /**
  36043. * Defines wether maintaining the alt key down switch the movement mode from
  36044. * orientation to zoom.
  36045. */
  36046. useAltToZoom: boolean;
  36047. /**
  36048. * Rotation speed of the camera
  36049. */
  36050. angularSpeed: number;
  36051. private _keys;
  36052. private _ctrlPressed;
  36053. private _altPressed;
  36054. private _onCanvasBlurObserver;
  36055. private _onKeyboardObserver;
  36056. private _engine;
  36057. private _scene;
  36058. /**
  36059. * Attach the input controls to a specific dom element to get the input from.
  36060. * @param element Defines the element the controls should be listened from
  36061. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36062. */
  36063. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36064. /**
  36065. * Detach the current controls from the specified dom element.
  36066. * @param element Defines the element to stop listening the inputs from
  36067. */
  36068. detachControl(element: Nullable<HTMLElement>): void;
  36069. /**
  36070. * Update the current camera state depending on the inputs that have been used this frame.
  36071. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36072. */
  36073. checkInputs(): void;
  36074. /**
  36075. * Gets the class name of the current intput.
  36076. * @returns the class name
  36077. */
  36078. getClassName(): string;
  36079. /**
  36080. * Get the friendly name associated with the input class.
  36081. * @returns the input friendly name
  36082. */
  36083. getSimpleName(): string;
  36084. }
  36085. }
  36086. declare module BABYLON {
  36087. /**
  36088. * Manage the mouse wheel inputs to control an arc rotate camera.
  36089. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36090. */
  36091. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36092. /**
  36093. * Defines the camera the input is attached to.
  36094. */
  36095. camera: ArcRotateCamera;
  36096. /**
  36097. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36098. */
  36099. wheelPrecision: number;
  36100. /**
  36101. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36102. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36103. */
  36104. wheelDeltaPercentage: number;
  36105. private _wheel;
  36106. private _observer;
  36107. private computeDeltaFromMouseWheelLegacyEvent;
  36108. /**
  36109. * Attach the input controls to a specific dom element to get the input from.
  36110. * @param element Defines the element the controls should be listened from
  36111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36112. */
  36113. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36114. /**
  36115. * Detach the current controls from the specified dom element.
  36116. * @param element Defines the element to stop listening the inputs from
  36117. */
  36118. detachControl(element: Nullable<HTMLElement>): void;
  36119. /**
  36120. * Gets the class name of the current intput.
  36121. * @returns the class name
  36122. */
  36123. getClassName(): string;
  36124. /**
  36125. * Get the friendly name associated with the input class.
  36126. * @returns the input friendly name
  36127. */
  36128. getSimpleName(): string;
  36129. }
  36130. }
  36131. declare module BABYLON {
  36132. /**
  36133. * Default Inputs manager for the ArcRotateCamera.
  36134. * It groups all the default supported inputs for ease of use.
  36135. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36136. */
  36137. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36138. /**
  36139. * Instantiates a new ArcRotateCameraInputsManager.
  36140. * @param camera Defines the camera the inputs belong to
  36141. */
  36142. constructor(camera: ArcRotateCamera);
  36143. /**
  36144. * Add mouse wheel input support to the input manager.
  36145. * @returns the current input manager
  36146. */
  36147. addMouseWheel(): ArcRotateCameraInputsManager;
  36148. /**
  36149. * Add pointers input support to the input manager.
  36150. * @returns the current input manager
  36151. */
  36152. addPointers(): ArcRotateCameraInputsManager;
  36153. /**
  36154. * Add keyboard input support to the input manager.
  36155. * @returns the current input manager
  36156. */
  36157. addKeyboard(): ArcRotateCameraInputsManager;
  36158. }
  36159. }
  36160. declare module BABYLON {
  36161. /**
  36162. * This represents an orbital type of camera.
  36163. *
  36164. * 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.
  36165. * 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.
  36166. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36167. */
  36168. export class ArcRotateCamera extends TargetCamera {
  36169. /**
  36170. * Defines the rotation angle of the camera along the longitudinal axis.
  36171. */
  36172. alpha: number;
  36173. /**
  36174. * Defines the rotation angle of the camera along the latitudinal axis.
  36175. */
  36176. beta: number;
  36177. /**
  36178. * Defines the radius of the camera from it s target point.
  36179. */
  36180. radius: number;
  36181. protected _target: Vector3;
  36182. protected _targetHost: Nullable<AbstractMesh>;
  36183. /**
  36184. * Defines the target point of the camera.
  36185. * The camera looks towards it form the radius distance.
  36186. */
  36187. target: Vector3;
  36188. /**
  36189. * Define the current local position of the camera in the scene
  36190. */
  36191. position: Vector3;
  36192. protected _upVector: Vector3;
  36193. protected _upToYMatrix: Matrix;
  36194. protected _YToUpMatrix: Matrix;
  36195. /**
  36196. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36197. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36198. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36199. */
  36200. upVector: Vector3;
  36201. /**
  36202. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36203. */
  36204. setMatUp(): void;
  36205. /**
  36206. * Current inertia value on the longitudinal axis.
  36207. * The bigger this number the longer it will take for the camera to stop.
  36208. */
  36209. inertialAlphaOffset: number;
  36210. /**
  36211. * Current inertia value on the latitudinal axis.
  36212. * The bigger this number the longer it will take for the camera to stop.
  36213. */
  36214. inertialBetaOffset: number;
  36215. /**
  36216. * Current inertia value on the radius axis.
  36217. * The bigger this number the longer it will take for the camera to stop.
  36218. */
  36219. inertialRadiusOffset: number;
  36220. /**
  36221. * Minimum allowed angle on the longitudinal axis.
  36222. * This can help limiting how the Camera is able to move in the scene.
  36223. */
  36224. lowerAlphaLimit: Nullable<number>;
  36225. /**
  36226. * Maximum allowed angle on the longitudinal axis.
  36227. * This can help limiting how the Camera is able to move in the scene.
  36228. */
  36229. upperAlphaLimit: Nullable<number>;
  36230. /**
  36231. * Minimum allowed angle on the latitudinal axis.
  36232. * This can help limiting how the Camera is able to move in the scene.
  36233. */
  36234. lowerBetaLimit: number;
  36235. /**
  36236. * Maximum allowed angle on the latitudinal axis.
  36237. * This can help limiting how the Camera is able to move in the scene.
  36238. */
  36239. upperBetaLimit: number;
  36240. /**
  36241. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36242. * This can help limiting how the Camera is able to move in the scene.
  36243. */
  36244. lowerRadiusLimit: Nullable<number>;
  36245. /**
  36246. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36247. * This can help limiting how the Camera is able to move in the scene.
  36248. */
  36249. upperRadiusLimit: Nullable<number>;
  36250. /**
  36251. * Defines the current inertia value used during panning of the camera along the X axis.
  36252. */
  36253. inertialPanningX: number;
  36254. /**
  36255. * Defines the current inertia value used during panning of the camera along the Y axis.
  36256. */
  36257. inertialPanningY: number;
  36258. /**
  36259. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36260. * Basically if your fingers moves away from more than this distance you will be considered
  36261. * in pinch mode.
  36262. */
  36263. pinchToPanMaxDistance: number;
  36264. /**
  36265. * Defines the maximum distance the camera can pan.
  36266. * This could help keeping the cammera always in your scene.
  36267. */
  36268. panningDistanceLimit: Nullable<number>;
  36269. /**
  36270. * Defines the target of the camera before paning.
  36271. */
  36272. panningOriginTarget: Vector3;
  36273. /**
  36274. * Defines the value of the inertia used during panning.
  36275. * 0 would mean stop inertia and one would mean no decelleration at all.
  36276. */
  36277. panningInertia: number;
  36278. /**
  36279. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36280. */
  36281. angularSensibilityX: number;
  36282. /**
  36283. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36284. */
  36285. angularSensibilityY: number;
  36286. /**
  36287. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36288. */
  36289. pinchPrecision: number;
  36290. /**
  36291. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36292. * It will be used instead of pinchDeltaPrecision if different from 0.
  36293. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36294. */
  36295. pinchDeltaPercentage: number;
  36296. /**
  36297. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36298. */
  36299. panningSensibility: number;
  36300. /**
  36301. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36302. */
  36303. keysUp: number[];
  36304. /**
  36305. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36306. */
  36307. keysDown: number[];
  36308. /**
  36309. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36310. */
  36311. keysLeft: number[];
  36312. /**
  36313. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36314. */
  36315. keysRight: number[];
  36316. /**
  36317. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36318. */
  36319. wheelPrecision: number;
  36320. /**
  36321. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36322. * It will be used instead of pinchDeltaPrecision if different from 0.
  36323. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36324. */
  36325. wheelDeltaPercentage: number;
  36326. /**
  36327. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36328. */
  36329. zoomOnFactor: number;
  36330. /**
  36331. * Defines a screen offset for the camera position.
  36332. */
  36333. targetScreenOffset: Vector2;
  36334. /**
  36335. * Allows the camera to be completely reversed.
  36336. * If false the camera can not arrive upside down.
  36337. */
  36338. allowUpsideDown: boolean;
  36339. /**
  36340. * Define if double tap/click is used to restore the previously saved state of the camera.
  36341. */
  36342. useInputToRestoreState: boolean;
  36343. /** @hidden */
  36344. _viewMatrix: Matrix;
  36345. /** @hidden */
  36346. _useCtrlForPanning: boolean;
  36347. /** @hidden */
  36348. _panningMouseButton: number;
  36349. /**
  36350. * Defines the input associated to the camera.
  36351. */
  36352. inputs: ArcRotateCameraInputsManager;
  36353. /** @hidden */
  36354. _reset: () => void;
  36355. /**
  36356. * Defines the allowed panning axis.
  36357. */
  36358. panningAxis: Vector3;
  36359. protected _localDirection: Vector3;
  36360. protected _transformedDirection: Vector3;
  36361. private _bouncingBehavior;
  36362. /**
  36363. * Gets the bouncing behavior of the camera if it has been enabled.
  36364. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36365. */
  36366. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36367. /**
  36368. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36369. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36370. */
  36371. useBouncingBehavior: boolean;
  36372. private _framingBehavior;
  36373. /**
  36374. * Gets the framing behavior of the camera if it has been enabled.
  36375. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36376. */
  36377. readonly framingBehavior: Nullable<FramingBehavior>;
  36378. /**
  36379. * Defines if the framing behavior of the camera is enabled on the camera.
  36380. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36381. */
  36382. useFramingBehavior: boolean;
  36383. private _autoRotationBehavior;
  36384. /**
  36385. * Gets the auto rotation behavior of the camera if it has been enabled.
  36386. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36387. */
  36388. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36389. /**
  36390. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36391. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36392. */
  36393. useAutoRotationBehavior: boolean;
  36394. /**
  36395. * Observable triggered when the mesh target has been changed on the camera.
  36396. */
  36397. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36398. /**
  36399. * Event raised when the camera is colliding with a mesh.
  36400. */
  36401. onCollide: (collidedMesh: AbstractMesh) => void;
  36402. /**
  36403. * Defines whether the camera should check collision with the objects oh the scene.
  36404. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36405. */
  36406. checkCollisions: boolean;
  36407. /**
  36408. * Defines the collision radius of the camera.
  36409. * This simulates a sphere around the camera.
  36410. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36411. */
  36412. collisionRadius: Vector3;
  36413. protected _collider: Collider;
  36414. protected _previousPosition: Vector3;
  36415. protected _collisionVelocity: Vector3;
  36416. protected _newPosition: Vector3;
  36417. protected _previousAlpha: number;
  36418. protected _previousBeta: number;
  36419. protected _previousRadius: number;
  36420. protected _collisionTriggered: boolean;
  36421. protected _targetBoundingCenter: Nullable<Vector3>;
  36422. private _computationVector;
  36423. /**
  36424. * Instantiates a new ArcRotateCamera in a given scene
  36425. * @param name Defines the name of the camera
  36426. * @param alpha Defines the camera rotation along the logitudinal axis
  36427. * @param beta Defines the camera rotation along the latitudinal axis
  36428. * @param radius Defines the camera distance from its target
  36429. * @param target Defines the camera target
  36430. * @param scene Defines the scene the camera belongs to
  36431. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36432. */
  36433. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36434. /** @hidden */
  36435. _initCache(): void;
  36436. /** @hidden */
  36437. _updateCache(ignoreParentClass?: boolean): void;
  36438. protected _getTargetPosition(): Vector3;
  36439. private _storedAlpha;
  36440. private _storedBeta;
  36441. private _storedRadius;
  36442. private _storedTarget;
  36443. private _storedTargetScreenOffset;
  36444. /**
  36445. * Stores the current state of the camera (alpha, beta, radius and target)
  36446. * @returns the camera itself
  36447. */
  36448. storeState(): Camera;
  36449. /**
  36450. * @hidden
  36451. * Restored camera state. You must call storeState() first
  36452. */
  36453. _restoreStateValues(): boolean;
  36454. /** @hidden */
  36455. _isSynchronizedViewMatrix(): boolean;
  36456. /**
  36457. * Attached controls to the current camera.
  36458. * @param element Defines the element the controls should be listened from
  36459. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36460. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36461. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36462. */
  36463. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36464. /**
  36465. * Detach the current controls from the camera.
  36466. * The camera will stop reacting to inputs.
  36467. * @param element Defines the element to stop listening the inputs from
  36468. */
  36469. detachControl(element: HTMLElement): void;
  36470. /** @hidden */
  36471. _checkInputs(): void;
  36472. protected _checkLimits(): void;
  36473. /**
  36474. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36475. */
  36476. rebuildAnglesAndRadius(): void;
  36477. /**
  36478. * Use a position to define the current camera related information like aplha, beta and radius
  36479. * @param position Defines the position to set the camera at
  36480. */
  36481. setPosition(position: Vector3): void;
  36482. /**
  36483. * Defines the target the camera should look at.
  36484. * This will automatically adapt alpha beta and radius to fit within the new target.
  36485. * @param target Defines the new target as a Vector or a mesh
  36486. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36487. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36488. */
  36489. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36490. /** @hidden */
  36491. _getViewMatrix(): Matrix;
  36492. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36493. /**
  36494. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36495. * @param meshes Defines the mesh to zoom on
  36496. * @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)
  36497. */
  36498. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36499. /**
  36500. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36501. * The target will be changed but the radius
  36502. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36503. * @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)
  36504. */
  36505. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36506. min: Vector3;
  36507. max: Vector3;
  36508. distance: number;
  36509. }, doNotUpdateMaxZ?: boolean): void;
  36510. /**
  36511. * @override
  36512. * Override Camera.createRigCamera
  36513. */
  36514. createRigCamera(name: string, cameraIndex: number): Camera;
  36515. /**
  36516. * @hidden
  36517. * @override
  36518. * Override Camera._updateRigCameras
  36519. */
  36520. _updateRigCameras(): void;
  36521. /**
  36522. * Destroy the camera and release the current resources hold by it.
  36523. */
  36524. dispose(): void;
  36525. /**
  36526. * Gets the current object class name.
  36527. * @return the class name
  36528. */
  36529. getClassName(): string;
  36530. }
  36531. }
  36532. declare module BABYLON {
  36533. /**
  36534. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36535. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36536. */
  36537. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36538. /**
  36539. * Gets the name of the behavior.
  36540. */
  36541. readonly name: string;
  36542. private _zoomStopsAnimation;
  36543. private _idleRotationSpeed;
  36544. private _idleRotationWaitTime;
  36545. private _idleRotationSpinupTime;
  36546. /**
  36547. * Sets the flag that indicates if user zooming should stop animation.
  36548. */
  36549. /**
  36550. * Gets the flag that indicates if user zooming should stop animation.
  36551. */
  36552. zoomStopsAnimation: boolean;
  36553. /**
  36554. * Sets the default speed at which the camera rotates around the model.
  36555. */
  36556. /**
  36557. * Gets the default speed at which the camera rotates around the model.
  36558. */
  36559. idleRotationSpeed: number;
  36560. /**
  36561. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36562. */
  36563. /**
  36564. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36565. */
  36566. idleRotationWaitTime: number;
  36567. /**
  36568. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36569. */
  36570. /**
  36571. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36572. */
  36573. idleRotationSpinupTime: number;
  36574. /**
  36575. * Gets a value indicating if the camera is currently rotating because of this behavior
  36576. */
  36577. readonly rotationInProgress: boolean;
  36578. private _onPrePointerObservableObserver;
  36579. private _onAfterCheckInputsObserver;
  36580. private _attachedCamera;
  36581. private _isPointerDown;
  36582. private _lastFrameTime;
  36583. private _lastInteractionTime;
  36584. private _cameraRotationSpeed;
  36585. /**
  36586. * Initializes the behavior.
  36587. */
  36588. init(): void;
  36589. /**
  36590. * Attaches the behavior to its arc rotate camera.
  36591. * @param camera Defines the camera to attach the behavior to
  36592. */
  36593. attach(camera: ArcRotateCamera): void;
  36594. /**
  36595. * Detaches the behavior from its current arc rotate camera.
  36596. */
  36597. detach(): void;
  36598. /**
  36599. * Returns true if user is scrolling.
  36600. * @return true if user is scrolling.
  36601. */
  36602. private _userIsZooming;
  36603. private _lastFrameRadius;
  36604. private _shouldAnimationStopForInteraction;
  36605. /**
  36606. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36607. */
  36608. private _applyUserInteraction;
  36609. private _userIsMoving;
  36610. }
  36611. }
  36612. declare module BABYLON {
  36613. /**
  36614. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36615. */
  36616. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36617. private ui;
  36618. /**
  36619. * The name of the behavior
  36620. */
  36621. name: string;
  36622. /**
  36623. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36624. */
  36625. distanceAwayFromFace: number;
  36626. /**
  36627. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36628. */
  36629. distanceAwayFromBottomOfFace: number;
  36630. private _faceVectors;
  36631. private _target;
  36632. private _scene;
  36633. private _onRenderObserver;
  36634. private _tmpMatrix;
  36635. private _tmpVector;
  36636. /**
  36637. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36638. * @param ui The transform node that should be attched to the mesh
  36639. */
  36640. constructor(ui: TransformNode);
  36641. /**
  36642. * Initializes the behavior
  36643. */
  36644. init(): void;
  36645. private _closestFace;
  36646. private _zeroVector;
  36647. private _lookAtTmpMatrix;
  36648. private _lookAtToRef;
  36649. /**
  36650. * Attaches the AttachToBoxBehavior to the passed in mesh
  36651. * @param target The mesh that the specified node will be attached to
  36652. */
  36653. attach(target: Mesh): void;
  36654. /**
  36655. * Detaches the behavior from the mesh
  36656. */
  36657. detach(): void;
  36658. }
  36659. }
  36660. declare module BABYLON {
  36661. /**
  36662. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36663. */
  36664. export class FadeInOutBehavior implements Behavior<Mesh> {
  36665. /**
  36666. * Time in milliseconds to delay before fading in (Default: 0)
  36667. */
  36668. delay: number;
  36669. /**
  36670. * Time in milliseconds for the mesh to fade in (Default: 300)
  36671. */
  36672. fadeInTime: number;
  36673. private _millisecondsPerFrame;
  36674. private _hovered;
  36675. private _hoverValue;
  36676. private _ownerNode;
  36677. /**
  36678. * Instatiates the FadeInOutBehavior
  36679. */
  36680. constructor();
  36681. /**
  36682. * The name of the behavior
  36683. */
  36684. readonly name: string;
  36685. /**
  36686. * Initializes the behavior
  36687. */
  36688. init(): void;
  36689. /**
  36690. * Attaches the fade behavior on the passed in mesh
  36691. * @param ownerNode The mesh that will be faded in/out once attached
  36692. */
  36693. attach(ownerNode: Mesh): void;
  36694. /**
  36695. * Detaches the behavior from the mesh
  36696. */
  36697. detach(): void;
  36698. /**
  36699. * Triggers the mesh to begin fading in or out
  36700. * @param value if the object should fade in or out (true to fade in)
  36701. */
  36702. fadeIn(value: boolean): void;
  36703. private _update;
  36704. private _setAllVisibility;
  36705. }
  36706. }
  36707. declare module BABYLON {
  36708. /**
  36709. * Class containing a set of static utilities functions for managing Pivots
  36710. * @hidden
  36711. */
  36712. export class PivotTools {
  36713. private static _PivotCached;
  36714. private static _OldPivotPoint;
  36715. private static _PivotTranslation;
  36716. private static _PivotTmpVector;
  36717. /** @hidden */
  36718. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36719. /** @hidden */
  36720. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36721. }
  36722. }
  36723. declare module BABYLON {
  36724. /**
  36725. * Class containing static functions to help procedurally build meshes
  36726. */
  36727. export class PlaneBuilder {
  36728. /**
  36729. * Creates a plane mesh
  36730. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36731. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36732. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36734. * * 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
  36735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36736. * @param name defines the name of the mesh
  36737. * @param options defines the options used to create the mesh
  36738. * @param scene defines the hosting scene
  36739. * @returns the plane mesh
  36740. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36741. */
  36742. static CreatePlane(name: string, options: {
  36743. size?: number;
  36744. width?: number;
  36745. height?: number;
  36746. sideOrientation?: number;
  36747. frontUVs?: Vector4;
  36748. backUVs?: Vector4;
  36749. updatable?: boolean;
  36750. sourcePlane?: Plane;
  36751. }, scene?: Nullable<Scene>): Mesh;
  36752. }
  36753. }
  36754. declare module BABYLON {
  36755. /**
  36756. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36757. */
  36758. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36759. private static _AnyMouseID;
  36760. /**
  36761. * Abstract mesh the behavior is set on
  36762. */
  36763. attachedNode: AbstractMesh;
  36764. private _dragPlane;
  36765. private _scene;
  36766. private _pointerObserver;
  36767. private _beforeRenderObserver;
  36768. private static _planeScene;
  36769. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36770. /**
  36771. * 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)
  36772. */
  36773. maxDragAngle: number;
  36774. /**
  36775. * @hidden
  36776. */
  36777. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36778. /**
  36779. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36780. */
  36781. currentDraggingPointerID: number;
  36782. /**
  36783. * The last position where the pointer hit the drag plane in world space
  36784. */
  36785. lastDragPosition: Vector3;
  36786. /**
  36787. * If the behavior is currently in a dragging state
  36788. */
  36789. dragging: boolean;
  36790. /**
  36791. * 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)
  36792. */
  36793. dragDeltaRatio: number;
  36794. /**
  36795. * If the drag plane orientation should be updated during the dragging (Default: true)
  36796. */
  36797. updateDragPlane: boolean;
  36798. private _debugMode;
  36799. private _moving;
  36800. /**
  36801. * Fires each time the attached mesh is dragged with the pointer
  36802. * * delta between last drag position and current drag position in world space
  36803. * * dragDistance along the drag axis
  36804. * * dragPlaneNormal normal of the current drag plane used during the drag
  36805. * * dragPlanePoint in world space where the drag intersects the drag plane
  36806. */
  36807. onDragObservable: Observable<{
  36808. delta: Vector3;
  36809. dragPlanePoint: Vector3;
  36810. dragPlaneNormal: Vector3;
  36811. dragDistance: number;
  36812. pointerId: number;
  36813. }>;
  36814. /**
  36815. * Fires each time a drag begins (eg. mouse down on mesh)
  36816. */
  36817. onDragStartObservable: Observable<{
  36818. dragPlanePoint: Vector3;
  36819. pointerId: number;
  36820. }>;
  36821. /**
  36822. * Fires each time a drag ends (eg. mouse release after drag)
  36823. */
  36824. onDragEndObservable: Observable<{
  36825. dragPlanePoint: Vector3;
  36826. pointerId: number;
  36827. }>;
  36828. /**
  36829. * If the attached mesh should be moved when dragged
  36830. */
  36831. moveAttached: boolean;
  36832. /**
  36833. * If the drag behavior will react to drag events (Default: true)
  36834. */
  36835. enabled: boolean;
  36836. /**
  36837. * If pointer events should start and release the drag (Default: true)
  36838. */
  36839. startAndReleaseDragOnPointerEvents: boolean;
  36840. /**
  36841. * If camera controls should be detached during the drag
  36842. */
  36843. detachCameraControls: boolean;
  36844. /**
  36845. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36846. */
  36847. useObjectOrienationForDragging: boolean;
  36848. private _options;
  36849. /**
  36850. * Creates a pointer drag behavior that can be attached to a mesh
  36851. * @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)
  36852. */
  36853. constructor(options?: {
  36854. dragAxis?: Vector3;
  36855. dragPlaneNormal?: Vector3;
  36856. });
  36857. /**
  36858. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36859. */
  36860. validateDrag: (targetPosition: Vector3) => boolean;
  36861. /**
  36862. * The name of the behavior
  36863. */
  36864. readonly name: string;
  36865. /**
  36866. * Initializes the behavior
  36867. */
  36868. init(): void;
  36869. private _tmpVector;
  36870. private _alternatePickedPoint;
  36871. private _worldDragAxis;
  36872. private _targetPosition;
  36873. private _attachedElement;
  36874. /**
  36875. * Attaches the drag behavior the passed in mesh
  36876. * @param ownerNode The mesh that will be dragged around once attached
  36877. * @param predicate Predicate to use for pick filtering
  36878. */
  36879. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  36880. /**
  36881. * Force relase the drag action by code.
  36882. */
  36883. releaseDrag(): void;
  36884. private _startDragRay;
  36885. private _lastPointerRay;
  36886. /**
  36887. * Simulates the start of a pointer drag event on the behavior
  36888. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36889. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36890. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36891. */
  36892. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36893. private _startDrag;
  36894. private _dragDelta;
  36895. private _moveDrag;
  36896. private _pickWithRayOnDragPlane;
  36897. private _pointA;
  36898. private _pointB;
  36899. private _pointC;
  36900. private _lineA;
  36901. private _lineB;
  36902. private _localAxis;
  36903. private _lookAt;
  36904. private _updateDragPlanePosition;
  36905. /**
  36906. * Detaches the behavior from the mesh
  36907. */
  36908. detach(): void;
  36909. }
  36910. }
  36911. declare module BABYLON {
  36912. /**
  36913. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36914. */
  36915. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36916. private _dragBehaviorA;
  36917. private _dragBehaviorB;
  36918. private _startDistance;
  36919. private _initialScale;
  36920. private _targetScale;
  36921. private _ownerNode;
  36922. private _sceneRenderObserver;
  36923. /**
  36924. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36925. */
  36926. constructor();
  36927. /**
  36928. * The name of the behavior
  36929. */
  36930. readonly name: string;
  36931. /**
  36932. * Initializes the behavior
  36933. */
  36934. init(): void;
  36935. private _getCurrentDistance;
  36936. /**
  36937. * Attaches the scale behavior the passed in mesh
  36938. * @param ownerNode The mesh that will be scaled around once attached
  36939. */
  36940. attach(ownerNode: Mesh): void;
  36941. /**
  36942. * Detaches the behavior from the mesh
  36943. */
  36944. detach(): void;
  36945. }
  36946. }
  36947. declare module BABYLON {
  36948. /**
  36949. * 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
  36950. */
  36951. export class SixDofDragBehavior implements Behavior<Mesh> {
  36952. private static _virtualScene;
  36953. private _ownerNode;
  36954. private _sceneRenderObserver;
  36955. private _scene;
  36956. private _targetPosition;
  36957. private _virtualOriginMesh;
  36958. private _virtualDragMesh;
  36959. private _pointerObserver;
  36960. private _moving;
  36961. private _startingOrientation;
  36962. /**
  36963. * 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)
  36964. */
  36965. private zDragFactor;
  36966. /**
  36967. * If the object should rotate to face the drag origin
  36968. */
  36969. rotateDraggedObject: boolean;
  36970. /**
  36971. * If the behavior is currently in a dragging state
  36972. */
  36973. dragging: boolean;
  36974. /**
  36975. * 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)
  36976. */
  36977. dragDeltaRatio: number;
  36978. /**
  36979. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36980. */
  36981. currentDraggingPointerID: number;
  36982. /**
  36983. * If camera controls should be detached during the drag
  36984. */
  36985. detachCameraControls: boolean;
  36986. /**
  36987. * Fires each time a drag starts
  36988. */
  36989. onDragStartObservable: Observable<{}>;
  36990. /**
  36991. * Fires each time a drag ends (eg. mouse release after drag)
  36992. */
  36993. onDragEndObservable: Observable<{}>;
  36994. /**
  36995. * 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
  36996. */
  36997. constructor();
  36998. /**
  36999. * The name of the behavior
  37000. */
  37001. readonly name: string;
  37002. /**
  37003. * Initializes the behavior
  37004. */
  37005. init(): void;
  37006. /**
  37007. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37008. */
  37009. private readonly _pointerCamera;
  37010. /**
  37011. * Attaches the scale behavior the passed in mesh
  37012. * @param ownerNode The mesh that will be scaled around once attached
  37013. */
  37014. attach(ownerNode: Mesh): void;
  37015. /**
  37016. * Detaches the behavior from the mesh
  37017. */
  37018. detach(): void;
  37019. }
  37020. }
  37021. declare module BABYLON {
  37022. /**
  37023. * Class used to apply inverse kinematics to bones
  37024. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37025. */
  37026. export class BoneIKController {
  37027. private static _tmpVecs;
  37028. private static _tmpQuat;
  37029. private static _tmpMats;
  37030. /**
  37031. * Gets or sets the target mesh
  37032. */
  37033. targetMesh: AbstractMesh;
  37034. /** Gets or sets the mesh used as pole */
  37035. poleTargetMesh: AbstractMesh;
  37036. /**
  37037. * Gets or sets the bone used as pole
  37038. */
  37039. poleTargetBone: Nullable<Bone>;
  37040. /**
  37041. * Gets or sets the target position
  37042. */
  37043. targetPosition: Vector3;
  37044. /**
  37045. * Gets or sets the pole target position
  37046. */
  37047. poleTargetPosition: Vector3;
  37048. /**
  37049. * Gets or sets the pole target local offset
  37050. */
  37051. poleTargetLocalOffset: Vector3;
  37052. /**
  37053. * Gets or sets the pole angle
  37054. */
  37055. poleAngle: number;
  37056. /**
  37057. * Gets or sets the mesh associated with the controller
  37058. */
  37059. mesh: AbstractMesh;
  37060. /**
  37061. * 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)
  37062. */
  37063. slerpAmount: number;
  37064. private _bone1Quat;
  37065. private _bone1Mat;
  37066. private _bone2Ang;
  37067. private _bone1;
  37068. private _bone2;
  37069. private _bone1Length;
  37070. private _bone2Length;
  37071. private _maxAngle;
  37072. private _maxReach;
  37073. private _rightHandedSystem;
  37074. private _bendAxis;
  37075. private _slerping;
  37076. private _adjustRoll;
  37077. /**
  37078. * Gets or sets maximum allowed angle
  37079. */
  37080. maxAngle: number;
  37081. /**
  37082. * Creates a new BoneIKController
  37083. * @param mesh defines the mesh to control
  37084. * @param bone defines the bone to control
  37085. * @param options defines options to set up the controller
  37086. */
  37087. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37088. targetMesh?: AbstractMesh;
  37089. poleTargetMesh?: AbstractMesh;
  37090. poleTargetBone?: Bone;
  37091. poleTargetLocalOffset?: Vector3;
  37092. poleAngle?: number;
  37093. bendAxis?: Vector3;
  37094. maxAngle?: number;
  37095. slerpAmount?: number;
  37096. });
  37097. private _setMaxAngle;
  37098. /**
  37099. * Force the controller to update the bones
  37100. */
  37101. update(): void;
  37102. }
  37103. }
  37104. declare module BABYLON {
  37105. /**
  37106. * Class used to make a bone look toward a point in space
  37107. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37108. */
  37109. export class BoneLookController {
  37110. private static _tmpVecs;
  37111. private static _tmpQuat;
  37112. private static _tmpMats;
  37113. /**
  37114. * The target Vector3 that the bone will look at
  37115. */
  37116. target: Vector3;
  37117. /**
  37118. * The mesh that the bone is attached to
  37119. */
  37120. mesh: AbstractMesh;
  37121. /**
  37122. * The bone that will be looking to the target
  37123. */
  37124. bone: Bone;
  37125. /**
  37126. * The up axis of the coordinate system that is used when the bone is rotated
  37127. */
  37128. upAxis: Vector3;
  37129. /**
  37130. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37131. */
  37132. upAxisSpace: Space;
  37133. /**
  37134. * Used to make an adjustment to the yaw of the bone
  37135. */
  37136. adjustYaw: number;
  37137. /**
  37138. * Used to make an adjustment to the pitch of the bone
  37139. */
  37140. adjustPitch: number;
  37141. /**
  37142. * Used to make an adjustment to the roll of the bone
  37143. */
  37144. adjustRoll: number;
  37145. /**
  37146. * 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)
  37147. */
  37148. slerpAmount: number;
  37149. private _minYaw;
  37150. private _maxYaw;
  37151. private _minPitch;
  37152. private _maxPitch;
  37153. private _minYawSin;
  37154. private _minYawCos;
  37155. private _maxYawSin;
  37156. private _maxYawCos;
  37157. private _midYawConstraint;
  37158. private _minPitchTan;
  37159. private _maxPitchTan;
  37160. private _boneQuat;
  37161. private _slerping;
  37162. private _transformYawPitch;
  37163. private _transformYawPitchInv;
  37164. private _firstFrameSkipped;
  37165. private _yawRange;
  37166. private _fowardAxis;
  37167. /**
  37168. * Gets or sets the minimum yaw angle that the bone can look to
  37169. */
  37170. minYaw: number;
  37171. /**
  37172. * Gets or sets the maximum yaw angle that the bone can look to
  37173. */
  37174. maxYaw: number;
  37175. /**
  37176. * Gets or sets the minimum pitch angle that the bone can look to
  37177. */
  37178. minPitch: number;
  37179. /**
  37180. * Gets or sets the maximum pitch angle that the bone can look to
  37181. */
  37182. maxPitch: number;
  37183. /**
  37184. * Create a BoneLookController
  37185. * @param mesh the mesh that the bone belongs to
  37186. * @param bone the bone that will be looking to the target
  37187. * @param target the target Vector3 to look at
  37188. * @param options optional settings:
  37189. * * maxYaw: the maximum angle the bone will yaw to
  37190. * * minYaw: the minimum angle the bone will yaw to
  37191. * * maxPitch: the maximum angle the bone will pitch to
  37192. * * minPitch: the minimum angle the bone will yaw to
  37193. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37194. * * upAxis: the up axis of the coordinate system
  37195. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37196. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37197. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37198. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37199. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37200. * * adjustRoll: used to make an adjustment to the roll of the bone
  37201. **/
  37202. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37203. maxYaw?: number;
  37204. minYaw?: number;
  37205. maxPitch?: number;
  37206. minPitch?: number;
  37207. slerpAmount?: number;
  37208. upAxis?: Vector3;
  37209. upAxisSpace?: Space;
  37210. yawAxis?: Vector3;
  37211. pitchAxis?: Vector3;
  37212. adjustYaw?: number;
  37213. adjustPitch?: number;
  37214. adjustRoll?: number;
  37215. });
  37216. /**
  37217. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37218. */
  37219. update(): void;
  37220. private _getAngleDiff;
  37221. private _getAngleBetween;
  37222. private _isAngleBetween;
  37223. }
  37224. }
  37225. declare module BABYLON {
  37226. /**
  37227. * Manage the gamepad inputs to control an arc rotate camera.
  37228. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37229. */
  37230. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37231. /**
  37232. * Defines the camera the input is attached to.
  37233. */
  37234. camera: ArcRotateCamera;
  37235. /**
  37236. * Defines the gamepad the input is gathering event from.
  37237. */
  37238. gamepad: Nullable<Gamepad>;
  37239. /**
  37240. * Defines the gamepad rotation sensiblity.
  37241. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37242. */
  37243. gamepadRotationSensibility: number;
  37244. /**
  37245. * Defines the gamepad move sensiblity.
  37246. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37247. */
  37248. gamepadMoveSensibility: number;
  37249. private _onGamepadConnectedObserver;
  37250. private _onGamepadDisconnectedObserver;
  37251. /**
  37252. * Attach the input controls to a specific dom element to get the input from.
  37253. * @param element Defines the element the controls should be listened from
  37254. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37255. */
  37256. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37257. /**
  37258. * Detach the current controls from the specified dom element.
  37259. * @param element Defines the element to stop listening the inputs from
  37260. */
  37261. detachControl(element: Nullable<HTMLElement>): void;
  37262. /**
  37263. * Update the current camera state depending on the inputs that have been used this frame.
  37264. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37265. */
  37266. checkInputs(): void;
  37267. /**
  37268. * Gets the class name of the current intput.
  37269. * @returns the class name
  37270. */
  37271. getClassName(): string;
  37272. /**
  37273. * Get the friendly name associated with the input class.
  37274. * @returns the input friendly name
  37275. */
  37276. getSimpleName(): string;
  37277. }
  37278. }
  37279. declare module BABYLON {
  37280. interface ArcRotateCameraInputsManager {
  37281. /**
  37282. * Add orientation input support to the input manager.
  37283. * @returns the current input manager
  37284. */
  37285. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37286. }
  37287. /**
  37288. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37289. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37290. */
  37291. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37292. /**
  37293. * Defines the camera the input is attached to.
  37294. */
  37295. camera: ArcRotateCamera;
  37296. /**
  37297. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37298. */
  37299. alphaCorrection: number;
  37300. /**
  37301. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37302. */
  37303. gammaCorrection: number;
  37304. private _alpha;
  37305. private _gamma;
  37306. private _dirty;
  37307. private _deviceOrientationHandler;
  37308. /**
  37309. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37310. */
  37311. constructor();
  37312. /**
  37313. * Attach the input controls to a specific dom element to get the input from.
  37314. * @param element Defines the element the controls should be listened from
  37315. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37316. */
  37317. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37318. /** @hidden */
  37319. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37320. /**
  37321. * Update the current camera state depending on the inputs that have been used this frame.
  37322. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37323. */
  37324. checkInputs(): void;
  37325. /**
  37326. * Detach the current controls from the specified dom element.
  37327. * @param element Defines the element to stop listening the inputs from
  37328. */
  37329. detachControl(element: Nullable<HTMLElement>): void;
  37330. /**
  37331. * Gets the class name of the current intput.
  37332. * @returns the class name
  37333. */
  37334. getClassName(): string;
  37335. /**
  37336. * Get the friendly name associated with the input class.
  37337. * @returns the input friendly name
  37338. */
  37339. getSimpleName(): string;
  37340. }
  37341. }
  37342. declare module BABYLON {
  37343. /**
  37344. * Listen to mouse events to control the camera.
  37345. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37346. */
  37347. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37348. /**
  37349. * Defines the camera the input is attached to.
  37350. */
  37351. camera: FlyCamera;
  37352. /**
  37353. * Defines if touch is enabled. (Default is true.)
  37354. */
  37355. touchEnabled: boolean;
  37356. /**
  37357. * Defines the buttons associated with the input to handle camera rotation.
  37358. */
  37359. buttons: number[];
  37360. /**
  37361. * Assign buttons for Yaw control.
  37362. */
  37363. buttonsYaw: number[];
  37364. /**
  37365. * Assign buttons for Pitch control.
  37366. */
  37367. buttonsPitch: number[];
  37368. /**
  37369. * Assign buttons for Roll control.
  37370. */
  37371. buttonsRoll: number[];
  37372. /**
  37373. * Detect if any button is being pressed while mouse is moved.
  37374. * -1 = Mouse locked.
  37375. * 0 = Left button.
  37376. * 1 = Middle Button.
  37377. * 2 = Right Button.
  37378. */
  37379. activeButton: number;
  37380. /**
  37381. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37382. * Higher values reduce its sensitivity.
  37383. */
  37384. angularSensibility: number;
  37385. private _mousemoveCallback;
  37386. private _observer;
  37387. private _rollObserver;
  37388. private previousPosition;
  37389. private noPreventDefault;
  37390. private element;
  37391. /**
  37392. * Listen to mouse events to control the camera.
  37393. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37394. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37395. */
  37396. constructor(touchEnabled?: boolean);
  37397. /**
  37398. * Attach the mouse control to the HTML DOM element.
  37399. * @param element Defines the element that listens to the input events.
  37400. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37401. */
  37402. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37403. /**
  37404. * Detach the current controls from the specified dom element.
  37405. * @param element Defines the element to stop listening the inputs from
  37406. */
  37407. detachControl(element: Nullable<HTMLElement>): void;
  37408. /**
  37409. * Gets the class name of the current input.
  37410. * @returns the class name.
  37411. */
  37412. getClassName(): string;
  37413. /**
  37414. * Get the friendly name associated with the input class.
  37415. * @returns the input's friendly name.
  37416. */
  37417. getSimpleName(): string;
  37418. private _pointerInput;
  37419. private _onMouseMove;
  37420. /**
  37421. * Rotate camera by mouse offset.
  37422. */
  37423. private rotateCamera;
  37424. }
  37425. }
  37426. declare module BABYLON {
  37427. /**
  37428. * Default Inputs manager for the FlyCamera.
  37429. * It groups all the default supported inputs for ease of use.
  37430. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37431. */
  37432. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37433. /**
  37434. * Instantiates a new FlyCameraInputsManager.
  37435. * @param camera Defines the camera the inputs belong to.
  37436. */
  37437. constructor(camera: FlyCamera);
  37438. /**
  37439. * Add keyboard input support to the input manager.
  37440. * @returns the new FlyCameraKeyboardMoveInput().
  37441. */
  37442. addKeyboard(): FlyCameraInputsManager;
  37443. /**
  37444. * Add mouse input support to the input manager.
  37445. * @param touchEnabled Enable touch screen support.
  37446. * @returns the new FlyCameraMouseInput().
  37447. */
  37448. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37449. }
  37450. }
  37451. declare module BABYLON {
  37452. /**
  37453. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37454. * such as in a 3D Space Shooter or a Flight Simulator.
  37455. */
  37456. export class FlyCamera extends TargetCamera {
  37457. /**
  37458. * Define the collision ellipsoid of the camera.
  37459. * This is helpful for simulating a camera body, like a player's body.
  37460. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37461. */
  37462. ellipsoid: Vector3;
  37463. /**
  37464. * Define an offset for the position of the ellipsoid around the camera.
  37465. * This can be helpful if the camera is attached away from the player's body center,
  37466. * such as at its head.
  37467. */
  37468. ellipsoidOffset: Vector3;
  37469. /**
  37470. * Enable or disable collisions of the camera with the rest of the scene objects.
  37471. */
  37472. checkCollisions: boolean;
  37473. /**
  37474. * Enable or disable gravity on the camera.
  37475. */
  37476. applyGravity: boolean;
  37477. /**
  37478. * Define the current direction the camera is moving to.
  37479. */
  37480. cameraDirection: Vector3;
  37481. /**
  37482. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37483. * This overrides and empties cameraRotation.
  37484. */
  37485. rotationQuaternion: Quaternion;
  37486. /**
  37487. * Track Roll to maintain the wanted Rolling when looking around.
  37488. */
  37489. _trackRoll: number;
  37490. /**
  37491. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37492. */
  37493. rollCorrect: number;
  37494. /**
  37495. * Mimic a banked turn, Rolling the camera when Yawing.
  37496. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37497. */
  37498. bankedTurn: boolean;
  37499. /**
  37500. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37501. */
  37502. bankedTurnLimit: number;
  37503. /**
  37504. * Value of 0 disables the banked Roll.
  37505. * Value of 1 is equal to the Yaw angle in radians.
  37506. */
  37507. bankedTurnMultiplier: number;
  37508. /**
  37509. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37510. */
  37511. inputs: FlyCameraInputsManager;
  37512. /**
  37513. * Gets the input sensibility for mouse input.
  37514. * Higher values reduce sensitivity.
  37515. */
  37516. /**
  37517. * Sets the input sensibility for a mouse input.
  37518. * Higher values reduce sensitivity.
  37519. */
  37520. angularSensibility: number;
  37521. /**
  37522. * Get the keys for camera movement forward.
  37523. */
  37524. /**
  37525. * Set the keys for camera movement forward.
  37526. */
  37527. keysForward: number[];
  37528. /**
  37529. * Get the keys for camera movement backward.
  37530. */
  37531. keysBackward: number[];
  37532. /**
  37533. * Get the keys for camera movement up.
  37534. */
  37535. /**
  37536. * Set the keys for camera movement up.
  37537. */
  37538. keysUp: number[];
  37539. /**
  37540. * Get the keys for camera movement down.
  37541. */
  37542. /**
  37543. * Set the keys for camera movement down.
  37544. */
  37545. keysDown: number[];
  37546. /**
  37547. * Get the keys for camera movement left.
  37548. */
  37549. /**
  37550. * Set the keys for camera movement left.
  37551. */
  37552. keysLeft: number[];
  37553. /**
  37554. * Set the keys for camera movement right.
  37555. */
  37556. /**
  37557. * Set the keys for camera movement right.
  37558. */
  37559. keysRight: number[];
  37560. /**
  37561. * Event raised when the camera collides with a mesh in the scene.
  37562. */
  37563. onCollide: (collidedMesh: AbstractMesh) => void;
  37564. private _collider;
  37565. private _needMoveForGravity;
  37566. private _oldPosition;
  37567. private _diffPosition;
  37568. private _newPosition;
  37569. /** @hidden */
  37570. _localDirection: Vector3;
  37571. /** @hidden */
  37572. _transformedDirection: Vector3;
  37573. /**
  37574. * Instantiates a FlyCamera.
  37575. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37576. * such as in a 3D Space Shooter or a Flight Simulator.
  37577. * @param name Define the name of the camera in the scene.
  37578. * @param position Define the starting position of the camera in the scene.
  37579. * @param scene Define the scene the camera belongs to.
  37580. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37581. */
  37582. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37583. /**
  37584. * Attach a control to the HTML DOM element.
  37585. * @param element Defines the element that listens to the input events.
  37586. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37587. */
  37588. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37589. /**
  37590. * Detach a control from the HTML DOM element.
  37591. * The camera will stop reacting to that input.
  37592. * @param element Defines the element that listens to the input events.
  37593. */
  37594. detachControl(element: HTMLElement): void;
  37595. private _collisionMask;
  37596. /**
  37597. * Get the mask that the camera ignores in collision events.
  37598. */
  37599. /**
  37600. * Set the mask that the camera ignores in collision events.
  37601. */
  37602. collisionMask: number;
  37603. /** @hidden */
  37604. _collideWithWorld(displacement: Vector3): void;
  37605. /** @hidden */
  37606. private _onCollisionPositionChange;
  37607. /** @hidden */
  37608. _checkInputs(): void;
  37609. /** @hidden */
  37610. _decideIfNeedsToMove(): boolean;
  37611. /** @hidden */
  37612. _updatePosition(): void;
  37613. /**
  37614. * Restore the Roll to its target value at the rate specified.
  37615. * @param rate - Higher means slower restoring.
  37616. * @hidden
  37617. */
  37618. restoreRoll(rate: number): void;
  37619. /**
  37620. * Destroy the camera and release the current resources held by it.
  37621. */
  37622. dispose(): void;
  37623. /**
  37624. * Get the current object class name.
  37625. * @returns the class name.
  37626. */
  37627. getClassName(): string;
  37628. }
  37629. }
  37630. declare module BABYLON {
  37631. /**
  37632. * Listen to keyboard events to control the camera.
  37633. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37634. */
  37635. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37636. /**
  37637. * Defines the camera the input is attached to.
  37638. */
  37639. camera: FlyCamera;
  37640. /**
  37641. * The list of keyboard keys used to control the forward move of the camera.
  37642. */
  37643. keysForward: number[];
  37644. /**
  37645. * The list of keyboard keys used to control the backward move of the camera.
  37646. */
  37647. keysBackward: number[];
  37648. /**
  37649. * The list of keyboard keys used to control the forward move of the camera.
  37650. */
  37651. keysUp: number[];
  37652. /**
  37653. * The list of keyboard keys used to control the backward move of the camera.
  37654. */
  37655. keysDown: number[];
  37656. /**
  37657. * The list of keyboard keys used to control the right strafe move of the camera.
  37658. */
  37659. keysRight: number[];
  37660. /**
  37661. * The list of keyboard keys used to control the left strafe move of the camera.
  37662. */
  37663. keysLeft: number[];
  37664. private _keys;
  37665. private _onCanvasBlurObserver;
  37666. private _onKeyboardObserver;
  37667. private _engine;
  37668. private _scene;
  37669. /**
  37670. * Attach the input controls to a specific dom element to get the input from.
  37671. * @param element Defines the element the controls should be listened from
  37672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37673. */
  37674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37675. /**
  37676. * Detach the current controls from the specified dom element.
  37677. * @param element Defines the element to stop listening the inputs from
  37678. */
  37679. detachControl(element: Nullable<HTMLElement>): void;
  37680. /**
  37681. * Gets the class name of the current intput.
  37682. * @returns the class name
  37683. */
  37684. getClassName(): string;
  37685. /** @hidden */
  37686. _onLostFocus(e: FocusEvent): void;
  37687. /**
  37688. * Get the friendly name associated with the input class.
  37689. * @returns the input friendly name
  37690. */
  37691. getSimpleName(): string;
  37692. /**
  37693. * Update the current camera state depending on the inputs that have been used this frame.
  37694. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37695. */
  37696. checkInputs(): void;
  37697. }
  37698. }
  37699. declare module BABYLON {
  37700. /**
  37701. * Manage the mouse wheel inputs to control a follow camera.
  37702. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37703. */
  37704. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37705. /**
  37706. * Defines the camera the input is attached to.
  37707. */
  37708. camera: FollowCamera;
  37709. /**
  37710. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37711. */
  37712. axisControlRadius: boolean;
  37713. /**
  37714. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37715. */
  37716. axisControlHeight: boolean;
  37717. /**
  37718. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37719. */
  37720. axisControlRotation: boolean;
  37721. /**
  37722. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37723. * relation to mouseWheel events.
  37724. */
  37725. wheelPrecision: number;
  37726. /**
  37727. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37728. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37729. */
  37730. wheelDeltaPercentage: number;
  37731. private _wheel;
  37732. private _observer;
  37733. /**
  37734. * Attach the input controls to a specific dom element to get the input from.
  37735. * @param element Defines the element the controls should be listened from
  37736. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37737. */
  37738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37739. /**
  37740. * Detach the current controls from the specified dom element.
  37741. * @param element Defines the element to stop listening the inputs from
  37742. */
  37743. detachControl(element: Nullable<HTMLElement>): void;
  37744. /**
  37745. * Gets the class name of the current intput.
  37746. * @returns the class name
  37747. */
  37748. getClassName(): string;
  37749. /**
  37750. * Get the friendly name associated with the input class.
  37751. * @returns the input friendly name
  37752. */
  37753. getSimpleName(): string;
  37754. }
  37755. }
  37756. declare module BABYLON {
  37757. /**
  37758. * Manage the pointers inputs to control an follow camera.
  37759. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37760. */
  37761. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37762. /**
  37763. * Defines the camera the input is attached to.
  37764. */
  37765. camera: FollowCamera;
  37766. /**
  37767. * Gets the class name of the current input.
  37768. * @returns the class name
  37769. */
  37770. getClassName(): string;
  37771. /**
  37772. * Defines the pointer angular sensibility along the X axis or how fast is
  37773. * the camera rotating.
  37774. * A negative number will reverse the axis direction.
  37775. */
  37776. angularSensibilityX: number;
  37777. /**
  37778. * Defines the pointer angular sensibility along the Y axis or how fast is
  37779. * the camera rotating.
  37780. * A negative number will reverse the axis direction.
  37781. */
  37782. angularSensibilityY: number;
  37783. /**
  37784. * Defines the pointer pinch precision or how fast is the camera zooming.
  37785. * A negative number will reverse the axis direction.
  37786. */
  37787. pinchPrecision: number;
  37788. /**
  37789. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37790. * from 0.
  37791. * It defines the percentage of current camera.radius to use as delta when
  37792. * pinch zoom is used.
  37793. */
  37794. pinchDeltaPercentage: number;
  37795. /**
  37796. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37797. */
  37798. axisXControlRadius: boolean;
  37799. /**
  37800. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37801. */
  37802. axisXControlHeight: boolean;
  37803. /**
  37804. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37805. */
  37806. axisXControlRotation: boolean;
  37807. /**
  37808. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37809. */
  37810. axisYControlRadius: boolean;
  37811. /**
  37812. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37813. */
  37814. axisYControlHeight: boolean;
  37815. /**
  37816. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37817. */
  37818. axisYControlRotation: boolean;
  37819. /**
  37820. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37821. */
  37822. axisPinchControlRadius: boolean;
  37823. /**
  37824. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37825. */
  37826. axisPinchControlHeight: boolean;
  37827. /**
  37828. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37829. */
  37830. axisPinchControlRotation: boolean;
  37831. /**
  37832. * Log error messages if basic misconfiguration has occurred.
  37833. */
  37834. warningEnable: boolean;
  37835. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37836. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37837. private _warningCounter;
  37838. private _warning;
  37839. }
  37840. }
  37841. declare module BABYLON {
  37842. /**
  37843. * Default Inputs manager for the FollowCamera.
  37844. * It groups all the default supported inputs for ease of use.
  37845. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37846. */
  37847. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37848. /**
  37849. * Instantiates a new FollowCameraInputsManager.
  37850. * @param camera Defines the camera the inputs belong to
  37851. */
  37852. constructor(camera: FollowCamera);
  37853. /**
  37854. * Add keyboard input support to the input manager.
  37855. * @returns the current input manager
  37856. */
  37857. addKeyboard(): FollowCameraInputsManager;
  37858. /**
  37859. * Add mouse wheel input support to the input manager.
  37860. * @returns the current input manager
  37861. */
  37862. addMouseWheel(): FollowCameraInputsManager;
  37863. /**
  37864. * Add pointers input support to the input manager.
  37865. * @returns the current input manager
  37866. */
  37867. addPointers(): FollowCameraInputsManager;
  37868. /**
  37869. * Add orientation input support to the input manager.
  37870. * @returns the current input manager
  37871. */
  37872. addVRDeviceOrientation(): FollowCameraInputsManager;
  37873. }
  37874. }
  37875. declare module BABYLON {
  37876. /**
  37877. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37878. * an arc rotate version arcFollowCamera are available.
  37879. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37880. */
  37881. export class FollowCamera extends TargetCamera {
  37882. /**
  37883. * Distance the follow camera should follow an object at
  37884. */
  37885. radius: number;
  37886. /**
  37887. * Minimum allowed distance of the camera to the axis of rotation
  37888. * (The camera can not get closer).
  37889. * This can help limiting how the Camera is able to move in the scene.
  37890. */
  37891. lowerRadiusLimit: Nullable<number>;
  37892. /**
  37893. * Maximum allowed distance of the camera to the axis of rotation
  37894. * (The camera can not get further).
  37895. * This can help limiting how the Camera is able to move in the scene.
  37896. */
  37897. upperRadiusLimit: Nullable<number>;
  37898. /**
  37899. * Define a rotation offset between the camera and the object it follows
  37900. */
  37901. rotationOffset: number;
  37902. /**
  37903. * Minimum allowed angle to camera position relative to target object.
  37904. * This can help limiting how the Camera is able to move in the scene.
  37905. */
  37906. lowerRotationOffsetLimit: Nullable<number>;
  37907. /**
  37908. * Maximum allowed angle to camera position relative to target object.
  37909. * This can help limiting how the Camera is able to move in the scene.
  37910. */
  37911. upperRotationOffsetLimit: Nullable<number>;
  37912. /**
  37913. * Define a height offset between the camera and the object it follows.
  37914. * It can help following an object from the top (like a car chaing a plane)
  37915. */
  37916. heightOffset: number;
  37917. /**
  37918. * Minimum allowed height of camera position relative to target object.
  37919. * This can help limiting how the Camera is able to move in the scene.
  37920. */
  37921. lowerHeightOffsetLimit: Nullable<number>;
  37922. /**
  37923. * Maximum allowed height of camera position relative to target object.
  37924. * This can help limiting how the Camera is able to move in the scene.
  37925. */
  37926. upperHeightOffsetLimit: Nullable<number>;
  37927. /**
  37928. * Define how fast the camera can accelerate to follow it s target.
  37929. */
  37930. cameraAcceleration: number;
  37931. /**
  37932. * Define the speed limit of the camera following an object.
  37933. */
  37934. maxCameraSpeed: number;
  37935. /**
  37936. * Define the target of the camera.
  37937. */
  37938. lockedTarget: Nullable<AbstractMesh>;
  37939. /**
  37940. * Defines the input associated with the camera.
  37941. */
  37942. inputs: FollowCameraInputsManager;
  37943. /**
  37944. * Instantiates the follow camera.
  37945. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37946. * @param name Define the name of the camera in the scene
  37947. * @param position Define the position of the camera
  37948. * @param scene Define the scene the camera belong to
  37949. * @param lockedTarget Define the target of the camera
  37950. */
  37951. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37952. private _follow;
  37953. /**
  37954. * Attached controls to the current camera.
  37955. * @param element Defines the element the controls should be listened from
  37956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37957. */
  37958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37959. /**
  37960. * Detach the current controls from the camera.
  37961. * The camera will stop reacting to inputs.
  37962. * @param element Defines the element to stop listening the inputs from
  37963. */
  37964. detachControl(element: HTMLElement): void;
  37965. /** @hidden */
  37966. _checkInputs(): void;
  37967. private _checkLimits;
  37968. /**
  37969. * Gets the camera class name.
  37970. * @returns the class name
  37971. */
  37972. getClassName(): string;
  37973. }
  37974. /**
  37975. * Arc Rotate version of the follow camera.
  37976. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37977. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37978. */
  37979. export class ArcFollowCamera extends TargetCamera {
  37980. /** The longitudinal angle of the camera */
  37981. alpha: number;
  37982. /** The latitudinal angle of the camera */
  37983. beta: number;
  37984. /** The radius of the camera from its target */
  37985. radius: number;
  37986. /** Define the camera target (the messh it should follow) */
  37987. target: Nullable<AbstractMesh>;
  37988. private _cartesianCoordinates;
  37989. /**
  37990. * Instantiates a new ArcFollowCamera
  37991. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37992. * @param name Define the name of the camera
  37993. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37994. * @param beta Define the rotation angle of the camera around the elevation axis
  37995. * @param radius Define the radius of the camera from its target point
  37996. * @param target Define the target of the camera
  37997. * @param scene Define the scene the camera belongs to
  37998. */
  37999. constructor(name: string,
  38000. /** The longitudinal angle of the camera */
  38001. alpha: number,
  38002. /** The latitudinal angle of the camera */
  38003. beta: number,
  38004. /** The radius of the camera from its target */
  38005. radius: number,
  38006. /** Define the camera target (the messh it should follow) */
  38007. target: Nullable<AbstractMesh>, scene: Scene);
  38008. private _follow;
  38009. /** @hidden */
  38010. _checkInputs(): void;
  38011. /**
  38012. * Returns the class name of the object.
  38013. * It is mostly used internally for serialization purposes.
  38014. */
  38015. getClassName(): string;
  38016. }
  38017. }
  38018. declare module BABYLON {
  38019. /**
  38020. * Manage the keyboard inputs to control the movement of a follow camera.
  38021. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38022. */
  38023. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38024. /**
  38025. * Defines the camera the input is attached to.
  38026. */
  38027. camera: FollowCamera;
  38028. /**
  38029. * Defines the list of key codes associated with the up action (increase heightOffset)
  38030. */
  38031. keysHeightOffsetIncr: number[];
  38032. /**
  38033. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38034. */
  38035. keysHeightOffsetDecr: number[];
  38036. /**
  38037. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38038. */
  38039. keysHeightOffsetModifierAlt: boolean;
  38040. /**
  38041. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38042. */
  38043. keysHeightOffsetModifierCtrl: boolean;
  38044. /**
  38045. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38046. */
  38047. keysHeightOffsetModifierShift: boolean;
  38048. /**
  38049. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38050. */
  38051. keysRotationOffsetIncr: number[];
  38052. /**
  38053. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38054. */
  38055. keysRotationOffsetDecr: number[];
  38056. /**
  38057. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38058. */
  38059. keysRotationOffsetModifierAlt: boolean;
  38060. /**
  38061. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38062. */
  38063. keysRotationOffsetModifierCtrl: boolean;
  38064. /**
  38065. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38066. */
  38067. keysRotationOffsetModifierShift: boolean;
  38068. /**
  38069. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38070. */
  38071. keysRadiusIncr: number[];
  38072. /**
  38073. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38074. */
  38075. keysRadiusDecr: number[];
  38076. /**
  38077. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38078. */
  38079. keysRadiusModifierAlt: boolean;
  38080. /**
  38081. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38082. */
  38083. keysRadiusModifierCtrl: boolean;
  38084. /**
  38085. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38086. */
  38087. keysRadiusModifierShift: boolean;
  38088. /**
  38089. * Defines the rate of change of heightOffset.
  38090. */
  38091. heightSensibility: number;
  38092. /**
  38093. * Defines the rate of change of rotationOffset.
  38094. */
  38095. rotationSensibility: number;
  38096. /**
  38097. * Defines the rate of change of radius.
  38098. */
  38099. radiusSensibility: number;
  38100. private _keys;
  38101. private _ctrlPressed;
  38102. private _altPressed;
  38103. private _shiftPressed;
  38104. private _onCanvasBlurObserver;
  38105. private _onKeyboardObserver;
  38106. private _engine;
  38107. private _scene;
  38108. /**
  38109. * Attach the input controls to a specific dom element to get the input from.
  38110. * @param element Defines the element the controls should be listened from
  38111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38112. */
  38113. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38114. /**
  38115. * Detach the current controls from the specified dom element.
  38116. * @param element Defines the element to stop listening the inputs from
  38117. */
  38118. detachControl(element: Nullable<HTMLElement>): void;
  38119. /**
  38120. * Update the current camera state depending on the inputs that have been used this frame.
  38121. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38122. */
  38123. checkInputs(): void;
  38124. /**
  38125. * Gets the class name of the current input.
  38126. * @returns the class name
  38127. */
  38128. getClassName(): string;
  38129. /**
  38130. * Get the friendly name associated with the input class.
  38131. * @returns the input friendly name
  38132. */
  38133. getSimpleName(): string;
  38134. /**
  38135. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38136. * allow modification of the heightOffset value.
  38137. */
  38138. private _modifierHeightOffset;
  38139. /**
  38140. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38141. * allow modification of the rotationOffset value.
  38142. */
  38143. private _modifierRotationOffset;
  38144. /**
  38145. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38146. * allow modification of the radius value.
  38147. */
  38148. private _modifierRadius;
  38149. }
  38150. }
  38151. declare module BABYLON {
  38152. interface FreeCameraInputsManager {
  38153. /**
  38154. * @hidden
  38155. */
  38156. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38157. /**
  38158. * Add orientation input support to the input manager.
  38159. * @returns the current input manager
  38160. */
  38161. addDeviceOrientation(): FreeCameraInputsManager;
  38162. }
  38163. /**
  38164. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38165. * Screen rotation is taken into account.
  38166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38167. */
  38168. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38169. private _camera;
  38170. private _screenOrientationAngle;
  38171. private _constantTranform;
  38172. private _screenQuaternion;
  38173. private _alpha;
  38174. private _beta;
  38175. private _gamma;
  38176. /**
  38177. * Can be used to detect if a device orientation sensor is availible on a device
  38178. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38179. * @returns a promise that will resolve on orientation change
  38180. */
  38181. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38182. /**
  38183. * @hidden
  38184. */
  38185. _onDeviceOrientationChangedObservable: Observable<void>;
  38186. /**
  38187. * Instantiates a new input
  38188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38189. */
  38190. constructor();
  38191. /**
  38192. * Define the camera controlled by the input.
  38193. */
  38194. camera: FreeCamera;
  38195. /**
  38196. * Attach the input controls to a specific dom element to get the input from.
  38197. * @param element Defines the element the controls should be listened from
  38198. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38199. */
  38200. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38201. private _orientationChanged;
  38202. private _deviceOrientation;
  38203. /**
  38204. * Detach the current controls from the specified dom element.
  38205. * @param element Defines the element to stop listening the inputs from
  38206. */
  38207. detachControl(element: Nullable<HTMLElement>): void;
  38208. /**
  38209. * Update the current camera state depending on the inputs that have been used this frame.
  38210. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38211. */
  38212. checkInputs(): void;
  38213. /**
  38214. * Gets the class name of the current intput.
  38215. * @returns the class name
  38216. */
  38217. getClassName(): string;
  38218. /**
  38219. * Get the friendly name associated with the input class.
  38220. * @returns the input friendly name
  38221. */
  38222. getSimpleName(): string;
  38223. }
  38224. }
  38225. declare module BABYLON {
  38226. /**
  38227. * Manage the gamepad inputs to control a free camera.
  38228. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38229. */
  38230. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38231. /**
  38232. * Define the camera the input is attached to.
  38233. */
  38234. camera: FreeCamera;
  38235. /**
  38236. * Define the Gamepad controlling the input
  38237. */
  38238. gamepad: Nullable<Gamepad>;
  38239. /**
  38240. * Defines the gamepad rotation sensiblity.
  38241. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38242. */
  38243. gamepadAngularSensibility: number;
  38244. /**
  38245. * Defines the gamepad move sensiblity.
  38246. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38247. */
  38248. gamepadMoveSensibility: number;
  38249. private _onGamepadConnectedObserver;
  38250. private _onGamepadDisconnectedObserver;
  38251. private _cameraTransform;
  38252. private _deltaTransform;
  38253. private _vector3;
  38254. private _vector2;
  38255. /**
  38256. * Attach the input controls to a specific dom element to get the input from.
  38257. * @param element Defines the element the controls should be listened from
  38258. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38259. */
  38260. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38261. /**
  38262. * Detach the current controls from the specified dom element.
  38263. * @param element Defines the element to stop listening the inputs from
  38264. */
  38265. detachControl(element: Nullable<HTMLElement>): void;
  38266. /**
  38267. * Update the current camera state depending on the inputs that have been used this frame.
  38268. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38269. */
  38270. checkInputs(): void;
  38271. /**
  38272. * Gets the class name of the current intput.
  38273. * @returns the class name
  38274. */
  38275. getClassName(): string;
  38276. /**
  38277. * Get the friendly name associated with the input class.
  38278. * @returns the input friendly name
  38279. */
  38280. getSimpleName(): string;
  38281. }
  38282. }
  38283. declare module BABYLON {
  38284. /**
  38285. * Defines the potential axis of a Joystick
  38286. */
  38287. export enum JoystickAxis {
  38288. /** X axis */
  38289. X = 0,
  38290. /** Y axis */
  38291. Y = 1,
  38292. /** Z axis */
  38293. Z = 2
  38294. }
  38295. /**
  38296. * Class used to define virtual joystick (used in touch mode)
  38297. */
  38298. export class VirtualJoystick {
  38299. /**
  38300. * Gets or sets a boolean indicating that left and right values must be inverted
  38301. */
  38302. reverseLeftRight: boolean;
  38303. /**
  38304. * Gets or sets a boolean indicating that up and down values must be inverted
  38305. */
  38306. reverseUpDown: boolean;
  38307. /**
  38308. * Gets the offset value for the position (ie. the change of the position value)
  38309. */
  38310. deltaPosition: Vector3;
  38311. /**
  38312. * Gets a boolean indicating if the virtual joystick was pressed
  38313. */
  38314. pressed: boolean;
  38315. /**
  38316. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38317. */
  38318. static Canvas: Nullable<HTMLCanvasElement>;
  38319. private static _globalJoystickIndex;
  38320. private static vjCanvasContext;
  38321. private static vjCanvasWidth;
  38322. private static vjCanvasHeight;
  38323. private static halfWidth;
  38324. private _action;
  38325. private _axisTargetedByLeftAndRight;
  38326. private _axisTargetedByUpAndDown;
  38327. private _joystickSensibility;
  38328. private _inversedSensibility;
  38329. private _joystickPointerID;
  38330. private _joystickColor;
  38331. private _joystickPointerPos;
  38332. private _joystickPreviousPointerPos;
  38333. private _joystickPointerStartPos;
  38334. private _deltaJoystickVector;
  38335. private _leftJoystick;
  38336. private _touches;
  38337. private _onPointerDownHandlerRef;
  38338. private _onPointerMoveHandlerRef;
  38339. private _onPointerUpHandlerRef;
  38340. private _onResize;
  38341. /**
  38342. * Creates a new virtual joystick
  38343. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38344. */
  38345. constructor(leftJoystick?: boolean);
  38346. /**
  38347. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38348. * @param newJoystickSensibility defines the new sensibility
  38349. */
  38350. setJoystickSensibility(newJoystickSensibility: number): void;
  38351. private _onPointerDown;
  38352. private _onPointerMove;
  38353. private _onPointerUp;
  38354. /**
  38355. * Change the color of the virtual joystick
  38356. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38357. */
  38358. setJoystickColor(newColor: string): void;
  38359. /**
  38360. * Defines a callback to call when the joystick is touched
  38361. * @param action defines the callback
  38362. */
  38363. setActionOnTouch(action: () => any): void;
  38364. /**
  38365. * Defines which axis you'd like to control for left & right
  38366. * @param axis defines the axis to use
  38367. */
  38368. setAxisForLeftRight(axis: JoystickAxis): void;
  38369. /**
  38370. * Defines which axis you'd like to control for up & down
  38371. * @param axis defines the axis to use
  38372. */
  38373. setAxisForUpDown(axis: JoystickAxis): void;
  38374. private _drawVirtualJoystick;
  38375. /**
  38376. * Release internal HTML canvas
  38377. */
  38378. releaseCanvas(): void;
  38379. }
  38380. }
  38381. declare module BABYLON {
  38382. interface FreeCameraInputsManager {
  38383. /**
  38384. * Add virtual joystick input support to the input manager.
  38385. * @returns the current input manager
  38386. */
  38387. addVirtualJoystick(): FreeCameraInputsManager;
  38388. }
  38389. /**
  38390. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38391. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38392. */
  38393. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38394. /**
  38395. * Defines the camera the input is attached to.
  38396. */
  38397. camera: FreeCamera;
  38398. private _leftjoystick;
  38399. private _rightjoystick;
  38400. /**
  38401. * Gets the left stick of the virtual joystick.
  38402. * @returns The virtual Joystick
  38403. */
  38404. getLeftJoystick(): VirtualJoystick;
  38405. /**
  38406. * Gets the right stick of the virtual joystick.
  38407. * @returns The virtual Joystick
  38408. */
  38409. getRightJoystick(): VirtualJoystick;
  38410. /**
  38411. * Update the current camera state depending on the inputs that have been used this frame.
  38412. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38413. */
  38414. checkInputs(): void;
  38415. /**
  38416. * Attach the input controls to a specific dom element to get the input from.
  38417. * @param element Defines the element the controls should be listened from
  38418. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38419. */
  38420. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38421. /**
  38422. * Detach the current controls from the specified dom element.
  38423. * @param element Defines the element to stop listening the inputs from
  38424. */
  38425. detachControl(element: Nullable<HTMLElement>): void;
  38426. /**
  38427. * Gets the class name of the current intput.
  38428. * @returns the class name
  38429. */
  38430. getClassName(): string;
  38431. /**
  38432. * Get the friendly name associated with the input class.
  38433. * @returns the input friendly name
  38434. */
  38435. getSimpleName(): string;
  38436. }
  38437. }
  38438. declare module BABYLON {
  38439. /**
  38440. * This represents a FPS type of camera controlled by touch.
  38441. * This is like a universal camera minus the Gamepad controls.
  38442. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38443. */
  38444. export class TouchCamera extends FreeCamera {
  38445. /**
  38446. * Defines the touch sensibility for rotation.
  38447. * The higher the faster.
  38448. */
  38449. touchAngularSensibility: number;
  38450. /**
  38451. * Defines the touch sensibility for move.
  38452. * The higher the faster.
  38453. */
  38454. touchMoveSensibility: number;
  38455. /**
  38456. * Instantiates a new touch camera.
  38457. * This represents a FPS type of camera controlled by touch.
  38458. * This is like a universal camera minus the Gamepad controls.
  38459. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38460. * @param name Define the name of the camera in the scene
  38461. * @param position Define the start position of the camera in the scene
  38462. * @param scene Define the scene the camera belongs to
  38463. */
  38464. constructor(name: string, position: Vector3, scene: Scene);
  38465. /**
  38466. * Gets the current object class name.
  38467. * @return the class name
  38468. */
  38469. getClassName(): string;
  38470. /** @hidden */
  38471. _setupInputs(): void;
  38472. }
  38473. }
  38474. declare module BABYLON {
  38475. /**
  38476. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38477. * being tilted forward or back and left or right.
  38478. */
  38479. export class DeviceOrientationCamera extends FreeCamera {
  38480. private _initialQuaternion;
  38481. private _quaternionCache;
  38482. private _tmpDragQuaternion;
  38483. private _disablePointerInputWhenUsingDeviceOrientation;
  38484. /**
  38485. * Creates a new device orientation camera
  38486. * @param name The name of the camera
  38487. * @param position The start position camera
  38488. * @param scene The scene the camera belongs to
  38489. */
  38490. constructor(name: string, position: Vector3, scene: Scene);
  38491. /**
  38492. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38493. */
  38494. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38495. private _dragFactor;
  38496. /**
  38497. * Enabled turning on the y axis when the orientation sensor is active
  38498. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38499. */
  38500. enableHorizontalDragging(dragFactor?: number): void;
  38501. /**
  38502. * Gets the current instance class name ("DeviceOrientationCamera").
  38503. * This helps avoiding instanceof at run time.
  38504. * @returns the class name
  38505. */
  38506. getClassName(): string;
  38507. /**
  38508. * @hidden
  38509. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38510. */
  38511. _checkInputs(): void;
  38512. /**
  38513. * Reset the camera to its default orientation on the specified axis only.
  38514. * @param axis The axis to reset
  38515. */
  38516. resetToCurrentRotation(axis?: Axis): void;
  38517. }
  38518. }
  38519. declare module BABYLON {
  38520. /**
  38521. * Defines supported buttons for XBox360 compatible gamepads
  38522. */
  38523. export enum Xbox360Button {
  38524. /** A */
  38525. A = 0,
  38526. /** B */
  38527. B = 1,
  38528. /** X */
  38529. X = 2,
  38530. /** Y */
  38531. Y = 3,
  38532. /** Start */
  38533. Start = 4,
  38534. /** Back */
  38535. Back = 5,
  38536. /** Left button */
  38537. LB = 6,
  38538. /** Right button */
  38539. RB = 7,
  38540. /** Left stick */
  38541. LeftStick = 8,
  38542. /** Right stick */
  38543. RightStick = 9
  38544. }
  38545. /** Defines values for XBox360 DPad */
  38546. export enum Xbox360Dpad {
  38547. /** Up */
  38548. Up = 0,
  38549. /** Down */
  38550. Down = 1,
  38551. /** Left */
  38552. Left = 2,
  38553. /** Right */
  38554. Right = 3
  38555. }
  38556. /**
  38557. * Defines a XBox360 gamepad
  38558. */
  38559. export class Xbox360Pad extends Gamepad {
  38560. private _leftTrigger;
  38561. private _rightTrigger;
  38562. private _onlefttriggerchanged;
  38563. private _onrighttriggerchanged;
  38564. private _onbuttondown;
  38565. private _onbuttonup;
  38566. private _ondpaddown;
  38567. private _ondpadup;
  38568. /** Observable raised when a button is pressed */
  38569. onButtonDownObservable: Observable<Xbox360Button>;
  38570. /** Observable raised when a button is released */
  38571. onButtonUpObservable: Observable<Xbox360Button>;
  38572. /** Observable raised when a pad is pressed */
  38573. onPadDownObservable: Observable<Xbox360Dpad>;
  38574. /** Observable raised when a pad is released */
  38575. onPadUpObservable: Observable<Xbox360Dpad>;
  38576. private _buttonA;
  38577. private _buttonB;
  38578. private _buttonX;
  38579. private _buttonY;
  38580. private _buttonBack;
  38581. private _buttonStart;
  38582. private _buttonLB;
  38583. private _buttonRB;
  38584. private _buttonLeftStick;
  38585. private _buttonRightStick;
  38586. private _dPadUp;
  38587. private _dPadDown;
  38588. private _dPadLeft;
  38589. private _dPadRight;
  38590. private _isXboxOnePad;
  38591. /**
  38592. * Creates a new XBox360 gamepad object
  38593. * @param id defines the id of this gamepad
  38594. * @param index defines its index
  38595. * @param gamepad defines the internal HTML gamepad object
  38596. * @param xboxOne defines if it is a XBox One gamepad
  38597. */
  38598. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38599. /**
  38600. * Defines the callback to call when left trigger is pressed
  38601. * @param callback defines the callback to use
  38602. */
  38603. onlefttriggerchanged(callback: (value: number) => void): void;
  38604. /**
  38605. * Defines the callback to call when right trigger is pressed
  38606. * @param callback defines the callback to use
  38607. */
  38608. onrighttriggerchanged(callback: (value: number) => void): void;
  38609. /**
  38610. * Gets the left trigger value
  38611. */
  38612. /**
  38613. * Sets the left trigger value
  38614. */
  38615. leftTrigger: number;
  38616. /**
  38617. * Gets the right trigger value
  38618. */
  38619. /**
  38620. * Sets the right trigger value
  38621. */
  38622. rightTrigger: number;
  38623. /**
  38624. * Defines the callback to call when a button is pressed
  38625. * @param callback defines the callback to use
  38626. */
  38627. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38628. /**
  38629. * Defines the callback to call when a button is released
  38630. * @param callback defines the callback to use
  38631. */
  38632. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38633. /**
  38634. * Defines the callback to call when a pad is pressed
  38635. * @param callback defines the callback to use
  38636. */
  38637. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38638. /**
  38639. * Defines the callback to call when a pad is released
  38640. * @param callback defines the callback to use
  38641. */
  38642. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38643. private _setButtonValue;
  38644. private _setDPadValue;
  38645. /**
  38646. * Gets the value of the `A` button
  38647. */
  38648. /**
  38649. * Sets the value of the `A` button
  38650. */
  38651. buttonA: number;
  38652. /**
  38653. * Gets the value of the `B` button
  38654. */
  38655. /**
  38656. * Sets the value of the `B` button
  38657. */
  38658. buttonB: number;
  38659. /**
  38660. * Gets the value of the `X` button
  38661. */
  38662. /**
  38663. * Sets the value of the `X` button
  38664. */
  38665. buttonX: number;
  38666. /**
  38667. * Gets the value of the `Y` button
  38668. */
  38669. /**
  38670. * Sets the value of the `Y` button
  38671. */
  38672. buttonY: number;
  38673. /**
  38674. * Gets the value of the `Start` button
  38675. */
  38676. /**
  38677. * Sets the value of the `Start` button
  38678. */
  38679. buttonStart: number;
  38680. /**
  38681. * Gets the value of the `Back` button
  38682. */
  38683. /**
  38684. * Sets the value of the `Back` button
  38685. */
  38686. buttonBack: number;
  38687. /**
  38688. * Gets the value of the `Left` button
  38689. */
  38690. /**
  38691. * Sets the value of the `Left` button
  38692. */
  38693. buttonLB: number;
  38694. /**
  38695. * Gets the value of the `Right` button
  38696. */
  38697. /**
  38698. * Sets the value of the `Right` button
  38699. */
  38700. buttonRB: number;
  38701. /**
  38702. * Gets the value of the Left joystick
  38703. */
  38704. /**
  38705. * Sets the value of the Left joystick
  38706. */
  38707. buttonLeftStick: number;
  38708. /**
  38709. * Gets the value of the Right joystick
  38710. */
  38711. /**
  38712. * Sets the value of the Right joystick
  38713. */
  38714. buttonRightStick: number;
  38715. /**
  38716. * Gets the value of D-pad up
  38717. */
  38718. /**
  38719. * Sets the value of D-pad up
  38720. */
  38721. dPadUp: number;
  38722. /**
  38723. * Gets the value of D-pad down
  38724. */
  38725. /**
  38726. * Sets the value of D-pad down
  38727. */
  38728. dPadDown: number;
  38729. /**
  38730. * Gets the value of D-pad left
  38731. */
  38732. /**
  38733. * Sets the value of D-pad left
  38734. */
  38735. dPadLeft: number;
  38736. /**
  38737. * Gets the value of D-pad right
  38738. */
  38739. /**
  38740. * Sets the value of D-pad right
  38741. */
  38742. dPadRight: number;
  38743. /**
  38744. * Force the gamepad to synchronize with device values
  38745. */
  38746. update(): void;
  38747. /**
  38748. * Disposes the gamepad
  38749. */
  38750. dispose(): void;
  38751. }
  38752. }
  38753. declare module BABYLON {
  38754. /**
  38755. * Defines supported buttons for DualShock compatible gamepads
  38756. */
  38757. export enum DualShockButton {
  38758. /** Cross */
  38759. Cross = 0,
  38760. /** Circle */
  38761. Circle = 1,
  38762. /** Square */
  38763. Square = 2,
  38764. /** Triangle */
  38765. Triangle = 3,
  38766. /** Options */
  38767. Options = 4,
  38768. /** Share */
  38769. Share = 5,
  38770. /** L1 */
  38771. L1 = 6,
  38772. /** R1 */
  38773. R1 = 7,
  38774. /** Left stick */
  38775. LeftStick = 8,
  38776. /** Right stick */
  38777. RightStick = 9
  38778. }
  38779. /** Defines values for DualShock DPad */
  38780. export enum DualShockDpad {
  38781. /** Up */
  38782. Up = 0,
  38783. /** Down */
  38784. Down = 1,
  38785. /** Left */
  38786. Left = 2,
  38787. /** Right */
  38788. Right = 3
  38789. }
  38790. /**
  38791. * Defines a DualShock gamepad
  38792. */
  38793. export class DualShockPad extends Gamepad {
  38794. private _leftTrigger;
  38795. private _rightTrigger;
  38796. private _onlefttriggerchanged;
  38797. private _onrighttriggerchanged;
  38798. private _onbuttondown;
  38799. private _onbuttonup;
  38800. private _ondpaddown;
  38801. private _ondpadup;
  38802. /** Observable raised when a button is pressed */
  38803. onButtonDownObservable: Observable<DualShockButton>;
  38804. /** Observable raised when a button is released */
  38805. onButtonUpObservable: Observable<DualShockButton>;
  38806. /** Observable raised when a pad is pressed */
  38807. onPadDownObservable: Observable<DualShockDpad>;
  38808. /** Observable raised when a pad is released */
  38809. onPadUpObservable: Observable<DualShockDpad>;
  38810. private _buttonCross;
  38811. private _buttonCircle;
  38812. private _buttonSquare;
  38813. private _buttonTriangle;
  38814. private _buttonShare;
  38815. private _buttonOptions;
  38816. private _buttonL1;
  38817. private _buttonR1;
  38818. private _buttonLeftStick;
  38819. private _buttonRightStick;
  38820. private _dPadUp;
  38821. private _dPadDown;
  38822. private _dPadLeft;
  38823. private _dPadRight;
  38824. /**
  38825. * Creates a new DualShock gamepad object
  38826. * @param id defines the id of this gamepad
  38827. * @param index defines its index
  38828. * @param gamepad defines the internal HTML gamepad object
  38829. */
  38830. constructor(id: string, index: number, gamepad: any);
  38831. /**
  38832. * Defines the callback to call when left trigger is pressed
  38833. * @param callback defines the callback to use
  38834. */
  38835. onlefttriggerchanged(callback: (value: number) => void): void;
  38836. /**
  38837. * Defines the callback to call when right trigger is pressed
  38838. * @param callback defines the callback to use
  38839. */
  38840. onrighttriggerchanged(callback: (value: number) => void): void;
  38841. /**
  38842. * Gets the left trigger value
  38843. */
  38844. /**
  38845. * Sets the left trigger value
  38846. */
  38847. leftTrigger: number;
  38848. /**
  38849. * Gets the right trigger value
  38850. */
  38851. /**
  38852. * Sets the right trigger value
  38853. */
  38854. rightTrigger: number;
  38855. /**
  38856. * Defines the callback to call when a button is pressed
  38857. * @param callback defines the callback to use
  38858. */
  38859. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38860. /**
  38861. * Defines the callback to call when a button is released
  38862. * @param callback defines the callback to use
  38863. */
  38864. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38865. /**
  38866. * Defines the callback to call when a pad is pressed
  38867. * @param callback defines the callback to use
  38868. */
  38869. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38870. /**
  38871. * Defines the callback to call when a pad is released
  38872. * @param callback defines the callback to use
  38873. */
  38874. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38875. private _setButtonValue;
  38876. private _setDPadValue;
  38877. /**
  38878. * Gets the value of the `Cross` button
  38879. */
  38880. /**
  38881. * Sets the value of the `Cross` button
  38882. */
  38883. buttonCross: number;
  38884. /**
  38885. * Gets the value of the `Circle` button
  38886. */
  38887. /**
  38888. * Sets the value of the `Circle` button
  38889. */
  38890. buttonCircle: number;
  38891. /**
  38892. * Gets the value of the `Square` button
  38893. */
  38894. /**
  38895. * Sets the value of the `Square` button
  38896. */
  38897. buttonSquare: number;
  38898. /**
  38899. * Gets the value of the `Triangle` button
  38900. */
  38901. /**
  38902. * Sets the value of the `Triangle` button
  38903. */
  38904. buttonTriangle: number;
  38905. /**
  38906. * Gets the value of the `Options` button
  38907. */
  38908. /**
  38909. * Sets the value of the `Options` button
  38910. */
  38911. buttonOptions: number;
  38912. /**
  38913. * Gets the value of the `Share` button
  38914. */
  38915. /**
  38916. * Sets the value of the `Share` button
  38917. */
  38918. buttonShare: number;
  38919. /**
  38920. * Gets the value of the `L1` button
  38921. */
  38922. /**
  38923. * Sets the value of the `L1` button
  38924. */
  38925. buttonL1: number;
  38926. /**
  38927. * Gets the value of the `R1` button
  38928. */
  38929. /**
  38930. * Sets the value of the `R1` button
  38931. */
  38932. buttonR1: number;
  38933. /**
  38934. * Gets the value of the Left joystick
  38935. */
  38936. /**
  38937. * Sets the value of the Left joystick
  38938. */
  38939. buttonLeftStick: number;
  38940. /**
  38941. * Gets the value of the Right joystick
  38942. */
  38943. /**
  38944. * Sets the value of the Right joystick
  38945. */
  38946. buttonRightStick: number;
  38947. /**
  38948. * Gets the value of D-pad up
  38949. */
  38950. /**
  38951. * Sets the value of D-pad up
  38952. */
  38953. dPadUp: number;
  38954. /**
  38955. * Gets the value of D-pad down
  38956. */
  38957. /**
  38958. * Sets the value of D-pad down
  38959. */
  38960. dPadDown: number;
  38961. /**
  38962. * Gets the value of D-pad left
  38963. */
  38964. /**
  38965. * Sets the value of D-pad left
  38966. */
  38967. dPadLeft: number;
  38968. /**
  38969. * Gets the value of D-pad right
  38970. */
  38971. /**
  38972. * Sets the value of D-pad right
  38973. */
  38974. dPadRight: number;
  38975. /**
  38976. * Force the gamepad to synchronize with device values
  38977. */
  38978. update(): void;
  38979. /**
  38980. * Disposes the gamepad
  38981. */
  38982. dispose(): void;
  38983. }
  38984. }
  38985. declare module BABYLON {
  38986. /**
  38987. * Manager for handling gamepads
  38988. */
  38989. export class GamepadManager {
  38990. private _scene?;
  38991. private _babylonGamepads;
  38992. private _oneGamepadConnected;
  38993. /** @hidden */
  38994. _isMonitoring: boolean;
  38995. private _gamepadEventSupported;
  38996. private _gamepadSupport;
  38997. /**
  38998. * observable to be triggered when the gamepad controller has been connected
  38999. */
  39000. onGamepadConnectedObservable: Observable<Gamepad>;
  39001. /**
  39002. * observable to be triggered when the gamepad controller has been disconnected
  39003. */
  39004. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39005. private _onGamepadConnectedEvent;
  39006. private _onGamepadDisconnectedEvent;
  39007. /**
  39008. * Initializes the gamepad manager
  39009. * @param _scene BabylonJS scene
  39010. */
  39011. constructor(_scene?: Scene | undefined);
  39012. /**
  39013. * The gamepads in the game pad manager
  39014. */
  39015. readonly gamepads: Gamepad[];
  39016. /**
  39017. * Get the gamepad controllers based on type
  39018. * @param type The type of gamepad controller
  39019. * @returns Nullable gamepad
  39020. */
  39021. getGamepadByType(type?: number): Nullable<Gamepad>;
  39022. /**
  39023. * Disposes the gamepad manager
  39024. */
  39025. dispose(): void;
  39026. private _addNewGamepad;
  39027. private _startMonitoringGamepads;
  39028. private _stopMonitoringGamepads;
  39029. /** @hidden */
  39030. _checkGamepadsStatus(): void;
  39031. private _updateGamepadObjects;
  39032. }
  39033. }
  39034. declare module BABYLON {
  39035. interface Scene {
  39036. /** @hidden */
  39037. _gamepadManager: Nullable<GamepadManager>;
  39038. /**
  39039. * Gets the gamepad manager associated with the scene
  39040. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39041. */
  39042. gamepadManager: GamepadManager;
  39043. }
  39044. /**
  39045. * Interface representing a free camera inputs manager
  39046. */
  39047. interface FreeCameraInputsManager {
  39048. /**
  39049. * Adds gamepad input support to the FreeCameraInputsManager.
  39050. * @returns the FreeCameraInputsManager
  39051. */
  39052. addGamepad(): FreeCameraInputsManager;
  39053. }
  39054. /**
  39055. * Interface representing an arc rotate camera inputs manager
  39056. */
  39057. interface ArcRotateCameraInputsManager {
  39058. /**
  39059. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39060. * @returns the camera inputs manager
  39061. */
  39062. addGamepad(): ArcRotateCameraInputsManager;
  39063. }
  39064. /**
  39065. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39066. */
  39067. export class GamepadSystemSceneComponent implements ISceneComponent {
  39068. /**
  39069. * The component name helpfull to identify the component in the list of scene components.
  39070. */
  39071. readonly name: string;
  39072. /**
  39073. * The scene the component belongs to.
  39074. */
  39075. scene: Scene;
  39076. /**
  39077. * Creates a new instance of the component for the given scene
  39078. * @param scene Defines the scene to register the component in
  39079. */
  39080. constructor(scene: Scene);
  39081. /**
  39082. * Registers the component in a given scene
  39083. */
  39084. register(): void;
  39085. /**
  39086. * Rebuilds the elements related to this component in case of
  39087. * context lost for instance.
  39088. */
  39089. rebuild(): void;
  39090. /**
  39091. * Disposes the component and the associated ressources
  39092. */
  39093. dispose(): void;
  39094. private _beforeCameraUpdate;
  39095. }
  39096. }
  39097. declare module BABYLON {
  39098. /**
  39099. * 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,
  39100. * which still works and will still be found in many Playgrounds.
  39101. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39102. */
  39103. export class UniversalCamera extends TouchCamera {
  39104. /**
  39105. * Defines the gamepad rotation sensiblity.
  39106. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39107. */
  39108. gamepadAngularSensibility: number;
  39109. /**
  39110. * Defines the gamepad move sensiblity.
  39111. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39112. */
  39113. gamepadMoveSensibility: number;
  39114. /**
  39115. * 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,
  39116. * which still works and will still be found in many Playgrounds.
  39117. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39118. * @param name Define the name of the camera in the scene
  39119. * @param position Define the start position of the camera in the scene
  39120. * @param scene Define the scene the camera belongs to
  39121. */
  39122. constructor(name: string, position: Vector3, scene: Scene);
  39123. /**
  39124. * Gets the current object class name.
  39125. * @return the class name
  39126. */
  39127. getClassName(): string;
  39128. }
  39129. }
  39130. declare module BABYLON {
  39131. /**
  39132. * This represents a FPS type of camera. This is only here for back compat purpose.
  39133. * Please use the UniversalCamera instead as both are identical.
  39134. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39135. */
  39136. export class GamepadCamera extends UniversalCamera {
  39137. /**
  39138. * Instantiates a new Gamepad Camera
  39139. * This represents a FPS type of camera. This is only here for back compat purpose.
  39140. * Please use the UniversalCamera instead as both are identical.
  39141. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39142. * @param name Define the name of the camera in the scene
  39143. * @param position Define the start position of the camera in the scene
  39144. * @param scene Define the scene the camera belongs to
  39145. */
  39146. constructor(name: string, position: Vector3, scene: Scene);
  39147. /**
  39148. * Gets the current object class name.
  39149. * @return the class name
  39150. */
  39151. getClassName(): string;
  39152. }
  39153. }
  39154. declare module BABYLON {
  39155. /** @hidden */
  39156. export var passPixelShader: {
  39157. name: string;
  39158. shader: string;
  39159. };
  39160. }
  39161. declare module BABYLON {
  39162. /** @hidden */
  39163. export var passCubePixelShader: {
  39164. name: string;
  39165. shader: string;
  39166. };
  39167. }
  39168. declare module BABYLON {
  39169. /**
  39170. * PassPostProcess which produces an output the same as it's input
  39171. */
  39172. export class PassPostProcess extends PostProcess {
  39173. /**
  39174. * Creates the PassPostProcess
  39175. * @param name The name of the effect.
  39176. * @param options The required width/height ratio to downsize to before computing the render pass.
  39177. * @param camera The camera to apply the render pass to.
  39178. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39179. * @param engine The engine which the post process will be applied. (default: current engine)
  39180. * @param reusable If the post process can be reused on the same frame. (default: false)
  39181. * @param textureType The type of texture to be used when performing the post processing.
  39182. * @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)
  39183. */
  39184. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39185. }
  39186. /**
  39187. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39188. */
  39189. export class PassCubePostProcess extends PostProcess {
  39190. private _face;
  39191. /**
  39192. * Gets or sets the cube face to display.
  39193. * * 0 is +X
  39194. * * 1 is -X
  39195. * * 2 is +Y
  39196. * * 3 is -Y
  39197. * * 4 is +Z
  39198. * * 5 is -Z
  39199. */
  39200. face: number;
  39201. /**
  39202. * Creates the PassCubePostProcess
  39203. * @param name The name of the effect.
  39204. * @param options The required width/height ratio to downsize to before computing the render pass.
  39205. * @param camera The camera to apply the render pass to.
  39206. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39207. * @param engine The engine which the post process will be applied. (default: current engine)
  39208. * @param reusable If the post process can be reused on the same frame. (default: false)
  39209. * @param textureType The type of texture to be used when performing the post processing.
  39210. * @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)
  39211. */
  39212. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39213. }
  39214. }
  39215. declare module BABYLON {
  39216. /** @hidden */
  39217. export var anaglyphPixelShader: {
  39218. name: string;
  39219. shader: string;
  39220. };
  39221. }
  39222. declare module BABYLON {
  39223. /**
  39224. * Postprocess used to generate anaglyphic rendering
  39225. */
  39226. export class AnaglyphPostProcess extends PostProcess {
  39227. private _passedProcess;
  39228. /**
  39229. * Creates a new AnaglyphPostProcess
  39230. * @param name defines postprocess name
  39231. * @param options defines creation options or target ratio scale
  39232. * @param rigCameras defines cameras using this postprocess
  39233. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39234. * @param engine defines hosting engine
  39235. * @param reusable defines if the postprocess will be reused multiple times per frame
  39236. */
  39237. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39238. }
  39239. }
  39240. declare module BABYLON {
  39241. /**
  39242. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39243. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39244. */
  39245. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39246. /**
  39247. * Creates a new AnaglyphArcRotateCamera
  39248. * @param name defines camera name
  39249. * @param alpha defines alpha angle (in radians)
  39250. * @param beta defines beta angle (in radians)
  39251. * @param radius defines radius
  39252. * @param target defines camera target
  39253. * @param interaxialDistance defines distance between each color axis
  39254. * @param scene defines the hosting scene
  39255. */
  39256. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39257. /**
  39258. * Gets camera class name
  39259. * @returns AnaglyphArcRotateCamera
  39260. */
  39261. getClassName(): string;
  39262. }
  39263. }
  39264. declare module BABYLON {
  39265. /**
  39266. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39267. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39268. */
  39269. export class AnaglyphFreeCamera extends FreeCamera {
  39270. /**
  39271. * Creates a new AnaglyphFreeCamera
  39272. * @param name defines camera name
  39273. * @param position defines initial position
  39274. * @param interaxialDistance defines distance between each color axis
  39275. * @param scene defines the hosting scene
  39276. */
  39277. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39278. /**
  39279. * Gets camera class name
  39280. * @returns AnaglyphFreeCamera
  39281. */
  39282. getClassName(): string;
  39283. }
  39284. }
  39285. declare module BABYLON {
  39286. /**
  39287. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39288. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39289. */
  39290. export class AnaglyphGamepadCamera extends GamepadCamera {
  39291. /**
  39292. * Creates a new AnaglyphGamepadCamera
  39293. * @param name defines camera name
  39294. * @param position defines initial position
  39295. * @param interaxialDistance defines distance between each color axis
  39296. * @param scene defines the hosting scene
  39297. */
  39298. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39299. /**
  39300. * Gets camera class name
  39301. * @returns AnaglyphGamepadCamera
  39302. */
  39303. getClassName(): string;
  39304. }
  39305. }
  39306. declare module BABYLON {
  39307. /**
  39308. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39309. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39310. */
  39311. export class AnaglyphUniversalCamera extends UniversalCamera {
  39312. /**
  39313. * Creates a new AnaglyphUniversalCamera
  39314. * @param name defines camera name
  39315. * @param position defines initial position
  39316. * @param interaxialDistance defines distance between each color axis
  39317. * @param scene defines the hosting scene
  39318. */
  39319. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39320. /**
  39321. * Gets camera class name
  39322. * @returns AnaglyphUniversalCamera
  39323. */
  39324. getClassName(): string;
  39325. }
  39326. }
  39327. declare module BABYLON {
  39328. /** @hidden */
  39329. export var stereoscopicInterlacePixelShader: {
  39330. name: string;
  39331. shader: string;
  39332. };
  39333. }
  39334. declare module BABYLON {
  39335. /**
  39336. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39337. */
  39338. export class StereoscopicInterlacePostProcess extends PostProcess {
  39339. private _stepSize;
  39340. private _passedProcess;
  39341. /**
  39342. * Initializes a StereoscopicInterlacePostProcess
  39343. * @param name The name of the effect.
  39344. * @param rigCameras The rig cameras to be appled to the post process
  39345. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39346. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39347. * @param engine The engine which the post process will be applied. (default: current engine)
  39348. * @param reusable If the post process can be reused on the same frame. (default: false)
  39349. */
  39350. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39351. }
  39352. }
  39353. declare module BABYLON {
  39354. /**
  39355. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39356. * @see http://doc.babylonjs.com/features/cameras
  39357. */
  39358. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39359. /**
  39360. * Creates a new StereoscopicArcRotateCamera
  39361. * @param name defines camera name
  39362. * @param alpha defines alpha angle (in radians)
  39363. * @param beta defines beta angle (in radians)
  39364. * @param radius defines radius
  39365. * @param target defines camera target
  39366. * @param interaxialDistance defines distance between each color axis
  39367. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39368. * @param scene defines the hosting scene
  39369. */
  39370. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39371. /**
  39372. * Gets camera class name
  39373. * @returns StereoscopicArcRotateCamera
  39374. */
  39375. getClassName(): string;
  39376. }
  39377. }
  39378. declare module BABYLON {
  39379. /**
  39380. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39381. * @see http://doc.babylonjs.com/features/cameras
  39382. */
  39383. export class StereoscopicFreeCamera extends FreeCamera {
  39384. /**
  39385. * Creates a new StereoscopicFreeCamera
  39386. * @param name defines camera name
  39387. * @param position defines initial position
  39388. * @param interaxialDistance defines distance between each color axis
  39389. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39390. * @param scene defines the hosting scene
  39391. */
  39392. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39393. /**
  39394. * Gets camera class name
  39395. * @returns StereoscopicFreeCamera
  39396. */
  39397. getClassName(): string;
  39398. }
  39399. }
  39400. declare module BABYLON {
  39401. /**
  39402. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39403. * @see http://doc.babylonjs.com/features/cameras
  39404. */
  39405. export class StereoscopicGamepadCamera extends GamepadCamera {
  39406. /**
  39407. * Creates a new StereoscopicGamepadCamera
  39408. * @param name defines camera name
  39409. * @param position defines initial position
  39410. * @param interaxialDistance defines distance between each color axis
  39411. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39412. * @param scene defines the hosting scene
  39413. */
  39414. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39415. /**
  39416. * Gets camera class name
  39417. * @returns StereoscopicGamepadCamera
  39418. */
  39419. getClassName(): string;
  39420. }
  39421. }
  39422. declare module BABYLON {
  39423. /**
  39424. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39425. * @see http://doc.babylonjs.com/features/cameras
  39426. */
  39427. export class StereoscopicUniversalCamera extends UniversalCamera {
  39428. /**
  39429. * Creates a new StereoscopicUniversalCamera
  39430. * @param name defines camera name
  39431. * @param position defines initial position
  39432. * @param interaxialDistance defines distance between each color axis
  39433. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39434. * @param scene defines the hosting scene
  39435. */
  39436. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39437. /**
  39438. * Gets camera class name
  39439. * @returns StereoscopicUniversalCamera
  39440. */
  39441. getClassName(): string;
  39442. }
  39443. }
  39444. declare module BABYLON {
  39445. /**
  39446. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39447. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39448. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39449. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39450. */
  39451. export class VirtualJoysticksCamera extends FreeCamera {
  39452. /**
  39453. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39454. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39455. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39456. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39457. * @param name Define the name of the camera in the scene
  39458. * @param position Define the start position of the camera in the scene
  39459. * @param scene Define the scene the camera belongs to
  39460. */
  39461. constructor(name: string, position: Vector3, scene: Scene);
  39462. /**
  39463. * Gets the current object class name.
  39464. * @return the class name
  39465. */
  39466. getClassName(): string;
  39467. }
  39468. }
  39469. declare module BABYLON {
  39470. /**
  39471. * This represents all the required metrics to create a VR camera.
  39472. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39473. */
  39474. export class VRCameraMetrics {
  39475. /**
  39476. * Define the horizontal resolution off the screen.
  39477. */
  39478. hResolution: number;
  39479. /**
  39480. * Define the vertical resolution off the screen.
  39481. */
  39482. vResolution: number;
  39483. /**
  39484. * Define the horizontal screen size.
  39485. */
  39486. hScreenSize: number;
  39487. /**
  39488. * Define the vertical screen size.
  39489. */
  39490. vScreenSize: number;
  39491. /**
  39492. * Define the vertical screen center position.
  39493. */
  39494. vScreenCenter: number;
  39495. /**
  39496. * Define the distance of the eyes to the screen.
  39497. */
  39498. eyeToScreenDistance: number;
  39499. /**
  39500. * Define the distance between both lenses
  39501. */
  39502. lensSeparationDistance: number;
  39503. /**
  39504. * Define the distance between both viewer's eyes.
  39505. */
  39506. interpupillaryDistance: number;
  39507. /**
  39508. * Define the distortion factor of the VR postprocess.
  39509. * Please, touch with care.
  39510. */
  39511. distortionK: number[];
  39512. /**
  39513. * Define the chromatic aberration correction factors for the VR post process.
  39514. */
  39515. chromaAbCorrection: number[];
  39516. /**
  39517. * Define the scale factor of the post process.
  39518. * The smaller the better but the slower.
  39519. */
  39520. postProcessScaleFactor: number;
  39521. /**
  39522. * Define an offset for the lens center.
  39523. */
  39524. lensCenterOffset: number;
  39525. /**
  39526. * Define if the current vr camera should compensate the distortion of the lense or not.
  39527. */
  39528. compensateDistortion: boolean;
  39529. /**
  39530. * Defines if multiview should be enabled when rendering (Default: false)
  39531. */
  39532. multiviewEnabled: boolean;
  39533. /**
  39534. * Gets the rendering aspect ratio based on the provided resolutions.
  39535. */
  39536. readonly aspectRatio: number;
  39537. /**
  39538. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39539. */
  39540. readonly aspectRatioFov: number;
  39541. /**
  39542. * @hidden
  39543. */
  39544. readonly leftHMatrix: Matrix;
  39545. /**
  39546. * @hidden
  39547. */
  39548. readonly rightHMatrix: Matrix;
  39549. /**
  39550. * @hidden
  39551. */
  39552. readonly leftPreViewMatrix: Matrix;
  39553. /**
  39554. * @hidden
  39555. */
  39556. readonly rightPreViewMatrix: Matrix;
  39557. /**
  39558. * Get the default VRMetrics based on the most generic setup.
  39559. * @returns the default vr metrics
  39560. */
  39561. static GetDefault(): VRCameraMetrics;
  39562. }
  39563. }
  39564. declare module BABYLON {
  39565. /** @hidden */
  39566. export var vrDistortionCorrectionPixelShader: {
  39567. name: string;
  39568. shader: string;
  39569. };
  39570. }
  39571. declare module BABYLON {
  39572. /**
  39573. * VRDistortionCorrectionPostProcess used for mobile VR
  39574. */
  39575. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39576. private _isRightEye;
  39577. private _distortionFactors;
  39578. private _postProcessScaleFactor;
  39579. private _lensCenterOffset;
  39580. private _scaleIn;
  39581. private _scaleFactor;
  39582. private _lensCenter;
  39583. /**
  39584. * Initializes the VRDistortionCorrectionPostProcess
  39585. * @param name The name of the effect.
  39586. * @param camera The camera to apply the render pass to.
  39587. * @param isRightEye If this is for the right eye distortion
  39588. * @param vrMetrics All the required metrics for the VR camera
  39589. */
  39590. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39591. }
  39592. }
  39593. declare module BABYLON {
  39594. /**
  39595. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39596. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39597. */
  39598. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39599. /**
  39600. * Creates a new VRDeviceOrientationArcRotateCamera
  39601. * @param name defines camera name
  39602. * @param alpha defines the camera rotation along the logitudinal axis
  39603. * @param beta defines the camera rotation along the latitudinal axis
  39604. * @param radius defines the camera distance from its target
  39605. * @param target defines the camera target
  39606. * @param scene defines the scene the camera belongs to
  39607. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39608. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39609. */
  39610. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39611. /**
  39612. * Gets camera class name
  39613. * @returns VRDeviceOrientationArcRotateCamera
  39614. */
  39615. getClassName(): string;
  39616. }
  39617. }
  39618. declare module BABYLON {
  39619. /**
  39620. * Camera used to simulate VR rendering (based on FreeCamera)
  39621. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39622. */
  39623. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39624. /**
  39625. * Creates a new VRDeviceOrientationFreeCamera
  39626. * @param name defines camera name
  39627. * @param position defines the start position of the camera
  39628. * @param scene defines the scene the camera belongs to
  39629. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39630. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39631. */
  39632. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39633. /**
  39634. * Gets camera class name
  39635. * @returns VRDeviceOrientationFreeCamera
  39636. */
  39637. getClassName(): string;
  39638. }
  39639. }
  39640. declare module BABYLON {
  39641. /**
  39642. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39643. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39644. */
  39645. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39646. /**
  39647. * Creates a new VRDeviceOrientationGamepadCamera
  39648. * @param name defines camera name
  39649. * @param position defines the start position of the camera
  39650. * @param scene defines the scene the camera belongs to
  39651. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39652. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39653. */
  39654. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39655. /**
  39656. * Gets camera class name
  39657. * @returns VRDeviceOrientationGamepadCamera
  39658. */
  39659. getClassName(): string;
  39660. }
  39661. }
  39662. declare module BABYLON {
  39663. /**
  39664. * Base class of materials working in push mode in babylon JS
  39665. * @hidden
  39666. */
  39667. export class PushMaterial extends Material {
  39668. protected _activeEffect: Effect;
  39669. protected _normalMatrix: Matrix;
  39670. /**
  39671. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39672. * This means that the material can keep using a previous shader while a new one is being compiled.
  39673. * This is mostly used when shader parallel compilation is supported (true by default)
  39674. */
  39675. allowShaderHotSwapping: boolean;
  39676. constructor(name: string, scene: Scene);
  39677. getEffect(): Effect;
  39678. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39679. /**
  39680. * Binds the given world matrix to the active effect
  39681. *
  39682. * @param world the matrix to bind
  39683. */
  39684. bindOnlyWorldMatrix(world: Matrix): void;
  39685. /**
  39686. * Binds the given normal matrix to the active effect
  39687. *
  39688. * @param normalMatrix the matrix to bind
  39689. */
  39690. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39691. bind(world: Matrix, mesh?: Mesh): void;
  39692. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39693. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39694. }
  39695. }
  39696. declare module BABYLON {
  39697. /**
  39698. * This groups all the flags used to control the materials channel.
  39699. */
  39700. export class MaterialFlags {
  39701. private static _DiffuseTextureEnabled;
  39702. /**
  39703. * Are diffuse textures enabled in the application.
  39704. */
  39705. static DiffuseTextureEnabled: boolean;
  39706. private static _AmbientTextureEnabled;
  39707. /**
  39708. * Are ambient textures enabled in the application.
  39709. */
  39710. static AmbientTextureEnabled: boolean;
  39711. private static _OpacityTextureEnabled;
  39712. /**
  39713. * Are opacity textures enabled in the application.
  39714. */
  39715. static OpacityTextureEnabled: boolean;
  39716. private static _ReflectionTextureEnabled;
  39717. /**
  39718. * Are reflection textures enabled in the application.
  39719. */
  39720. static ReflectionTextureEnabled: boolean;
  39721. private static _EmissiveTextureEnabled;
  39722. /**
  39723. * Are emissive textures enabled in the application.
  39724. */
  39725. static EmissiveTextureEnabled: boolean;
  39726. private static _SpecularTextureEnabled;
  39727. /**
  39728. * Are specular textures enabled in the application.
  39729. */
  39730. static SpecularTextureEnabled: boolean;
  39731. private static _BumpTextureEnabled;
  39732. /**
  39733. * Are bump textures enabled in the application.
  39734. */
  39735. static BumpTextureEnabled: boolean;
  39736. private static _LightmapTextureEnabled;
  39737. /**
  39738. * Are lightmap textures enabled in the application.
  39739. */
  39740. static LightmapTextureEnabled: boolean;
  39741. private static _RefractionTextureEnabled;
  39742. /**
  39743. * Are refraction textures enabled in the application.
  39744. */
  39745. static RefractionTextureEnabled: boolean;
  39746. private static _ColorGradingTextureEnabled;
  39747. /**
  39748. * Are color grading textures enabled in the application.
  39749. */
  39750. static ColorGradingTextureEnabled: boolean;
  39751. private static _FresnelEnabled;
  39752. /**
  39753. * Are fresnels enabled in the application.
  39754. */
  39755. static FresnelEnabled: boolean;
  39756. private static _ClearCoatTextureEnabled;
  39757. /**
  39758. * Are clear coat textures enabled in the application.
  39759. */
  39760. static ClearCoatTextureEnabled: boolean;
  39761. private static _ClearCoatBumpTextureEnabled;
  39762. /**
  39763. * Are clear coat bump textures enabled in the application.
  39764. */
  39765. static ClearCoatBumpTextureEnabled: boolean;
  39766. private static _ClearCoatTintTextureEnabled;
  39767. /**
  39768. * Are clear coat tint textures enabled in the application.
  39769. */
  39770. static ClearCoatTintTextureEnabled: boolean;
  39771. private static _SheenTextureEnabled;
  39772. /**
  39773. * Are sheen textures enabled in the application.
  39774. */
  39775. static SheenTextureEnabled: boolean;
  39776. private static _AnisotropicTextureEnabled;
  39777. /**
  39778. * Are anisotropic textures enabled in the application.
  39779. */
  39780. static AnisotropicTextureEnabled: boolean;
  39781. private static _ThicknessTextureEnabled;
  39782. /**
  39783. * Are thickness textures enabled in the application.
  39784. */
  39785. static ThicknessTextureEnabled: boolean;
  39786. }
  39787. }
  39788. declare module BABYLON {
  39789. /** @hidden */
  39790. export var defaultFragmentDeclaration: {
  39791. name: string;
  39792. shader: string;
  39793. };
  39794. }
  39795. declare module BABYLON {
  39796. /** @hidden */
  39797. export var defaultUboDeclaration: {
  39798. name: string;
  39799. shader: string;
  39800. };
  39801. }
  39802. declare module BABYLON {
  39803. /** @hidden */
  39804. export var lightFragmentDeclaration: {
  39805. name: string;
  39806. shader: string;
  39807. };
  39808. }
  39809. declare module BABYLON {
  39810. /** @hidden */
  39811. export var lightUboDeclaration: {
  39812. name: string;
  39813. shader: string;
  39814. };
  39815. }
  39816. declare module BABYLON {
  39817. /** @hidden */
  39818. export var lightsFragmentFunctions: {
  39819. name: string;
  39820. shader: string;
  39821. };
  39822. }
  39823. declare module BABYLON {
  39824. /** @hidden */
  39825. export var shadowsFragmentFunctions: {
  39826. name: string;
  39827. shader: string;
  39828. };
  39829. }
  39830. declare module BABYLON {
  39831. /** @hidden */
  39832. export var fresnelFunction: {
  39833. name: string;
  39834. shader: string;
  39835. };
  39836. }
  39837. declare module BABYLON {
  39838. /** @hidden */
  39839. export var reflectionFunction: {
  39840. name: string;
  39841. shader: string;
  39842. };
  39843. }
  39844. declare module BABYLON {
  39845. /** @hidden */
  39846. export var bumpFragmentFunctions: {
  39847. name: string;
  39848. shader: string;
  39849. };
  39850. }
  39851. declare module BABYLON {
  39852. /** @hidden */
  39853. export var logDepthDeclaration: {
  39854. name: string;
  39855. shader: string;
  39856. };
  39857. }
  39858. declare module BABYLON {
  39859. /** @hidden */
  39860. export var bumpFragment: {
  39861. name: string;
  39862. shader: string;
  39863. };
  39864. }
  39865. declare module BABYLON {
  39866. /** @hidden */
  39867. export var depthPrePass: {
  39868. name: string;
  39869. shader: string;
  39870. };
  39871. }
  39872. declare module BABYLON {
  39873. /** @hidden */
  39874. export var lightFragment: {
  39875. name: string;
  39876. shader: string;
  39877. };
  39878. }
  39879. declare module BABYLON {
  39880. /** @hidden */
  39881. export var logDepthFragment: {
  39882. name: string;
  39883. shader: string;
  39884. };
  39885. }
  39886. declare module BABYLON {
  39887. /** @hidden */
  39888. export var defaultPixelShader: {
  39889. name: string;
  39890. shader: string;
  39891. };
  39892. }
  39893. declare module BABYLON {
  39894. /** @hidden */
  39895. export var defaultVertexDeclaration: {
  39896. name: string;
  39897. shader: string;
  39898. };
  39899. }
  39900. declare module BABYLON {
  39901. /** @hidden */
  39902. export var bumpVertexDeclaration: {
  39903. name: string;
  39904. shader: string;
  39905. };
  39906. }
  39907. declare module BABYLON {
  39908. /** @hidden */
  39909. export var bumpVertex: {
  39910. name: string;
  39911. shader: string;
  39912. };
  39913. }
  39914. declare module BABYLON {
  39915. /** @hidden */
  39916. export var fogVertex: {
  39917. name: string;
  39918. shader: string;
  39919. };
  39920. }
  39921. declare module BABYLON {
  39922. /** @hidden */
  39923. export var shadowsVertex: {
  39924. name: string;
  39925. shader: string;
  39926. };
  39927. }
  39928. declare module BABYLON {
  39929. /** @hidden */
  39930. export var pointCloudVertex: {
  39931. name: string;
  39932. shader: string;
  39933. };
  39934. }
  39935. declare module BABYLON {
  39936. /** @hidden */
  39937. export var logDepthVertex: {
  39938. name: string;
  39939. shader: string;
  39940. };
  39941. }
  39942. declare module BABYLON {
  39943. /** @hidden */
  39944. export var defaultVertexShader: {
  39945. name: string;
  39946. shader: string;
  39947. };
  39948. }
  39949. declare module BABYLON {
  39950. /** @hidden */
  39951. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39952. MAINUV1: boolean;
  39953. MAINUV2: boolean;
  39954. DIFFUSE: boolean;
  39955. DIFFUSEDIRECTUV: number;
  39956. AMBIENT: boolean;
  39957. AMBIENTDIRECTUV: number;
  39958. OPACITY: boolean;
  39959. OPACITYDIRECTUV: number;
  39960. OPACITYRGB: boolean;
  39961. REFLECTION: boolean;
  39962. EMISSIVE: boolean;
  39963. EMISSIVEDIRECTUV: number;
  39964. SPECULAR: boolean;
  39965. SPECULARDIRECTUV: number;
  39966. BUMP: boolean;
  39967. BUMPDIRECTUV: number;
  39968. PARALLAX: boolean;
  39969. PARALLAXOCCLUSION: boolean;
  39970. SPECULAROVERALPHA: boolean;
  39971. CLIPPLANE: boolean;
  39972. CLIPPLANE2: boolean;
  39973. CLIPPLANE3: boolean;
  39974. CLIPPLANE4: boolean;
  39975. ALPHATEST: boolean;
  39976. DEPTHPREPASS: boolean;
  39977. ALPHAFROMDIFFUSE: boolean;
  39978. POINTSIZE: boolean;
  39979. FOG: boolean;
  39980. SPECULARTERM: boolean;
  39981. DIFFUSEFRESNEL: boolean;
  39982. OPACITYFRESNEL: boolean;
  39983. REFLECTIONFRESNEL: boolean;
  39984. REFRACTIONFRESNEL: boolean;
  39985. EMISSIVEFRESNEL: boolean;
  39986. FRESNEL: boolean;
  39987. NORMAL: boolean;
  39988. UV1: boolean;
  39989. UV2: boolean;
  39990. VERTEXCOLOR: boolean;
  39991. VERTEXALPHA: boolean;
  39992. NUM_BONE_INFLUENCERS: number;
  39993. BonesPerMesh: number;
  39994. BONETEXTURE: boolean;
  39995. INSTANCES: boolean;
  39996. GLOSSINESS: boolean;
  39997. ROUGHNESS: boolean;
  39998. EMISSIVEASILLUMINATION: boolean;
  39999. LINKEMISSIVEWITHDIFFUSE: boolean;
  40000. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40001. LIGHTMAP: boolean;
  40002. LIGHTMAPDIRECTUV: number;
  40003. OBJECTSPACE_NORMALMAP: boolean;
  40004. USELIGHTMAPASSHADOWMAP: boolean;
  40005. REFLECTIONMAP_3D: boolean;
  40006. REFLECTIONMAP_SPHERICAL: boolean;
  40007. REFLECTIONMAP_PLANAR: boolean;
  40008. REFLECTIONMAP_CUBIC: boolean;
  40009. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40010. REFLECTIONMAP_PROJECTION: boolean;
  40011. REFLECTIONMAP_SKYBOX: boolean;
  40012. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40013. REFLECTIONMAP_EXPLICIT: boolean;
  40014. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40015. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40016. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40017. INVERTCUBICMAP: boolean;
  40018. LOGARITHMICDEPTH: boolean;
  40019. REFRACTION: boolean;
  40020. REFRACTIONMAP_3D: boolean;
  40021. REFLECTIONOVERALPHA: boolean;
  40022. TWOSIDEDLIGHTING: boolean;
  40023. SHADOWFLOAT: boolean;
  40024. MORPHTARGETS: boolean;
  40025. MORPHTARGETS_NORMAL: boolean;
  40026. MORPHTARGETS_TANGENT: boolean;
  40027. MORPHTARGETS_UV: boolean;
  40028. NUM_MORPH_INFLUENCERS: number;
  40029. NONUNIFORMSCALING: boolean;
  40030. PREMULTIPLYALPHA: boolean;
  40031. IMAGEPROCESSING: boolean;
  40032. VIGNETTE: boolean;
  40033. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40034. VIGNETTEBLENDMODEOPAQUE: boolean;
  40035. TONEMAPPING: boolean;
  40036. TONEMAPPING_ACES: boolean;
  40037. CONTRAST: boolean;
  40038. COLORCURVES: boolean;
  40039. COLORGRADING: boolean;
  40040. COLORGRADING3D: boolean;
  40041. SAMPLER3DGREENDEPTH: boolean;
  40042. SAMPLER3DBGRMAP: boolean;
  40043. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40044. MULTIVIEW: boolean;
  40045. /**
  40046. * If the reflection texture on this material is in linear color space
  40047. * @hidden
  40048. */
  40049. IS_REFLECTION_LINEAR: boolean;
  40050. /**
  40051. * If the refraction texture on this material is in linear color space
  40052. * @hidden
  40053. */
  40054. IS_REFRACTION_LINEAR: boolean;
  40055. EXPOSURE: boolean;
  40056. constructor();
  40057. setReflectionMode(modeToEnable: string): void;
  40058. }
  40059. /**
  40060. * This is the default material used in Babylon. It is the best trade off between quality
  40061. * and performances.
  40062. * @see http://doc.babylonjs.com/babylon101/materials
  40063. */
  40064. export class StandardMaterial extends PushMaterial {
  40065. private _diffuseTexture;
  40066. /**
  40067. * The basic texture of the material as viewed under a light.
  40068. */
  40069. diffuseTexture: Nullable<BaseTexture>;
  40070. private _ambientTexture;
  40071. /**
  40072. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40073. */
  40074. ambientTexture: Nullable<BaseTexture>;
  40075. private _opacityTexture;
  40076. /**
  40077. * Define the transparency of the material from a texture.
  40078. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40079. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40080. */
  40081. opacityTexture: Nullable<BaseTexture>;
  40082. private _reflectionTexture;
  40083. /**
  40084. * Define the texture used to display the reflection.
  40085. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40086. */
  40087. reflectionTexture: Nullable<BaseTexture>;
  40088. private _emissiveTexture;
  40089. /**
  40090. * Define texture of the material as if self lit.
  40091. * This will be mixed in the final result even in the absence of light.
  40092. */
  40093. emissiveTexture: Nullable<BaseTexture>;
  40094. private _specularTexture;
  40095. /**
  40096. * Define how the color and intensity of the highlight given by the light in the material.
  40097. */
  40098. specularTexture: Nullable<BaseTexture>;
  40099. private _bumpTexture;
  40100. /**
  40101. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40102. * 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.
  40103. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40104. */
  40105. bumpTexture: Nullable<BaseTexture>;
  40106. private _lightmapTexture;
  40107. /**
  40108. * Complex lighting can be computationally expensive to compute at runtime.
  40109. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40110. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40111. */
  40112. lightmapTexture: Nullable<BaseTexture>;
  40113. private _refractionTexture;
  40114. /**
  40115. * Define the texture used to display the refraction.
  40116. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40117. */
  40118. refractionTexture: Nullable<BaseTexture>;
  40119. /**
  40120. * The color of the material lit by the environmental background lighting.
  40121. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40122. */
  40123. ambientColor: Color3;
  40124. /**
  40125. * The basic color of the material as viewed under a light.
  40126. */
  40127. diffuseColor: Color3;
  40128. /**
  40129. * Define how the color and intensity of the highlight given by the light in the material.
  40130. */
  40131. specularColor: Color3;
  40132. /**
  40133. * Define the color of the material as if self lit.
  40134. * This will be mixed in the final result even in the absence of light.
  40135. */
  40136. emissiveColor: Color3;
  40137. /**
  40138. * Defines how sharp are the highlights in the material.
  40139. * The bigger the value the sharper giving a more glossy feeling to the result.
  40140. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40141. */
  40142. specularPower: number;
  40143. private _useAlphaFromDiffuseTexture;
  40144. /**
  40145. * Does the transparency come from the diffuse texture alpha channel.
  40146. */
  40147. useAlphaFromDiffuseTexture: boolean;
  40148. private _useEmissiveAsIllumination;
  40149. /**
  40150. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40151. */
  40152. useEmissiveAsIllumination: boolean;
  40153. private _linkEmissiveWithDiffuse;
  40154. /**
  40155. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40156. * the emissive level when the final color is close to one.
  40157. */
  40158. linkEmissiveWithDiffuse: boolean;
  40159. private _useSpecularOverAlpha;
  40160. /**
  40161. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40162. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40163. */
  40164. useSpecularOverAlpha: boolean;
  40165. private _useReflectionOverAlpha;
  40166. /**
  40167. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40168. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40169. */
  40170. useReflectionOverAlpha: boolean;
  40171. private _disableLighting;
  40172. /**
  40173. * Does lights from the scene impacts this material.
  40174. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40175. */
  40176. disableLighting: boolean;
  40177. private _useObjectSpaceNormalMap;
  40178. /**
  40179. * Allows using an object space normal map (instead of tangent space).
  40180. */
  40181. useObjectSpaceNormalMap: boolean;
  40182. private _useParallax;
  40183. /**
  40184. * Is parallax enabled or not.
  40185. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40186. */
  40187. useParallax: boolean;
  40188. private _useParallaxOcclusion;
  40189. /**
  40190. * Is parallax occlusion enabled or not.
  40191. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40192. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40193. */
  40194. useParallaxOcclusion: boolean;
  40195. /**
  40196. * 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.
  40197. */
  40198. parallaxScaleBias: number;
  40199. private _roughness;
  40200. /**
  40201. * Helps to define how blurry the reflections should appears in the material.
  40202. */
  40203. roughness: number;
  40204. /**
  40205. * In case of refraction, define the value of the index of refraction.
  40206. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40207. */
  40208. indexOfRefraction: number;
  40209. /**
  40210. * Invert the refraction texture alongside the y axis.
  40211. * It can be useful with procedural textures or probe for instance.
  40212. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40213. */
  40214. invertRefractionY: boolean;
  40215. /**
  40216. * Defines the alpha limits in alpha test mode.
  40217. */
  40218. alphaCutOff: number;
  40219. private _useLightmapAsShadowmap;
  40220. /**
  40221. * In case of light mapping, define whether the map contains light or shadow informations.
  40222. */
  40223. useLightmapAsShadowmap: boolean;
  40224. private _diffuseFresnelParameters;
  40225. /**
  40226. * Define the diffuse fresnel parameters of the material.
  40227. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40228. */
  40229. diffuseFresnelParameters: FresnelParameters;
  40230. private _opacityFresnelParameters;
  40231. /**
  40232. * Define the opacity fresnel parameters of the material.
  40233. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40234. */
  40235. opacityFresnelParameters: FresnelParameters;
  40236. private _reflectionFresnelParameters;
  40237. /**
  40238. * Define the reflection fresnel parameters of the material.
  40239. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40240. */
  40241. reflectionFresnelParameters: FresnelParameters;
  40242. private _refractionFresnelParameters;
  40243. /**
  40244. * Define the refraction fresnel parameters of the material.
  40245. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40246. */
  40247. refractionFresnelParameters: FresnelParameters;
  40248. private _emissiveFresnelParameters;
  40249. /**
  40250. * Define the emissive fresnel parameters of the material.
  40251. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40252. */
  40253. emissiveFresnelParameters: FresnelParameters;
  40254. private _useReflectionFresnelFromSpecular;
  40255. /**
  40256. * If true automatically deducts the fresnels values from the material specularity.
  40257. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40258. */
  40259. useReflectionFresnelFromSpecular: boolean;
  40260. private _useGlossinessFromSpecularMapAlpha;
  40261. /**
  40262. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40263. */
  40264. useGlossinessFromSpecularMapAlpha: boolean;
  40265. private _maxSimultaneousLights;
  40266. /**
  40267. * Defines the maximum number of lights that can be used in the material
  40268. */
  40269. maxSimultaneousLights: number;
  40270. private _invertNormalMapX;
  40271. /**
  40272. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40273. */
  40274. invertNormalMapX: boolean;
  40275. private _invertNormalMapY;
  40276. /**
  40277. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40278. */
  40279. invertNormalMapY: boolean;
  40280. private _twoSidedLighting;
  40281. /**
  40282. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40283. */
  40284. twoSidedLighting: boolean;
  40285. /**
  40286. * Default configuration related to image processing available in the standard Material.
  40287. */
  40288. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40289. /**
  40290. * Gets the image processing configuration used either in this material.
  40291. */
  40292. /**
  40293. * Sets the Default image processing configuration used either in the this material.
  40294. *
  40295. * If sets to null, the scene one is in use.
  40296. */
  40297. imageProcessingConfiguration: ImageProcessingConfiguration;
  40298. /**
  40299. * Keep track of the image processing observer to allow dispose and replace.
  40300. */
  40301. private _imageProcessingObserver;
  40302. /**
  40303. * Attaches a new image processing configuration to the Standard Material.
  40304. * @param configuration
  40305. */
  40306. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40307. /**
  40308. * Gets wether the color curves effect is enabled.
  40309. */
  40310. /**
  40311. * Sets wether the color curves effect is enabled.
  40312. */
  40313. cameraColorCurvesEnabled: boolean;
  40314. /**
  40315. * Gets wether the color grading effect is enabled.
  40316. */
  40317. /**
  40318. * Gets wether the color grading effect is enabled.
  40319. */
  40320. cameraColorGradingEnabled: boolean;
  40321. /**
  40322. * Gets wether tonemapping is enabled or not.
  40323. */
  40324. /**
  40325. * Sets wether tonemapping is enabled or not
  40326. */
  40327. cameraToneMappingEnabled: boolean;
  40328. /**
  40329. * The camera exposure used on this material.
  40330. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40331. * This corresponds to a photographic exposure.
  40332. */
  40333. /**
  40334. * The camera exposure used on this material.
  40335. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40336. * This corresponds to a photographic exposure.
  40337. */
  40338. cameraExposure: number;
  40339. /**
  40340. * Gets The camera contrast used on this material.
  40341. */
  40342. /**
  40343. * Sets The camera contrast used on this material.
  40344. */
  40345. cameraContrast: number;
  40346. /**
  40347. * Gets the Color Grading 2D Lookup Texture.
  40348. */
  40349. /**
  40350. * Sets the Color Grading 2D Lookup Texture.
  40351. */
  40352. cameraColorGradingTexture: Nullable<BaseTexture>;
  40353. /**
  40354. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40355. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40356. * 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;
  40357. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40358. */
  40359. /**
  40360. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40361. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40362. * 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;
  40363. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40364. */
  40365. cameraColorCurves: Nullable<ColorCurves>;
  40366. /**
  40367. * Custom callback helping to override the default shader used in the material.
  40368. */
  40369. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40370. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40371. protected _worldViewProjectionMatrix: Matrix;
  40372. protected _globalAmbientColor: Color3;
  40373. protected _useLogarithmicDepth: boolean;
  40374. protected _rebuildInParallel: boolean;
  40375. /**
  40376. * Instantiates a new standard material.
  40377. * This is the default material used in Babylon. It is the best trade off between quality
  40378. * and performances.
  40379. * @see http://doc.babylonjs.com/babylon101/materials
  40380. * @param name Define the name of the material in the scene
  40381. * @param scene Define the scene the material belong to
  40382. */
  40383. constructor(name: string, scene: Scene);
  40384. /**
  40385. * Gets a boolean indicating that current material needs to register RTT
  40386. */
  40387. readonly hasRenderTargetTextures: boolean;
  40388. /**
  40389. * Gets the current class name of the material e.g. "StandardMaterial"
  40390. * Mainly use in serialization.
  40391. * @returns the class name
  40392. */
  40393. getClassName(): string;
  40394. /**
  40395. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40396. * You can try switching to logarithmic depth.
  40397. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40398. */
  40399. useLogarithmicDepth: boolean;
  40400. /**
  40401. * Specifies if the material will require alpha blending
  40402. * @returns a boolean specifying if alpha blending is needed
  40403. */
  40404. needAlphaBlending(): boolean;
  40405. /**
  40406. * Specifies if this material should be rendered in alpha test mode
  40407. * @returns a boolean specifying if an alpha test is needed.
  40408. */
  40409. needAlphaTesting(): boolean;
  40410. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40411. /**
  40412. * Get the texture used for alpha test purpose.
  40413. * @returns the diffuse texture in case of the standard material.
  40414. */
  40415. getAlphaTestTexture(): Nullable<BaseTexture>;
  40416. /**
  40417. * Get if the submesh is ready to be used and all its information available.
  40418. * Child classes can use it to update shaders
  40419. * @param mesh defines the mesh to check
  40420. * @param subMesh defines which submesh to check
  40421. * @param useInstances specifies that instances should be used
  40422. * @returns a boolean indicating that the submesh is ready or not
  40423. */
  40424. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40425. /**
  40426. * Builds the material UBO layouts.
  40427. * Used internally during the effect preparation.
  40428. */
  40429. buildUniformLayout(): void;
  40430. /**
  40431. * Unbinds the material from the mesh
  40432. */
  40433. unbind(): void;
  40434. /**
  40435. * Binds the submesh to this material by preparing the effect and shader to draw
  40436. * @param world defines the world transformation matrix
  40437. * @param mesh defines the mesh containing the submesh
  40438. * @param subMesh defines the submesh to bind the material to
  40439. */
  40440. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40441. /**
  40442. * Get the list of animatables in the material.
  40443. * @returns the list of animatables object used in the material
  40444. */
  40445. getAnimatables(): IAnimatable[];
  40446. /**
  40447. * Gets the active textures from the material
  40448. * @returns an array of textures
  40449. */
  40450. getActiveTextures(): BaseTexture[];
  40451. /**
  40452. * Specifies if the material uses a texture
  40453. * @param texture defines the texture to check against the material
  40454. * @returns a boolean specifying if the material uses the texture
  40455. */
  40456. hasTexture(texture: BaseTexture): boolean;
  40457. /**
  40458. * Disposes the material
  40459. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40460. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40461. */
  40462. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40463. /**
  40464. * Makes a duplicate of the material, and gives it a new name
  40465. * @param name defines the new name for the duplicated material
  40466. * @returns the cloned material
  40467. */
  40468. clone(name: string): StandardMaterial;
  40469. /**
  40470. * Serializes this material in a JSON representation
  40471. * @returns the serialized material object
  40472. */
  40473. serialize(): any;
  40474. /**
  40475. * Creates a standard material from parsed material data
  40476. * @param source defines the JSON representation of the material
  40477. * @param scene defines the hosting scene
  40478. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40479. * @returns a new standard material
  40480. */
  40481. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40482. /**
  40483. * Are diffuse textures enabled in the application.
  40484. */
  40485. static DiffuseTextureEnabled: boolean;
  40486. /**
  40487. * Are ambient textures enabled in the application.
  40488. */
  40489. static AmbientTextureEnabled: boolean;
  40490. /**
  40491. * Are opacity textures enabled in the application.
  40492. */
  40493. static OpacityTextureEnabled: boolean;
  40494. /**
  40495. * Are reflection textures enabled in the application.
  40496. */
  40497. static ReflectionTextureEnabled: boolean;
  40498. /**
  40499. * Are emissive textures enabled in the application.
  40500. */
  40501. static EmissiveTextureEnabled: boolean;
  40502. /**
  40503. * Are specular textures enabled in the application.
  40504. */
  40505. static SpecularTextureEnabled: boolean;
  40506. /**
  40507. * Are bump textures enabled in the application.
  40508. */
  40509. static BumpTextureEnabled: boolean;
  40510. /**
  40511. * Are lightmap textures enabled in the application.
  40512. */
  40513. static LightmapTextureEnabled: boolean;
  40514. /**
  40515. * Are refraction textures enabled in the application.
  40516. */
  40517. static RefractionTextureEnabled: boolean;
  40518. /**
  40519. * Are color grading textures enabled in the application.
  40520. */
  40521. static ColorGradingTextureEnabled: boolean;
  40522. /**
  40523. * Are fresnels enabled in the application.
  40524. */
  40525. static FresnelEnabled: boolean;
  40526. }
  40527. }
  40528. declare module BABYLON {
  40529. /** @hidden */
  40530. export var imageProcessingPixelShader: {
  40531. name: string;
  40532. shader: string;
  40533. };
  40534. }
  40535. declare module BABYLON {
  40536. /**
  40537. * ImageProcessingPostProcess
  40538. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40539. */
  40540. export class ImageProcessingPostProcess extends PostProcess {
  40541. /**
  40542. * Default configuration related to image processing available in the PBR Material.
  40543. */
  40544. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40545. /**
  40546. * Gets the image processing configuration used either in this material.
  40547. */
  40548. /**
  40549. * Sets the Default image processing configuration used either in the this material.
  40550. *
  40551. * If sets to null, the scene one is in use.
  40552. */
  40553. imageProcessingConfiguration: ImageProcessingConfiguration;
  40554. /**
  40555. * Keep track of the image processing observer to allow dispose and replace.
  40556. */
  40557. private _imageProcessingObserver;
  40558. /**
  40559. * Attaches a new image processing configuration to the PBR Material.
  40560. * @param configuration
  40561. */
  40562. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40563. /**
  40564. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40565. */
  40566. /**
  40567. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40568. */
  40569. colorCurves: Nullable<ColorCurves>;
  40570. /**
  40571. * Gets wether the color curves effect is enabled.
  40572. */
  40573. /**
  40574. * Sets wether the color curves effect is enabled.
  40575. */
  40576. colorCurvesEnabled: boolean;
  40577. /**
  40578. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40579. */
  40580. /**
  40581. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40582. */
  40583. colorGradingTexture: Nullable<BaseTexture>;
  40584. /**
  40585. * Gets wether the color grading effect is enabled.
  40586. */
  40587. /**
  40588. * Gets wether the color grading effect is enabled.
  40589. */
  40590. colorGradingEnabled: boolean;
  40591. /**
  40592. * Gets exposure used in the effect.
  40593. */
  40594. /**
  40595. * Sets exposure used in the effect.
  40596. */
  40597. exposure: number;
  40598. /**
  40599. * Gets wether tonemapping is enabled or not.
  40600. */
  40601. /**
  40602. * Sets wether tonemapping is enabled or not
  40603. */
  40604. toneMappingEnabled: boolean;
  40605. /**
  40606. * Gets the type of tone mapping effect.
  40607. */
  40608. /**
  40609. * Sets the type of tone mapping effect.
  40610. */
  40611. toneMappingType: number;
  40612. /**
  40613. * Gets contrast used in the effect.
  40614. */
  40615. /**
  40616. * Sets contrast used in the effect.
  40617. */
  40618. contrast: number;
  40619. /**
  40620. * Gets Vignette stretch size.
  40621. */
  40622. /**
  40623. * Sets Vignette stretch size.
  40624. */
  40625. vignetteStretch: number;
  40626. /**
  40627. * Gets Vignette centre X Offset.
  40628. */
  40629. /**
  40630. * Sets Vignette centre X Offset.
  40631. */
  40632. vignetteCentreX: number;
  40633. /**
  40634. * Gets Vignette centre Y Offset.
  40635. */
  40636. /**
  40637. * Sets Vignette centre Y Offset.
  40638. */
  40639. vignetteCentreY: number;
  40640. /**
  40641. * Gets Vignette weight or intensity of the vignette effect.
  40642. */
  40643. /**
  40644. * Sets Vignette weight or intensity of the vignette effect.
  40645. */
  40646. vignetteWeight: number;
  40647. /**
  40648. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40649. * if vignetteEnabled is set to true.
  40650. */
  40651. /**
  40652. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40653. * if vignetteEnabled is set to true.
  40654. */
  40655. vignetteColor: Color4;
  40656. /**
  40657. * Gets Camera field of view used by the Vignette effect.
  40658. */
  40659. /**
  40660. * Sets Camera field of view used by the Vignette effect.
  40661. */
  40662. vignetteCameraFov: number;
  40663. /**
  40664. * Gets the vignette blend mode allowing different kind of effect.
  40665. */
  40666. /**
  40667. * Sets the vignette blend mode allowing different kind of effect.
  40668. */
  40669. vignetteBlendMode: number;
  40670. /**
  40671. * Gets wether the vignette effect is enabled.
  40672. */
  40673. /**
  40674. * Sets wether the vignette effect is enabled.
  40675. */
  40676. vignetteEnabled: boolean;
  40677. private _fromLinearSpace;
  40678. /**
  40679. * Gets wether the input of the processing is in Gamma or Linear Space.
  40680. */
  40681. /**
  40682. * Sets wether the input of the processing is in Gamma or Linear Space.
  40683. */
  40684. fromLinearSpace: boolean;
  40685. /**
  40686. * Defines cache preventing GC.
  40687. */
  40688. private _defines;
  40689. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40690. /**
  40691. * "ImageProcessingPostProcess"
  40692. * @returns "ImageProcessingPostProcess"
  40693. */
  40694. getClassName(): string;
  40695. protected _updateParameters(): void;
  40696. dispose(camera?: Camera): void;
  40697. }
  40698. }
  40699. declare module BABYLON {
  40700. /**
  40701. * Class containing static functions to help procedurally build meshes
  40702. */
  40703. export class GroundBuilder {
  40704. /**
  40705. * Creates a ground mesh
  40706. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40707. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40709. * @param name defines the name of the mesh
  40710. * @param options defines the options used to create the mesh
  40711. * @param scene defines the hosting scene
  40712. * @returns the ground mesh
  40713. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40714. */
  40715. static CreateGround(name: string, options: {
  40716. width?: number;
  40717. height?: number;
  40718. subdivisions?: number;
  40719. subdivisionsX?: number;
  40720. subdivisionsY?: number;
  40721. updatable?: boolean;
  40722. }, scene: any): Mesh;
  40723. /**
  40724. * Creates a tiled ground mesh
  40725. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40726. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40727. * * 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
  40728. * * 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
  40729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40730. * @param name defines the name of the mesh
  40731. * @param options defines the options used to create the mesh
  40732. * @param scene defines the hosting scene
  40733. * @returns the tiled ground mesh
  40734. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40735. */
  40736. static CreateTiledGround(name: string, options: {
  40737. xmin: number;
  40738. zmin: number;
  40739. xmax: number;
  40740. zmax: number;
  40741. subdivisions?: {
  40742. w: number;
  40743. h: number;
  40744. };
  40745. precision?: {
  40746. w: number;
  40747. h: number;
  40748. };
  40749. updatable?: boolean;
  40750. }, scene?: Nullable<Scene>): Mesh;
  40751. /**
  40752. * Creates a ground mesh from a height map
  40753. * * The parameter `url` sets the URL of the height map image resource.
  40754. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40755. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40756. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40757. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40758. * * 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.
  40759. * * 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).
  40760. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40762. * @param name defines the name of the mesh
  40763. * @param url defines the url to the height map
  40764. * @param options defines the options used to create the mesh
  40765. * @param scene defines the hosting scene
  40766. * @returns the ground mesh
  40767. * @see https://doc.babylonjs.com/babylon101/height_map
  40768. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40769. */
  40770. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40771. width?: number;
  40772. height?: number;
  40773. subdivisions?: number;
  40774. minHeight?: number;
  40775. maxHeight?: number;
  40776. colorFilter?: Color3;
  40777. alphaFilter?: number;
  40778. updatable?: boolean;
  40779. onReady?: (mesh: GroundMesh) => void;
  40780. }, scene?: Nullable<Scene>): GroundMesh;
  40781. }
  40782. }
  40783. declare module BABYLON {
  40784. /**
  40785. * Class containing static functions to help procedurally build meshes
  40786. */
  40787. export class TorusBuilder {
  40788. /**
  40789. * Creates a torus mesh
  40790. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40791. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40792. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40794. * * 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
  40795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40796. * @param name defines the name of the mesh
  40797. * @param options defines the options used to create the mesh
  40798. * @param scene defines the hosting scene
  40799. * @returns the torus mesh
  40800. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40801. */
  40802. static CreateTorus(name: string, options: {
  40803. diameter?: number;
  40804. thickness?: number;
  40805. tessellation?: number;
  40806. updatable?: boolean;
  40807. sideOrientation?: number;
  40808. frontUVs?: Vector4;
  40809. backUVs?: Vector4;
  40810. }, scene: any): Mesh;
  40811. }
  40812. }
  40813. declare module BABYLON {
  40814. /**
  40815. * Class containing static functions to help procedurally build meshes
  40816. */
  40817. export class CylinderBuilder {
  40818. /**
  40819. * Creates a cylinder or a cone mesh
  40820. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40821. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40822. * * 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.
  40823. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40824. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40825. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40826. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40827. * * 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).
  40828. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40829. * * 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).
  40830. * * 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
  40831. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40832. * * 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
  40833. * * 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.
  40834. * * If `enclose` is false, a ring surface is one element.
  40835. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40836. * * 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
  40837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40838. * * 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
  40839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40840. * @param name defines the name of the mesh
  40841. * @param options defines the options used to create the mesh
  40842. * @param scene defines the hosting scene
  40843. * @returns the cylinder mesh
  40844. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40845. */
  40846. static CreateCylinder(name: string, options: {
  40847. height?: number;
  40848. diameterTop?: number;
  40849. diameterBottom?: number;
  40850. diameter?: number;
  40851. tessellation?: number;
  40852. subdivisions?: number;
  40853. arc?: number;
  40854. faceColors?: Color4[];
  40855. faceUV?: Vector4[];
  40856. updatable?: boolean;
  40857. hasRings?: boolean;
  40858. enclose?: boolean;
  40859. cap?: number;
  40860. sideOrientation?: number;
  40861. frontUVs?: Vector4;
  40862. backUVs?: Vector4;
  40863. }, scene: any): Mesh;
  40864. }
  40865. }
  40866. declare module BABYLON {
  40867. /**
  40868. * Options to modify the vr teleportation behavior.
  40869. */
  40870. export interface VRTeleportationOptions {
  40871. /**
  40872. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40873. */
  40874. floorMeshName?: string;
  40875. /**
  40876. * A list of meshes to be used as the teleportation floor. (default: empty)
  40877. */
  40878. floorMeshes?: Mesh[];
  40879. }
  40880. /**
  40881. * Options to modify the vr experience helper's behavior.
  40882. */
  40883. export interface VRExperienceHelperOptions extends WebVROptions {
  40884. /**
  40885. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40886. */
  40887. createDeviceOrientationCamera?: boolean;
  40888. /**
  40889. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40890. */
  40891. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40892. /**
  40893. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40894. */
  40895. laserToggle?: boolean;
  40896. /**
  40897. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40898. */
  40899. floorMeshes?: Mesh[];
  40900. /**
  40901. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40902. */
  40903. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40904. }
  40905. /**
  40906. * Event containing information after VR has been entered
  40907. */
  40908. export class OnAfterEnteringVRObservableEvent {
  40909. /**
  40910. * If entering vr was successful
  40911. */
  40912. success: boolean;
  40913. }
  40914. /**
  40915. * Helps to quickly add VR support to an existing scene.
  40916. * See http://doc.babylonjs.com/how_to/webvr_helper
  40917. */
  40918. export class VRExperienceHelper {
  40919. /** Options to modify the vr experience helper's behavior. */
  40920. webVROptions: VRExperienceHelperOptions;
  40921. private _scene;
  40922. private _position;
  40923. private _btnVR;
  40924. private _btnVRDisplayed;
  40925. private _webVRsupported;
  40926. private _webVRready;
  40927. private _webVRrequesting;
  40928. private _webVRpresenting;
  40929. private _hasEnteredVR;
  40930. private _fullscreenVRpresenting;
  40931. private _canvas;
  40932. private _webVRCamera;
  40933. private _vrDeviceOrientationCamera;
  40934. private _deviceOrientationCamera;
  40935. private _existingCamera;
  40936. private _onKeyDown;
  40937. private _onVrDisplayPresentChange;
  40938. private _onVRDisplayChanged;
  40939. private _onVRRequestPresentStart;
  40940. private _onVRRequestPresentComplete;
  40941. /**
  40942. * 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)
  40943. */
  40944. enableGazeEvenWhenNoPointerLock: boolean;
  40945. /**
  40946. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40947. */
  40948. exitVROnDoubleTap: boolean;
  40949. /**
  40950. * Observable raised right before entering VR.
  40951. */
  40952. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40953. /**
  40954. * Observable raised when entering VR has completed.
  40955. */
  40956. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40957. /**
  40958. * Observable raised when exiting VR.
  40959. */
  40960. onExitingVRObservable: Observable<VRExperienceHelper>;
  40961. /**
  40962. * Observable raised when controller mesh is loaded.
  40963. */
  40964. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40965. /** Return this.onEnteringVRObservable
  40966. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40967. */
  40968. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40969. /** Return this.onExitingVRObservable
  40970. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40971. */
  40972. readonly onExitingVR: Observable<VRExperienceHelper>;
  40973. /** Return this.onControllerMeshLoadedObservable
  40974. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40975. */
  40976. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40977. private _rayLength;
  40978. private _useCustomVRButton;
  40979. private _teleportationRequested;
  40980. private _teleportActive;
  40981. private _floorMeshName;
  40982. private _floorMeshesCollection;
  40983. private _rotationAllowed;
  40984. private _teleportBackwardsVector;
  40985. private _teleportationTarget;
  40986. private _isDefaultTeleportationTarget;
  40987. private _postProcessMove;
  40988. private _teleportationFillColor;
  40989. private _teleportationBorderColor;
  40990. private _rotationAngle;
  40991. private _haloCenter;
  40992. private _cameraGazer;
  40993. private _padSensibilityUp;
  40994. private _padSensibilityDown;
  40995. private _leftController;
  40996. private _rightController;
  40997. /**
  40998. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40999. */
  41000. onNewMeshSelected: Observable<AbstractMesh>;
  41001. /**
  41002. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  41003. * This observable will provide the mesh and the controller used to select the mesh
  41004. */
  41005. onMeshSelectedWithController: Observable<{
  41006. mesh: AbstractMesh;
  41007. controller: WebVRController;
  41008. }>;
  41009. /**
  41010. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41011. */
  41012. onNewMeshPicked: Observable<PickingInfo>;
  41013. private _circleEase;
  41014. /**
  41015. * Observable raised before camera teleportation
  41016. */
  41017. onBeforeCameraTeleport: Observable<Vector3>;
  41018. /**
  41019. * Observable raised after camera teleportation
  41020. */
  41021. onAfterCameraTeleport: Observable<Vector3>;
  41022. /**
  41023. * Observable raised when current selected mesh gets unselected
  41024. */
  41025. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41026. private _raySelectionPredicate;
  41027. /**
  41028. * To be optionaly changed by user to define custom ray selection
  41029. */
  41030. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41031. /**
  41032. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41033. */
  41034. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41035. /**
  41036. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41037. */
  41038. teleportationEnabled: boolean;
  41039. private _defaultHeight;
  41040. private _teleportationInitialized;
  41041. private _interactionsEnabled;
  41042. private _interactionsRequested;
  41043. private _displayGaze;
  41044. private _displayLaserPointer;
  41045. /**
  41046. * The mesh used to display where the user is going to teleport.
  41047. */
  41048. /**
  41049. * Sets the mesh to be used to display where the user is going to teleport.
  41050. */
  41051. teleportationTarget: Mesh;
  41052. /**
  41053. * 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
  41054. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41055. * See http://doc.babylonjs.com/resources/baking_transformations
  41056. */
  41057. gazeTrackerMesh: Mesh;
  41058. /**
  41059. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41060. */
  41061. updateGazeTrackerScale: boolean;
  41062. /**
  41063. * If the gaze trackers color should be updated when selecting meshes
  41064. */
  41065. updateGazeTrackerColor: boolean;
  41066. /**
  41067. * If the controller laser color should be updated when selecting meshes
  41068. */
  41069. updateControllerLaserColor: boolean;
  41070. /**
  41071. * The gaze tracking mesh corresponding to the left controller
  41072. */
  41073. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41074. /**
  41075. * The gaze tracking mesh corresponding to the right controller
  41076. */
  41077. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41078. /**
  41079. * If the ray of the gaze should be displayed.
  41080. */
  41081. /**
  41082. * Sets if the ray of the gaze should be displayed.
  41083. */
  41084. displayGaze: boolean;
  41085. /**
  41086. * If the ray of the LaserPointer should be displayed.
  41087. */
  41088. /**
  41089. * Sets if the ray of the LaserPointer should be displayed.
  41090. */
  41091. displayLaserPointer: boolean;
  41092. /**
  41093. * The deviceOrientationCamera used as the camera when not in VR.
  41094. */
  41095. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41096. /**
  41097. * Based on the current WebVR support, returns the current VR camera used.
  41098. */
  41099. readonly currentVRCamera: Nullable<Camera>;
  41100. /**
  41101. * The webVRCamera which is used when in VR.
  41102. */
  41103. readonly webVRCamera: WebVRFreeCamera;
  41104. /**
  41105. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41106. */
  41107. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41108. /**
  41109. * The html button that is used to trigger entering into VR.
  41110. */
  41111. readonly vrButton: Nullable<HTMLButtonElement>;
  41112. private readonly _teleportationRequestInitiated;
  41113. /**
  41114. * Defines wether or not Pointer lock should be requested when switching to
  41115. * full screen.
  41116. */
  41117. requestPointerLockOnFullScreen: boolean;
  41118. /**
  41119. * Instantiates a VRExperienceHelper.
  41120. * Helps to quickly add VR support to an existing scene.
  41121. * @param scene The scene the VRExperienceHelper belongs to.
  41122. * @param webVROptions Options to modify the vr experience helper's behavior.
  41123. */
  41124. constructor(scene: Scene,
  41125. /** Options to modify the vr experience helper's behavior. */
  41126. webVROptions?: VRExperienceHelperOptions);
  41127. private _onDefaultMeshLoaded;
  41128. private _onResize;
  41129. private _onFullscreenChange;
  41130. /**
  41131. * Gets a value indicating if we are currently in VR mode.
  41132. */
  41133. readonly isInVRMode: boolean;
  41134. private onVrDisplayPresentChange;
  41135. private onVRDisplayChanged;
  41136. private moveButtonToBottomRight;
  41137. private displayVRButton;
  41138. private updateButtonVisibility;
  41139. private _cachedAngularSensibility;
  41140. /**
  41141. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41142. * Otherwise, will use the fullscreen API.
  41143. */
  41144. enterVR(): void;
  41145. /**
  41146. * Attempt to exit VR, or fullscreen.
  41147. */
  41148. exitVR(): void;
  41149. /**
  41150. * The position of the vr experience helper.
  41151. */
  41152. /**
  41153. * Sets the position of the vr experience helper.
  41154. */
  41155. position: Vector3;
  41156. /**
  41157. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41158. */
  41159. enableInteractions(): void;
  41160. private readonly _noControllerIsActive;
  41161. private beforeRender;
  41162. private _isTeleportationFloor;
  41163. /**
  41164. * Adds a floor mesh to be used for teleportation.
  41165. * @param floorMesh the mesh to be used for teleportation.
  41166. */
  41167. addFloorMesh(floorMesh: Mesh): void;
  41168. /**
  41169. * Removes a floor mesh from being used for teleportation.
  41170. * @param floorMesh the mesh to be removed.
  41171. */
  41172. removeFloorMesh(floorMesh: Mesh): void;
  41173. /**
  41174. * Enables interactions and teleportation using the VR controllers and gaze.
  41175. * @param vrTeleportationOptions options to modify teleportation behavior.
  41176. */
  41177. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41178. private _onNewGamepadConnected;
  41179. private _tryEnableInteractionOnController;
  41180. private _onNewGamepadDisconnected;
  41181. private _enableInteractionOnController;
  41182. private _checkTeleportWithRay;
  41183. private _checkRotate;
  41184. private _checkTeleportBackwards;
  41185. private _enableTeleportationOnController;
  41186. private _createTeleportationCircles;
  41187. private _displayTeleportationTarget;
  41188. private _hideTeleportationTarget;
  41189. private _rotateCamera;
  41190. private _moveTeleportationSelectorTo;
  41191. private _workingVector;
  41192. private _workingQuaternion;
  41193. private _workingMatrix;
  41194. /**
  41195. * Teleports the users feet to the desired location
  41196. * @param location The location where the user's feet should be placed
  41197. */
  41198. teleportCamera(location: Vector3): void;
  41199. private _convertNormalToDirectionOfRay;
  41200. private _castRayAndSelectObject;
  41201. private _notifySelectedMeshUnselected;
  41202. /**
  41203. * Sets the color of the laser ray from the vr controllers.
  41204. * @param color new color for the ray.
  41205. */
  41206. changeLaserColor(color: Color3): void;
  41207. /**
  41208. * Sets the color of the ray from the vr headsets gaze.
  41209. * @param color new color for the ray.
  41210. */
  41211. changeGazeColor(color: Color3): void;
  41212. /**
  41213. * Exits VR and disposes of the vr experience helper
  41214. */
  41215. dispose(): void;
  41216. /**
  41217. * Gets the name of the VRExperienceHelper class
  41218. * @returns "VRExperienceHelper"
  41219. */
  41220. getClassName(): string;
  41221. }
  41222. }
  41223. declare module BABYLON {
  41224. /**
  41225. * Manages an XRSession to work with Babylon's engine
  41226. * @see https://doc.babylonjs.com/how_to/webxr
  41227. */
  41228. export class WebXRSessionManager implements IDisposable {
  41229. private scene;
  41230. /**
  41231. * Fires every time a new xrFrame arrives which can be used to update the camera
  41232. */
  41233. onXRFrameObservable: Observable<any>;
  41234. /**
  41235. * Fires when the xr session is ended either by the device or manually done
  41236. */
  41237. onXRSessionEnded: Observable<any>;
  41238. /**
  41239. * Underlying xr session
  41240. */
  41241. session: XRSession;
  41242. /**
  41243. * Type of reference space used when creating the session
  41244. */
  41245. referenceSpace: XRReferenceSpace;
  41246. /** @hidden */
  41247. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41248. /**
  41249. * Current XR frame
  41250. */
  41251. currentFrame: Nullable<XRFrame>;
  41252. private _xrNavigator;
  41253. private baseLayer;
  41254. /**
  41255. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41256. * @param scene The scene which the session should be created for
  41257. */
  41258. constructor(scene: Scene);
  41259. /**
  41260. * Initializes the manager
  41261. * After initialization enterXR can be called to start an XR session
  41262. * @returns Promise which resolves after it is initialized
  41263. */
  41264. initializeAsync(): Promise<void>;
  41265. /**
  41266. * Initializes an xr session
  41267. * @param xrSessionMode mode to initialize
  41268. * @returns a promise which will resolve once the session has been initialized
  41269. */
  41270. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41271. /**
  41272. * Sets the reference space on the xr session
  41273. * @param referenceSpace space to set
  41274. * @returns a promise that will resolve once the reference space has been set
  41275. */
  41276. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41277. /**
  41278. * Updates the render state of the session
  41279. * @param state state to set
  41280. * @returns a promise that resolves once the render state has been updated
  41281. */
  41282. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41283. /**
  41284. * Starts rendering to the xr layer
  41285. * @returns a promise that will resolve once rendering has started
  41286. */
  41287. startRenderingToXRAsync(): Promise<void>;
  41288. /**
  41289. * Stops the xrSession and restores the renderloop
  41290. * @returns Promise which resolves after it exits XR
  41291. */
  41292. exitXRAsync(): Promise<unknown>;
  41293. /**
  41294. * Checks if a session would be supported for the creation options specified
  41295. * @param sessionMode session mode to check if supported eg. immersive-vr
  41296. * @returns true if supported
  41297. */
  41298. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41299. /**
  41300. * @hidden
  41301. * Converts the render layer of xrSession to a render target
  41302. * @param session session to create render target for
  41303. * @param scene scene the new render target should be created for
  41304. */
  41305. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41306. /**
  41307. * Disposes of the session manager
  41308. */
  41309. dispose(): void;
  41310. }
  41311. }
  41312. declare module BABYLON {
  41313. /**
  41314. * WebXR Camera which holds the views for the xrSession
  41315. * @see https://doc.babylonjs.com/how_to/webxr
  41316. */
  41317. export class WebXRCamera extends FreeCamera {
  41318. private static _TmpMatrix;
  41319. /**
  41320. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41321. * @param name the name of the camera
  41322. * @param scene the scene to add the camera to
  41323. */
  41324. constructor(name: string, scene: Scene);
  41325. private _updateNumberOfRigCameras;
  41326. /** @hidden */
  41327. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41328. /**
  41329. * Updates the cameras position from the current pose information of the XR session
  41330. * @param xrSessionManager the session containing pose information
  41331. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41332. */
  41333. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41334. }
  41335. }
  41336. declare module BABYLON {
  41337. /**
  41338. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41339. */
  41340. export class WebXRManagedOutputCanvas implements IDisposable {
  41341. private helper;
  41342. private _canvas;
  41343. /**
  41344. * xrpresent context of the canvas which can be used to display/mirror xr content
  41345. */
  41346. canvasContext: WebGLRenderingContext;
  41347. /**
  41348. * xr layer for the canvas
  41349. */
  41350. xrLayer: Nullable<XRWebGLLayer>;
  41351. /**
  41352. * Initializes the xr layer for the session
  41353. * @param xrSession xr session
  41354. * @returns a promise that will resolve once the XR Layer has been created
  41355. */
  41356. initializeXRLayerAsync(xrSession: any): any;
  41357. /**
  41358. * Initializes the canvas to be added/removed upon entering/exiting xr
  41359. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41360. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41361. */
  41362. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41363. /**
  41364. * Disposes of the object
  41365. */
  41366. dispose(): void;
  41367. private _setManagedOutputCanvas;
  41368. private _addCanvas;
  41369. private _removeCanvas;
  41370. }
  41371. }
  41372. declare module BABYLON {
  41373. /**
  41374. * States of the webXR experience
  41375. */
  41376. export enum WebXRState {
  41377. /**
  41378. * Transitioning to being in XR mode
  41379. */
  41380. ENTERING_XR = 0,
  41381. /**
  41382. * Transitioning to non XR mode
  41383. */
  41384. EXITING_XR = 1,
  41385. /**
  41386. * In XR mode and presenting
  41387. */
  41388. IN_XR = 2,
  41389. /**
  41390. * Not entered XR mode
  41391. */
  41392. NOT_IN_XR = 3
  41393. }
  41394. /**
  41395. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41396. * @see https://doc.babylonjs.com/how_to/webxr
  41397. */
  41398. export class WebXRExperienceHelper implements IDisposable {
  41399. private scene;
  41400. /**
  41401. * 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
  41402. */
  41403. container: AbstractMesh;
  41404. /**
  41405. * Camera used to render xr content
  41406. */
  41407. camera: WebXRCamera;
  41408. /**
  41409. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41410. */
  41411. state: WebXRState;
  41412. private _setState;
  41413. private static _TmpVector;
  41414. /**
  41415. * Fires when the state of the experience helper has changed
  41416. */
  41417. onStateChangedObservable: Observable<WebXRState>;
  41418. /** Session manager used to keep track of xr session */
  41419. sessionManager: WebXRSessionManager;
  41420. private _nonVRCamera;
  41421. private _originalSceneAutoClear;
  41422. private _supported;
  41423. /**
  41424. * Creates the experience helper
  41425. * @param scene the scene to attach the experience helper to
  41426. * @returns a promise for the experience helper
  41427. */
  41428. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41429. /**
  41430. * Creates a WebXRExperienceHelper
  41431. * @param scene The scene the helper should be created in
  41432. */
  41433. private constructor();
  41434. /**
  41435. * Exits XR mode and returns the scene to its original state
  41436. * @returns promise that resolves after xr mode has exited
  41437. */
  41438. exitXRAsync(): Promise<unknown>;
  41439. /**
  41440. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41441. * @param sessionCreationOptions options for the XR session
  41442. * @param referenceSpaceType frame of reference of the XR session
  41443. * @param outputCanvas the output canvas that will be used to enter XR mode
  41444. * @returns promise that resolves after xr mode has entered
  41445. */
  41446. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41447. /**
  41448. * Updates the global position of the camera by moving the camera's container
  41449. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41450. * @param position The desired global position of the camera
  41451. */
  41452. setPositionOfCameraUsingContainer(position: Vector3): void;
  41453. /**
  41454. * Rotates the xr camera by rotating the camera's container around the camera's position
  41455. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41456. * @param rotation the desired quaternion rotation to apply to the camera
  41457. */
  41458. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41459. /**
  41460. * Disposes of the experience helper
  41461. */
  41462. dispose(): void;
  41463. }
  41464. }
  41465. declare module BABYLON {
  41466. /**
  41467. * Button which can be used to enter a different mode of XR
  41468. */
  41469. export class WebXREnterExitUIButton {
  41470. /** button element */
  41471. element: HTMLElement;
  41472. /** XR initialization options for the button */
  41473. sessionMode: XRSessionMode;
  41474. /** Reference space type */
  41475. referenceSpaceType: XRReferenceSpaceType;
  41476. /**
  41477. * Creates a WebXREnterExitUIButton
  41478. * @param element button element
  41479. * @param sessionMode XR initialization session mode
  41480. * @param referenceSpaceType the type of reference space to be used
  41481. */
  41482. constructor(
  41483. /** button element */
  41484. element: HTMLElement,
  41485. /** XR initialization options for the button */
  41486. sessionMode: XRSessionMode,
  41487. /** Reference space type */
  41488. referenceSpaceType: XRReferenceSpaceType);
  41489. /**
  41490. * Overwritable function which can be used to update the button's visuals when the state changes
  41491. * @param activeButton the current active button in the UI
  41492. */
  41493. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41494. }
  41495. /**
  41496. * Options to create the webXR UI
  41497. */
  41498. export class WebXREnterExitUIOptions {
  41499. /**
  41500. * Context to enter xr with
  41501. */
  41502. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41503. /**
  41504. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41505. */
  41506. customButtons?: Array<WebXREnterExitUIButton>;
  41507. }
  41508. /**
  41509. * UI to allow the user to enter/exit XR mode
  41510. */
  41511. export class WebXREnterExitUI implements IDisposable {
  41512. private scene;
  41513. private _overlay;
  41514. private _buttons;
  41515. private _activeButton;
  41516. /**
  41517. * Fired every time the active button is changed.
  41518. *
  41519. * When xr is entered via a button that launches xr that button will be the callback parameter
  41520. *
  41521. * When exiting xr the callback parameter will be null)
  41522. */
  41523. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41524. /**
  41525. * Creates UI to allow the user to enter/exit XR mode
  41526. * @param scene the scene to add the ui to
  41527. * @param helper the xr experience helper to enter/exit xr with
  41528. * @param options options to configure the UI
  41529. * @returns the created ui
  41530. */
  41531. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41532. private constructor();
  41533. private _updateButtons;
  41534. /**
  41535. * Disposes of the object
  41536. */
  41537. dispose(): void;
  41538. }
  41539. }
  41540. declare module BABYLON {
  41541. /**
  41542. * Represents an XR input
  41543. */
  41544. export class WebXRController {
  41545. private scene;
  41546. /** The underlying input source for the controller */
  41547. inputSource: XRInputSource;
  41548. private parentContainer;
  41549. /**
  41550. * 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
  41551. */
  41552. grip?: AbstractMesh;
  41553. /**
  41554. * Pointer which can be used to select objects or attach a visible laser to
  41555. */
  41556. pointer: AbstractMesh;
  41557. /**
  41558. * Event that fires when the controller is removed/disposed
  41559. */
  41560. onDisposeObservable: Observable<{}>;
  41561. private _tmpMatrix;
  41562. private _tmpQuaternion;
  41563. private _tmpVector;
  41564. /**
  41565. * Creates the controller
  41566. * @see https://doc.babylonjs.com/how_to/webxr
  41567. * @param scene the scene which the controller should be associated to
  41568. * @param inputSource the underlying input source for the controller
  41569. * @param parentContainer parent that the controller meshes should be children of
  41570. */
  41571. constructor(scene: Scene,
  41572. /** The underlying input source for the controller */
  41573. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41574. /**
  41575. * Updates the controller pose based on the given XRFrame
  41576. * @param xrFrame xr frame to update the pose with
  41577. * @param referenceSpace reference space to use
  41578. */
  41579. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41580. /**
  41581. * Gets a world space ray coming from the controller
  41582. * @param result the resulting ray
  41583. */
  41584. getWorldPointerRayToRef(result: Ray): void;
  41585. /**
  41586. * Disposes of the object
  41587. */
  41588. dispose(): void;
  41589. }
  41590. }
  41591. declare module BABYLON {
  41592. /**
  41593. * XR input used to track XR inputs such as controllers/rays
  41594. */
  41595. export class WebXRInput implements IDisposable {
  41596. /**
  41597. * Base experience the input listens to
  41598. */
  41599. baseExperience: WebXRExperienceHelper;
  41600. /**
  41601. * XR controllers being tracked
  41602. */
  41603. controllers: Array<WebXRController>;
  41604. private _frameObserver;
  41605. private _stateObserver;
  41606. /**
  41607. * Event when a controller has been connected/added
  41608. */
  41609. onControllerAddedObservable: Observable<WebXRController>;
  41610. /**
  41611. * Event when a controller has been removed/disconnected
  41612. */
  41613. onControllerRemovedObservable: Observable<WebXRController>;
  41614. /**
  41615. * Initializes the WebXRInput
  41616. * @param baseExperience experience helper which the input should be created for
  41617. */
  41618. constructor(
  41619. /**
  41620. * Base experience the input listens to
  41621. */
  41622. baseExperience: WebXRExperienceHelper);
  41623. private _onInputSourcesChange;
  41624. private _addAndRemoveControllers;
  41625. /**
  41626. * Disposes of the object
  41627. */
  41628. dispose(): void;
  41629. }
  41630. }
  41631. declare module BABYLON {
  41632. /**
  41633. * Enables teleportation
  41634. */
  41635. export class WebXRControllerTeleportation {
  41636. private _teleportationFillColor;
  41637. private _teleportationBorderColor;
  41638. private _tmpRay;
  41639. private _tmpVector;
  41640. /**
  41641. * Creates a WebXRControllerTeleportation
  41642. * @param input input manager to add teleportation to
  41643. * @param floorMeshes floormeshes which can be teleported to
  41644. */
  41645. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41646. }
  41647. }
  41648. declare module BABYLON {
  41649. /**
  41650. * Handles pointer input automatically for the pointer of XR controllers
  41651. */
  41652. export class WebXRControllerPointerSelection {
  41653. private static _idCounter;
  41654. private _tmpRay;
  41655. /**
  41656. * Creates a WebXRControllerPointerSelection
  41657. * @param input input manager to setup pointer selection
  41658. */
  41659. constructor(input: WebXRInput);
  41660. private _convertNormalToDirectionOfRay;
  41661. private _updatePointerDistance;
  41662. }
  41663. }
  41664. declare module BABYLON {
  41665. /**
  41666. * Class used to represent data loading progression
  41667. */
  41668. export class SceneLoaderProgressEvent {
  41669. /** defines if data length to load can be evaluated */
  41670. readonly lengthComputable: boolean;
  41671. /** defines the loaded data length */
  41672. readonly loaded: number;
  41673. /** defines the data length to load */
  41674. readonly total: number;
  41675. /**
  41676. * Create a new progress event
  41677. * @param lengthComputable defines if data length to load can be evaluated
  41678. * @param loaded defines the loaded data length
  41679. * @param total defines the data length to load
  41680. */
  41681. constructor(
  41682. /** defines if data length to load can be evaluated */
  41683. lengthComputable: boolean,
  41684. /** defines the loaded data length */
  41685. loaded: number,
  41686. /** defines the data length to load */
  41687. total: number);
  41688. /**
  41689. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41690. * @param event defines the source event
  41691. * @returns a new SceneLoaderProgressEvent
  41692. */
  41693. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41694. }
  41695. /**
  41696. * Interface used by SceneLoader plugins to define supported file extensions
  41697. */
  41698. export interface ISceneLoaderPluginExtensions {
  41699. /**
  41700. * Defines the list of supported extensions
  41701. */
  41702. [extension: string]: {
  41703. isBinary: boolean;
  41704. };
  41705. }
  41706. /**
  41707. * Interface used by SceneLoader plugin factory
  41708. */
  41709. export interface ISceneLoaderPluginFactory {
  41710. /**
  41711. * Defines the name of the factory
  41712. */
  41713. name: string;
  41714. /**
  41715. * Function called to create a new plugin
  41716. * @return the new plugin
  41717. */
  41718. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41719. /**
  41720. * Boolean indicating if the plugin can direct load specific data
  41721. */
  41722. canDirectLoad?: (data: string) => boolean;
  41723. }
  41724. /**
  41725. * Interface used to define a SceneLoader plugin
  41726. */
  41727. export interface ISceneLoaderPlugin {
  41728. /**
  41729. * The friendly name of this plugin.
  41730. */
  41731. name: string;
  41732. /**
  41733. * The file extensions supported by this plugin.
  41734. */
  41735. extensions: string | ISceneLoaderPluginExtensions;
  41736. /**
  41737. * Import meshes into a scene.
  41738. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41739. * @param scene The scene to import into
  41740. * @param data The data to import
  41741. * @param rootUrl The root url for scene and resources
  41742. * @param meshes The meshes array to import into
  41743. * @param particleSystems The particle systems array to import into
  41744. * @param skeletons The skeletons array to import into
  41745. * @param onError The callback when import fails
  41746. * @returns True if successful or false otherwise
  41747. */
  41748. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41749. /**
  41750. * Load into a scene.
  41751. * @param scene The scene to load into
  41752. * @param data The data to import
  41753. * @param rootUrl The root url for scene and resources
  41754. * @param onError The callback when import fails
  41755. * @returns true if successful or false otherwise
  41756. */
  41757. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41758. /**
  41759. * The callback that returns true if the data can be directly loaded.
  41760. */
  41761. canDirectLoad?: (data: string) => boolean;
  41762. /**
  41763. * The callback that allows custom handling of the root url based on the response url.
  41764. */
  41765. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41766. /**
  41767. * Load into an asset container.
  41768. * @param scene The scene to load into
  41769. * @param data The data to import
  41770. * @param rootUrl The root url for scene and resources
  41771. * @param onError The callback when import fails
  41772. * @returns The loaded asset container
  41773. */
  41774. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41775. }
  41776. /**
  41777. * Interface used to define an async SceneLoader plugin
  41778. */
  41779. export interface ISceneLoaderPluginAsync {
  41780. /**
  41781. * The friendly name of this plugin.
  41782. */
  41783. name: string;
  41784. /**
  41785. * The file extensions supported by this plugin.
  41786. */
  41787. extensions: string | ISceneLoaderPluginExtensions;
  41788. /**
  41789. * Import meshes into a scene.
  41790. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41791. * @param scene The scene to import into
  41792. * @param data The data to import
  41793. * @param rootUrl The root url for scene and resources
  41794. * @param onProgress The callback when the load progresses
  41795. * @param fileName Defines the name of the file to load
  41796. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41797. */
  41798. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41799. meshes: AbstractMesh[];
  41800. particleSystems: IParticleSystem[];
  41801. skeletons: Skeleton[];
  41802. animationGroups: AnimationGroup[];
  41803. }>;
  41804. /**
  41805. * Load into a scene.
  41806. * @param scene The scene to load into
  41807. * @param data The data to import
  41808. * @param rootUrl The root url for scene and resources
  41809. * @param onProgress The callback when the load progresses
  41810. * @param fileName Defines the name of the file to load
  41811. * @returns Nothing
  41812. */
  41813. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41814. /**
  41815. * The callback that returns true if the data can be directly loaded.
  41816. */
  41817. canDirectLoad?: (data: string) => boolean;
  41818. /**
  41819. * The callback that allows custom handling of the root url based on the response url.
  41820. */
  41821. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41822. /**
  41823. * Load into an asset container.
  41824. * @param scene The scene to load into
  41825. * @param data The data to import
  41826. * @param rootUrl The root url for scene and resources
  41827. * @param onProgress The callback when the load progresses
  41828. * @param fileName Defines the name of the file to load
  41829. * @returns The loaded asset container
  41830. */
  41831. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41832. }
  41833. /**
  41834. * Class used to load scene from various file formats using registered plugins
  41835. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41836. */
  41837. export class SceneLoader {
  41838. /**
  41839. * No logging while loading
  41840. */
  41841. static readonly NO_LOGGING: number;
  41842. /**
  41843. * Minimal logging while loading
  41844. */
  41845. static readonly MINIMAL_LOGGING: number;
  41846. /**
  41847. * Summary logging while loading
  41848. */
  41849. static readonly SUMMARY_LOGGING: number;
  41850. /**
  41851. * Detailled logging while loading
  41852. */
  41853. static readonly DETAILED_LOGGING: number;
  41854. /**
  41855. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41856. */
  41857. static ForceFullSceneLoadingForIncremental: boolean;
  41858. /**
  41859. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41860. */
  41861. static ShowLoadingScreen: boolean;
  41862. /**
  41863. * Defines the current logging level (while loading the scene)
  41864. * @ignorenaming
  41865. */
  41866. static loggingLevel: number;
  41867. /**
  41868. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41869. */
  41870. static CleanBoneMatrixWeights: boolean;
  41871. /**
  41872. * Event raised when a plugin is used to load a scene
  41873. */
  41874. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41875. private static _registeredPlugins;
  41876. private static _getDefaultPlugin;
  41877. private static _getPluginForExtension;
  41878. private static _getPluginForDirectLoad;
  41879. private static _getPluginForFilename;
  41880. private static _getDirectLoad;
  41881. private static _loadData;
  41882. private static _getFileInfo;
  41883. /**
  41884. * Gets a plugin that can load the given extension
  41885. * @param extension defines the extension to load
  41886. * @returns a plugin or null if none works
  41887. */
  41888. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41889. /**
  41890. * Gets a boolean indicating that the given extension can be loaded
  41891. * @param extension defines the extension to load
  41892. * @returns true if the extension is supported
  41893. */
  41894. static IsPluginForExtensionAvailable(extension: string): boolean;
  41895. /**
  41896. * Adds a new plugin to the list of registered plugins
  41897. * @param plugin defines the plugin to add
  41898. */
  41899. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41900. /**
  41901. * Import meshes into a scene
  41902. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41903. * @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)
  41904. * @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)
  41905. * @param scene the instance of BABYLON.Scene to append to
  41906. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41907. * @param onProgress a callback with a progress event for each file being loaded
  41908. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41909. * @param pluginExtension the extension used to determine the plugin
  41910. * @returns The loaded plugin
  41911. */
  41912. 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>;
  41913. /**
  41914. * Import meshes into a scene
  41915. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41916. * @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)
  41917. * @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)
  41918. * @param scene the instance of BABYLON.Scene to append to
  41919. * @param onProgress a callback with a progress event for each file being loaded
  41920. * @param pluginExtension the extension used to determine the plugin
  41921. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41922. */
  41923. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41924. meshes: AbstractMesh[];
  41925. particleSystems: IParticleSystem[];
  41926. skeletons: Skeleton[];
  41927. animationGroups: AnimationGroup[];
  41928. }>;
  41929. /**
  41930. * Load a scene
  41931. * @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)
  41932. * @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)
  41933. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41934. * @param onSuccess a callback with the scene when import succeeds
  41935. * @param onProgress a callback with a progress event for each file being loaded
  41936. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41937. * @param pluginExtension the extension used to determine the plugin
  41938. * @returns The loaded plugin
  41939. */
  41940. 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>;
  41941. /**
  41942. * Load a scene
  41943. * @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)
  41944. * @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)
  41945. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41946. * @param onProgress a callback with a progress event for each file being loaded
  41947. * @param pluginExtension the extension used to determine the plugin
  41948. * @returns The loaded scene
  41949. */
  41950. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41951. /**
  41952. * Append a scene
  41953. * @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)
  41954. * @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)
  41955. * @param scene is the instance of BABYLON.Scene to append to
  41956. * @param onSuccess a callback with the scene when import succeeds
  41957. * @param onProgress a callback with a progress event for each file being loaded
  41958. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41959. * @param pluginExtension the extension used to determine the plugin
  41960. * @returns The loaded plugin
  41961. */
  41962. 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>;
  41963. /**
  41964. * Append a scene
  41965. * @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)
  41966. * @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)
  41967. * @param scene is the instance of BABYLON.Scene to append to
  41968. * @param onProgress a callback with a progress event for each file being loaded
  41969. * @param pluginExtension the extension used to determine the plugin
  41970. * @returns The given scene
  41971. */
  41972. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41973. /**
  41974. * Load a scene into an asset container
  41975. * @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)
  41976. * @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)
  41977. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41978. * @param onSuccess a callback with the scene when import succeeds
  41979. * @param onProgress a callback with a progress event for each file being loaded
  41980. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41981. * @param pluginExtension the extension used to determine the plugin
  41982. * @returns The loaded plugin
  41983. */
  41984. 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>;
  41985. /**
  41986. * Load a scene into an asset container
  41987. * @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)
  41988. * @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)
  41989. * @param scene is the instance of Scene to append to
  41990. * @param onProgress a callback with a progress event for each file being loaded
  41991. * @param pluginExtension the extension used to determine the plugin
  41992. * @returns The loaded asset container
  41993. */
  41994. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41995. }
  41996. }
  41997. declare module BABYLON {
  41998. /**
  41999. * Generic Controller
  42000. */
  42001. export class GenericController extends WebVRController {
  42002. /**
  42003. * Base Url for the controller model.
  42004. */
  42005. static readonly MODEL_BASE_URL: string;
  42006. /**
  42007. * File name for the controller model.
  42008. */
  42009. static readonly MODEL_FILENAME: string;
  42010. /**
  42011. * Creates a new GenericController from a gamepad
  42012. * @param vrGamepad the gamepad that the controller should be created from
  42013. */
  42014. constructor(vrGamepad: any);
  42015. /**
  42016. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42017. * @param scene scene in which to add meshes
  42018. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42019. */
  42020. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42021. /**
  42022. * Called once for each button that changed state since the last frame
  42023. * @param buttonIdx Which button index changed
  42024. * @param state New state of the button
  42025. * @param changes Which properties on the state changed since last frame
  42026. */
  42027. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42028. }
  42029. }
  42030. declare module BABYLON {
  42031. /**
  42032. * Defines the WindowsMotionController object that the state of the windows motion controller
  42033. */
  42034. export class WindowsMotionController extends WebVRController {
  42035. /**
  42036. * The base url used to load the left and right controller models
  42037. */
  42038. static MODEL_BASE_URL: string;
  42039. /**
  42040. * The name of the left controller model file
  42041. */
  42042. static MODEL_LEFT_FILENAME: string;
  42043. /**
  42044. * The name of the right controller model file
  42045. */
  42046. static MODEL_RIGHT_FILENAME: string;
  42047. /**
  42048. * The controller name prefix for this controller type
  42049. */
  42050. static readonly GAMEPAD_ID_PREFIX: string;
  42051. /**
  42052. * The controller id pattern for this controller type
  42053. */
  42054. private static readonly GAMEPAD_ID_PATTERN;
  42055. private _loadedMeshInfo;
  42056. private readonly _mapping;
  42057. /**
  42058. * Fired when the trackpad on this controller is clicked
  42059. */
  42060. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42061. /**
  42062. * Fired when the trackpad on this controller is modified
  42063. */
  42064. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42065. /**
  42066. * The current x and y values of this controller's trackpad
  42067. */
  42068. trackpad: StickValues;
  42069. /**
  42070. * Creates a new WindowsMotionController from a gamepad
  42071. * @param vrGamepad the gamepad that the controller should be created from
  42072. */
  42073. constructor(vrGamepad: any);
  42074. /**
  42075. * Fired when the trigger on this controller is modified
  42076. */
  42077. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42078. /**
  42079. * Fired when the menu button on this controller is modified
  42080. */
  42081. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42082. /**
  42083. * Fired when the grip button on this controller is modified
  42084. */
  42085. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42086. /**
  42087. * Fired when the thumbstick button on this controller is modified
  42088. */
  42089. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42090. /**
  42091. * Fired when the touchpad button on this controller is modified
  42092. */
  42093. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42094. /**
  42095. * Fired when the touchpad values on this controller are modified
  42096. */
  42097. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42098. private _updateTrackpad;
  42099. /**
  42100. * Called once per frame by the engine.
  42101. */
  42102. update(): void;
  42103. /**
  42104. * Called once for each button that changed state since the last frame
  42105. * @param buttonIdx Which button index changed
  42106. * @param state New state of the button
  42107. * @param changes Which properties on the state changed since last frame
  42108. */
  42109. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42110. /**
  42111. * Moves the buttons on the controller mesh based on their current state
  42112. * @param buttonName the name of the button to move
  42113. * @param buttonValue the value of the button which determines the buttons new position
  42114. */
  42115. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42116. /**
  42117. * Moves the axis on the controller mesh based on its current state
  42118. * @param axis the index of the axis
  42119. * @param axisValue the value of the axis which determines the meshes new position
  42120. * @hidden
  42121. */
  42122. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42123. /**
  42124. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42125. * @param scene scene in which to add meshes
  42126. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42127. */
  42128. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42129. /**
  42130. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42131. * can be transformed by button presses and axes values, based on this._mapping.
  42132. *
  42133. * @param scene scene in which the meshes exist
  42134. * @param meshes list of meshes that make up the controller model to process
  42135. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42136. */
  42137. private processModel;
  42138. private createMeshInfo;
  42139. /**
  42140. * Gets the ray of the controller in the direction the controller is pointing
  42141. * @param length the length the resulting ray should be
  42142. * @returns a ray in the direction the controller is pointing
  42143. */
  42144. getForwardRay(length?: number): Ray;
  42145. /**
  42146. * Disposes of the controller
  42147. */
  42148. dispose(): void;
  42149. }
  42150. }
  42151. declare module BABYLON {
  42152. /**
  42153. * Oculus Touch Controller
  42154. */
  42155. export class OculusTouchController extends WebVRController {
  42156. /**
  42157. * Base Url for the controller model.
  42158. */
  42159. static MODEL_BASE_URL: string;
  42160. /**
  42161. * File name for the left controller model.
  42162. */
  42163. static MODEL_LEFT_FILENAME: string;
  42164. /**
  42165. * File name for the right controller model.
  42166. */
  42167. static MODEL_RIGHT_FILENAME: string;
  42168. /**
  42169. * Base Url for the Quest controller model.
  42170. */
  42171. static QUEST_MODEL_BASE_URL: string;
  42172. /**
  42173. * @hidden
  42174. * If the controllers are running on a device that needs the updated Quest controller models
  42175. */
  42176. static _IsQuest: boolean;
  42177. /**
  42178. * Fired when the secondary trigger on this controller is modified
  42179. */
  42180. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42181. /**
  42182. * Fired when the thumb rest on this controller is modified
  42183. */
  42184. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42185. /**
  42186. * Creates a new OculusTouchController from a gamepad
  42187. * @param vrGamepad the gamepad that the controller should be created from
  42188. */
  42189. constructor(vrGamepad: any);
  42190. /**
  42191. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42192. * @param scene scene in which to add meshes
  42193. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42194. */
  42195. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42196. /**
  42197. * Fired when the A button on this controller is modified
  42198. */
  42199. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42200. /**
  42201. * Fired when the B button on this controller is modified
  42202. */
  42203. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42204. /**
  42205. * Fired when the X button on this controller is modified
  42206. */
  42207. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42208. /**
  42209. * Fired when the Y button on this controller is modified
  42210. */
  42211. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42212. /**
  42213. * Called once for each button that changed state since the last frame
  42214. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42215. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42216. * 2) secondary trigger (same)
  42217. * 3) A (right) X (left), touch, pressed = value
  42218. * 4) B / Y
  42219. * 5) thumb rest
  42220. * @param buttonIdx Which button index changed
  42221. * @param state New state of the button
  42222. * @param changes Which properties on the state changed since last frame
  42223. */
  42224. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42225. }
  42226. }
  42227. declare module BABYLON {
  42228. /**
  42229. * Vive Controller
  42230. */
  42231. export class ViveController extends WebVRController {
  42232. /**
  42233. * Base Url for the controller model.
  42234. */
  42235. static MODEL_BASE_URL: string;
  42236. /**
  42237. * File name for the controller model.
  42238. */
  42239. static MODEL_FILENAME: string;
  42240. /**
  42241. * Creates a new ViveController from a gamepad
  42242. * @param vrGamepad the gamepad that the controller should be created from
  42243. */
  42244. constructor(vrGamepad: any);
  42245. /**
  42246. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42247. * @param scene scene in which to add meshes
  42248. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42249. */
  42250. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42251. /**
  42252. * Fired when the left button on this controller is modified
  42253. */
  42254. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42255. /**
  42256. * Fired when the right button on this controller is modified
  42257. */
  42258. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42259. /**
  42260. * Fired when the menu button on this controller is modified
  42261. */
  42262. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42263. /**
  42264. * Called once for each button that changed state since the last frame
  42265. * Vive mapping:
  42266. * 0: touchpad
  42267. * 1: trigger
  42268. * 2: left AND right buttons
  42269. * 3: menu button
  42270. * @param buttonIdx Which button index changed
  42271. * @param state New state of the button
  42272. * @param changes Which properties on the state changed since last frame
  42273. */
  42274. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42275. }
  42276. }
  42277. declare module BABYLON {
  42278. /**
  42279. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42280. */
  42281. export class WebXRControllerModelLoader {
  42282. /**
  42283. * Creates the WebXRControllerModelLoader
  42284. * @param input xr input that creates the controllers
  42285. */
  42286. constructor(input: WebXRInput);
  42287. }
  42288. }
  42289. declare module BABYLON {
  42290. /**
  42291. * Contains an array of blocks representing the octree
  42292. */
  42293. export interface IOctreeContainer<T> {
  42294. /**
  42295. * Blocks within the octree
  42296. */
  42297. blocks: Array<OctreeBlock<T>>;
  42298. }
  42299. /**
  42300. * Class used to store a cell in an octree
  42301. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42302. */
  42303. export class OctreeBlock<T> {
  42304. /**
  42305. * Gets the content of the current block
  42306. */
  42307. entries: T[];
  42308. /**
  42309. * Gets the list of block children
  42310. */
  42311. blocks: Array<OctreeBlock<T>>;
  42312. private _depth;
  42313. private _maxDepth;
  42314. private _capacity;
  42315. private _minPoint;
  42316. private _maxPoint;
  42317. private _boundingVectors;
  42318. private _creationFunc;
  42319. /**
  42320. * Creates a new block
  42321. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42322. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42323. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42324. * @param depth defines the current depth of this block in the octree
  42325. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42326. * @param creationFunc defines a callback to call when an element is added to the block
  42327. */
  42328. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42329. /**
  42330. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42331. */
  42332. readonly capacity: number;
  42333. /**
  42334. * Gets the minimum vector (in world space) of the block's bounding box
  42335. */
  42336. readonly minPoint: Vector3;
  42337. /**
  42338. * Gets the maximum vector (in world space) of the block's bounding box
  42339. */
  42340. readonly maxPoint: Vector3;
  42341. /**
  42342. * Add a new element to this block
  42343. * @param entry defines the element to add
  42344. */
  42345. addEntry(entry: T): void;
  42346. /**
  42347. * Remove an element from this block
  42348. * @param entry defines the element to remove
  42349. */
  42350. removeEntry(entry: T): void;
  42351. /**
  42352. * Add an array of elements to this block
  42353. * @param entries defines the array of elements to add
  42354. */
  42355. addEntries(entries: T[]): void;
  42356. /**
  42357. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42358. * @param frustumPlanes defines the frustum planes to test
  42359. * @param selection defines the array to store current content if selection is positive
  42360. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42361. */
  42362. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42363. /**
  42364. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42365. * @param sphereCenter defines the bounding sphere center
  42366. * @param sphereRadius defines the bounding sphere radius
  42367. * @param selection defines the array to store current content if selection is positive
  42368. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42369. */
  42370. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42371. /**
  42372. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42373. * @param ray defines the ray to test with
  42374. * @param selection defines the array to store current content if selection is positive
  42375. */
  42376. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42377. /**
  42378. * Subdivide the content into child blocks (this block will then be empty)
  42379. */
  42380. createInnerBlocks(): void;
  42381. /**
  42382. * @hidden
  42383. */
  42384. 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;
  42385. }
  42386. }
  42387. declare module BABYLON {
  42388. /**
  42389. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42390. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42391. */
  42392. export class Octree<T> {
  42393. /** 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.) */
  42394. maxDepth: number;
  42395. /**
  42396. * Blocks within the octree containing objects
  42397. */
  42398. blocks: Array<OctreeBlock<T>>;
  42399. /**
  42400. * Content stored in the octree
  42401. */
  42402. dynamicContent: T[];
  42403. private _maxBlockCapacity;
  42404. private _selectionContent;
  42405. private _creationFunc;
  42406. /**
  42407. * Creates a octree
  42408. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42409. * @param creationFunc function to be used to instatiate the octree
  42410. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42411. * @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.)
  42412. */
  42413. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42414. /** 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.) */
  42415. maxDepth?: number);
  42416. /**
  42417. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42418. * @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);
  42419. * @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);
  42420. * @param entries meshes to be added to the octree blocks
  42421. */
  42422. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42423. /**
  42424. * Adds a mesh to the octree
  42425. * @param entry Mesh to add to the octree
  42426. */
  42427. addMesh(entry: T): void;
  42428. /**
  42429. * Remove an element from the octree
  42430. * @param entry defines the element to remove
  42431. */
  42432. removeMesh(entry: T): void;
  42433. /**
  42434. * Selects an array of meshes within the frustum
  42435. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42436. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42437. * @returns array of meshes within the frustum
  42438. */
  42439. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42440. /**
  42441. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42442. * @param sphereCenter defines the bounding sphere center
  42443. * @param sphereRadius defines the bounding sphere radius
  42444. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42445. * @returns an array of objects that intersect the sphere
  42446. */
  42447. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42448. /**
  42449. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42450. * @param ray defines the ray to test with
  42451. * @returns array of intersected objects
  42452. */
  42453. intersectsRay(ray: Ray): SmartArray<T>;
  42454. /**
  42455. * Adds a mesh into the octree block if it intersects the block
  42456. */
  42457. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42458. /**
  42459. * Adds a submesh into the octree block if it intersects the block
  42460. */
  42461. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42462. }
  42463. }
  42464. declare module BABYLON {
  42465. interface Scene {
  42466. /**
  42467. * @hidden
  42468. * Backing Filed
  42469. */
  42470. _selectionOctree: Octree<AbstractMesh>;
  42471. /**
  42472. * Gets the octree used to boost mesh selection (picking)
  42473. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42474. */
  42475. selectionOctree: Octree<AbstractMesh>;
  42476. /**
  42477. * Creates or updates the octree used to boost selection (picking)
  42478. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42479. * @param maxCapacity defines the maximum capacity per leaf
  42480. * @param maxDepth defines the maximum depth of the octree
  42481. * @returns an octree of AbstractMesh
  42482. */
  42483. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42484. }
  42485. interface AbstractMesh {
  42486. /**
  42487. * @hidden
  42488. * Backing Field
  42489. */
  42490. _submeshesOctree: Octree<SubMesh>;
  42491. /**
  42492. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42493. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42494. * @param maxCapacity defines the maximum size of each block (64 by default)
  42495. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42496. * @returns the new octree
  42497. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42498. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42499. */
  42500. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42501. }
  42502. /**
  42503. * Defines the octree scene component responsible to manage any octrees
  42504. * in a given scene.
  42505. */
  42506. export class OctreeSceneComponent {
  42507. /**
  42508. * The component name help to identify the component in the list of scene components.
  42509. */
  42510. readonly name: string;
  42511. /**
  42512. * The scene the component belongs to.
  42513. */
  42514. scene: Scene;
  42515. /**
  42516. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42517. */
  42518. readonly checksIsEnabled: boolean;
  42519. /**
  42520. * Creates a new instance of the component for the given scene
  42521. * @param scene Defines the scene to register the component in
  42522. */
  42523. constructor(scene: Scene);
  42524. /**
  42525. * Registers the component in a given scene
  42526. */
  42527. register(): void;
  42528. /**
  42529. * Return the list of active meshes
  42530. * @returns the list of active meshes
  42531. */
  42532. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42533. /**
  42534. * Return the list of active sub meshes
  42535. * @param mesh The mesh to get the candidates sub meshes from
  42536. * @returns the list of active sub meshes
  42537. */
  42538. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42539. private _tempRay;
  42540. /**
  42541. * Return the list of sub meshes intersecting with a given local ray
  42542. * @param mesh defines the mesh to find the submesh for
  42543. * @param localRay defines the ray in local space
  42544. * @returns the list of intersecting sub meshes
  42545. */
  42546. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42547. /**
  42548. * Return the list of sub meshes colliding with a collider
  42549. * @param mesh defines the mesh to find the submesh for
  42550. * @param collider defines the collider to evaluate the collision against
  42551. * @returns the list of colliding sub meshes
  42552. */
  42553. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42554. /**
  42555. * Rebuilds the elements related to this component in case of
  42556. * context lost for instance.
  42557. */
  42558. rebuild(): void;
  42559. /**
  42560. * Disposes the component and the associated ressources.
  42561. */
  42562. dispose(): void;
  42563. }
  42564. }
  42565. declare module BABYLON {
  42566. /**
  42567. * Renders a layer on top of an existing scene
  42568. */
  42569. export class UtilityLayerRenderer implements IDisposable {
  42570. /** the original scene that will be rendered on top of */
  42571. originalScene: Scene;
  42572. private _pointerCaptures;
  42573. private _lastPointerEvents;
  42574. private static _DefaultUtilityLayer;
  42575. private static _DefaultKeepDepthUtilityLayer;
  42576. private _sharedGizmoLight;
  42577. private _renderCamera;
  42578. /**
  42579. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42580. * @returns the camera that is used when rendering the utility layer
  42581. */
  42582. getRenderCamera(): Nullable<Camera>;
  42583. /**
  42584. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42585. * @param cam the camera that should be used when rendering the utility layer
  42586. */
  42587. setRenderCamera(cam: Nullable<Camera>): void;
  42588. /**
  42589. * @hidden
  42590. * Light which used by gizmos to get light shading
  42591. */
  42592. _getSharedGizmoLight(): HemisphericLight;
  42593. /**
  42594. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42595. */
  42596. pickUtilitySceneFirst: boolean;
  42597. /**
  42598. * 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)
  42599. */
  42600. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42601. /**
  42602. * 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)
  42603. */
  42604. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42605. /**
  42606. * The scene that is rendered on top of the original scene
  42607. */
  42608. utilityLayerScene: Scene;
  42609. /**
  42610. * If the utility layer should automatically be rendered on top of existing scene
  42611. */
  42612. shouldRender: boolean;
  42613. /**
  42614. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42615. */
  42616. onlyCheckPointerDownEvents: boolean;
  42617. /**
  42618. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42619. */
  42620. processAllEvents: boolean;
  42621. /**
  42622. * Observable raised when the pointer move from the utility layer scene to the main scene
  42623. */
  42624. onPointerOutObservable: Observable<number>;
  42625. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42626. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42627. private _afterRenderObserver;
  42628. private _sceneDisposeObserver;
  42629. private _originalPointerObserver;
  42630. /**
  42631. * Instantiates a UtilityLayerRenderer
  42632. * @param originalScene the original scene that will be rendered on top of
  42633. * @param handleEvents boolean indicating if the utility layer should handle events
  42634. */
  42635. constructor(
  42636. /** the original scene that will be rendered on top of */
  42637. originalScene: Scene, handleEvents?: boolean);
  42638. private _notifyObservers;
  42639. /**
  42640. * Renders the utility layers scene on top of the original scene
  42641. */
  42642. render(): void;
  42643. /**
  42644. * Disposes of the renderer
  42645. */
  42646. dispose(): void;
  42647. private _updateCamera;
  42648. }
  42649. }
  42650. declare module BABYLON {
  42651. /**
  42652. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42653. */
  42654. export class Gizmo implements IDisposable {
  42655. /** The utility layer the gizmo will be added to */
  42656. gizmoLayer: UtilityLayerRenderer;
  42657. /**
  42658. * The root mesh of the gizmo
  42659. */
  42660. _rootMesh: Mesh;
  42661. private _attachedMesh;
  42662. /**
  42663. * Ratio for the scale of the gizmo (Default: 1)
  42664. */
  42665. scaleRatio: number;
  42666. /**
  42667. * If a custom mesh has been set (Default: false)
  42668. */
  42669. protected _customMeshSet: boolean;
  42670. /**
  42671. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42672. * * When set, interactions will be enabled
  42673. */
  42674. attachedMesh: Nullable<AbstractMesh>;
  42675. /**
  42676. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42677. * @param mesh The mesh to replace the default mesh of the gizmo
  42678. */
  42679. setCustomMesh(mesh: Mesh): void;
  42680. /**
  42681. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42682. */
  42683. updateGizmoRotationToMatchAttachedMesh: boolean;
  42684. /**
  42685. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42686. */
  42687. updateGizmoPositionToMatchAttachedMesh: boolean;
  42688. /**
  42689. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42690. */
  42691. updateScale: boolean;
  42692. protected _interactionsEnabled: boolean;
  42693. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42694. private _beforeRenderObserver;
  42695. private _tempVector;
  42696. /**
  42697. * Creates a gizmo
  42698. * @param gizmoLayer The utility layer the gizmo will be added to
  42699. */
  42700. constructor(
  42701. /** The utility layer the gizmo will be added to */
  42702. gizmoLayer?: UtilityLayerRenderer);
  42703. /**
  42704. * Updates the gizmo to match the attached mesh's position/rotation
  42705. */
  42706. protected _update(): void;
  42707. /**
  42708. * Disposes of the gizmo
  42709. */
  42710. dispose(): void;
  42711. }
  42712. }
  42713. declare module BABYLON {
  42714. /**
  42715. * Single plane drag gizmo
  42716. */
  42717. export class PlaneDragGizmo extends Gizmo {
  42718. /**
  42719. * Drag behavior responsible for the gizmos dragging interactions
  42720. */
  42721. dragBehavior: PointerDragBehavior;
  42722. private _pointerObserver;
  42723. /**
  42724. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42725. */
  42726. snapDistance: number;
  42727. /**
  42728. * Event that fires each time the gizmo snaps to a new location.
  42729. * * snapDistance is the the change in distance
  42730. */
  42731. onSnapObservable: Observable<{
  42732. snapDistance: number;
  42733. }>;
  42734. private _plane;
  42735. private _coloredMaterial;
  42736. private _hoverMaterial;
  42737. private _isEnabled;
  42738. private _parent;
  42739. /** @hidden */
  42740. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42741. /** @hidden */
  42742. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42743. /**
  42744. * Creates a PlaneDragGizmo
  42745. * @param gizmoLayer The utility layer the gizmo will be added to
  42746. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42747. * @param color The color of the gizmo
  42748. */
  42749. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42750. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42751. /**
  42752. * If the gizmo is enabled
  42753. */
  42754. isEnabled: boolean;
  42755. /**
  42756. * Disposes of the gizmo
  42757. */
  42758. dispose(): void;
  42759. }
  42760. }
  42761. declare module BABYLON {
  42762. /**
  42763. * Gizmo that enables dragging a mesh along 3 axis
  42764. */
  42765. export class PositionGizmo extends Gizmo {
  42766. /**
  42767. * Internal gizmo used for interactions on the x axis
  42768. */
  42769. xGizmo: AxisDragGizmo;
  42770. /**
  42771. * Internal gizmo used for interactions on the y axis
  42772. */
  42773. yGizmo: AxisDragGizmo;
  42774. /**
  42775. * Internal gizmo used for interactions on the z axis
  42776. */
  42777. zGizmo: AxisDragGizmo;
  42778. /**
  42779. * Internal gizmo used for interactions on the yz plane
  42780. */
  42781. xPlaneGizmo: PlaneDragGizmo;
  42782. /**
  42783. * Internal gizmo used for interactions on the xz plane
  42784. */
  42785. yPlaneGizmo: PlaneDragGizmo;
  42786. /**
  42787. * Internal gizmo used for interactions on the xy plane
  42788. */
  42789. zPlaneGizmo: PlaneDragGizmo;
  42790. /**
  42791. * private variables
  42792. */
  42793. private _meshAttached;
  42794. private _updateGizmoRotationToMatchAttachedMesh;
  42795. private _snapDistance;
  42796. private _scaleRatio;
  42797. /** Fires an event when any of it's sub gizmos are dragged */
  42798. onDragStartObservable: Observable<unknown>;
  42799. /** Fires an event when any of it's sub gizmos are released from dragging */
  42800. onDragEndObservable: Observable<unknown>;
  42801. /**
  42802. * If set to true, planar drag is enabled
  42803. */
  42804. private _planarGizmoEnabled;
  42805. attachedMesh: Nullable<AbstractMesh>;
  42806. /**
  42807. * Creates a PositionGizmo
  42808. * @param gizmoLayer The utility layer the gizmo will be added to
  42809. */
  42810. constructor(gizmoLayer?: UtilityLayerRenderer);
  42811. /**
  42812. * If the planar drag gizmo is enabled
  42813. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42814. */
  42815. planarGizmoEnabled: boolean;
  42816. updateGizmoRotationToMatchAttachedMesh: boolean;
  42817. /**
  42818. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42819. */
  42820. snapDistance: number;
  42821. /**
  42822. * Ratio for the scale of the gizmo (Default: 1)
  42823. */
  42824. scaleRatio: number;
  42825. /**
  42826. * Disposes of the gizmo
  42827. */
  42828. dispose(): void;
  42829. /**
  42830. * CustomMeshes are not supported by this gizmo
  42831. * @param mesh The mesh to replace the default mesh of the gizmo
  42832. */
  42833. setCustomMesh(mesh: Mesh): void;
  42834. }
  42835. }
  42836. declare module BABYLON {
  42837. /**
  42838. * Single axis drag gizmo
  42839. */
  42840. export class AxisDragGizmo extends Gizmo {
  42841. /**
  42842. * Drag behavior responsible for the gizmos dragging interactions
  42843. */
  42844. dragBehavior: PointerDragBehavior;
  42845. private _pointerObserver;
  42846. /**
  42847. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42848. */
  42849. snapDistance: number;
  42850. /**
  42851. * Event that fires each time the gizmo snaps to a new location.
  42852. * * snapDistance is the the change in distance
  42853. */
  42854. onSnapObservable: Observable<{
  42855. snapDistance: number;
  42856. }>;
  42857. private _isEnabled;
  42858. private _parent;
  42859. private _arrow;
  42860. private _coloredMaterial;
  42861. private _hoverMaterial;
  42862. /** @hidden */
  42863. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42864. /** @hidden */
  42865. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42866. /**
  42867. * Creates an AxisDragGizmo
  42868. * @param gizmoLayer The utility layer the gizmo will be added to
  42869. * @param dragAxis The axis which the gizmo will be able to drag on
  42870. * @param color The color of the gizmo
  42871. */
  42872. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42873. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42874. /**
  42875. * If the gizmo is enabled
  42876. */
  42877. isEnabled: boolean;
  42878. /**
  42879. * Disposes of the gizmo
  42880. */
  42881. dispose(): void;
  42882. }
  42883. }
  42884. declare module BABYLON.Debug {
  42885. /**
  42886. * The Axes viewer will show 3 axes in a specific point in space
  42887. */
  42888. export class AxesViewer {
  42889. private _xAxis;
  42890. private _yAxis;
  42891. private _zAxis;
  42892. private _scaleLinesFactor;
  42893. private _instanced;
  42894. /**
  42895. * Gets the hosting scene
  42896. */
  42897. scene: Scene;
  42898. /**
  42899. * Gets or sets a number used to scale line length
  42900. */
  42901. scaleLines: number;
  42902. /** Gets the node hierarchy used to render x-axis */
  42903. readonly xAxis: TransformNode;
  42904. /** Gets the node hierarchy used to render y-axis */
  42905. readonly yAxis: TransformNode;
  42906. /** Gets the node hierarchy used to render z-axis */
  42907. readonly zAxis: TransformNode;
  42908. /**
  42909. * Creates a new AxesViewer
  42910. * @param scene defines the hosting scene
  42911. * @param scaleLines defines a number used to scale line length (1 by default)
  42912. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42913. * @param xAxis defines the node hierarchy used to render the x-axis
  42914. * @param yAxis defines the node hierarchy used to render the y-axis
  42915. * @param zAxis defines the node hierarchy used to render the z-axis
  42916. */
  42917. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42918. /**
  42919. * Force the viewer to update
  42920. * @param position defines the position of the viewer
  42921. * @param xaxis defines the x axis of the viewer
  42922. * @param yaxis defines the y axis of the viewer
  42923. * @param zaxis defines the z axis of the viewer
  42924. */
  42925. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42926. /**
  42927. * Creates an instance of this axes viewer.
  42928. * @returns a new axes viewer with instanced meshes
  42929. */
  42930. createInstance(): AxesViewer;
  42931. /** Releases resources */
  42932. dispose(): void;
  42933. private static _SetRenderingGroupId;
  42934. }
  42935. }
  42936. declare module BABYLON.Debug {
  42937. /**
  42938. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42939. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42940. */
  42941. export class BoneAxesViewer extends AxesViewer {
  42942. /**
  42943. * Gets or sets the target mesh where to display the axes viewer
  42944. */
  42945. mesh: Nullable<Mesh>;
  42946. /**
  42947. * Gets or sets the target bone where to display the axes viewer
  42948. */
  42949. bone: Nullable<Bone>;
  42950. /** Gets current position */
  42951. pos: Vector3;
  42952. /** Gets direction of X axis */
  42953. xaxis: Vector3;
  42954. /** Gets direction of Y axis */
  42955. yaxis: Vector3;
  42956. /** Gets direction of Z axis */
  42957. zaxis: Vector3;
  42958. /**
  42959. * Creates a new BoneAxesViewer
  42960. * @param scene defines the hosting scene
  42961. * @param bone defines the target bone
  42962. * @param mesh defines the target mesh
  42963. * @param scaleLines defines a scaling factor for line length (1 by default)
  42964. */
  42965. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42966. /**
  42967. * Force the viewer to update
  42968. */
  42969. update(): void;
  42970. /** Releases resources */
  42971. dispose(): void;
  42972. }
  42973. }
  42974. declare module BABYLON {
  42975. /**
  42976. * Interface used to define scene explorer extensibility option
  42977. */
  42978. export interface IExplorerExtensibilityOption {
  42979. /**
  42980. * Define the option label
  42981. */
  42982. label: string;
  42983. /**
  42984. * Defines the action to execute on click
  42985. */
  42986. action: (entity: any) => void;
  42987. }
  42988. /**
  42989. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42990. */
  42991. export interface IExplorerExtensibilityGroup {
  42992. /**
  42993. * Defines a predicate to test if a given type mut be extended
  42994. */
  42995. predicate: (entity: any) => boolean;
  42996. /**
  42997. * Gets the list of options added to a type
  42998. */
  42999. entries: IExplorerExtensibilityOption[];
  43000. }
  43001. /**
  43002. * Interface used to define the options to use to create the Inspector
  43003. */
  43004. export interface IInspectorOptions {
  43005. /**
  43006. * Display in overlay mode (default: false)
  43007. */
  43008. overlay?: boolean;
  43009. /**
  43010. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43011. */
  43012. globalRoot?: HTMLElement;
  43013. /**
  43014. * Display the Scene explorer
  43015. */
  43016. showExplorer?: boolean;
  43017. /**
  43018. * Display the property inspector
  43019. */
  43020. showInspector?: boolean;
  43021. /**
  43022. * Display in embed mode (both panes on the right)
  43023. */
  43024. embedMode?: boolean;
  43025. /**
  43026. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43027. */
  43028. handleResize?: boolean;
  43029. /**
  43030. * Allow the panes to popup (default: true)
  43031. */
  43032. enablePopup?: boolean;
  43033. /**
  43034. * Allow the panes to be closed by users (default: true)
  43035. */
  43036. enableClose?: boolean;
  43037. /**
  43038. * Optional list of extensibility entries
  43039. */
  43040. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43041. /**
  43042. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43043. */
  43044. inspectorURL?: string;
  43045. }
  43046. interface Scene {
  43047. /**
  43048. * @hidden
  43049. * Backing field
  43050. */
  43051. _debugLayer: DebugLayer;
  43052. /**
  43053. * Gets the debug layer (aka Inspector) associated with the scene
  43054. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43055. */
  43056. debugLayer: DebugLayer;
  43057. }
  43058. /**
  43059. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43060. * what is happening in your scene
  43061. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43062. */
  43063. export class DebugLayer {
  43064. /**
  43065. * Define the url to get the inspector script from.
  43066. * By default it uses the babylonjs CDN.
  43067. * @ignoreNaming
  43068. */
  43069. static InspectorURL: string;
  43070. private _scene;
  43071. private BJSINSPECTOR;
  43072. private _onPropertyChangedObservable?;
  43073. /**
  43074. * Observable triggered when a property is changed through the inspector.
  43075. */
  43076. readonly onPropertyChangedObservable: any;
  43077. /**
  43078. * Instantiates a new debug layer.
  43079. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43080. * what is happening in your scene
  43081. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43082. * @param scene Defines the scene to inspect
  43083. */
  43084. constructor(scene: Scene);
  43085. /** Creates the inspector window. */
  43086. private _createInspector;
  43087. /**
  43088. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43089. * @param entity defines the entity to select
  43090. * @param lineContainerTitle defines the specific block to highlight
  43091. */
  43092. select(entity: any, lineContainerTitle?: string): void;
  43093. /** Get the inspector from bundle or global */
  43094. private _getGlobalInspector;
  43095. /**
  43096. * Get if the inspector is visible or not.
  43097. * @returns true if visible otherwise, false
  43098. */
  43099. isVisible(): boolean;
  43100. /**
  43101. * Hide the inspector and close its window.
  43102. */
  43103. hide(): void;
  43104. /**
  43105. * Launch the debugLayer.
  43106. * @param config Define the configuration of the inspector
  43107. * @return a promise fulfilled when the debug layer is visible
  43108. */
  43109. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43110. }
  43111. }
  43112. declare module BABYLON {
  43113. /**
  43114. * Class containing static functions to help procedurally build meshes
  43115. */
  43116. export class BoxBuilder {
  43117. /**
  43118. * Creates a box mesh
  43119. * * The parameter `size` sets the size (float) of each box side (default 1)
  43120. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43121. * * 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)
  43122. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43124. * * 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
  43125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43126. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43127. * @param name defines the name of the mesh
  43128. * @param options defines the options used to create the mesh
  43129. * @param scene defines the hosting scene
  43130. * @returns the box mesh
  43131. */
  43132. static CreateBox(name: string, options: {
  43133. size?: number;
  43134. width?: number;
  43135. height?: number;
  43136. depth?: number;
  43137. faceUV?: Vector4[];
  43138. faceColors?: Color4[];
  43139. sideOrientation?: number;
  43140. frontUVs?: Vector4;
  43141. backUVs?: Vector4;
  43142. wrap?: boolean;
  43143. topBaseAt?: number;
  43144. bottomBaseAt?: number;
  43145. updatable?: boolean;
  43146. }, scene?: Nullable<Scene>): Mesh;
  43147. }
  43148. }
  43149. declare module BABYLON {
  43150. /**
  43151. * Class containing static functions to help procedurally build meshes
  43152. */
  43153. export class SphereBuilder {
  43154. /**
  43155. * Creates a sphere mesh
  43156. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43157. * * 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`)
  43158. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43159. * * 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
  43160. * * 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)
  43161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43162. * * 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
  43163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43164. * @param name defines the name of the mesh
  43165. * @param options defines the options used to create the mesh
  43166. * @param scene defines the hosting scene
  43167. * @returns the sphere mesh
  43168. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43169. */
  43170. static CreateSphere(name: string, options: {
  43171. segments?: number;
  43172. diameter?: number;
  43173. diameterX?: number;
  43174. diameterY?: number;
  43175. diameterZ?: number;
  43176. arc?: number;
  43177. slice?: number;
  43178. sideOrientation?: number;
  43179. frontUVs?: Vector4;
  43180. backUVs?: Vector4;
  43181. updatable?: boolean;
  43182. }, scene?: Nullable<Scene>): Mesh;
  43183. }
  43184. }
  43185. declare module BABYLON.Debug {
  43186. /**
  43187. * Used to show the physics impostor around the specific mesh
  43188. */
  43189. export class PhysicsViewer {
  43190. /** @hidden */
  43191. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43192. /** @hidden */
  43193. protected _meshes: Array<Nullable<AbstractMesh>>;
  43194. /** @hidden */
  43195. protected _scene: Nullable<Scene>;
  43196. /** @hidden */
  43197. protected _numMeshes: number;
  43198. /** @hidden */
  43199. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43200. private _renderFunction;
  43201. private _utilityLayer;
  43202. private _debugBoxMesh;
  43203. private _debugSphereMesh;
  43204. private _debugCylinderMesh;
  43205. private _debugMaterial;
  43206. private _debugMeshMeshes;
  43207. /**
  43208. * Creates a new PhysicsViewer
  43209. * @param scene defines the hosting scene
  43210. */
  43211. constructor(scene: Scene);
  43212. /** @hidden */
  43213. protected _updateDebugMeshes(): void;
  43214. /**
  43215. * Renders a specified physic impostor
  43216. * @param impostor defines the impostor to render
  43217. * @param targetMesh defines the mesh represented by the impostor
  43218. * @returns the new debug mesh used to render the impostor
  43219. */
  43220. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43221. /**
  43222. * Hides a specified physic impostor
  43223. * @param impostor defines the impostor to hide
  43224. */
  43225. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43226. private _getDebugMaterial;
  43227. private _getDebugBoxMesh;
  43228. private _getDebugSphereMesh;
  43229. private _getDebugCylinderMesh;
  43230. private _getDebugMeshMesh;
  43231. private _getDebugMesh;
  43232. /** Releases all resources */
  43233. dispose(): void;
  43234. }
  43235. }
  43236. declare module BABYLON {
  43237. /**
  43238. * Class containing static functions to help procedurally build meshes
  43239. */
  43240. export class LinesBuilder {
  43241. /**
  43242. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43243. * * 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
  43244. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43245. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43246. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43247. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43248. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43249. * * 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
  43250. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43252. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43253. * @param name defines the name of the new line system
  43254. * @param options defines the options used to create the line system
  43255. * @param scene defines the hosting scene
  43256. * @returns a new line system mesh
  43257. */
  43258. static CreateLineSystem(name: string, options: {
  43259. lines: Vector3[][];
  43260. updatable?: boolean;
  43261. instance?: Nullable<LinesMesh>;
  43262. colors?: Nullable<Color4[][]>;
  43263. useVertexAlpha?: boolean;
  43264. }, scene: Nullable<Scene>): LinesMesh;
  43265. /**
  43266. * Creates a line mesh
  43267. * 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
  43268. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43269. * * The parameter `points` is an array successive Vector3
  43270. * * 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
  43271. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43272. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43273. * * When updating an instance, remember that only point positions can change, not the number of points
  43274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43275. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43276. * @param name defines the name of the new line system
  43277. * @param options defines the options used to create the line system
  43278. * @param scene defines the hosting scene
  43279. * @returns a new line mesh
  43280. */
  43281. static CreateLines(name: string, options: {
  43282. points: Vector3[];
  43283. updatable?: boolean;
  43284. instance?: Nullable<LinesMesh>;
  43285. colors?: Color4[];
  43286. useVertexAlpha?: boolean;
  43287. }, scene?: Nullable<Scene>): LinesMesh;
  43288. /**
  43289. * Creates a dashed line mesh
  43290. * * 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
  43291. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43292. * * The parameter `points` is an array successive Vector3
  43293. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43294. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43295. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43296. * * 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
  43297. * * When updating an instance, remember that only point positions can change, not the number of points
  43298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43299. * @param name defines the name of the mesh
  43300. * @param options defines the options used to create the mesh
  43301. * @param scene defines the hosting scene
  43302. * @returns the dashed line mesh
  43303. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43304. */
  43305. static CreateDashedLines(name: string, options: {
  43306. points: Vector3[];
  43307. dashSize?: number;
  43308. gapSize?: number;
  43309. dashNb?: number;
  43310. updatable?: boolean;
  43311. instance?: LinesMesh;
  43312. }, scene?: Nullable<Scene>): LinesMesh;
  43313. }
  43314. }
  43315. declare module BABYLON {
  43316. /**
  43317. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43318. * in order to better appreciate the issue one might have.
  43319. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43320. */
  43321. export class RayHelper {
  43322. /**
  43323. * Defines the ray we are currently tryin to visualize.
  43324. */
  43325. ray: Nullable<Ray>;
  43326. private _renderPoints;
  43327. private _renderLine;
  43328. private _renderFunction;
  43329. private _scene;
  43330. private _updateToMeshFunction;
  43331. private _attachedToMesh;
  43332. private _meshSpaceDirection;
  43333. private _meshSpaceOrigin;
  43334. /**
  43335. * Helper function to create a colored helper in a scene in one line.
  43336. * @param ray Defines the ray we are currently tryin to visualize
  43337. * @param scene Defines the scene the ray is used in
  43338. * @param color Defines the color we want to see the ray in
  43339. * @returns The newly created ray helper.
  43340. */
  43341. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43342. /**
  43343. * Instantiate a new ray helper.
  43344. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43345. * in order to better appreciate the issue one might have.
  43346. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43347. * @param ray Defines the ray we are currently tryin to visualize
  43348. */
  43349. constructor(ray: Ray);
  43350. /**
  43351. * Shows the ray we are willing to debug.
  43352. * @param scene Defines the scene the ray needs to be rendered in
  43353. * @param color Defines the color the ray needs to be rendered in
  43354. */
  43355. show(scene: Scene, color?: Color3): void;
  43356. /**
  43357. * Hides the ray we are debugging.
  43358. */
  43359. hide(): void;
  43360. private _render;
  43361. /**
  43362. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43363. * @param mesh Defines the mesh we want the helper attached to
  43364. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43365. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43366. * @param length Defines the length of the ray
  43367. */
  43368. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43369. /**
  43370. * Detach the ray helper from the mesh it has previously been attached to.
  43371. */
  43372. detachFromMesh(): void;
  43373. private _updateToMesh;
  43374. /**
  43375. * Dispose the helper and release its associated resources.
  43376. */
  43377. dispose(): void;
  43378. }
  43379. }
  43380. declare module BABYLON.Debug {
  43381. /**
  43382. * Class used to render a debug view of a given skeleton
  43383. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43384. */
  43385. export class SkeletonViewer {
  43386. /** defines the skeleton to render */
  43387. skeleton: Skeleton;
  43388. /** defines the mesh attached to the skeleton */
  43389. mesh: AbstractMesh;
  43390. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43391. autoUpdateBonesMatrices: boolean;
  43392. /** defines the rendering group id to use with the viewer */
  43393. renderingGroupId: number;
  43394. /** Gets or sets the color used to render the skeleton */
  43395. color: Color3;
  43396. private _scene;
  43397. private _debugLines;
  43398. private _debugMesh;
  43399. private _isEnabled;
  43400. private _renderFunction;
  43401. private _utilityLayer;
  43402. /**
  43403. * Returns the mesh used to render the bones
  43404. */
  43405. readonly debugMesh: Nullable<LinesMesh>;
  43406. /**
  43407. * Creates a new SkeletonViewer
  43408. * @param skeleton defines the skeleton to render
  43409. * @param mesh defines the mesh attached to the skeleton
  43410. * @param scene defines the hosting scene
  43411. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43412. * @param renderingGroupId defines the rendering group id to use with the viewer
  43413. */
  43414. constructor(
  43415. /** defines the skeleton to render */
  43416. skeleton: Skeleton,
  43417. /** defines the mesh attached to the skeleton */
  43418. mesh: AbstractMesh, scene: Scene,
  43419. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43420. autoUpdateBonesMatrices?: boolean,
  43421. /** defines the rendering group id to use with the viewer */
  43422. renderingGroupId?: number);
  43423. /** Gets or sets a boolean indicating if the viewer is enabled */
  43424. isEnabled: boolean;
  43425. private _getBonePosition;
  43426. private _getLinesForBonesWithLength;
  43427. private _getLinesForBonesNoLength;
  43428. /** Update the viewer to sync with current skeleton state */
  43429. update(): void;
  43430. /** Release associated resources */
  43431. dispose(): void;
  43432. }
  43433. }
  43434. declare module BABYLON {
  43435. /**
  43436. * Options to create the null engine
  43437. */
  43438. export class NullEngineOptions {
  43439. /**
  43440. * Render width (Default: 512)
  43441. */
  43442. renderWidth: number;
  43443. /**
  43444. * Render height (Default: 256)
  43445. */
  43446. renderHeight: number;
  43447. /**
  43448. * Texture size (Default: 512)
  43449. */
  43450. textureSize: number;
  43451. /**
  43452. * If delta time between frames should be constant
  43453. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43454. */
  43455. deterministicLockstep: boolean;
  43456. /**
  43457. * Maximum about of steps between frames (Default: 4)
  43458. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43459. */
  43460. lockstepMaxSteps: number;
  43461. }
  43462. /**
  43463. * The null engine class provides support for headless version of babylon.js.
  43464. * This can be used in server side scenario or for testing purposes
  43465. */
  43466. export class NullEngine extends Engine {
  43467. private _options;
  43468. /**
  43469. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43470. */
  43471. isDeterministicLockStep(): boolean;
  43472. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43473. getLockstepMaxSteps(): number;
  43474. /**
  43475. * Sets hardware scaling, used to save performance if needed
  43476. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43477. */
  43478. getHardwareScalingLevel(): number;
  43479. constructor(options?: NullEngineOptions);
  43480. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43481. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43482. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43483. getRenderWidth(useScreen?: boolean): number;
  43484. getRenderHeight(useScreen?: boolean): number;
  43485. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43486. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43487. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43488. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43489. bindSamplers(effect: Effect): void;
  43490. enableEffect(effect: Effect): void;
  43491. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43492. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43493. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43494. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43495. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43496. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43497. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43498. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43499. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43500. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43501. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43502. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43503. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43504. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43505. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43506. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43507. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43508. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43509. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43510. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43511. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43512. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43513. bindBuffers(vertexBuffers: {
  43514. [key: string]: VertexBuffer;
  43515. }, indexBuffer: DataBuffer, effect: Effect): void;
  43516. wipeCaches(bruteForce?: boolean): void;
  43517. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43518. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43519. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43520. /** @hidden */
  43521. _createTexture(): WebGLTexture;
  43522. /** @hidden */
  43523. _releaseTexture(texture: InternalTexture): void;
  43524. 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;
  43525. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43526. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43527. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43528. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43529. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43530. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43531. areAllEffectsReady(): boolean;
  43532. /**
  43533. * @hidden
  43534. * Get the current error code of the webGL context
  43535. * @returns the error code
  43536. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43537. */
  43538. getError(): number;
  43539. /** @hidden */
  43540. _getUnpackAlignement(): number;
  43541. /** @hidden */
  43542. _unpackFlipY(value: boolean): void;
  43543. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43544. /**
  43545. * Updates a dynamic vertex buffer.
  43546. * @param vertexBuffer the vertex buffer to update
  43547. * @param data the data used to update the vertex buffer
  43548. * @param byteOffset the byte offset of the data (optional)
  43549. * @param byteLength the byte length of the data (optional)
  43550. */
  43551. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43552. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43553. /** @hidden */
  43554. _bindTexture(channel: number, texture: InternalTexture): void;
  43555. protected _deleteBuffer(buffer: WebGLBuffer): void;
  43556. releaseEffects(): void;
  43557. displayLoadingUI(): void;
  43558. hideLoadingUI(): void;
  43559. /** @hidden */
  43560. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43561. /** @hidden */
  43562. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43563. /** @hidden */
  43564. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43565. /** @hidden */
  43566. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43567. }
  43568. }
  43569. declare module BABYLON {
  43570. /** @hidden */
  43571. export class _OcclusionDataStorage {
  43572. /** @hidden */
  43573. occlusionInternalRetryCounter: number;
  43574. /** @hidden */
  43575. isOcclusionQueryInProgress: boolean;
  43576. /** @hidden */
  43577. isOccluded: boolean;
  43578. /** @hidden */
  43579. occlusionRetryCount: number;
  43580. /** @hidden */
  43581. occlusionType: number;
  43582. /** @hidden */
  43583. occlusionQueryAlgorithmType: number;
  43584. }
  43585. interface Engine {
  43586. /**
  43587. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43588. * @return the new query
  43589. */
  43590. createQuery(): WebGLQuery;
  43591. /**
  43592. * Delete and release a webGL query
  43593. * @param query defines the query to delete
  43594. * @return the current engine
  43595. */
  43596. deleteQuery(query: WebGLQuery): Engine;
  43597. /**
  43598. * Check if a given query has resolved and got its value
  43599. * @param query defines the query to check
  43600. * @returns true if the query got its value
  43601. */
  43602. isQueryResultAvailable(query: WebGLQuery): boolean;
  43603. /**
  43604. * Gets the value of a given query
  43605. * @param query defines the query to check
  43606. * @returns the value of the query
  43607. */
  43608. getQueryResult(query: WebGLQuery): number;
  43609. /**
  43610. * Initiates an occlusion query
  43611. * @param algorithmType defines the algorithm to use
  43612. * @param query defines the query to use
  43613. * @returns the current engine
  43614. * @see http://doc.babylonjs.com/features/occlusionquery
  43615. */
  43616. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43617. /**
  43618. * Ends an occlusion query
  43619. * @see http://doc.babylonjs.com/features/occlusionquery
  43620. * @param algorithmType defines the algorithm to use
  43621. * @returns the current engine
  43622. */
  43623. endOcclusionQuery(algorithmType: number): Engine;
  43624. /**
  43625. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43626. * Please note that only one query can be issued at a time
  43627. * @returns a time token used to track the time span
  43628. */
  43629. startTimeQuery(): Nullable<_TimeToken>;
  43630. /**
  43631. * Ends a time query
  43632. * @param token defines the token used to measure the time span
  43633. * @returns the time spent (in ns)
  43634. */
  43635. endTimeQuery(token: _TimeToken): int;
  43636. /** @hidden */
  43637. _currentNonTimestampToken: Nullable<_TimeToken>;
  43638. /** @hidden */
  43639. _createTimeQuery(): WebGLQuery;
  43640. /** @hidden */
  43641. _deleteTimeQuery(query: WebGLQuery): void;
  43642. /** @hidden */
  43643. _getGlAlgorithmType(algorithmType: number): number;
  43644. /** @hidden */
  43645. _getTimeQueryResult(query: WebGLQuery): any;
  43646. /** @hidden */
  43647. _getTimeQueryAvailability(query: WebGLQuery): any;
  43648. }
  43649. interface AbstractMesh {
  43650. /**
  43651. * Backing filed
  43652. * @hidden
  43653. */
  43654. __occlusionDataStorage: _OcclusionDataStorage;
  43655. /**
  43656. * Access property
  43657. * @hidden
  43658. */
  43659. _occlusionDataStorage: _OcclusionDataStorage;
  43660. /**
  43661. * 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.
  43662. * The default value is -1 which means don't break the query and wait till the result
  43663. * @see http://doc.babylonjs.com/features/occlusionquery
  43664. */
  43665. occlusionRetryCount: number;
  43666. /**
  43667. * 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:
  43668. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43669. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43670. * * 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.
  43671. * @see http://doc.babylonjs.com/features/occlusionquery
  43672. */
  43673. occlusionType: number;
  43674. /**
  43675. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43676. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43677. * * 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.
  43678. * @see http://doc.babylonjs.com/features/occlusionquery
  43679. */
  43680. occlusionQueryAlgorithmType: number;
  43681. /**
  43682. * 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
  43683. * @see http://doc.babylonjs.com/features/occlusionquery
  43684. */
  43685. isOccluded: boolean;
  43686. /**
  43687. * Flag to check the progress status of the query
  43688. * @see http://doc.babylonjs.com/features/occlusionquery
  43689. */
  43690. isOcclusionQueryInProgress: boolean;
  43691. }
  43692. }
  43693. declare module BABYLON {
  43694. /** @hidden */
  43695. export var _forceTransformFeedbackToBundle: boolean;
  43696. interface Engine {
  43697. /**
  43698. * Creates a webGL transform feedback object
  43699. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43700. * @returns the webGL transform feedback object
  43701. */
  43702. createTransformFeedback(): WebGLTransformFeedback;
  43703. /**
  43704. * Delete a webGL transform feedback object
  43705. * @param value defines the webGL transform feedback object to delete
  43706. */
  43707. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43708. /**
  43709. * Bind a webGL transform feedback object to the webgl context
  43710. * @param value defines the webGL transform feedback object to bind
  43711. */
  43712. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43713. /**
  43714. * Begins a transform feedback operation
  43715. * @param usePoints defines if points or triangles must be used
  43716. */
  43717. beginTransformFeedback(usePoints: boolean): void;
  43718. /**
  43719. * Ends a transform feedback operation
  43720. */
  43721. endTransformFeedback(): void;
  43722. /**
  43723. * Specify the varyings to use with transform feedback
  43724. * @param program defines the associated webGL program
  43725. * @param value defines the list of strings representing the varying names
  43726. */
  43727. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43728. /**
  43729. * Bind a webGL buffer for a transform feedback operation
  43730. * @param value defines the webGL buffer to bind
  43731. */
  43732. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43733. }
  43734. }
  43735. declare module BABYLON {
  43736. /**
  43737. * Creation options of the multi render target texture.
  43738. */
  43739. export interface IMultiRenderTargetOptions {
  43740. /**
  43741. * Define if the texture needs to create mip maps after render.
  43742. */
  43743. generateMipMaps?: boolean;
  43744. /**
  43745. * Define the types of all the draw buffers we want to create
  43746. */
  43747. types?: number[];
  43748. /**
  43749. * Define the sampling modes of all the draw buffers we want to create
  43750. */
  43751. samplingModes?: number[];
  43752. /**
  43753. * Define if a depth buffer is required
  43754. */
  43755. generateDepthBuffer?: boolean;
  43756. /**
  43757. * Define if a stencil buffer is required
  43758. */
  43759. generateStencilBuffer?: boolean;
  43760. /**
  43761. * Define if a depth texture is required instead of a depth buffer
  43762. */
  43763. generateDepthTexture?: boolean;
  43764. /**
  43765. * Define the number of desired draw buffers
  43766. */
  43767. textureCount?: number;
  43768. /**
  43769. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43770. */
  43771. doNotChangeAspectRatio?: boolean;
  43772. /**
  43773. * Define the default type of the buffers we are creating
  43774. */
  43775. defaultType?: number;
  43776. }
  43777. /**
  43778. * A multi render target, like a render target provides the ability to render to a texture.
  43779. * Unlike the render target, it can render to several draw buffers in one draw.
  43780. * This is specially interesting in deferred rendering or for any effects requiring more than
  43781. * just one color from a single pass.
  43782. */
  43783. export class MultiRenderTarget extends RenderTargetTexture {
  43784. private _internalTextures;
  43785. private _textures;
  43786. private _multiRenderTargetOptions;
  43787. /**
  43788. * Get if draw buffers are currently supported by the used hardware and browser.
  43789. */
  43790. readonly isSupported: boolean;
  43791. /**
  43792. * Get the list of textures generated by the multi render target.
  43793. */
  43794. readonly textures: Texture[];
  43795. /**
  43796. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43797. */
  43798. readonly depthTexture: Texture;
  43799. /**
  43800. * Set the wrapping mode on U of all the textures we are rendering to.
  43801. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43802. */
  43803. wrapU: number;
  43804. /**
  43805. * Set the wrapping mode on V of all the textures we are rendering to.
  43806. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43807. */
  43808. wrapV: number;
  43809. /**
  43810. * Instantiate a new multi render target texture.
  43811. * A multi render target, like a render target provides the ability to render to a texture.
  43812. * Unlike the render target, it can render to several draw buffers in one draw.
  43813. * This is specially interesting in deferred rendering or for any effects requiring more than
  43814. * just one color from a single pass.
  43815. * @param name Define the name of the texture
  43816. * @param size Define the size of the buffers to render to
  43817. * @param count Define the number of target we are rendering into
  43818. * @param scene Define the scene the texture belongs to
  43819. * @param options Define the options used to create the multi render target
  43820. */
  43821. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43822. /** @hidden */
  43823. _rebuild(): void;
  43824. private _createInternalTextures;
  43825. private _createTextures;
  43826. /**
  43827. * Define the number of samples used if MSAA is enabled.
  43828. */
  43829. samples: number;
  43830. /**
  43831. * Resize all the textures in the multi render target.
  43832. * Be carrefull as it will recreate all the data in the new texture.
  43833. * @param size Define the new size
  43834. */
  43835. resize(size: any): void;
  43836. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43837. /**
  43838. * Dispose the render targets and their associated resources
  43839. */
  43840. dispose(): void;
  43841. /**
  43842. * Release all the underlying texture used as draw buffers.
  43843. */
  43844. releaseInternalTextures(): void;
  43845. }
  43846. }
  43847. declare module BABYLON {
  43848. interface Engine {
  43849. /**
  43850. * Unbind a list of render target textures from the webGL context
  43851. * This is used only when drawBuffer extension or webGL2 are active
  43852. * @param textures defines the render target textures to unbind
  43853. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43854. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43855. */
  43856. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43857. /**
  43858. * Create a multi render target texture
  43859. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43860. * @param size defines the size of the texture
  43861. * @param options defines the creation options
  43862. * @returns the cube texture as an InternalTexture
  43863. */
  43864. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43865. /**
  43866. * Update the sample count for a given multiple render target texture
  43867. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43868. * @param textures defines the textures to update
  43869. * @param samples defines the sample count to set
  43870. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43871. */
  43872. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43873. }
  43874. }
  43875. declare module BABYLON {
  43876. /** @hidden */
  43877. export var rgbdEncodePixelShader: {
  43878. name: string;
  43879. shader: string;
  43880. };
  43881. }
  43882. declare module BABYLON {
  43883. /** @hidden */
  43884. export var rgbdDecodePixelShader: {
  43885. name: string;
  43886. shader: string;
  43887. };
  43888. }
  43889. declare module BABYLON {
  43890. /**
  43891. * Raw texture data and descriptor sufficient for WebGL texture upload
  43892. */
  43893. export interface EnvironmentTextureInfo {
  43894. /**
  43895. * Version of the environment map
  43896. */
  43897. version: number;
  43898. /**
  43899. * Width of image
  43900. */
  43901. width: number;
  43902. /**
  43903. * Irradiance information stored in the file.
  43904. */
  43905. irradiance: any;
  43906. /**
  43907. * Specular information stored in the file.
  43908. */
  43909. specular: any;
  43910. }
  43911. /**
  43912. * Defines One Image in the file. It requires only the position in the file
  43913. * as well as the length.
  43914. */
  43915. interface BufferImageData {
  43916. /**
  43917. * Length of the image data.
  43918. */
  43919. length: number;
  43920. /**
  43921. * Position of the data from the null terminator delimiting the end of the JSON.
  43922. */
  43923. position: number;
  43924. }
  43925. /**
  43926. * Defines the specular data enclosed in the file.
  43927. * This corresponds to the version 1 of the data.
  43928. */
  43929. export interface EnvironmentTextureSpecularInfoV1 {
  43930. /**
  43931. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  43932. */
  43933. specularDataPosition?: number;
  43934. /**
  43935. * This contains all the images data needed to reconstruct the cubemap.
  43936. */
  43937. mipmaps: Array<BufferImageData>;
  43938. /**
  43939. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  43940. */
  43941. lodGenerationScale: number;
  43942. }
  43943. /**
  43944. * Sets of helpers addressing the serialization and deserialization of environment texture
  43945. * stored in a BabylonJS env file.
  43946. * Those files are usually stored as .env files.
  43947. */
  43948. export class EnvironmentTextureTools {
  43949. /**
  43950. * Magic number identifying the env file.
  43951. */
  43952. private static _MagicBytes;
  43953. /**
  43954. * Gets the environment info from an env file.
  43955. * @param data The array buffer containing the .env bytes.
  43956. * @returns the environment file info (the json header) if successfully parsed.
  43957. */
  43958. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  43959. /**
  43960. * Creates an environment texture from a loaded cube texture.
  43961. * @param texture defines the cube texture to convert in env file
  43962. * @return a promise containing the environment data if succesfull.
  43963. */
  43964. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  43965. /**
  43966. * Creates a JSON representation of the spherical data.
  43967. * @param texture defines the texture containing the polynomials
  43968. * @return the JSON representation of the spherical info
  43969. */
  43970. private static _CreateEnvTextureIrradiance;
  43971. /**
  43972. * Creates the ArrayBufferViews used for initializing environment texture image data.
  43973. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  43974. * @param info parameters that determine what views will be created for accessing the underlying buffer
  43975. * @return the views described by info providing access to the underlying buffer
  43976. */
  43977. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  43978. /**
  43979. * Uploads the texture info contained in the env file to the GPU.
  43980. * @param texture defines the internal texture to upload to
  43981. * @param arrayBuffer defines the buffer cotaining the data to load
  43982. * @param info defines the texture info retrieved through the GetEnvInfo method
  43983. * @returns a promise
  43984. */
  43985. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  43986. /**
  43987. * Uploads the levels of image data to the GPU.
  43988. * @param texture defines the internal texture to upload to
  43989. * @param imageData defines the array buffer views of image data [mipmap][face]
  43990. * @returns a promise
  43991. */
  43992. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  43993. /**
  43994. * Uploads spherical polynomials information to the texture.
  43995. * @param texture defines the texture we are trying to upload the information to
  43996. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  43997. */
  43998. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  43999. /** @hidden */
  44000. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44001. }
  44002. }
  44003. declare module BABYLON {
  44004. /**
  44005. * Contains position and normal vectors for a vertex
  44006. */
  44007. export class PositionNormalVertex {
  44008. /** the position of the vertex (defaut: 0,0,0) */
  44009. position: Vector3;
  44010. /** the normal of the vertex (defaut: 0,1,0) */
  44011. normal: Vector3;
  44012. /**
  44013. * Creates a PositionNormalVertex
  44014. * @param position the position of the vertex (defaut: 0,0,0)
  44015. * @param normal the normal of the vertex (defaut: 0,1,0)
  44016. */
  44017. constructor(
  44018. /** the position of the vertex (defaut: 0,0,0) */
  44019. position?: Vector3,
  44020. /** the normal of the vertex (defaut: 0,1,0) */
  44021. normal?: Vector3);
  44022. /**
  44023. * Clones the PositionNormalVertex
  44024. * @returns the cloned PositionNormalVertex
  44025. */
  44026. clone(): PositionNormalVertex;
  44027. }
  44028. /**
  44029. * Contains position, normal and uv vectors for a vertex
  44030. */
  44031. export class PositionNormalTextureVertex {
  44032. /** the position of the vertex (defaut: 0,0,0) */
  44033. position: Vector3;
  44034. /** the normal of the vertex (defaut: 0,1,0) */
  44035. normal: Vector3;
  44036. /** the uv of the vertex (default: 0,0) */
  44037. uv: Vector2;
  44038. /**
  44039. * Creates a PositionNormalTextureVertex
  44040. * @param position the position of the vertex (defaut: 0,0,0)
  44041. * @param normal the normal of the vertex (defaut: 0,1,0)
  44042. * @param uv the uv of the vertex (default: 0,0)
  44043. */
  44044. constructor(
  44045. /** the position of the vertex (defaut: 0,0,0) */
  44046. position?: Vector3,
  44047. /** the normal of the vertex (defaut: 0,1,0) */
  44048. normal?: Vector3,
  44049. /** the uv of the vertex (default: 0,0) */
  44050. uv?: Vector2);
  44051. /**
  44052. * Clones the PositionNormalTextureVertex
  44053. * @returns the cloned PositionNormalTextureVertex
  44054. */
  44055. clone(): PositionNormalTextureVertex;
  44056. }
  44057. }
  44058. declare module BABYLON {
  44059. /** @hidden */
  44060. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44061. private _genericAttributeLocation;
  44062. private _varyingLocationCount;
  44063. private _varyingLocationMap;
  44064. private _replacements;
  44065. private _textureCount;
  44066. private _uniforms;
  44067. lineProcessor(line: string): string;
  44068. attributeProcessor(attribute: string): string;
  44069. varyingProcessor(varying: string, isFragment: boolean): string;
  44070. uniformProcessor(uniform: string): string;
  44071. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44072. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44073. }
  44074. }
  44075. declare module BABYLON {
  44076. /**
  44077. * Container for accessors for natively-stored mesh data buffers.
  44078. */
  44079. class NativeDataBuffer extends DataBuffer {
  44080. /**
  44081. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44082. */
  44083. nativeIndexBuffer?: any;
  44084. /**
  44085. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44086. */
  44087. nativeVertexBuffer?: any;
  44088. }
  44089. /** @hidden */
  44090. export class NativeEngine extends Engine {
  44091. private readonly _native;
  44092. getHardwareScalingLevel(): number;
  44093. constructor();
  44094. /**
  44095. * Can be used to override the current requestAnimationFrame requester.
  44096. * @hidden
  44097. */
  44098. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44099. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44100. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44101. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44102. recordVertexArrayObject(vertexBuffers: {
  44103. [key: string]: VertexBuffer;
  44104. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44105. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44106. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44107. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44108. /**
  44109. * Draw a list of indexed primitives
  44110. * @param fillMode defines the primitive to use
  44111. * @param indexStart defines the starting index
  44112. * @param indexCount defines the number of index to draw
  44113. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44114. */
  44115. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44116. /**
  44117. * Draw a list of unindexed primitives
  44118. * @param fillMode defines the primitive to use
  44119. * @param verticesStart defines the index of first vertex to draw
  44120. * @param verticesCount defines the count of vertices to draw
  44121. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44122. */
  44123. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44124. createPipelineContext(): IPipelineContext;
  44125. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44126. /** @hidden */
  44127. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44128. /** @hidden */
  44129. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44130. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44131. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44132. protected _setProgram(program: WebGLProgram): void;
  44133. _releaseEffect(effect: Effect): void;
  44134. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44135. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44136. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44137. bindSamplers(effect: Effect): void;
  44138. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44139. getRenderWidth(useScreen?: boolean): number;
  44140. getRenderHeight(useScreen?: boolean): number;
  44141. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44142. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44143. /**
  44144. * Set the z offset to apply to current rendering
  44145. * @param value defines the offset to apply
  44146. */
  44147. setZOffset(value: number): void;
  44148. /**
  44149. * Gets the current value of the zOffset
  44150. * @returns the current zOffset state
  44151. */
  44152. getZOffset(): number;
  44153. /**
  44154. * Enable or disable depth buffering
  44155. * @param enable defines the state to set
  44156. */
  44157. setDepthBuffer(enable: boolean): void;
  44158. /**
  44159. * Gets a boolean indicating if depth writing is enabled
  44160. * @returns the current depth writing state
  44161. */
  44162. getDepthWrite(): boolean;
  44163. /**
  44164. * Enable or disable depth writing
  44165. * @param enable defines the state to set
  44166. */
  44167. setDepthWrite(enable: boolean): void;
  44168. /**
  44169. * Enable or disable color writing
  44170. * @param enable defines the state to set
  44171. */
  44172. setColorWrite(enable: boolean): void;
  44173. /**
  44174. * Gets a boolean indicating if color writing is enabled
  44175. * @returns the current color writing state
  44176. */
  44177. getColorWrite(): boolean;
  44178. /**
  44179. * Sets alpha constants used by some alpha blending modes
  44180. * @param r defines the red component
  44181. * @param g defines the green component
  44182. * @param b defines the blue component
  44183. * @param a defines the alpha component
  44184. */
  44185. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44186. /**
  44187. * Sets the current alpha mode
  44188. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  44189. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44190. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44191. */
  44192. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44193. /**
  44194. * Gets the current alpha mode
  44195. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44196. * @returns the current alpha mode
  44197. */
  44198. getAlphaMode(): number;
  44199. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44200. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44201. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44202. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44203. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44204. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44205. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44206. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44207. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44208. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44209. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44210. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44211. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44212. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44213. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44214. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44215. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44216. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44217. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44218. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44219. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44220. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44221. wipeCaches(bruteForce?: boolean): void;
  44222. _createTexture(): WebGLTexture;
  44223. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44224. /**
  44225. * Usually called from BABYLON.Texture.ts.
  44226. * Passed information to create a WebGLTexture
  44227. * @param urlArg defines a value which contains one of the following:
  44228. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44229. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44230. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44231. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44232. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44233. * @param scene needed for loading to the correct scene
  44234. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44235. * @param onLoad optional callback to be called upon successful completion
  44236. * @param onError optional callback to be called upon failure
  44237. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44238. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44239. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44240. * @param forcedExtension defines the extension to use to pick the right loader
  44241. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44242. */
  44243. 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;
  44244. /**
  44245. * Creates a cube texture
  44246. * @param rootUrl defines the url where the files to load is located
  44247. * @param scene defines the current scene
  44248. * @param files defines the list of files to load (1 per face)
  44249. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44250. * @param onLoad defines an optional callback raised when the texture is loaded
  44251. * @param onError defines an optional callback raised if there is an issue to load the texture
  44252. * @param format defines the format of the data
  44253. * @param forcedExtension defines the extension to use to pick the right loader
  44254. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44255. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44256. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44257. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44258. * @returns the cube texture as an InternalTexture
  44259. */
  44260. 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;
  44261. private _getSamplingFilter;
  44262. private static _GetNativeTextureFormat;
  44263. createRenderTargetTexture(size: number | {
  44264. width: number;
  44265. height: number;
  44266. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44267. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44268. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44269. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44270. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44271. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44272. /**
  44273. * Updates a dynamic vertex buffer.
  44274. * @param vertexBuffer the vertex buffer to update
  44275. * @param data the data used to update the vertex buffer
  44276. * @param byteOffset the byte offset of the data (optional)
  44277. * @param byteLength the byte length of the data (optional)
  44278. */
  44279. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44280. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44281. private _updateAnisotropicLevel;
  44282. private _getAddressMode;
  44283. /** @hidden */
  44284. _bindTexture(channel: number, texture: InternalTexture): void;
  44285. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44286. releaseEffects(): void;
  44287. /** @hidden */
  44288. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44289. /** @hidden */
  44290. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44291. /** @hidden */
  44292. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44293. /** @hidden */
  44294. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44295. }
  44296. }
  44297. declare module BABYLON {
  44298. /**
  44299. * Gather the list of clipboard event types as constants.
  44300. */
  44301. export class ClipboardEventTypes {
  44302. /**
  44303. * The clipboard event is fired when a copy command is active (pressed).
  44304. */
  44305. static readonly COPY: number;
  44306. /**
  44307. * The clipboard event is fired when a cut command is active (pressed).
  44308. */
  44309. static readonly CUT: number;
  44310. /**
  44311. * The clipboard event is fired when a paste command is active (pressed).
  44312. */
  44313. static readonly PASTE: number;
  44314. }
  44315. /**
  44316. * This class is used to store clipboard related info for the onClipboardObservable event.
  44317. */
  44318. export class ClipboardInfo {
  44319. /**
  44320. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44321. */
  44322. type: number;
  44323. /**
  44324. * Defines the related dom event
  44325. */
  44326. event: ClipboardEvent;
  44327. /**
  44328. *Creates an instance of ClipboardInfo.
  44329. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44330. * @param event Defines the related dom event
  44331. */
  44332. constructor(
  44333. /**
  44334. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44335. */
  44336. type: number,
  44337. /**
  44338. * Defines the related dom event
  44339. */
  44340. event: ClipboardEvent);
  44341. /**
  44342. * Get the clipboard event's type from the keycode.
  44343. * @param keyCode Defines the keyCode for the current keyboard event.
  44344. * @return {number}
  44345. */
  44346. static GetTypeFromCharacter(keyCode: number): number;
  44347. }
  44348. }
  44349. declare module BABYLON {
  44350. /**
  44351. * Google Daydream controller
  44352. */
  44353. export class DaydreamController extends WebVRController {
  44354. /**
  44355. * Base Url for the controller model.
  44356. */
  44357. static MODEL_BASE_URL: string;
  44358. /**
  44359. * File name for the controller model.
  44360. */
  44361. static MODEL_FILENAME: string;
  44362. /**
  44363. * Gamepad Id prefix used to identify Daydream Controller.
  44364. */
  44365. static readonly GAMEPAD_ID_PREFIX: string;
  44366. /**
  44367. * Creates a new DaydreamController from a gamepad
  44368. * @param vrGamepad the gamepad that the controller should be created from
  44369. */
  44370. constructor(vrGamepad: any);
  44371. /**
  44372. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44373. * @param scene scene in which to add meshes
  44374. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44375. */
  44376. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44377. /**
  44378. * Called once for each button that changed state since the last frame
  44379. * @param buttonIdx Which button index changed
  44380. * @param state New state of the button
  44381. * @param changes Which properties on the state changed since last frame
  44382. */
  44383. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44384. }
  44385. }
  44386. declare module BABYLON {
  44387. /**
  44388. * Gear VR Controller
  44389. */
  44390. export class GearVRController extends WebVRController {
  44391. /**
  44392. * Base Url for the controller model.
  44393. */
  44394. static MODEL_BASE_URL: string;
  44395. /**
  44396. * File name for the controller model.
  44397. */
  44398. static MODEL_FILENAME: string;
  44399. /**
  44400. * Gamepad Id prefix used to identify this controller.
  44401. */
  44402. static readonly GAMEPAD_ID_PREFIX: string;
  44403. private readonly _buttonIndexToObservableNameMap;
  44404. /**
  44405. * Creates a new GearVRController from a gamepad
  44406. * @param vrGamepad the gamepad that the controller should be created from
  44407. */
  44408. constructor(vrGamepad: any);
  44409. /**
  44410. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44411. * @param scene scene in which to add meshes
  44412. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44413. */
  44414. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44415. /**
  44416. * Called once for each button that changed state since the last frame
  44417. * @param buttonIdx Which button index changed
  44418. * @param state New state of the button
  44419. * @param changes Which properties on the state changed since last frame
  44420. */
  44421. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44422. }
  44423. }
  44424. declare module BABYLON {
  44425. /**
  44426. * Class containing static functions to help procedurally build meshes
  44427. */
  44428. export class PolyhedronBuilder {
  44429. /**
  44430. * Creates a polyhedron mesh
  44431. * * 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
  44432. * * The parameter `size` (positive float, default 1) sets the polygon size
  44433. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44434. * * 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`
  44435. * * 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
  44436. * * 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)`)
  44437. * * 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
  44438. * * 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
  44439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44440. * * 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
  44441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44442. * @param name defines the name of the mesh
  44443. * @param options defines the options used to create the mesh
  44444. * @param scene defines the hosting scene
  44445. * @returns the polyhedron mesh
  44446. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44447. */
  44448. static CreatePolyhedron(name: string, options: {
  44449. type?: number;
  44450. size?: number;
  44451. sizeX?: number;
  44452. sizeY?: number;
  44453. sizeZ?: number;
  44454. custom?: any;
  44455. faceUV?: Vector4[];
  44456. faceColors?: Color4[];
  44457. flat?: boolean;
  44458. updatable?: boolean;
  44459. sideOrientation?: number;
  44460. frontUVs?: Vector4;
  44461. backUVs?: Vector4;
  44462. }, scene?: Nullable<Scene>): Mesh;
  44463. }
  44464. }
  44465. declare module BABYLON {
  44466. /**
  44467. * Gizmo that enables scaling a mesh along 3 axis
  44468. */
  44469. export class ScaleGizmo extends Gizmo {
  44470. /**
  44471. * Internal gizmo used for interactions on the x axis
  44472. */
  44473. xGizmo: AxisScaleGizmo;
  44474. /**
  44475. * Internal gizmo used for interactions on the y axis
  44476. */
  44477. yGizmo: AxisScaleGizmo;
  44478. /**
  44479. * Internal gizmo used for interactions on the z axis
  44480. */
  44481. zGizmo: AxisScaleGizmo;
  44482. /**
  44483. * Internal gizmo used to scale all axis equally
  44484. */
  44485. uniformScaleGizmo: AxisScaleGizmo;
  44486. private _meshAttached;
  44487. private _updateGizmoRotationToMatchAttachedMesh;
  44488. private _snapDistance;
  44489. private _scaleRatio;
  44490. private _uniformScalingMesh;
  44491. private _octahedron;
  44492. /** Fires an event when any of it's sub gizmos are dragged */
  44493. onDragStartObservable: Observable<unknown>;
  44494. /** Fires an event when any of it's sub gizmos are released from dragging */
  44495. onDragEndObservable: Observable<unknown>;
  44496. attachedMesh: Nullable<AbstractMesh>;
  44497. /**
  44498. * Creates a ScaleGizmo
  44499. * @param gizmoLayer The utility layer the gizmo will be added to
  44500. */
  44501. constructor(gizmoLayer?: UtilityLayerRenderer);
  44502. updateGizmoRotationToMatchAttachedMesh: boolean;
  44503. /**
  44504. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44505. */
  44506. snapDistance: number;
  44507. /**
  44508. * Ratio for the scale of the gizmo (Default: 1)
  44509. */
  44510. scaleRatio: number;
  44511. /**
  44512. * Disposes of the gizmo
  44513. */
  44514. dispose(): void;
  44515. }
  44516. }
  44517. declare module BABYLON {
  44518. /**
  44519. * Single axis scale gizmo
  44520. */
  44521. export class AxisScaleGizmo extends Gizmo {
  44522. /**
  44523. * Drag behavior responsible for the gizmos dragging interactions
  44524. */
  44525. dragBehavior: PointerDragBehavior;
  44526. private _pointerObserver;
  44527. /**
  44528. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44529. */
  44530. snapDistance: number;
  44531. /**
  44532. * Event that fires each time the gizmo snaps to a new location.
  44533. * * snapDistance is the the change in distance
  44534. */
  44535. onSnapObservable: Observable<{
  44536. snapDistance: number;
  44537. }>;
  44538. /**
  44539. * If the scaling operation should be done on all axis (default: false)
  44540. */
  44541. uniformScaling: boolean;
  44542. private _isEnabled;
  44543. private _parent;
  44544. private _arrow;
  44545. private _coloredMaterial;
  44546. private _hoverMaterial;
  44547. /**
  44548. * Creates an AxisScaleGizmo
  44549. * @param gizmoLayer The utility layer the gizmo will be added to
  44550. * @param dragAxis The axis which the gizmo will be able to scale on
  44551. * @param color The color of the gizmo
  44552. */
  44553. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44554. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44555. /**
  44556. * If the gizmo is enabled
  44557. */
  44558. isEnabled: boolean;
  44559. /**
  44560. * Disposes of the gizmo
  44561. */
  44562. dispose(): void;
  44563. /**
  44564. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44565. * @param mesh The mesh to replace the default mesh of the gizmo
  44566. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44567. */
  44568. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44569. }
  44570. }
  44571. declare module BABYLON {
  44572. /**
  44573. * Bounding box gizmo
  44574. */
  44575. export class BoundingBoxGizmo extends Gizmo {
  44576. private _lineBoundingBox;
  44577. private _rotateSpheresParent;
  44578. private _scaleBoxesParent;
  44579. private _boundingDimensions;
  44580. private _renderObserver;
  44581. private _pointerObserver;
  44582. private _scaleDragSpeed;
  44583. private _tmpQuaternion;
  44584. private _tmpVector;
  44585. private _tmpRotationMatrix;
  44586. /**
  44587. * 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)
  44588. */
  44589. ignoreChildren: boolean;
  44590. /**
  44591. * 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)
  44592. */
  44593. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44594. /**
  44595. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44596. */
  44597. rotationSphereSize: number;
  44598. /**
  44599. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44600. */
  44601. scaleBoxSize: number;
  44602. /**
  44603. * 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)
  44604. */
  44605. fixedDragMeshScreenSize: boolean;
  44606. /**
  44607. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44608. */
  44609. fixedDragMeshScreenSizeDistanceFactor: number;
  44610. /**
  44611. * Fired when a rotation sphere or scale box is dragged
  44612. */
  44613. onDragStartObservable: Observable<{}>;
  44614. /**
  44615. * Fired when a scale box is dragged
  44616. */
  44617. onScaleBoxDragObservable: Observable<{}>;
  44618. /**
  44619. * Fired when a scale box drag is ended
  44620. */
  44621. onScaleBoxDragEndObservable: Observable<{}>;
  44622. /**
  44623. * Fired when a rotation sphere is dragged
  44624. */
  44625. onRotationSphereDragObservable: Observable<{}>;
  44626. /**
  44627. * Fired when a rotation sphere drag is ended
  44628. */
  44629. onRotationSphereDragEndObservable: Observable<{}>;
  44630. /**
  44631. * 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)
  44632. */
  44633. scalePivot: Nullable<Vector3>;
  44634. /**
  44635. * Mesh used as a pivot to rotate the attached mesh
  44636. */
  44637. private _anchorMesh;
  44638. private _existingMeshScale;
  44639. private _dragMesh;
  44640. private pointerDragBehavior;
  44641. private coloredMaterial;
  44642. private hoverColoredMaterial;
  44643. /**
  44644. * Sets the color of the bounding box gizmo
  44645. * @param color the color to set
  44646. */
  44647. setColor(color: Color3): void;
  44648. /**
  44649. * Creates an BoundingBoxGizmo
  44650. * @param gizmoLayer The utility layer the gizmo will be added to
  44651. * @param color The color of the gizmo
  44652. */
  44653. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44654. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44655. private _selectNode;
  44656. /**
  44657. * Updates the bounding box information for the Gizmo
  44658. */
  44659. updateBoundingBox(): void;
  44660. private _updateRotationSpheres;
  44661. private _updateScaleBoxes;
  44662. /**
  44663. * Enables rotation on the specified axis and disables rotation on the others
  44664. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44665. */
  44666. setEnabledRotationAxis(axis: string): void;
  44667. /**
  44668. * Enables/disables scaling
  44669. * @param enable if scaling should be enabled
  44670. */
  44671. setEnabledScaling(enable: boolean): void;
  44672. private _updateDummy;
  44673. /**
  44674. * Enables a pointer drag behavior on the bounding box of the gizmo
  44675. */
  44676. enableDragBehavior(): void;
  44677. /**
  44678. * Disposes of the gizmo
  44679. */
  44680. dispose(): void;
  44681. /**
  44682. * 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)
  44683. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44684. * @returns the bounding box mesh with the passed in mesh as a child
  44685. */
  44686. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44687. /**
  44688. * CustomMeshes are not supported by this gizmo
  44689. * @param mesh The mesh to replace the default mesh of the gizmo
  44690. */
  44691. setCustomMesh(mesh: Mesh): void;
  44692. }
  44693. }
  44694. declare module BABYLON {
  44695. /**
  44696. * Single plane rotation gizmo
  44697. */
  44698. export class PlaneRotationGizmo extends Gizmo {
  44699. /**
  44700. * Drag behavior responsible for the gizmos dragging interactions
  44701. */
  44702. dragBehavior: PointerDragBehavior;
  44703. private _pointerObserver;
  44704. /**
  44705. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44706. */
  44707. snapDistance: number;
  44708. /**
  44709. * Event that fires each time the gizmo snaps to a new location.
  44710. * * snapDistance is the the change in distance
  44711. */
  44712. onSnapObservable: Observable<{
  44713. snapDistance: number;
  44714. }>;
  44715. private _isEnabled;
  44716. private _parent;
  44717. /**
  44718. * Creates a PlaneRotationGizmo
  44719. * @param gizmoLayer The utility layer the gizmo will be added to
  44720. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44721. * @param color The color of the gizmo
  44722. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44723. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44724. */
  44725. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44726. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44727. /**
  44728. * If the gizmo is enabled
  44729. */
  44730. isEnabled: boolean;
  44731. /**
  44732. * Disposes of the gizmo
  44733. */
  44734. dispose(): void;
  44735. }
  44736. }
  44737. declare module BABYLON {
  44738. /**
  44739. * Gizmo that enables rotating a mesh along 3 axis
  44740. */
  44741. export class RotationGizmo extends Gizmo {
  44742. /**
  44743. * Internal gizmo used for interactions on the x axis
  44744. */
  44745. xGizmo: PlaneRotationGizmo;
  44746. /**
  44747. * Internal gizmo used for interactions on the y axis
  44748. */
  44749. yGizmo: PlaneRotationGizmo;
  44750. /**
  44751. * Internal gizmo used for interactions on the z axis
  44752. */
  44753. zGizmo: PlaneRotationGizmo;
  44754. /** Fires an event when any of it's sub gizmos are dragged */
  44755. onDragStartObservable: Observable<unknown>;
  44756. /** Fires an event when any of it's sub gizmos are released from dragging */
  44757. onDragEndObservable: Observable<unknown>;
  44758. private _meshAttached;
  44759. attachedMesh: Nullable<AbstractMesh>;
  44760. /**
  44761. * Creates a RotationGizmo
  44762. * @param gizmoLayer The utility layer the gizmo will be added to
  44763. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44764. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44765. */
  44766. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  44767. updateGizmoRotationToMatchAttachedMesh: boolean;
  44768. /**
  44769. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44770. */
  44771. snapDistance: number;
  44772. /**
  44773. * Ratio for the scale of the gizmo (Default: 1)
  44774. */
  44775. scaleRatio: number;
  44776. /**
  44777. * Disposes of the gizmo
  44778. */
  44779. dispose(): void;
  44780. /**
  44781. * CustomMeshes are not supported by this gizmo
  44782. * @param mesh The mesh to replace the default mesh of the gizmo
  44783. */
  44784. setCustomMesh(mesh: Mesh): void;
  44785. }
  44786. }
  44787. declare module BABYLON {
  44788. /**
  44789. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44790. */
  44791. export class GizmoManager implements IDisposable {
  44792. private scene;
  44793. /**
  44794. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44795. */
  44796. gizmos: {
  44797. positionGizmo: Nullable<PositionGizmo>;
  44798. rotationGizmo: Nullable<RotationGizmo>;
  44799. scaleGizmo: Nullable<ScaleGizmo>;
  44800. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44801. };
  44802. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44803. clearGizmoOnEmptyPointerEvent: boolean;
  44804. /** Fires an event when the manager is attached to a mesh */
  44805. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44806. private _gizmosEnabled;
  44807. private _pointerObserver;
  44808. private _attachedMesh;
  44809. private _boundingBoxColor;
  44810. private _defaultUtilityLayer;
  44811. private _defaultKeepDepthUtilityLayer;
  44812. /**
  44813. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44814. */
  44815. boundingBoxDragBehavior: SixDofDragBehavior;
  44816. /**
  44817. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44818. */
  44819. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44820. /**
  44821. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44822. */
  44823. usePointerToAttachGizmos: boolean;
  44824. /**
  44825. * Utility layer that the bounding box gizmo belongs to
  44826. */
  44827. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44828. /**
  44829. * Utility layer that all gizmos besides bounding box belong to
  44830. */
  44831. readonly utilityLayer: UtilityLayerRenderer;
  44832. /**
  44833. * Instatiates a gizmo manager
  44834. * @param scene the scene to overlay the gizmos on top of
  44835. */
  44836. constructor(scene: Scene);
  44837. /**
  44838. * Attaches a set of gizmos to the specified mesh
  44839. * @param mesh The mesh the gizmo's should be attached to
  44840. */
  44841. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44842. /**
  44843. * If the position gizmo is enabled
  44844. */
  44845. positionGizmoEnabled: boolean;
  44846. /**
  44847. * If the rotation gizmo is enabled
  44848. */
  44849. rotationGizmoEnabled: boolean;
  44850. /**
  44851. * If the scale gizmo is enabled
  44852. */
  44853. scaleGizmoEnabled: boolean;
  44854. /**
  44855. * If the boundingBox gizmo is enabled
  44856. */
  44857. boundingBoxGizmoEnabled: boolean;
  44858. /**
  44859. * Disposes of the gizmo manager
  44860. */
  44861. dispose(): void;
  44862. }
  44863. }
  44864. declare module BABYLON {
  44865. /**
  44866. * A directional light is defined by a direction (what a surprise!).
  44867. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44868. * 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.
  44869. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44870. */
  44871. export class DirectionalLight extends ShadowLight {
  44872. private _shadowFrustumSize;
  44873. /**
  44874. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44875. */
  44876. /**
  44877. * Specifies a fix frustum size for the shadow generation.
  44878. */
  44879. shadowFrustumSize: number;
  44880. private _shadowOrthoScale;
  44881. /**
  44882. * Gets the shadow projection scale against the optimal computed one.
  44883. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44884. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44885. */
  44886. /**
  44887. * Sets the shadow projection scale against the optimal computed one.
  44888. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44889. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44890. */
  44891. shadowOrthoScale: number;
  44892. /**
  44893. * Automatically compute the projection matrix to best fit (including all the casters)
  44894. * on each frame.
  44895. */
  44896. autoUpdateExtends: boolean;
  44897. private _orthoLeft;
  44898. private _orthoRight;
  44899. private _orthoTop;
  44900. private _orthoBottom;
  44901. /**
  44902. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44903. * The directional light is emitted from everywhere in the given direction.
  44904. * It can cast shadows.
  44905. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44906. * @param name The friendly name of the light
  44907. * @param direction The direction of the light
  44908. * @param scene The scene the light belongs to
  44909. */
  44910. constructor(name: string, direction: Vector3, scene: Scene);
  44911. /**
  44912. * Returns the string "DirectionalLight".
  44913. * @return The class name
  44914. */
  44915. getClassName(): string;
  44916. /**
  44917. * Returns the integer 1.
  44918. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44919. */
  44920. getTypeID(): number;
  44921. /**
  44922. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44923. * Returns the DirectionalLight Shadow projection matrix.
  44924. */
  44925. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44926. /**
  44927. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44928. * Returns the DirectionalLight Shadow projection matrix.
  44929. */
  44930. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44931. /**
  44932. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44933. * Returns the DirectionalLight Shadow projection matrix.
  44934. */
  44935. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44936. protected _buildUniformLayout(): void;
  44937. /**
  44938. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44939. * @param effect The effect to update
  44940. * @param lightIndex The index of the light in the effect to update
  44941. * @returns The directional light
  44942. */
  44943. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44944. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  44945. /**
  44946. * Gets the minZ used for shadow according to both the scene and the light.
  44947. *
  44948. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44949. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44950. * @param activeCamera The camera we are returning the min for
  44951. * @returns the depth min z
  44952. */
  44953. getDepthMinZ(activeCamera: Camera): number;
  44954. /**
  44955. * Gets the maxZ used for shadow according to both the scene and the light.
  44956. *
  44957. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44958. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44959. * @param activeCamera The camera we are returning the max for
  44960. * @returns the depth max z
  44961. */
  44962. getDepthMaxZ(activeCamera: Camera): number;
  44963. /**
  44964. * Prepares the list of defines specific to the light type.
  44965. * @param defines the list of defines
  44966. * @param lightIndex defines the index of the light for the effect
  44967. */
  44968. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44969. }
  44970. }
  44971. declare module BABYLON {
  44972. /**
  44973. * Class containing static functions to help procedurally build meshes
  44974. */
  44975. export class HemisphereBuilder {
  44976. /**
  44977. * Creates a hemisphere mesh
  44978. * @param name defines the name of the mesh
  44979. * @param options defines the options used to create the mesh
  44980. * @param scene defines the hosting scene
  44981. * @returns the hemisphere mesh
  44982. */
  44983. static CreateHemisphere(name: string, options: {
  44984. segments?: number;
  44985. diameter?: number;
  44986. sideOrientation?: number;
  44987. }, scene: any): Mesh;
  44988. }
  44989. }
  44990. declare module BABYLON {
  44991. /**
  44992. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44993. * These values define a cone of light starting from the position, emitting toward the direction.
  44994. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44995. * and the exponent defines the speed of the decay of the light with distance (reach).
  44996. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44997. */
  44998. export class SpotLight extends ShadowLight {
  44999. private _angle;
  45000. private _innerAngle;
  45001. private _cosHalfAngle;
  45002. private _lightAngleScale;
  45003. private _lightAngleOffset;
  45004. /**
  45005. * Gets the cone angle of the spot light in Radians.
  45006. */
  45007. /**
  45008. * Sets the cone angle of the spot light in Radians.
  45009. */
  45010. angle: number;
  45011. /**
  45012. * Only used in gltf falloff mode, this defines the angle where
  45013. * the directional falloff will start before cutting at angle which could be seen
  45014. * as outer angle.
  45015. */
  45016. /**
  45017. * Only used in gltf falloff mode, this defines the angle where
  45018. * the directional falloff will start before cutting at angle which could be seen
  45019. * as outer angle.
  45020. */
  45021. innerAngle: number;
  45022. private _shadowAngleScale;
  45023. /**
  45024. * Allows scaling the angle of the light for shadow generation only.
  45025. */
  45026. /**
  45027. * Allows scaling the angle of the light for shadow generation only.
  45028. */
  45029. shadowAngleScale: number;
  45030. /**
  45031. * The light decay speed with the distance from the emission spot.
  45032. */
  45033. exponent: number;
  45034. private _projectionTextureMatrix;
  45035. /**
  45036. * Allows reading the projecton texture
  45037. */
  45038. readonly projectionTextureMatrix: Matrix;
  45039. protected _projectionTextureLightNear: number;
  45040. /**
  45041. * Gets the near clip of the Spotlight for texture projection.
  45042. */
  45043. /**
  45044. * Sets the near clip of the Spotlight for texture projection.
  45045. */
  45046. projectionTextureLightNear: number;
  45047. protected _projectionTextureLightFar: number;
  45048. /**
  45049. * Gets the far clip of the Spotlight for texture projection.
  45050. */
  45051. /**
  45052. * Sets the far clip of the Spotlight for texture projection.
  45053. */
  45054. projectionTextureLightFar: number;
  45055. protected _projectionTextureUpDirection: Vector3;
  45056. /**
  45057. * Gets the Up vector of the Spotlight for texture projection.
  45058. */
  45059. /**
  45060. * Sets the Up vector of the Spotlight for texture projection.
  45061. */
  45062. projectionTextureUpDirection: Vector3;
  45063. private _projectionTexture;
  45064. /**
  45065. * Gets the projection texture of the light.
  45066. */
  45067. /**
  45068. * Sets the projection texture of the light.
  45069. */
  45070. projectionTexture: Nullable<BaseTexture>;
  45071. private _projectionTextureViewLightDirty;
  45072. private _projectionTextureProjectionLightDirty;
  45073. private _projectionTextureDirty;
  45074. private _projectionTextureViewTargetVector;
  45075. private _projectionTextureViewLightMatrix;
  45076. private _projectionTextureProjectionLightMatrix;
  45077. private _projectionTextureScalingMatrix;
  45078. /**
  45079. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45080. * It can cast shadows.
  45081. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45082. * @param name The light friendly name
  45083. * @param position The position of the spot light in the scene
  45084. * @param direction The direction of the light in the scene
  45085. * @param angle The cone angle of the light in Radians
  45086. * @param exponent The light decay speed with the distance from the emission spot
  45087. * @param scene The scene the lights belongs to
  45088. */
  45089. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45090. /**
  45091. * Returns the string "SpotLight".
  45092. * @returns the class name
  45093. */
  45094. getClassName(): string;
  45095. /**
  45096. * Returns the integer 2.
  45097. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45098. */
  45099. getTypeID(): number;
  45100. /**
  45101. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45102. */
  45103. protected _setDirection(value: Vector3): void;
  45104. /**
  45105. * Overrides the position setter to recompute the projection texture view light Matrix.
  45106. */
  45107. protected _setPosition(value: Vector3): void;
  45108. /**
  45109. * 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.
  45110. * Returns the SpotLight.
  45111. */
  45112. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45113. protected _computeProjectionTextureViewLightMatrix(): void;
  45114. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45115. /**
  45116. * Main function for light texture projection matrix computing.
  45117. */
  45118. protected _computeProjectionTextureMatrix(): void;
  45119. protected _buildUniformLayout(): void;
  45120. private _computeAngleValues;
  45121. /**
  45122. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45123. * @param effect The effect to update
  45124. * @param lightIndex The index of the light in the effect to update
  45125. * @returns The spot light
  45126. */
  45127. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45128. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45129. /**
  45130. * Disposes the light and the associated resources.
  45131. */
  45132. dispose(): void;
  45133. /**
  45134. * Prepares the list of defines specific to the light type.
  45135. * @param defines the list of defines
  45136. * @param lightIndex defines the index of the light for the effect
  45137. */
  45138. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45139. }
  45140. }
  45141. declare module BABYLON {
  45142. /**
  45143. * Gizmo that enables viewing a light
  45144. */
  45145. export class LightGizmo extends Gizmo {
  45146. private _lightMesh;
  45147. private _material;
  45148. private cachedPosition;
  45149. private cachedForward;
  45150. /**
  45151. * Creates a LightGizmo
  45152. * @param gizmoLayer The utility layer the gizmo will be added to
  45153. */
  45154. constructor(gizmoLayer?: UtilityLayerRenderer);
  45155. private _light;
  45156. /**
  45157. * The light that the gizmo is attached to
  45158. */
  45159. light: Nullable<Light>;
  45160. /**
  45161. * Gets the material used to render the light gizmo
  45162. */
  45163. readonly material: StandardMaterial;
  45164. /**
  45165. * @hidden
  45166. * Updates the gizmo to match the attached mesh's position/rotation
  45167. */
  45168. protected _update(): void;
  45169. private static _Scale;
  45170. /**
  45171. * Creates the lines for a light mesh
  45172. */
  45173. private static _createLightLines;
  45174. /**
  45175. * Disposes of the light gizmo
  45176. */
  45177. dispose(): void;
  45178. private static _CreateHemisphericLightMesh;
  45179. private static _CreatePointLightMesh;
  45180. private static _CreateSpotLightMesh;
  45181. private static _CreateDirectionalLightMesh;
  45182. }
  45183. }
  45184. declare module BABYLON {
  45185. /** @hidden */
  45186. export var backgroundFragmentDeclaration: {
  45187. name: string;
  45188. shader: string;
  45189. };
  45190. }
  45191. declare module BABYLON {
  45192. /** @hidden */
  45193. export var backgroundUboDeclaration: {
  45194. name: string;
  45195. shader: string;
  45196. };
  45197. }
  45198. declare module BABYLON {
  45199. /** @hidden */
  45200. export var backgroundPixelShader: {
  45201. name: string;
  45202. shader: string;
  45203. };
  45204. }
  45205. declare module BABYLON {
  45206. /** @hidden */
  45207. export var backgroundVertexDeclaration: {
  45208. name: string;
  45209. shader: string;
  45210. };
  45211. }
  45212. declare module BABYLON {
  45213. /** @hidden */
  45214. export var backgroundVertexShader: {
  45215. name: string;
  45216. shader: string;
  45217. };
  45218. }
  45219. declare module BABYLON {
  45220. /**
  45221. * Background material used to create an efficient environement around your scene.
  45222. */
  45223. export class BackgroundMaterial extends PushMaterial {
  45224. /**
  45225. * Standard reflectance value at parallel view angle.
  45226. */
  45227. static StandardReflectance0: number;
  45228. /**
  45229. * Standard reflectance value at grazing angle.
  45230. */
  45231. static StandardReflectance90: number;
  45232. protected _primaryColor: Color3;
  45233. /**
  45234. * Key light Color (multiply against the environement texture)
  45235. */
  45236. primaryColor: Color3;
  45237. protected __perceptualColor: Nullable<Color3>;
  45238. /**
  45239. * Experimental Internal Use Only.
  45240. *
  45241. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45242. * This acts as a helper to set the primary color to a more "human friendly" value.
  45243. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45244. * output color as close as possible from the chosen value.
  45245. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45246. * part of lighting setup.)
  45247. */
  45248. _perceptualColor: Nullable<Color3>;
  45249. protected _primaryColorShadowLevel: float;
  45250. /**
  45251. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45252. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45253. */
  45254. primaryColorShadowLevel: float;
  45255. protected _primaryColorHighlightLevel: float;
  45256. /**
  45257. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45258. * The primary color is used at the level chosen to define what the white area would look.
  45259. */
  45260. primaryColorHighlightLevel: float;
  45261. protected _reflectionTexture: Nullable<BaseTexture>;
  45262. /**
  45263. * Reflection Texture used in the material.
  45264. * Should be author in a specific way for the best result (refer to the documentation).
  45265. */
  45266. reflectionTexture: Nullable<BaseTexture>;
  45267. protected _reflectionBlur: float;
  45268. /**
  45269. * Reflection Texture level of blur.
  45270. *
  45271. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45272. * texture twice.
  45273. */
  45274. reflectionBlur: float;
  45275. protected _diffuseTexture: Nullable<BaseTexture>;
  45276. /**
  45277. * Diffuse Texture used in the material.
  45278. * Should be author in a specific way for the best result (refer to the documentation).
  45279. */
  45280. diffuseTexture: Nullable<BaseTexture>;
  45281. protected _shadowLights: Nullable<IShadowLight[]>;
  45282. /**
  45283. * Specify the list of lights casting shadow on the material.
  45284. * All scene shadow lights will be included if null.
  45285. */
  45286. shadowLights: Nullable<IShadowLight[]>;
  45287. protected _shadowLevel: float;
  45288. /**
  45289. * Helps adjusting the shadow to a softer level if required.
  45290. * 0 means black shadows and 1 means no shadows.
  45291. */
  45292. shadowLevel: float;
  45293. protected _sceneCenter: Vector3;
  45294. /**
  45295. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45296. * It is usually zero but might be interesting to modify according to your setup.
  45297. */
  45298. sceneCenter: Vector3;
  45299. protected _opacityFresnel: boolean;
  45300. /**
  45301. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45302. * This helps ensuring a nice transition when the camera goes under the ground.
  45303. */
  45304. opacityFresnel: boolean;
  45305. protected _reflectionFresnel: boolean;
  45306. /**
  45307. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45308. * This helps adding a mirror texture on the ground.
  45309. */
  45310. reflectionFresnel: boolean;
  45311. protected _reflectionFalloffDistance: number;
  45312. /**
  45313. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45314. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45315. */
  45316. reflectionFalloffDistance: number;
  45317. protected _reflectionAmount: number;
  45318. /**
  45319. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45320. */
  45321. reflectionAmount: number;
  45322. protected _reflectionReflectance0: number;
  45323. /**
  45324. * This specifies the weight of the reflection at grazing angle.
  45325. */
  45326. reflectionReflectance0: number;
  45327. protected _reflectionReflectance90: number;
  45328. /**
  45329. * This specifies the weight of the reflection at a perpendicular point of view.
  45330. */
  45331. reflectionReflectance90: number;
  45332. /**
  45333. * Sets the reflection reflectance fresnel values according to the default standard
  45334. * empirically know to work well :-)
  45335. */
  45336. reflectionStandardFresnelWeight: number;
  45337. protected _useRGBColor: boolean;
  45338. /**
  45339. * Helps to directly use the maps channels instead of their level.
  45340. */
  45341. useRGBColor: boolean;
  45342. protected _enableNoise: boolean;
  45343. /**
  45344. * This helps reducing the banding effect that could occur on the background.
  45345. */
  45346. enableNoise: boolean;
  45347. /**
  45348. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45349. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45350. * Recommended to be keep at 1.0 except for special cases.
  45351. */
  45352. fovMultiplier: number;
  45353. private _fovMultiplier;
  45354. /**
  45355. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45356. */
  45357. useEquirectangularFOV: boolean;
  45358. private _maxSimultaneousLights;
  45359. /**
  45360. * Number of Simultaneous lights allowed on the material.
  45361. */
  45362. maxSimultaneousLights: int;
  45363. /**
  45364. * Default configuration related to image processing available in the Background Material.
  45365. */
  45366. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45367. /**
  45368. * Keep track of the image processing observer to allow dispose and replace.
  45369. */
  45370. private _imageProcessingObserver;
  45371. /**
  45372. * Attaches a new image processing configuration to the PBR Material.
  45373. * @param configuration (if null the scene configuration will be use)
  45374. */
  45375. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45376. /**
  45377. * Gets the image processing configuration used either in this material.
  45378. */
  45379. /**
  45380. * Sets the Default image processing configuration used either in the this material.
  45381. *
  45382. * If sets to null, the scene one is in use.
  45383. */
  45384. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45385. /**
  45386. * Gets wether the color curves effect is enabled.
  45387. */
  45388. /**
  45389. * Sets wether the color curves effect is enabled.
  45390. */
  45391. cameraColorCurvesEnabled: boolean;
  45392. /**
  45393. * Gets wether the color grading effect is enabled.
  45394. */
  45395. /**
  45396. * Gets wether the color grading effect is enabled.
  45397. */
  45398. cameraColorGradingEnabled: boolean;
  45399. /**
  45400. * Gets wether tonemapping is enabled or not.
  45401. */
  45402. /**
  45403. * Sets wether tonemapping is enabled or not
  45404. */
  45405. cameraToneMappingEnabled: boolean;
  45406. /**
  45407. * The camera exposure used on this material.
  45408. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45409. * This corresponds to a photographic exposure.
  45410. */
  45411. /**
  45412. * The camera exposure used on this material.
  45413. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45414. * This corresponds to a photographic exposure.
  45415. */
  45416. cameraExposure: float;
  45417. /**
  45418. * Gets The camera contrast used on this material.
  45419. */
  45420. /**
  45421. * Sets The camera contrast used on this material.
  45422. */
  45423. cameraContrast: float;
  45424. /**
  45425. * Gets the Color Grading 2D Lookup Texture.
  45426. */
  45427. /**
  45428. * Sets the Color Grading 2D Lookup Texture.
  45429. */
  45430. cameraColorGradingTexture: Nullable<BaseTexture>;
  45431. /**
  45432. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45433. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45434. * 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;
  45435. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45436. */
  45437. /**
  45438. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45439. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45440. * 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;
  45441. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45442. */
  45443. cameraColorCurves: Nullable<ColorCurves>;
  45444. /**
  45445. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45446. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45447. */
  45448. switchToBGR: boolean;
  45449. private _renderTargets;
  45450. private _reflectionControls;
  45451. private _white;
  45452. private _primaryShadowColor;
  45453. private _primaryHighlightColor;
  45454. /**
  45455. * Instantiates a Background Material in the given scene
  45456. * @param name The friendly name of the material
  45457. * @param scene The scene to add the material to
  45458. */
  45459. constructor(name: string, scene: Scene);
  45460. /**
  45461. * Gets a boolean indicating that current material needs to register RTT
  45462. */
  45463. readonly hasRenderTargetTextures: boolean;
  45464. /**
  45465. * The entire material has been created in order to prevent overdraw.
  45466. * @returns false
  45467. */
  45468. needAlphaTesting(): boolean;
  45469. /**
  45470. * The entire material has been created in order to prevent overdraw.
  45471. * @returns true if blending is enable
  45472. */
  45473. needAlphaBlending(): boolean;
  45474. /**
  45475. * Checks wether the material is ready to be rendered for a given mesh.
  45476. * @param mesh The mesh to render
  45477. * @param subMesh The submesh to check against
  45478. * @param useInstances Specify wether or not the material is used with instances
  45479. * @returns true if all the dependencies are ready (Textures, Effects...)
  45480. */
  45481. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45482. /**
  45483. * Compute the primary color according to the chosen perceptual color.
  45484. */
  45485. private _computePrimaryColorFromPerceptualColor;
  45486. /**
  45487. * Compute the highlights and shadow colors according to their chosen levels.
  45488. */
  45489. private _computePrimaryColors;
  45490. /**
  45491. * Build the uniform buffer used in the material.
  45492. */
  45493. buildUniformLayout(): void;
  45494. /**
  45495. * Unbind the material.
  45496. */
  45497. unbind(): void;
  45498. /**
  45499. * Bind only the world matrix to the material.
  45500. * @param world The world matrix to bind.
  45501. */
  45502. bindOnlyWorldMatrix(world: Matrix): void;
  45503. /**
  45504. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45505. * @param world The world matrix to bind.
  45506. * @param subMesh The submesh to bind for.
  45507. */
  45508. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45509. /**
  45510. * Checks to see if a texture is used in the material.
  45511. * @param texture - Base texture to use.
  45512. * @returns - Boolean specifying if a texture is used in the material.
  45513. */
  45514. hasTexture(texture: BaseTexture): boolean;
  45515. /**
  45516. * Dispose the material.
  45517. * @param forceDisposeEffect Force disposal of the associated effect.
  45518. * @param forceDisposeTextures Force disposal of the associated textures.
  45519. */
  45520. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45521. /**
  45522. * Clones the material.
  45523. * @param name The cloned name.
  45524. * @returns The cloned material.
  45525. */
  45526. clone(name: string): BackgroundMaterial;
  45527. /**
  45528. * Serializes the current material to its JSON representation.
  45529. * @returns The JSON representation.
  45530. */
  45531. serialize(): any;
  45532. /**
  45533. * Gets the class name of the material
  45534. * @returns "BackgroundMaterial"
  45535. */
  45536. getClassName(): string;
  45537. /**
  45538. * Parse a JSON input to create back a background material.
  45539. * @param source The JSON data to parse
  45540. * @param scene The scene to create the parsed material in
  45541. * @param rootUrl The root url of the assets the material depends upon
  45542. * @returns the instantiated BackgroundMaterial.
  45543. */
  45544. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45545. }
  45546. }
  45547. declare module BABYLON {
  45548. /**
  45549. * Represents the different options available during the creation of
  45550. * a Environment helper.
  45551. *
  45552. * This can control the default ground, skybox and image processing setup of your scene.
  45553. */
  45554. export interface IEnvironmentHelperOptions {
  45555. /**
  45556. * Specifies wether or not to create a ground.
  45557. * True by default.
  45558. */
  45559. createGround: boolean;
  45560. /**
  45561. * Specifies the ground size.
  45562. * 15 by default.
  45563. */
  45564. groundSize: number;
  45565. /**
  45566. * The texture used on the ground for the main color.
  45567. * Comes from the BabylonJS CDN by default.
  45568. *
  45569. * Remarks: Can be either a texture or a url.
  45570. */
  45571. groundTexture: string | BaseTexture;
  45572. /**
  45573. * The color mixed in the ground texture by default.
  45574. * BabylonJS clearColor by default.
  45575. */
  45576. groundColor: Color3;
  45577. /**
  45578. * Specifies the ground opacity.
  45579. * 1 by default.
  45580. */
  45581. groundOpacity: number;
  45582. /**
  45583. * Enables the ground to receive shadows.
  45584. * True by default.
  45585. */
  45586. enableGroundShadow: boolean;
  45587. /**
  45588. * Helps preventing the shadow to be fully black on the ground.
  45589. * 0.5 by default.
  45590. */
  45591. groundShadowLevel: number;
  45592. /**
  45593. * Creates a mirror texture attach to the ground.
  45594. * false by default.
  45595. */
  45596. enableGroundMirror: boolean;
  45597. /**
  45598. * Specifies the ground mirror size ratio.
  45599. * 0.3 by default as the default kernel is 64.
  45600. */
  45601. groundMirrorSizeRatio: number;
  45602. /**
  45603. * Specifies the ground mirror blur kernel size.
  45604. * 64 by default.
  45605. */
  45606. groundMirrorBlurKernel: number;
  45607. /**
  45608. * Specifies the ground mirror visibility amount.
  45609. * 1 by default
  45610. */
  45611. groundMirrorAmount: number;
  45612. /**
  45613. * Specifies the ground mirror reflectance weight.
  45614. * This uses the standard weight of the background material to setup the fresnel effect
  45615. * of the mirror.
  45616. * 1 by default.
  45617. */
  45618. groundMirrorFresnelWeight: number;
  45619. /**
  45620. * Specifies the ground mirror Falloff distance.
  45621. * This can helps reducing the size of the reflection.
  45622. * 0 by Default.
  45623. */
  45624. groundMirrorFallOffDistance: number;
  45625. /**
  45626. * Specifies the ground mirror texture type.
  45627. * Unsigned Int by Default.
  45628. */
  45629. groundMirrorTextureType: number;
  45630. /**
  45631. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45632. * the shown objects.
  45633. */
  45634. groundYBias: number;
  45635. /**
  45636. * Specifies wether or not to create a skybox.
  45637. * True by default.
  45638. */
  45639. createSkybox: boolean;
  45640. /**
  45641. * Specifies the skybox size.
  45642. * 20 by default.
  45643. */
  45644. skyboxSize: number;
  45645. /**
  45646. * The texture used on the skybox for the main color.
  45647. * Comes from the BabylonJS CDN by default.
  45648. *
  45649. * Remarks: Can be either a texture or a url.
  45650. */
  45651. skyboxTexture: string | BaseTexture;
  45652. /**
  45653. * The color mixed in the skybox texture by default.
  45654. * BabylonJS clearColor by default.
  45655. */
  45656. skyboxColor: Color3;
  45657. /**
  45658. * The background rotation around the Y axis of the scene.
  45659. * This helps aligning the key lights of your scene with the background.
  45660. * 0 by default.
  45661. */
  45662. backgroundYRotation: number;
  45663. /**
  45664. * Compute automatically the size of the elements to best fit with the scene.
  45665. */
  45666. sizeAuto: boolean;
  45667. /**
  45668. * Default position of the rootMesh if autoSize is not true.
  45669. */
  45670. rootPosition: Vector3;
  45671. /**
  45672. * Sets up the image processing in the scene.
  45673. * true by default.
  45674. */
  45675. setupImageProcessing: boolean;
  45676. /**
  45677. * The texture used as your environment texture in the scene.
  45678. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45679. *
  45680. * Remarks: Can be either a texture or a url.
  45681. */
  45682. environmentTexture: string | BaseTexture;
  45683. /**
  45684. * The value of the exposure to apply to the scene.
  45685. * 0.6 by default if setupImageProcessing is true.
  45686. */
  45687. cameraExposure: number;
  45688. /**
  45689. * The value of the contrast to apply to the scene.
  45690. * 1.6 by default if setupImageProcessing is true.
  45691. */
  45692. cameraContrast: number;
  45693. /**
  45694. * Specifies wether or not tonemapping should be enabled in the scene.
  45695. * true by default if setupImageProcessing is true.
  45696. */
  45697. toneMappingEnabled: boolean;
  45698. }
  45699. /**
  45700. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45701. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45702. * It also helps with the default setup of your imageProcessing configuration.
  45703. */
  45704. export class EnvironmentHelper {
  45705. /**
  45706. * Default ground texture URL.
  45707. */
  45708. private static _groundTextureCDNUrl;
  45709. /**
  45710. * Default skybox texture URL.
  45711. */
  45712. private static _skyboxTextureCDNUrl;
  45713. /**
  45714. * Default environment texture URL.
  45715. */
  45716. private static _environmentTextureCDNUrl;
  45717. /**
  45718. * Creates the default options for the helper.
  45719. */
  45720. private static _getDefaultOptions;
  45721. private _rootMesh;
  45722. /**
  45723. * Gets the root mesh created by the helper.
  45724. */
  45725. readonly rootMesh: Mesh;
  45726. private _skybox;
  45727. /**
  45728. * Gets the skybox created by the helper.
  45729. */
  45730. readonly skybox: Nullable<Mesh>;
  45731. private _skyboxTexture;
  45732. /**
  45733. * Gets the skybox texture created by the helper.
  45734. */
  45735. readonly skyboxTexture: Nullable<BaseTexture>;
  45736. private _skyboxMaterial;
  45737. /**
  45738. * Gets the skybox material created by the helper.
  45739. */
  45740. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45741. private _ground;
  45742. /**
  45743. * Gets the ground mesh created by the helper.
  45744. */
  45745. readonly ground: Nullable<Mesh>;
  45746. private _groundTexture;
  45747. /**
  45748. * Gets the ground texture created by the helper.
  45749. */
  45750. readonly groundTexture: Nullable<BaseTexture>;
  45751. private _groundMirror;
  45752. /**
  45753. * Gets the ground mirror created by the helper.
  45754. */
  45755. readonly groundMirror: Nullable<MirrorTexture>;
  45756. /**
  45757. * Gets the ground mirror render list to helps pushing the meshes
  45758. * you wish in the ground reflection.
  45759. */
  45760. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45761. private _groundMaterial;
  45762. /**
  45763. * Gets the ground material created by the helper.
  45764. */
  45765. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45766. /**
  45767. * Stores the creation options.
  45768. */
  45769. private readonly _scene;
  45770. private _options;
  45771. /**
  45772. * This observable will be notified with any error during the creation of the environment,
  45773. * mainly texture creation errors.
  45774. */
  45775. onErrorObservable: Observable<{
  45776. message?: string;
  45777. exception?: any;
  45778. }>;
  45779. /**
  45780. * constructor
  45781. * @param options Defines the options we want to customize the helper
  45782. * @param scene The scene to add the material to
  45783. */
  45784. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45785. /**
  45786. * Updates the background according to the new options
  45787. * @param options
  45788. */
  45789. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45790. /**
  45791. * Sets the primary color of all the available elements.
  45792. * @param color the main color to affect to the ground and the background
  45793. */
  45794. setMainColor(color: Color3): void;
  45795. /**
  45796. * Setup the image processing according to the specified options.
  45797. */
  45798. private _setupImageProcessing;
  45799. /**
  45800. * Setup the environment texture according to the specified options.
  45801. */
  45802. private _setupEnvironmentTexture;
  45803. /**
  45804. * Setup the background according to the specified options.
  45805. */
  45806. private _setupBackground;
  45807. /**
  45808. * Get the scene sizes according to the setup.
  45809. */
  45810. private _getSceneSize;
  45811. /**
  45812. * Setup the ground according to the specified options.
  45813. */
  45814. private _setupGround;
  45815. /**
  45816. * Setup the ground material according to the specified options.
  45817. */
  45818. private _setupGroundMaterial;
  45819. /**
  45820. * Setup the ground diffuse texture according to the specified options.
  45821. */
  45822. private _setupGroundDiffuseTexture;
  45823. /**
  45824. * Setup the ground mirror texture according to the specified options.
  45825. */
  45826. private _setupGroundMirrorTexture;
  45827. /**
  45828. * Setup the ground to receive the mirror texture.
  45829. */
  45830. private _setupMirrorInGroundMaterial;
  45831. /**
  45832. * Setup the skybox according to the specified options.
  45833. */
  45834. private _setupSkybox;
  45835. /**
  45836. * Setup the skybox material according to the specified options.
  45837. */
  45838. private _setupSkyboxMaterial;
  45839. /**
  45840. * Setup the skybox reflection texture according to the specified options.
  45841. */
  45842. private _setupSkyboxReflectionTexture;
  45843. private _errorHandler;
  45844. /**
  45845. * Dispose all the elements created by the Helper.
  45846. */
  45847. dispose(): void;
  45848. }
  45849. }
  45850. declare module BABYLON {
  45851. /**
  45852. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45853. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45854. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45855. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45856. */
  45857. export class PhotoDome extends TransformNode {
  45858. /**
  45859. * Define the image as a Monoscopic panoramic 360 image.
  45860. */
  45861. static readonly MODE_MONOSCOPIC: number;
  45862. /**
  45863. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45864. */
  45865. static readonly MODE_TOPBOTTOM: number;
  45866. /**
  45867. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45868. */
  45869. static readonly MODE_SIDEBYSIDE: number;
  45870. private _useDirectMapping;
  45871. /**
  45872. * The texture being displayed on the sphere
  45873. */
  45874. protected _photoTexture: Texture;
  45875. /**
  45876. * Gets or sets the texture being displayed on the sphere
  45877. */
  45878. photoTexture: Texture;
  45879. /**
  45880. * Observable raised when an error occured while loading the 360 image
  45881. */
  45882. onLoadErrorObservable: Observable<string>;
  45883. /**
  45884. * The skybox material
  45885. */
  45886. protected _material: BackgroundMaterial;
  45887. /**
  45888. * The surface used for the skybox
  45889. */
  45890. protected _mesh: Mesh;
  45891. /**
  45892. * Gets the mesh used for the skybox.
  45893. */
  45894. readonly mesh: Mesh;
  45895. /**
  45896. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45897. * Also see the options.resolution property.
  45898. */
  45899. fovMultiplier: number;
  45900. private _imageMode;
  45901. /**
  45902. * Gets or set the current video mode for the video. It can be:
  45903. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45904. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45905. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45906. */
  45907. imageMode: number;
  45908. /**
  45909. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45910. * @param name Element's name, child elements will append suffixes for their own names.
  45911. * @param urlsOfPhoto defines the url of the photo to display
  45912. * @param options defines an object containing optional or exposed sub element properties
  45913. * @param onError defines a callback called when an error occured while loading the texture
  45914. */
  45915. constructor(name: string, urlOfPhoto: string, options: {
  45916. resolution?: number;
  45917. size?: number;
  45918. useDirectMapping?: boolean;
  45919. faceForward?: boolean;
  45920. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45921. private _onBeforeCameraRenderObserver;
  45922. private _changeImageMode;
  45923. /**
  45924. * Releases resources associated with this node.
  45925. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45926. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45927. */
  45928. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45929. }
  45930. }
  45931. declare module BABYLON {
  45932. /**
  45933. * Class used to host RGBD texture specific utilities
  45934. */
  45935. export class RGBDTextureTools {
  45936. /**
  45937. * Expand the RGBD Texture from RGBD to Half Float if possible.
  45938. * @param texture the texture to expand.
  45939. */
  45940. static ExpandRGBDTexture(texture: Texture): void;
  45941. }
  45942. }
  45943. declare module BABYLON {
  45944. /**
  45945. * Class used to host texture specific utilities
  45946. */
  45947. export class BRDFTextureTools {
  45948. /**
  45949. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45950. * @param scene defines the hosting scene
  45951. * @returns the environment BRDF texture
  45952. */
  45953. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45954. private static _environmentBRDFBase64Texture;
  45955. }
  45956. }
  45957. declare module BABYLON {
  45958. /**
  45959. * @hidden
  45960. */
  45961. export interface IMaterialClearCoatDefines {
  45962. CLEARCOAT: boolean;
  45963. CLEARCOAT_DEFAULTIOR: boolean;
  45964. CLEARCOAT_TEXTURE: boolean;
  45965. CLEARCOAT_TEXTUREDIRECTUV: number;
  45966. CLEARCOAT_BUMP: boolean;
  45967. CLEARCOAT_BUMPDIRECTUV: number;
  45968. CLEARCOAT_TINT: boolean;
  45969. CLEARCOAT_TINT_TEXTURE: boolean;
  45970. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45971. /** @hidden */
  45972. _areTexturesDirty: boolean;
  45973. }
  45974. /**
  45975. * Define the code related to the clear coat parameters of the pbr material.
  45976. */
  45977. export class PBRClearCoatConfiguration {
  45978. /**
  45979. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45980. * The default fits with a polyurethane material.
  45981. */
  45982. private static readonly _DefaultIndexOfRefraction;
  45983. private _isEnabled;
  45984. /**
  45985. * Defines if the clear coat is enabled in the material.
  45986. */
  45987. isEnabled: boolean;
  45988. /**
  45989. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45990. */
  45991. intensity: number;
  45992. /**
  45993. * Defines the clear coat layer roughness.
  45994. */
  45995. roughness: number;
  45996. private _indexOfRefraction;
  45997. /**
  45998. * Defines the index of refraction of the clear coat.
  45999. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46000. * The default fits with a polyurethane material.
  46001. * Changing the default value is more performance intensive.
  46002. */
  46003. indexOfRefraction: number;
  46004. private _texture;
  46005. /**
  46006. * Stores the clear coat values in a texture.
  46007. */
  46008. texture: Nullable<BaseTexture>;
  46009. private _bumpTexture;
  46010. /**
  46011. * Define the clear coat specific bump texture.
  46012. */
  46013. bumpTexture: Nullable<BaseTexture>;
  46014. private _isTintEnabled;
  46015. /**
  46016. * Defines if the clear coat tint is enabled in the material.
  46017. */
  46018. isTintEnabled: boolean;
  46019. /**
  46020. * Defines the clear coat tint of the material.
  46021. * This is only use if tint is enabled
  46022. */
  46023. tintColor: Color3;
  46024. /**
  46025. * Defines the distance at which the tint color should be found in the
  46026. * clear coat media.
  46027. * This is only use if tint is enabled
  46028. */
  46029. tintColorAtDistance: number;
  46030. /**
  46031. * Defines the clear coat layer thickness.
  46032. * This is only use if tint is enabled
  46033. */
  46034. tintThickness: number;
  46035. private _tintTexture;
  46036. /**
  46037. * Stores the clear tint values in a texture.
  46038. * rgb is tint
  46039. * a is a thickness factor
  46040. */
  46041. tintTexture: Nullable<BaseTexture>;
  46042. /** @hidden */
  46043. private _internalMarkAllSubMeshesAsTexturesDirty;
  46044. /** @hidden */
  46045. _markAllSubMeshesAsTexturesDirty(): void;
  46046. /**
  46047. * Instantiate a new istance of clear coat configuration.
  46048. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46049. */
  46050. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46051. /**
  46052. * Gets wehter the submesh is ready to be used or not.
  46053. * @param defines the list of "defines" to update.
  46054. * @param scene defines the scene the material belongs to.
  46055. * @param engine defines the engine the material belongs to.
  46056. * @param disableBumpMap defines wether the material disables bump or not.
  46057. * @returns - boolean indicating that the submesh is ready or not.
  46058. */
  46059. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46060. /**
  46061. * Checks to see if a texture is used in the material.
  46062. * @param defines the list of "defines" to update.
  46063. * @param scene defines the scene to the material belongs to.
  46064. */
  46065. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46066. /**
  46067. * Binds the material data.
  46068. * @param uniformBuffer defines the Uniform buffer to fill in.
  46069. * @param scene defines the scene the material belongs to.
  46070. * @param engine defines the engine the material belongs to.
  46071. * @param disableBumpMap defines wether the material disables bump or not.
  46072. * @param isFrozen defines wether the material is frozen or not.
  46073. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46074. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46075. */
  46076. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46077. /**
  46078. * Checks to see if a texture is used in the material.
  46079. * @param texture - Base texture to use.
  46080. * @returns - Boolean specifying if a texture is used in the material.
  46081. */
  46082. hasTexture(texture: BaseTexture): boolean;
  46083. /**
  46084. * Returns an array of the actively used textures.
  46085. * @param activeTextures Array of BaseTextures
  46086. */
  46087. getActiveTextures(activeTextures: BaseTexture[]): void;
  46088. /**
  46089. * Returns the animatable textures.
  46090. * @param animatables Array of animatable textures.
  46091. */
  46092. getAnimatables(animatables: IAnimatable[]): void;
  46093. /**
  46094. * Disposes the resources of the material.
  46095. * @param forceDisposeTextures - Forces the disposal of all textures.
  46096. */
  46097. dispose(forceDisposeTextures?: boolean): void;
  46098. /**
  46099. * Get the current class name of the texture useful for serialization or dynamic coding.
  46100. * @returns "PBRClearCoatConfiguration"
  46101. */
  46102. getClassName(): string;
  46103. /**
  46104. * Add fallbacks to the effect fallbacks list.
  46105. * @param defines defines the Base texture to use.
  46106. * @param fallbacks defines the current fallback list.
  46107. * @param currentRank defines the current fallback rank.
  46108. * @returns the new fallback rank.
  46109. */
  46110. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46111. /**
  46112. * Add the required uniforms to the current list.
  46113. * @param uniforms defines the current uniform list.
  46114. */
  46115. static AddUniforms(uniforms: string[]): void;
  46116. /**
  46117. * Add the required samplers to the current list.
  46118. * @param samplers defines the current sampler list.
  46119. */
  46120. static AddSamplers(samplers: string[]): void;
  46121. /**
  46122. * Add the required uniforms to the current buffer.
  46123. * @param uniformBuffer defines the current uniform buffer.
  46124. */
  46125. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46126. /**
  46127. * Makes a duplicate of the current configuration into another one.
  46128. * @param clearCoatConfiguration define the config where to copy the info
  46129. */
  46130. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46131. /**
  46132. * Serializes this clear coat configuration.
  46133. * @returns - An object with the serialized config.
  46134. */
  46135. serialize(): any;
  46136. /**
  46137. * Parses a anisotropy Configuration from a serialized object.
  46138. * @param source - Serialized object.
  46139. * @param scene Defines the scene we are parsing for
  46140. * @param rootUrl Defines the rootUrl to load from
  46141. */
  46142. parse(source: any, scene: Scene, rootUrl: string): void;
  46143. }
  46144. }
  46145. declare module BABYLON {
  46146. /**
  46147. * @hidden
  46148. */
  46149. export interface IMaterialAnisotropicDefines {
  46150. ANISOTROPIC: boolean;
  46151. ANISOTROPIC_TEXTURE: boolean;
  46152. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46153. MAINUV1: boolean;
  46154. _areTexturesDirty: boolean;
  46155. _needUVs: boolean;
  46156. }
  46157. /**
  46158. * Define the code related to the anisotropic parameters of the pbr material.
  46159. */
  46160. export class PBRAnisotropicConfiguration {
  46161. private _isEnabled;
  46162. /**
  46163. * Defines if the anisotropy is enabled in the material.
  46164. */
  46165. isEnabled: boolean;
  46166. /**
  46167. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46168. */
  46169. intensity: number;
  46170. /**
  46171. * Defines if the effect is along the tangents, bitangents or in between.
  46172. * By default, the effect is "strectching" the highlights along the tangents.
  46173. */
  46174. direction: Vector2;
  46175. private _texture;
  46176. /**
  46177. * Stores the anisotropy values in a texture.
  46178. * rg is direction (like normal from -1 to 1)
  46179. * b is a intensity
  46180. */
  46181. texture: Nullable<BaseTexture>;
  46182. /** @hidden */
  46183. private _internalMarkAllSubMeshesAsTexturesDirty;
  46184. /** @hidden */
  46185. _markAllSubMeshesAsTexturesDirty(): void;
  46186. /**
  46187. * Instantiate a new istance of anisotropy configuration.
  46188. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46189. */
  46190. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46191. /**
  46192. * Specifies that the submesh is ready to be used.
  46193. * @param defines the list of "defines" to update.
  46194. * @param scene defines the scene the material belongs to.
  46195. * @returns - boolean indicating that the submesh is ready or not.
  46196. */
  46197. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46198. /**
  46199. * Checks to see if a texture is used in the material.
  46200. * @param defines the list of "defines" to update.
  46201. * @param mesh the mesh we are preparing the defines for.
  46202. * @param scene defines the scene the material belongs to.
  46203. */
  46204. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46205. /**
  46206. * Binds the material data.
  46207. * @param uniformBuffer defines the Uniform buffer to fill in.
  46208. * @param scene defines the scene the material belongs to.
  46209. * @param isFrozen defines wether the material is frozen or not.
  46210. */
  46211. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46212. /**
  46213. * Checks to see if a texture is used in the material.
  46214. * @param texture - Base texture to use.
  46215. * @returns - Boolean specifying if a texture is used in the material.
  46216. */
  46217. hasTexture(texture: BaseTexture): boolean;
  46218. /**
  46219. * Returns an array of the actively used textures.
  46220. * @param activeTextures Array of BaseTextures
  46221. */
  46222. getActiveTextures(activeTextures: BaseTexture[]): void;
  46223. /**
  46224. * Returns the animatable textures.
  46225. * @param animatables Array of animatable textures.
  46226. */
  46227. getAnimatables(animatables: IAnimatable[]): void;
  46228. /**
  46229. * Disposes the resources of the material.
  46230. * @param forceDisposeTextures - Forces the disposal of all textures.
  46231. */
  46232. dispose(forceDisposeTextures?: boolean): void;
  46233. /**
  46234. * Get the current class name of the texture useful for serialization or dynamic coding.
  46235. * @returns "PBRAnisotropicConfiguration"
  46236. */
  46237. getClassName(): string;
  46238. /**
  46239. * Add fallbacks to the effect fallbacks list.
  46240. * @param defines defines the Base texture to use.
  46241. * @param fallbacks defines the current fallback list.
  46242. * @param currentRank defines the current fallback rank.
  46243. * @returns the new fallback rank.
  46244. */
  46245. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46246. /**
  46247. * Add the required uniforms to the current list.
  46248. * @param uniforms defines the current uniform list.
  46249. */
  46250. static AddUniforms(uniforms: string[]): void;
  46251. /**
  46252. * Add the required uniforms to the current buffer.
  46253. * @param uniformBuffer defines the current uniform buffer.
  46254. */
  46255. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46256. /**
  46257. * Add the required samplers to the current list.
  46258. * @param samplers defines the current sampler list.
  46259. */
  46260. static AddSamplers(samplers: string[]): void;
  46261. /**
  46262. * Makes a duplicate of the current configuration into another one.
  46263. * @param anisotropicConfiguration define the config where to copy the info
  46264. */
  46265. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46266. /**
  46267. * Serializes this anisotropy configuration.
  46268. * @returns - An object with the serialized config.
  46269. */
  46270. serialize(): any;
  46271. /**
  46272. * Parses a anisotropy Configuration from a serialized object.
  46273. * @param source - Serialized object.
  46274. * @param scene Defines the scene we are parsing for
  46275. * @param rootUrl Defines the rootUrl to load from
  46276. */
  46277. parse(source: any, scene: Scene, rootUrl: string): void;
  46278. }
  46279. }
  46280. declare module BABYLON {
  46281. /**
  46282. * @hidden
  46283. */
  46284. export interface IMaterialBRDFDefines {
  46285. BRDF_V_HEIGHT_CORRELATED: boolean;
  46286. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46287. SPHERICAL_HARMONICS: boolean;
  46288. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46289. /** @hidden */
  46290. _areMiscDirty: boolean;
  46291. }
  46292. /**
  46293. * Define the code related to the BRDF parameters of the pbr material.
  46294. */
  46295. export class PBRBRDFConfiguration {
  46296. /**
  46297. * Default value used for the energy conservation.
  46298. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46299. */
  46300. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46301. /**
  46302. * Default value used for the Smith Visibility Height Correlated mode.
  46303. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46304. */
  46305. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46306. /**
  46307. * Default value used for the IBL diffuse part.
  46308. * This can help switching back to the polynomials mode globally which is a tiny bit
  46309. * less GPU intensive at the drawback of a lower quality.
  46310. */
  46311. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46312. /**
  46313. * Default value used for activating energy conservation for the specular workflow.
  46314. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46315. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46316. */
  46317. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  46318. private _useEnergyConservation;
  46319. /**
  46320. * Defines if the material uses energy conservation.
  46321. */
  46322. useEnergyConservation: boolean;
  46323. private _useSmithVisibilityHeightCorrelated;
  46324. /**
  46325. * LEGACY Mode set to false
  46326. * Defines if the material uses height smith correlated visibility term.
  46327. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46328. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46329. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46330. * Not relying on height correlated will also disable energy conservation.
  46331. */
  46332. useSmithVisibilityHeightCorrelated: boolean;
  46333. private _useSphericalHarmonics;
  46334. /**
  46335. * LEGACY Mode set to false
  46336. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46337. * diffuse part of the IBL.
  46338. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46339. * to the ground truth.
  46340. */
  46341. useSphericalHarmonics: boolean;
  46342. private _useSpecularGlossinessInputEnergyConservation;
  46343. /**
  46344. * Defines if the material uses energy conservation, when the specular workflow is active.
  46345. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46346. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46347. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  46348. */
  46349. useSpecularGlossinessInputEnergyConservation: boolean;
  46350. /** @hidden */
  46351. private _internalMarkAllSubMeshesAsMiscDirty;
  46352. /** @hidden */
  46353. _markAllSubMeshesAsMiscDirty(): void;
  46354. /**
  46355. * Instantiate a new istance of clear coat configuration.
  46356. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46357. */
  46358. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46359. /**
  46360. * Checks to see if a texture is used in the material.
  46361. * @param defines the list of "defines" to update.
  46362. */
  46363. prepareDefines(defines: IMaterialBRDFDefines): void;
  46364. /**
  46365. * Get the current class name of the texture useful for serialization or dynamic coding.
  46366. * @returns "PBRClearCoatConfiguration"
  46367. */
  46368. getClassName(): string;
  46369. /**
  46370. * Makes a duplicate of the current configuration into another one.
  46371. * @param brdfConfiguration define the config where to copy the info
  46372. */
  46373. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46374. /**
  46375. * Serializes this BRDF configuration.
  46376. * @returns - An object with the serialized config.
  46377. */
  46378. serialize(): any;
  46379. /**
  46380. * Parses a anisotropy Configuration from a serialized object.
  46381. * @param source - Serialized object.
  46382. * @param scene Defines the scene we are parsing for
  46383. * @param rootUrl Defines the rootUrl to load from
  46384. */
  46385. parse(source: any, scene: Scene, rootUrl: string): void;
  46386. }
  46387. }
  46388. declare module BABYLON {
  46389. /**
  46390. * @hidden
  46391. */
  46392. export interface IMaterialSheenDefines {
  46393. SHEEN: boolean;
  46394. SHEEN_TEXTURE: boolean;
  46395. SHEEN_TEXTUREDIRECTUV: number;
  46396. SHEEN_LINKWITHALBEDO: boolean;
  46397. /** @hidden */
  46398. _areTexturesDirty: boolean;
  46399. }
  46400. /**
  46401. * Define the code related to the Sheen parameters of the pbr material.
  46402. */
  46403. export class PBRSheenConfiguration {
  46404. private _isEnabled;
  46405. /**
  46406. * Defines if the material uses sheen.
  46407. */
  46408. isEnabled: boolean;
  46409. private _linkSheenWithAlbedo;
  46410. /**
  46411. * Defines if the sheen is linked to the sheen color.
  46412. */
  46413. linkSheenWithAlbedo: boolean;
  46414. /**
  46415. * Defines the sheen intensity.
  46416. */
  46417. intensity: number;
  46418. /**
  46419. * Defines the sheen color.
  46420. */
  46421. color: Color3;
  46422. private _texture;
  46423. /**
  46424. * Stores the sheen tint values in a texture.
  46425. * rgb is tint
  46426. * a is a intensity
  46427. */
  46428. texture: Nullable<BaseTexture>;
  46429. /** @hidden */
  46430. private _internalMarkAllSubMeshesAsTexturesDirty;
  46431. /** @hidden */
  46432. _markAllSubMeshesAsTexturesDirty(): void;
  46433. /**
  46434. * Instantiate a new istance of clear coat configuration.
  46435. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46436. */
  46437. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46438. /**
  46439. * Specifies that the submesh is ready to be used.
  46440. * @param defines the list of "defines" to update.
  46441. * @param scene defines the scene the material belongs to.
  46442. * @returns - boolean indicating that the submesh is ready or not.
  46443. */
  46444. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46445. /**
  46446. * Checks to see if a texture is used in the material.
  46447. * @param defines the list of "defines" to update.
  46448. * @param scene defines the scene the material belongs to.
  46449. */
  46450. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46451. /**
  46452. * Binds the material data.
  46453. * @param uniformBuffer defines the Uniform buffer to fill in.
  46454. * @param scene defines the scene the material belongs to.
  46455. * @param isFrozen defines wether the material is frozen or not.
  46456. */
  46457. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46458. /**
  46459. * Checks to see if a texture is used in the material.
  46460. * @param texture - Base texture to use.
  46461. * @returns - Boolean specifying if a texture is used in the material.
  46462. */
  46463. hasTexture(texture: BaseTexture): boolean;
  46464. /**
  46465. * Returns an array of the actively used textures.
  46466. * @param activeTextures Array of BaseTextures
  46467. */
  46468. getActiveTextures(activeTextures: BaseTexture[]): void;
  46469. /**
  46470. * Returns the animatable textures.
  46471. * @param animatables Array of animatable textures.
  46472. */
  46473. getAnimatables(animatables: IAnimatable[]): void;
  46474. /**
  46475. * Disposes the resources of the material.
  46476. * @param forceDisposeTextures - Forces the disposal of all textures.
  46477. */
  46478. dispose(forceDisposeTextures?: boolean): void;
  46479. /**
  46480. * Get the current class name of the texture useful for serialization or dynamic coding.
  46481. * @returns "PBRSheenConfiguration"
  46482. */
  46483. getClassName(): string;
  46484. /**
  46485. * Add fallbacks to the effect fallbacks list.
  46486. * @param defines defines the Base texture to use.
  46487. * @param fallbacks defines the current fallback list.
  46488. * @param currentRank defines the current fallback rank.
  46489. * @returns the new fallback rank.
  46490. */
  46491. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46492. /**
  46493. * Add the required uniforms to the current list.
  46494. * @param uniforms defines the current uniform list.
  46495. */
  46496. static AddUniforms(uniforms: string[]): void;
  46497. /**
  46498. * Add the required uniforms to the current buffer.
  46499. * @param uniformBuffer defines the current uniform buffer.
  46500. */
  46501. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46502. /**
  46503. * Add the required samplers to the current list.
  46504. * @param samplers defines the current sampler list.
  46505. */
  46506. static AddSamplers(samplers: string[]): void;
  46507. /**
  46508. * Makes a duplicate of the current configuration into another one.
  46509. * @param sheenConfiguration define the config where to copy the info
  46510. */
  46511. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46512. /**
  46513. * Serializes this BRDF configuration.
  46514. * @returns - An object with the serialized config.
  46515. */
  46516. serialize(): any;
  46517. /**
  46518. * Parses a anisotropy Configuration from a serialized object.
  46519. * @param source - Serialized object.
  46520. * @param scene Defines the scene we are parsing for
  46521. * @param rootUrl Defines the rootUrl to load from
  46522. */
  46523. parse(source: any, scene: Scene, rootUrl: string): void;
  46524. }
  46525. }
  46526. declare module BABYLON {
  46527. /**
  46528. * @hidden
  46529. */
  46530. export interface IMaterialSubSurfaceDefines {
  46531. SUBSURFACE: boolean;
  46532. SS_REFRACTION: boolean;
  46533. SS_TRANSLUCENCY: boolean;
  46534. SS_SCATERRING: boolean;
  46535. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46536. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46537. SS_REFRACTIONMAP_3D: boolean;
  46538. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46539. SS_LODINREFRACTIONALPHA: boolean;
  46540. SS_GAMMAREFRACTION: boolean;
  46541. SS_RGBDREFRACTION: boolean;
  46542. SS_LINEARSPECULARREFRACTION: boolean;
  46543. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46544. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46545. /** @hidden */
  46546. _areTexturesDirty: boolean;
  46547. }
  46548. /**
  46549. * Define the code related to the sub surface parameters of the pbr material.
  46550. */
  46551. export class PBRSubSurfaceConfiguration {
  46552. private _isRefractionEnabled;
  46553. /**
  46554. * Defines if the refraction is enabled in the material.
  46555. */
  46556. isRefractionEnabled: boolean;
  46557. private _isTranslucencyEnabled;
  46558. /**
  46559. * Defines if the translucency is enabled in the material.
  46560. */
  46561. isTranslucencyEnabled: boolean;
  46562. private _isScatteringEnabled;
  46563. /**
  46564. * Defines the refraction intensity of the material.
  46565. * The refraction when enabled replaces the Diffuse part of the material.
  46566. * The intensity helps transitionning between diffuse and refraction.
  46567. */
  46568. refractionIntensity: number;
  46569. /**
  46570. * Defines the translucency intensity of the material.
  46571. * When translucency has been enabled, this defines how much of the "translucency"
  46572. * is addded to the diffuse part of the material.
  46573. */
  46574. translucencyIntensity: number;
  46575. /**
  46576. * Defines the scattering intensity of the material.
  46577. * When scattering has been enabled, this defines how much of the "scattered light"
  46578. * is addded to the diffuse part of the material.
  46579. */
  46580. scatteringIntensity: number;
  46581. private _thicknessTexture;
  46582. /**
  46583. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46584. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46585. * 0 would mean minimumThickness
  46586. * 1 would mean maximumThickness
  46587. * The other channels might be use as a mask to vary the different effects intensity.
  46588. */
  46589. thicknessTexture: Nullable<BaseTexture>;
  46590. private _refractionTexture;
  46591. /**
  46592. * Defines the texture to use for refraction.
  46593. */
  46594. refractionTexture: Nullable<BaseTexture>;
  46595. private _indexOfRefraction;
  46596. /**
  46597. * Defines the index of refraction used in the material.
  46598. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46599. */
  46600. indexOfRefraction: number;
  46601. private _invertRefractionY;
  46602. /**
  46603. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46604. */
  46605. invertRefractionY: boolean;
  46606. private _linkRefractionWithTransparency;
  46607. /**
  46608. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46609. * Materials half opaque for instance using refraction could benefit from this control.
  46610. */
  46611. linkRefractionWithTransparency: boolean;
  46612. /**
  46613. * Defines the minimum thickness stored in the thickness map.
  46614. * If no thickness map is defined, this value will be used to simulate thickness.
  46615. */
  46616. minimumThickness: number;
  46617. /**
  46618. * Defines the maximum thickness stored in the thickness map.
  46619. */
  46620. maximumThickness: number;
  46621. /**
  46622. * Defines the volume tint of the material.
  46623. * This is used for both translucency and scattering.
  46624. */
  46625. tintColor: Color3;
  46626. /**
  46627. * Defines the distance at which the tint color should be found in the media.
  46628. * This is used for refraction only.
  46629. */
  46630. tintColorAtDistance: number;
  46631. /**
  46632. * Defines how far each channel transmit through the media.
  46633. * It is defined as a color to simplify it selection.
  46634. */
  46635. diffusionDistance: Color3;
  46636. private _useMaskFromThicknessTexture;
  46637. /**
  46638. * Stores the intensity of the different subsurface effects in the thickness texture.
  46639. * * the green channel is the translucency intensity.
  46640. * * the blue channel is the scattering intensity.
  46641. * * the alpha channel is the refraction intensity.
  46642. */
  46643. useMaskFromThicknessTexture: boolean;
  46644. /** @hidden */
  46645. private _internalMarkAllSubMeshesAsTexturesDirty;
  46646. /** @hidden */
  46647. _markAllSubMeshesAsTexturesDirty(): void;
  46648. /**
  46649. * Instantiate a new istance of sub surface configuration.
  46650. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46651. */
  46652. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46653. /**
  46654. * Gets wehter the submesh is ready to be used or not.
  46655. * @param defines the list of "defines" to update.
  46656. * @param scene defines the scene the material belongs to.
  46657. * @returns - boolean indicating that the submesh is ready or not.
  46658. */
  46659. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46660. /**
  46661. * Checks to see if a texture is used in the material.
  46662. * @param defines the list of "defines" to update.
  46663. * @param scene defines the scene to the material belongs to.
  46664. */
  46665. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46666. /**
  46667. * Binds the material data.
  46668. * @param uniformBuffer defines the Uniform buffer to fill in.
  46669. * @param scene defines the scene the material belongs to.
  46670. * @param engine defines the engine the material belongs to.
  46671. * @param isFrozen defines wether the material is frozen or not.
  46672. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46673. */
  46674. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46675. /**
  46676. * Unbinds the material from the mesh.
  46677. * @param activeEffect defines the effect that should be unbound from.
  46678. * @returns true if unbound, otherwise false
  46679. */
  46680. unbind(activeEffect: Effect): boolean;
  46681. /**
  46682. * Returns the texture used for refraction or null if none is used.
  46683. * @param scene defines the scene the material belongs to.
  46684. * @returns - Refraction texture if present. If no refraction texture and refraction
  46685. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46686. */
  46687. private _getRefractionTexture;
  46688. /**
  46689. * Returns true if alpha blending should be disabled.
  46690. */
  46691. readonly disableAlphaBlending: boolean;
  46692. /**
  46693. * Fills the list of render target textures.
  46694. * @param renderTargets the list of render targets to update
  46695. */
  46696. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46697. /**
  46698. * Checks to see if a texture is used in the material.
  46699. * @param texture - Base texture to use.
  46700. * @returns - Boolean specifying if a texture is used in the material.
  46701. */
  46702. hasTexture(texture: BaseTexture): boolean;
  46703. /**
  46704. * Gets a boolean indicating that current material needs to register RTT
  46705. * @returns true if this uses a render target otherwise false.
  46706. */
  46707. hasRenderTargetTextures(): boolean;
  46708. /**
  46709. * Returns an array of the actively used textures.
  46710. * @param activeTextures Array of BaseTextures
  46711. */
  46712. getActiveTextures(activeTextures: BaseTexture[]): void;
  46713. /**
  46714. * Returns the animatable textures.
  46715. * @param animatables Array of animatable textures.
  46716. */
  46717. getAnimatables(animatables: IAnimatable[]): void;
  46718. /**
  46719. * Disposes the resources of the material.
  46720. * @param forceDisposeTextures - Forces the disposal of all textures.
  46721. */
  46722. dispose(forceDisposeTextures?: boolean): void;
  46723. /**
  46724. * Get the current class name of the texture useful for serialization or dynamic coding.
  46725. * @returns "PBRSubSurfaceConfiguration"
  46726. */
  46727. getClassName(): string;
  46728. /**
  46729. * Add fallbacks to the effect fallbacks list.
  46730. * @param defines defines the Base texture to use.
  46731. * @param fallbacks defines the current fallback list.
  46732. * @param currentRank defines the current fallback rank.
  46733. * @returns the new fallback rank.
  46734. */
  46735. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46736. /**
  46737. * Add the required uniforms to the current list.
  46738. * @param uniforms defines the current uniform list.
  46739. */
  46740. static AddUniforms(uniforms: string[]): void;
  46741. /**
  46742. * Add the required samplers to the current list.
  46743. * @param samplers defines the current sampler list.
  46744. */
  46745. static AddSamplers(samplers: string[]): void;
  46746. /**
  46747. * Add the required uniforms to the current buffer.
  46748. * @param uniformBuffer defines the current uniform buffer.
  46749. */
  46750. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46751. /**
  46752. * Makes a duplicate of the current configuration into another one.
  46753. * @param configuration define the config where to copy the info
  46754. */
  46755. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46756. /**
  46757. * Serializes this Sub Surface configuration.
  46758. * @returns - An object with the serialized config.
  46759. */
  46760. serialize(): any;
  46761. /**
  46762. * Parses a anisotropy Configuration from a serialized object.
  46763. * @param source - Serialized object.
  46764. * @param scene Defines the scene we are parsing for
  46765. * @param rootUrl Defines the rootUrl to load from
  46766. */
  46767. parse(source: any, scene: Scene, rootUrl: string): void;
  46768. }
  46769. }
  46770. declare module BABYLON {
  46771. /** @hidden */
  46772. export var pbrFragmentDeclaration: {
  46773. name: string;
  46774. shader: string;
  46775. };
  46776. }
  46777. declare module BABYLON {
  46778. /** @hidden */
  46779. export var pbrUboDeclaration: {
  46780. name: string;
  46781. shader: string;
  46782. };
  46783. }
  46784. declare module BABYLON {
  46785. /** @hidden */
  46786. export var pbrFragmentExtraDeclaration: {
  46787. name: string;
  46788. shader: string;
  46789. };
  46790. }
  46791. declare module BABYLON {
  46792. /** @hidden */
  46793. export var pbrFragmentSamplersDeclaration: {
  46794. name: string;
  46795. shader: string;
  46796. };
  46797. }
  46798. declare module BABYLON {
  46799. /** @hidden */
  46800. export var pbrHelperFunctions: {
  46801. name: string;
  46802. shader: string;
  46803. };
  46804. }
  46805. declare module BABYLON {
  46806. /** @hidden */
  46807. export var harmonicsFunctions: {
  46808. name: string;
  46809. shader: string;
  46810. };
  46811. }
  46812. declare module BABYLON {
  46813. /** @hidden */
  46814. export var pbrDirectLightingSetupFunctions: {
  46815. name: string;
  46816. shader: string;
  46817. };
  46818. }
  46819. declare module BABYLON {
  46820. /** @hidden */
  46821. export var pbrDirectLightingFalloffFunctions: {
  46822. name: string;
  46823. shader: string;
  46824. };
  46825. }
  46826. declare module BABYLON {
  46827. /** @hidden */
  46828. export var pbrBRDFFunctions: {
  46829. name: string;
  46830. shader: string;
  46831. };
  46832. }
  46833. declare module BABYLON {
  46834. /** @hidden */
  46835. export var pbrDirectLightingFunctions: {
  46836. name: string;
  46837. shader: string;
  46838. };
  46839. }
  46840. declare module BABYLON {
  46841. /** @hidden */
  46842. export var pbrIBLFunctions: {
  46843. name: string;
  46844. shader: string;
  46845. };
  46846. }
  46847. declare module BABYLON {
  46848. /** @hidden */
  46849. export var pbrDebug: {
  46850. name: string;
  46851. shader: string;
  46852. };
  46853. }
  46854. declare module BABYLON {
  46855. /** @hidden */
  46856. export var pbrPixelShader: {
  46857. name: string;
  46858. shader: string;
  46859. };
  46860. }
  46861. declare module BABYLON {
  46862. /** @hidden */
  46863. export var pbrVertexDeclaration: {
  46864. name: string;
  46865. shader: string;
  46866. };
  46867. }
  46868. declare module BABYLON {
  46869. /** @hidden */
  46870. export var pbrVertexShader: {
  46871. name: string;
  46872. shader: string;
  46873. };
  46874. }
  46875. declare module BABYLON {
  46876. /**
  46877. * Manages the defines for the PBR Material.
  46878. * @hidden
  46879. */
  46880. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46881. PBR: boolean;
  46882. MAINUV1: boolean;
  46883. MAINUV2: boolean;
  46884. UV1: boolean;
  46885. UV2: boolean;
  46886. ALBEDO: boolean;
  46887. ALBEDODIRECTUV: number;
  46888. VERTEXCOLOR: boolean;
  46889. AMBIENT: boolean;
  46890. AMBIENTDIRECTUV: number;
  46891. AMBIENTINGRAYSCALE: boolean;
  46892. OPACITY: boolean;
  46893. VERTEXALPHA: boolean;
  46894. OPACITYDIRECTUV: number;
  46895. OPACITYRGB: boolean;
  46896. ALPHATEST: boolean;
  46897. DEPTHPREPASS: boolean;
  46898. ALPHABLEND: boolean;
  46899. ALPHAFROMALBEDO: boolean;
  46900. ALPHATESTVALUE: string;
  46901. SPECULAROVERALPHA: boolean;
  46902. RADIANCEOVERALPHA: boolean;
  46903. ALPHAFRESNEL: boolean;
  46904. LINEARALPHAFRESNEL: boolean;
  46905. PREMULTIPLYALPHA: boolean;
  46906. EMISSIVE: boolean;
  46907. EMISSIVEDIRECTUV: number;
  46908. REFLECTIVITY: boolean;
  46909. REFLECTIVITYDIRECTUV: number;
  46910. SPECULARTERM: boolean;
  46911. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46912. MICROSURFACEAUTOMATIC: boolean;
  46913. LODBASEDMICROSFURACE: boolean;
  46914. MICROSURFACEMAP: boolean;
  46915. MICROSURFACEMAPDIRECTUV: number;
  46916. METALLICWORKFLOW: boolean;
  46917. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46918. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46919. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46920. AOSTOREINMETALMAPRED: boolean;
  46921. ENVIRONMENTBRDF: boolean;
  46922. ENVIRONMENTBRDF_RGBD: boolean;
  46923. NORMAL: boolean;
  46924. TANGENT: boolean;
  46925. BUMP: boolean;
  46926. BUMPDIRECTUV: number;
  46927. OBJECTSPACE_NORMALMAP: boolean;
  46928. PARALLAX: boolean;
  46929. PARALLAXOCCLUSION: boolean;
  46930. NORMALXYSCALE: boolean;
  46931. LIGHTMAP: boolean;
  46932. LIGHTMAPDIRECTUV: number;
  46933. USELIGHTMAPASSHADOWMAP: boolean;
  46934. GAMMALIGHTMAP: boolean;
  46935. RGBDLIGHTMAP: boolean;
  46936. REFLECTION: boolean;
  46937. REFLECTIONMAP_3D: boolean;
  46938. REFLECTIONMAP_SPHERICAL: boolean;
  46939. REFLECTIONMAP_PLANAR: boolean;
  46940. REFLECTIONMAP_CUBIC: boolean;
  46941. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46942. REFLECTIONMAP_PROJECTION: boolean;
  46943. REFLECTIONMAP_SKYBOX: boolean;
  46944. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46945. REFLECTIONMAP_EXPLICIT: boolean;
  46946. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46947. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46948. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46949. INVERTCUBICMAP: boolean;
  46950. USESPHERICALFROMREFLECTIONMAP: boolean;
  46951. USEIRRADIANCEMAP: boolean;
  46952. SPHERICAL_HARMONICS: boolean;
  46953. USESPHERICALINVERTEX: boolean;
  46954. REFLECTIONMAP_OPPOSITEZ: boolean;
  46955. LODINREFLECTIONALPHA: boolean;
  46956. GAMMAREFLECTION: boolean;
  46957. RGBDREFLECTION: boolean;
  46958. LINEARSPECULARREFLECTION: boolean;
  46959. RADIANCEOCCLUSION: boolean;
  46960. HORIZONOCCLUSION: boolean;
  46961. INSTANCES: boolean;
  46962. NUM_BONE_INFLUENCERS: number;
  46963. BonesPerMesh: number;
  46964. BONETEXTURE: boolean;
  46965. NONUNIFORMSCALING: boolean;
  46966. MORPHTARGETS: boolean;
  46967. MORPHTARGETS_NORMAL: boolean;
  46968. MORPHTARGETS_TANGENT: boolean;
  46969. MORPHTARGETS_UV: boolean;
  46970. NUM_MORPH_INFLUENCERS: number;
  46971. IMAGEPROCESSING: boolean;
  46972. VIGNETTE: boolean;
  46973. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46974. VIGNETTEBLENDMODEOPAQUE: boolean;
  46975. TONEMAPPING: boolean;
  46976. TONEMAPPING_ACES: boolean;
  46977. CONTRAST: boolean;
  46978. COLORCURVES: boolean;
  46979. COLORGRADING: boolean;
  46980. COLORGRADING3D: boolean;
  46981. SAMPLER3DGREENDEPTH: boolean;
  46982. SAMPLER3DBGRMAP: boolean;
  46983. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46984. EXPOSURE: boolean;
  46985. MULTIVIEW: boolean;
  46986. USEPHYSICALLIGHTFALLOFF: boolean;
  46987. USEGLTFLIGHTFALLOFF: boolean;
  46988. TWOSIDEDLIGHTING: boolean;
  46989. SHADOWFLOAT: boolean;
  46990. CLIPPLANE: boolean;
  46991. CLIPPLANE2: boolean;
  46992. CLIPPLANE3: boolean;
  46993. CLIPPLANE4: boolean;
  46994. POINTSIZE: boolean;
  46995. FOG: boolean;
  46996. LOGARITHMICDEPTH: boolean;
  46997. FORCENORMALFORWARD: boolean;
  46998. SPECULARAA: boolean;
  46999. CLEARCOAT: boolean;
  47000. CLEARCOAT_DEFAULTIOR: boolean;
  47001. CLEARCOAT_TEXTURE: boolean;
  47002. CLEARCOAT_TEXTUREDIRECTUV: number;
  47003. CLEARCOAT_BUMP: boolean;
  47004. CLEARCOAT_BUMPDIRECTUV: number;
  47005. CLEARCOAT_TINT: boolean;
  47006. CLEARCOAT_TINT_TEXTURE: boolean;
  47007. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47008. ANISOTROPIC: boolean;
  47009. ANISOTROPIC_TEXTURE: boolean;
  47010. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47011. BRDF_V_HEIGHT_CORRELATED: boolean;
  47012. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47013. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47014. SHEEN: boolean;
  47015. SHEEN_TEXTURE: boolean;
  47016. SHEEN_TEXTUREDIRECTUV: number;
  47017. SHEEN_LINKWITHALBEDO: boolean;
  47018. SUBSURFACE: boolean;
  47019. SS_REFRACTION: boolean;
  47020. SS_TRANSLUCENCY: boolean;
  47021. SS_SCATERRING: boolean;
  47022. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47023. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47024. SS_REFRACTIONMAP_3D: boolean;
  47025. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47026. SS_LODINREFRACTIONALPHA: boolean;
  47027. SS_GAMMAREFRACTION: boolean;
  47028. SS_RGBDREFRACTION: boolean;
  47029. SS_LINEARSPECULARREFRACTION: boolean;
  47030. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47031. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47032. UNLIT: boolean;
  47033. DEBUGMODE: number;
  47034. /**
  47035. * Initializes the PBR Material defines.
  47036. */
  47037. constructor();
  47038. /**
  47039. * Resets the PBR Material defines.
  47040. */
  47041. reset(): void;
  47042. }
  47043. /**
  47044. * The Physically based material base class of BJS.
  47045. *
  47046. * This offers the main features of a standard PBR material.
  47047. * For more information, please refer to the documentation :
  47048. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47049. */
  47050. export abstract class PBRBaseMaterial extends PushMaterial {
  47051. /**
  47052. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47053. */
  47054. static readonly PBRMATERIAL_OPAQUE: number;
  47055. /**
  47056. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47057. */
  47058. static readonly PBRMATERIAL_ALPHATEST: number;
  47059. /**
  47060. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47061. */
  47062. static readonly PBRMATERIAL_ALPHABLEND: number;
  47063. /**
  47064. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47065. * They are also discarded below the alpha cutoff threshold to improve performances.
  47066. */
  47067. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47068. /**
  47069. * Defines the default value of how much AO map is occluding the analytical lights
  47070. * (point spot...).
  47071. */
  47072. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47073. /**
  47074. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47075. */
  47076. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47077. /**
  47078. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47079. * to enhance interoperability with other engines.
  47080. */
  47081. static readonly LIGHTFALLOFF_GLTF: number;
  47082. /**
  47083. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47084. * to enhance interoperability with other materials.
  47085. */
  47086. static readonly LIGHTFALLOFF_STANDARD: number;
  47087. /**
  47088. * Intensity of the direct lights e.g. the four lights available in your scene.
  47089. * This impacts both the direct diffuse and specular highlights.
  47090. */
  47091. protected _directIntensity: number;
  47092. /**
  47093. * Intensity of the emissive part of the material.
  47094. * This helps controlling the emissive effect without modifying the emissive color.
  47095. */
  47096. protected _emissiveIntensity: number;
  47097. /**
  47098. * Intensity of the environment e.g. how much the environment will light the object
  47099. * either through harmonics for rough material or through the refelction for shiny ones.
  47100. */
  47101. protected _environmentIntensity: number;
  47102. /**
  47103. * This is a special control allowing the reduction of the specular highlights coming from the
  47104. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47105. */
  47106. protected _specularIntensity: number;
  47107. /**
  47108. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47109. */
  47110. private _lightingInfos;
  47111. /**
  47112. * Debug Control allowing disabling the bump map on this material.
  47113. */
  47114. protected _disableBumpMap: boolean;
  47115. /**
  47116. * AKA Diffuse Texture in standard nomenclature.
  47117. */
  47118. protected _albedoTexture: Nullable<BaseTexture>;
  47119. /**
  47120. * AKA Occlusion Texture in other nomenclature.
  47121. */
  47122. protected _ambientTexture: Nullable<BaseTexture>;
  47123. /**
  47124. * AKA Occlusion Texture Intensity in other nomenclature.
  47125. */
  47126. protected _ambientTextureStrength: number;
  47127. /**
  47128. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47129. * 1 means it completely occludes it
  47130. * 0 mean it has no impact
  47131. */
  47132. protected _ambientTextureImpactOnAnalyticalLights: number;
  47133. /**
  47134. * Stores the alpha values in a texture.
  47135. */
  47136. protected _opacityTexture: Nullable<BaseTexture>;
  47137. /**
  47138. * Stores the reflection values in a texture.
  47139. */
  47140. protected _reflectionTexture: Nullable<BaseTexture>;
  47141. /**
  47142. * Stores the emissive values in a texture.
  47143. */
  47144. protected _emissiveTexture: Nullable<BaseTexture>;
  47145. /**
  47146. * AKA Specular texture in other nomenclature.
  47147. */
  47148. protected _reflectivityTexture: Nullable<BaseTexture>;
  47149. /**
  47150. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47151. */
  47152. protected _metallicTexture: Nullable<BaseTexture>;
  47153. /**
  47154. * Specifies the metallic scalar of the metallic/roughness workflow.
  47155. * Can also be used to scale the metalness values of the metallic texture.
  47156. */
  47157. protected _metallic: Nullable<number>;
  47158. /**
  47159. * Specifies the roughness scalar of the metallic/roughness workflow.
  47160. * Can also be used to scale the roughness values of the metallic texture.
  47161. */
  47162. protected _roughness: Nullable<number>;
  47163. /**
  47164. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47165. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47166. */
  47167. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47168. /**
  47169. * Stores surface normal data used to displace a mesh in a texture.
  47170. */
  47171. protected _bumpTexture: Nullable<BaseTexture>;
  47172. /**
  47173. * Stores the pre-calculated light information of a mesh in a texture.
  47174. */
  47175. protected _lightmapTexture: Nullable<BaseTexture>;
  47176. /**
  47177. * The color of a material in ambient lighting.
  47178. */
  47179. protected _ambientColor: Color3;
  47180. /**
  47181. * AKA Diffuse Color in other nomenclature.
  47182. */
  47183. protected _albedoColor: Color3;
  47184. /**
  47185. * AKA Specular Color in other nomenclature.
  47186. */
  47187. protected _reflectivityColor: Color3;
  47188. /**
  47189. * The color applied when light is reflected from a material.
  47190. */
  47191. protected _reflectionColor: Color3;
  47192. /**
  47193. * The color applied when light is emitted from a material.
  47194. */
  47195. protected _emissiveColor: Color3;
  47196. /**
  47197. * AKA Glossiness in other nomenclature.
  47198. */
  47199. protected _microSurface: number;
  47200. /**
  47201. * Specifies that the material will use the light map as a show map.
  47202. */
  47203. protected _useLightmapAsShadowmap: boolean;
  47204. /**
  47205. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47206. * makes the reflect vector face the model (under horizon).
  47207. */
  47208. protected _useHorizonOcclusion: boolean;
  47209. /**
  47210. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47211. * too much the area relying on ambient texture to define their ambient occlusion.
  47212. */
  47213. protected _useRadianceOcclusion: boolean;
  47214. /**
  47215. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47216. */
  47217. protected _useAlphaFromAlbedoTexture: boolean;
  47218. /**
  47219. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47220. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47221. */
  47222. protected _useSpecularOverAlpha: boolean;
  47223. /**
  47224. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47225. */
  47226. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47227. /**
  47228. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47229. */
  47230. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47231. /**
  47232. * Specifies if the metallic texture contains the roughness information in its green channel.
  47233. */
  47234. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47235. /**
  47236. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47237. */
  47238. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47239. /**
  47240. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47241. */
  47242. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47243. /**
  47244. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47245. */
  47246. protected _useAmbientInGrayScale: boolean;
  47247. /**
  47248. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47249. * The material will try to infer what glossiness each pixel should be.
  47250. */
  47251. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47252. /**
  47253. * Defines the falloff type used in this material.
  47254. * It by default is Physical.
  47255. */
  47256. protected _lightFalloff: number;
  47257. /**
  47258. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47259. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47260. */
  47261. protected _useRadianceOverAlpha: boolean;
  47262. /**
  47263. * Allows using an object space normal map (instead of tangent space).
  47264. */
  47265. protected _useObjectSpaceNormalMap: boolean;
  47266. /**
  47267. * Allows using the bump map in parallax mode.
  47268. */
  47269. protected _useParallax: boolean;
  47270. /**
  47271. * Allows using the bump map in parallax occlusion mode.
  47272. */
  47273. protected _useParallaxOcclusion: boolean;
  47274. /**
  47275. * Controls the scale bias of the parallax mode.
  47276. */
  47277. protected _parallaxScaleBias: number;
  47278. /**
  47279. * If sets to true, disables all the lights affecting the material.
  47280. */
  47281. protected _disableLighting: boolean;
  47282. /**
  47283. * Number of Simultaneous lights allowed on the material.
  47284. */
  47285. protected _maxSimultaneousLights: number;
  47286. /**
  47287. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47288. */
  47289. protected _invertNormalMapX: boolean;
  47290. /**
  47291. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47292. */
  47293. protected _invertNormalMapY: boolean;
  47294. /**
  47295. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47296. */
  47297. protected _twoSidedLighting: boolean;
  47298. /**
  47299. * Defines the alpha limits in alpha test mode.
  47300. */
  47301. protected _alphaCutOff: number;
  47302. /**
  47303. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47304. */
  47305. protected _forceAlphaTest: boolean;
  47306. /**
  47307. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47308. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47309. */
  47310. protected _useAlphaFresnel: boolean;
  47311. /**
  47312. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47313. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47314. */
  47315. protected _useLinearAlphaFresnel: boolean;
  47316. /**
  47317. * The transparency mode of the material.
  47318. */
  47319. protected _transparencyMode: Nullable<number>;
  47320. /**
  47321. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47322. * from cos thetav and roughness:
  47323. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47324. */
  47325. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47326. /**
  47327. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47328. */
  47329. protected _forceIrradianceInFragment: boolean;
  47330. /**
  47331. * Force normal to face away from face.
  47332. */
  47333. protected _forceNormalForward: boolean;
  47334. /**
  47335. * Enables specular anti aliasing in the PBR shader.
  47336. * It will both interacts on the Geometry for analytical and IBL lighting.
  47337. * It also prefilter the roughness map based on the bump values.
  47338. */
  47339. protected _enableSpecularAntiAliasing: boolean;
  47340. /**
  47341. * Default configuration related to image processing available in the PBR Material.
  47342. */
  47343. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47344. /**
  47345. * Keep track of the image processing observer to allow dispose and replace.
  47346. */
  47347. private _imageProcessingObserver;
  47348. /**
  47349. * Attaches a new image processing configuration to the PBR Material.
  47350. * @param configuration
  47351. */
  47352. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47353. /**
  47354. * Stores the available render targets.
  47355. */
  47356. private _renderTargets;
  47357. /**
  47358. * Sets the global ambient color for the material used in lighting calculations.
  47359. */
  47360. private _globalAmbientColor;
  47361. /**
  47362. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47363. */
  47364. private _useLogarithmicDepth;
  47365. /**
  47366. * If set to true, no lighting calculations will be applied.
  47367. */
  47368. private _unlit;
  47369. private _debugMode;
  47370. /**
  47371. * @hidden
  47372. * This is reserved for the inspector.
  47373. * Defines the material debug mode.
  47374. * It helps seeing only some components of the material while troubleshooting.
  47375. */
  47376. debugMode: number;
  47377. /**
  47378. * @hidden
  47379. * This is reserved for the inspector.
  47380. * Specify from where on screen the debug mode should start.
  47381. * The value goes from -1 (full screen) to 1 (not visible)
  47382. * It helps with side by side comparison against the final render
  47383. * This defaults to -1
  47384. */
  47385. private debugLimit;
  47386. /**
  47387. * @hidden
  47388. * This is reserved for the inspector.
  47389. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47390. * You can use the factor to better multiply the final value.
  47391. */
  47392. private debugFactor;
  47393. /**
  47394. * Defines the clear coat layer parameters for the material.
  47395. */
  47396. readonly clearCoat: PBRClearCoatConfiguration;
  47397. /**
  47398. * Defines the anisotropic parameters for the material.
  47399. */
  47400. readonly anisotropy: PBRAnisotropicConfiguration;
  47401. /**
  47402. * Defines the BRDF parameters for the material.
  47403. */
  47404. readonly brdf: PBRBRDFConfiguration;
  47405. /**
  47406. * Defines the Sheen parameters for the material.
  47407. */
  47408. readonly sheen: PBRSheenConfiguration;
  47409. /**
  47410. * Defines the SubSurface parameters for the material.
  47411. */
  47412. readonly subSurface: PBRSubSurfaceConfiguration;
  47413. /**
  47414. * Custom callback helping to override the default shader used in the material.
  47415. */
  47416. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47417. protected _rebuildInParallel: boolean;
  47418. /**
  47419. * Instantiates a new PBRMaterial instance.
  47420. *
  47421. * @param name The material name
  47422. * @param scene The scene the material will be use in.
  47423. */
  47424. constructor(name: string, scene: Scene);
  47425. /**
  47426. * Gets a boolean indicating that current material needs to register RTT
  47427. */
  47428. readonly hasRenderTargetTextures: boolean;
  47429. /**
  47430. * Gets the name of the material class.
  47431. */
  47432. getClassName(): string;
  47433. /**
  47434. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47435. */
  47436. /**
  47437. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47438. */
  47439. useLogarithmicDepth: boolean;
  47440. /**
  47441. * Gets the current transparency mode.
  47442. */
  47443. /**
  47444. * Sets the transparency mode of the material.
  47445. *
  47446. * | Value | Type | Description |
  47447. * | ----- | ----------------------------------- | ----------- |
  47448. * | 0 | OPAQUE | |
  47449. * | 1 | ALPHATEST | |
  47450. * | 2 | ALPHABLEND | |
  47451. * | 3 | ALPHATESTANDBLEND | |
  47452. *
  47453. */
  47454. transparencyMode: Nullable<number>;
  47455. /**
  47456. * Returns true if alpha blending should be disabled.
  47457. */
  47458. private readonly _disableAlphaBlending;
  47459. /**
  47460. * Specifies whether or not this material should be rendered in alpha blend mode.
  47461. */
  47462. needAlphaBlending(): boolean;
  47463. /**
  47464. * Specifies if the mesh will require alpha blending.
  47465. * @param mesh - BJS mesh.
  47466. */
  47467. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47468. /**
  47469. * Specifies whether or not this material should be rendered in alpha test mode.
  47470. */
  47471. needAlphaTesting(): boolean;
  47472. /**
  47473. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47474. */
  47475. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47476. /**
  47477. * Gets the texture used for the alpha test.
  47478. */
  47479. getAlphaTestTexture(): Nullable<BaseTexture>;
  47480. /**
  47481. * Specifies that the submesh is ready to be used.
  47482. * @param mesh - BJS mesh.
  47483. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47484. * @param useInstances - Specifies that instances should be used.
  47485. * @returns - boolean indicating that the submesh is ready or not.
  47486. */
  47487. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47488. /**
  47489. * Specifies if the material uses metallic roughness workflow.
  47490. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47491. */
  47492. isMetallicWorkflow(): boolean;
  47493. private _prepareEffect;
  47494. private _prepareDefines;
  47495. /**
  47496. * Force shader compilation
  47497. */
  47498. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47499. clipPlane: boolean;
  47500. }>): void;
  47501. /**
  47502. * Initializes the uniform buffer layout for the shader.
  47503. */
  47504. buildUniformLayout(): void;
  47505. /**
  47506. * Unbinds the material from the mesh
  47507. */
  47508. unbind(): void;
  47509. /**
  47510. * Binds the submesh data.
  47511. * @param world - The world matrix.
  47512. * @param mesh - The BJS mesh.
  47513. * @param subMesh - A submesh of the BJS mesh.
  47514. */
  47515. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47516. /**
  47517. * Returns the animatable textures.
  47518. * @returns - Array of animatable textures.
  47519. */
  47520. getAnimatables(): IAnimatable[];
  47521. /**
  47522. * Returns the texture used for reflections.
  47523. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47524. */
  47525. private _getReflectionTexture;
  47526. /**
  47527. * Returns an array of the actively used textures.
  47528. * @returns - Array of BaseTextures
  47529. */
  47530. getActiveTextures(): BaseTexture[];
  47531. /**
  47532. * Checks to see if a texture is used in the material.
  47533. * @param texture - Base texture to use.
  47534. * @returns - Boolean specifying if a texture is used in the material.
  47535. */
  47536. hasTexture(texture: BaseTexture): boolean;
  47537. /**
  47538. * Disposes the resources of the material.
  47539. * @param forceDisposeEffect - Forces the disposal of effects.
  47540. * @param forceDisposeTextures - Forces the disposal of all textures.
  47541. */
  47542. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47543. }
  47544. }
  47545. declare module BABYLON {
  47546. /**
  47547. * The Physically based material of BJS.
  47548. *
  47549. * This offers the main features of a standard PBR material.
  47550. * For more information, please refer to the documentation :
  47551. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47552. */
  47553. export class PBRMaterial extends PBRBaseMaterial {
  47554. /**
  47555. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47556. */
  47557. static readonly PBRMATERIAL_OPAQUE: number;
  47558. /**
  47559. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47560. */
  47561. static readonly PBRMATERIAL_ALPHATEST: number;
  47562. /**
  47563. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47564. */
  47565. static readonly PBRMATERIAL_ALPHABLEND: number;
  47566. /**
  47567. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47568. * They are also discarded below the alpha cutoff threshold to improve performances.
  47569. */
  47570. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47571. /**
  47572. * Defines the default value of how much AO map is occluding the analytical lights
  47573. * (point spot...).
  47574. */
  47575. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47576. /**
  47577. * Intensity of the direct lights e.g. the four lights available in your scene.
  47578. * This impacts both the direct diffuse and specular highlights.
  47579. */
  47580. directIntensity: number;
  47581. /**
  47582. * Intensity of the emissive part of the material.
  47583. * This helps controlling the emissive effect without modifying the emissive color.
  47584. */
  47585. emissiveIntensity: number;
  47586. /**
  47587. * Intensity of the environment e.g. how much the environment will light the object
  47588. * either through harmonics for rough material or through the refelction for shiny ones.
  47589. */
  47590. environmentIntensity: number;
  47591. /**
  47592. * This is a special control allowing the reduction of the specular highlights coming from the
  47593. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47594. */
  47595. specularIntensity: number;
  47596. /**
  47597. * Debug Control allowing disabling the bump map on this material.
  47598. */
  47599. disableBumpMap: boolean;
  47600. /**
  47601. * AKA Diffuse Texture in standard nomenclature.
  47602. */
  47603. albedoTexture: BaseTexture;
  47604. /**
  47605. * AKA Occlusion Texture in other nomenclature.
  47606. */
  47607. ambientTexture: BaseTexture;
  47608. /**
  47609. * AKA Occlusion Texture Intensity in other nomenclature.
  47610. */
  47611. ambientTextureStrength: number;
  47612. /**
  47613. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47614. * 1 means it completely occludes it
  47615. * 0 mean it has no impact
  47616. */
  47617. ambientTextureImpactOnAnalyticalLights: number;
  47618. /**
  47619. * Stores the alpha values in a texture.
  47620. */
  47621. opacityTexture: BaseTexture;
  47622. /**
  47623. * Stores the reflection values in a texture.
  47624. */
  47625. reflectionTexture: Nullable<BaseTexture>;
  47626. /**
  47627. * Stores the emissive values in a texture.
  47628. */
  47629. emissiveTexture: BaseTexture;
  47630. /**
  47631. * AKA Specular texture in other nomenclature.
  47632. */
  47633. reflectivityTexture: BaseTexture;
  47634. /**
  47635. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47636. */
  47637. metallicTexture: BaseTexture;
  47638. /**
  47639. * Specifies the metallic scalar of the metallic/roughness workflow.
  47640. * Can also be used to scale the metalness values of the metallic texture.
  47641. */
  47642. metallic: Nullable<number>;
  47643. /**
  47644. * Specifies the roughness scalar of the metallic/roughness workflow.
  47645. * Can also be used to scale the roughness values of the metallic texture.
  47646. */
  47647. roughness: Nullable<number>;
  47648. /**
  47649. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47650. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47651. */
  47652. microSurfaceTexture: BaseTexture;
  47653. /**
  47654. * Stores surface normal data used to displace a mesh in a texture.
  47655. */
  47656. bumpTexture: BaseTexture;
  47657. /**
  47658. * Stores the pre-calculated light information of a mesh in a texture.
  47659. */
  47660. lightmapTexture: BaseTexture;
  47661. /**
  47662. * Stores the refracted light information in a texture.
  47663. */
  47664. refractionTexture: Nullable<BaseTexture>;
  47665. /**
  47666. * The color of a material in ambient lighting.
  47667. */
  47668. ambientColor: Color3;
  47669. /**
  47670. * AKA Diffuse Color in other nomenclature.
  47671. */
  47672. albedoColor: Color3;
  47673. /**
  47674. * AKA Specular Color in other nomenclature.
  47675. */
  47676. reflectivityColor: Color3;
  47677. /**
  47678. * The color reflected from the material.
  47679. */
  47680. reflectionColor: Color3;
  47681. /**
  47682. * The color emitted from the material.
  47683. */
  47684. emissiveColor: Color3;
  47685. /**
  47686. * AKA Glossiness in other nomenclature.
  47687. */
  47688. microSurface: number;
  47689. /**
  47690. * source material index of refraction (IOR)' / 'destination material IOR.
  47691. */
  47692. indexOfRefraction: number;
  47693. /**
  47694. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47695. */
  47696. invertRefractionY: boolean;
  47697. /**
  47698. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47699. * Materials half opaque for instance using refraction could benefit from this control.
  47700. */
  47701. linkRefractionWithTransparency: boolean;
  47702. /**
  47703. * If true, the light map contains occlusion information instead of lighting info.
  47704. */
  47705. useLightmapAsShadowmap: boolean;
  47706. /**
  47707. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47708. */
  47709. useAlphaFromAlbedoTexture: boolean;
  47710. /**
  47711. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47712. */
  47713. forceAlphaTest: boolean;
  47714. /**
  47715. * Defines the alpha limits in alpha test mode.
  47716. */
  47717. alphaCutOff: number;
  47718. /**
  47719. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47720. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47721. */
  47722. useSpecularOverAlpha: boolean;
  47723. /**
  47724. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47725. */
  47726. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47727. /**
  47728. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47729. */
  47730. useRoughnessFromMetallicTextureAlpha: boolean;
  47731. /**
  47732. * Specifies if the metallic texture contains the roughness information in its green channel.
  47733. */
  47734. useRoughnessFromMetallicTextureGreen: boolean;
  47735. /**
  47736. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47737. */
  47738. useMetallnessFromMetallicTextureBlue: boolean;
  47739. /**
  47740. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47741. */
  47742. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47743. /**
  47744. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47745. */
  47746. useAmbientInGrayScale: boolean;
  47747. /**
  47748. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47749. * The material will try to infer what glossiness each pixel should be.
  47750. */
  47751. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47752. /**
  47753. * BJS is using an harcoded light falloff based on a manually sets up range.
  47754. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47755. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47756. */
  47757. /**
  47758. * BJS is using an harcoded light falloff based on a manually sets up range.
  47759. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47760. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47761. */
  47762. usePhysicalLightFalloff: boolean;
  47763. /**
  47764. * In order to support the falloff compatibility with gltf, a special mode has been added
  47765. * to reproduce the gltf light falloff.
  47766. */
  47767. /**
  47768. * In order to support the falloff compatibility with gltf, a special mode has been added
  47769. * to reproduce the gltf light falloff.
  47770. */
  47771. useGLTFLightFalloff: boolean;
  47772. /**
  47773. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47774. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47775. */
  47776. useRadianceOverAlpha: boolean;
  47777. /**
  47778. * Allows using an object space normal map (instead of tangent space).
  47779. */
  47780. useObjectSpaceNormalMap: boolean;
  47781. /**
  47782. * Allows using the bump map in parallax mode.
  47783. */
  47784. useParallax: boolean;
  47785. /**
  47786. * Allows using the bump map in parallax occlusion mode.
  47787. */
  47788. useParallaxOcclusion: boolean;
  47789. /**
  47790. * Controls the scale bias of the parallax mode.
  47791. */
  47792. parallaxScaleBias: number;
  47793. /**
  47794. * If sets to true, disables all the lights affecting the material.
  47795. */
  47796. disableLighting: boolean;
  47797. /**
  47798. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47799. */
  47800. forceIrradianceInFragment: boolean;
  47801. /**
  47802. * Number of Simultaneous lights allowed on the material.
  47803. */
  47804. maxSimultaneousLights: number;
  47805. /**
  47806. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47807. */
  47808. invertNormalMapX: boolean;
  47809. /**
  47810. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47811. */
  47812. invertNormalMapY: boolean;
  47813. /**
  47814. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47815. */
  47816. twoSidedLighting: boolean;
  47817. /**
  47818. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47819. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47820. */
  47821. useAlphaFresnel: boolean;
  47822. /**
  47823. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47824. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47825. */
  47826. useLinearAlphaFresnel: boolean;
  47827. /**
  47828. * Let user defines the brdf lookup texture used for IBL.
  47829. * A default 8bit version is embedded but you could point at :
  47830. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47831. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47832. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47833. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47834. */
  47835. environmentBRDFTexture: Nullable<BaseTexture>;
  47836. /**
  47837. * Force normal to face away from face.
  47838. */
  47839. forceNormalForward: boolean;
  47840. /**
  47841. * Enables specular anti aliasing in the PBR shader.
  47842. * It will both interacts on the Geometry for analytical and IBL lighting.
  47843. * It also prefilter the roughness map based on the bump values.
  47844. */
  47845. enableSpecularAntiAliasing: boolean;
  47846. /**
  47847. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47848. * makes the reflect vector face the model (under horizon).
  47849. */
  47850. useHorizonOcclusion: boolean;
  47851. /**
  47852. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47853. * too much the area relying on ambient texture to define their ambient occlusion.
  47854. */
  47855. useRadianceOcclusion: boolean;
  47856. /**
  47857. * If set to true, no lighting calculations will be applied.
  47858. */
  47859. unlit: boolean;
  47860. /**
  47861. * Gets the image processing configuration used either in this material.
  47862. */
  47863. /**
  47864. * Sets the Default image processing configuration used either in the this material.
  47865. *
  47866. * If sets to null, the scene one is in use.
  47867. */
  47868. imageProcessingConfiguration: ImageProcessingConfiguration;
  47869. /**
  47870. * Gets wether the color curves effect is enabled.
  47871. */
  47872. /**
  47873. * Sets wether the color curves effect is enabled.
  47874. */
  47875. cameraColorCurvesEnabled: boolean;
  47876. /**
  47877. * Gets wether the color grading effect is enabled.
  47878. */
  47879. /**
  47880. * Gets wether the color grading effect is enabled.
  47881. */
  47882. cameraColorGradingEnabled: boolean;
  47883. /**
  47884. * Gets wether tonemapping is enabled or not.
  47885. */
  47886. /**
  47887. * Sets wether tonemapping is enabled or not
  47888. */
  47889. cameraToneMappingEnabled: boolean;
  47890. /**
  47891. * The camera exposure used on this material.
  47892. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47893. * This corresponds to a photographic exposure.
  47894. */
  47895. /**
  47896. * The camera exposure used on this material.
  47897. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47898. * This corresponds to a photographic exposure.
  47899. */
  47900. cameraExposure: number;
  47901. /**
  47902. * Gets The camera contrast used on this material.
  47903. */
  47904. /**
  47905. * Sets The camera contrast used on this material.
  47906. */
  47907. cameraContrast: number;
  47908. /**
  47909. * Gets the Color Grading 2D Lookup Texture.
  47910. */
  47911. /**
  47912. * Sets the Color Grading 2D Lookup Texture.
  47913. */
  47914. cameraColorGradingTexture: Nullable<BaseTexture>;
  47915. /**
  47916. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47917. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47918. * 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;
  47919. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47920. */
  47921. /**
  47922. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47923. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47924. * 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;
  47925. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47926. */
  47927. cameraColorCurves: Nullable<ColorCurves>;
  47928. /**
  47929. * Instantiates a new PBRMaterial instance.
  47930. *
  47931. * @param name The material name
  47932. * @param scene The scene the material will be use in.
  47933. */
  47934. constructor(name: string, scene: Scene);
  47935. /**
  47936. * Returns the name of this material class.
  47937. */
  47938. getClassName(): string;
  47939. /**
  47940. * Makes a duplicate of the current material.
  47941. * @param name - name to use for the new material.
  47942. */
  47943. clone(name: string): PBRMaterial;
  47944. /**
  47945. * Serializes this PBR Material.
  47946. * @returns - An object with the serialized material.
  47947. */
  47948. serialize(): any;
  47949. /**
  47950. * Parses a PBR Material from a serialized object.
  47951. * @param source - Serialized object.
  47952. * @param scene - BJS scene instance.
  47953. * @param rootUrl - url for the scene object
  47954. * @returns - PBRMaterial
  47955. */
  47956. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47957. }
  47958. }
  47959. declare module BABYLON {
  47960. /**
  47961. * Direct draw surface info
  47962. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47963. */
  47964. export interface DDSInfo {
  47965. /**
  47966. * Width of the texture
  47967. */
  47968. width: number;
  47969. /**
  47970. * Width of the texture
  47971. */
  47972. height: number;
  47973. /**
  47974. * Number of Mipmaps for the texture
  47975. * @see https://en.wikipedia.org/wiki/Mipmap
  47976. */
  47977. mipmapCount: number;
  47978. /**
  47979. * If the textures format is a known fourCC format
  47980. * @see https://www.fourcc.org/
  47981. */
  47982. isFourCC: boolean;
  47983. /**
  47984. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47985. */
  47986. isRGB: boolean;
  47987. /**
  47988. * If the texture is a lumincance format
  47989. */
  47990. isLuminance: boolean;
  47991. /**
  47992. * If this is a cube texture
  47993. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47994. */
  47995. isCube: boolean;
  47996. /**
  47997. * If the texture is a compressed format eg. FOURCC_DXT1
  47998. */
  47999. isCompressed: boolean;
  48000. /**
  48001. * The dxgiFormat of the texture
  48002. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48003. */
  48004. dxgiFormat: number;
  48005. /**
  48006. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48007. */
  48008. textureType: number;
  48009. /**
  48010. * Sphericle polynomial created for the dds texture
  48011. */
  48012. sphericalPolynomial?: SphericalPolynomial;
  48013. }
  48014. /**
  48015. * Class used to provide DDS decompression tools
  48016. */
  48017. export class DDSTools {
  48018. /**
  48019. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48020. */
  48021. static StoreLODInAlphaChannel: boolean;
  48022. /**
  48023. * Gets DDS information from an array buffer
  48024. * @param arrayBuffer defines the array buffer to read data from
  48025. * @returns the DDS information
  48026. */
  48027. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48028. private static _FloatView;
  48029. private static _Int32View;
  48030. private static _ToHalfFloat;
  48031. private static _FromHalfFloat;
  48032. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48033. private static _GetHalfFloatRGBAArrayBuffer;
  48034. private static _GetFloatRGBAArrayBuffer;
  48035. private static _GetFloatAsUIntRGBAArrayBuffer;
  48036. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48037. private static _GetRGBAArrayBuffer;
  48038. private static _ExtractLongWordOrder;
  48039. private static _GetRGBArrayBuffer;
  48040. private static _GetLuminanceArrayBuffer;
  48041. /**
  48042. * Uploads DDS Levels to a Babylon Texture
  48043. * @hidden
  48044. */
  48045. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48046. }
  48047. interface Engine {
  48048. /**
  48049. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48050. * @param rootUrl defines the url where the file to load is located
  48051. * @param scene defines the current scene
  48052. * @param lodScale defines scale to apply to the mip map selection
  48053. * @param lodOffset defines offset to apply to the mip map selection
  48054. * @param onLoad defines an optional callback raised when the texture is loaded
  48055. * @param onError defines an optional callback raised if there is an issue to load the texture
  48056. * @param format defines the format of the data
  48057. * @param forcedExtension defines the extension to use to pick the right loader
  48058. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48059. * @returns the cube texture as an InternalTexture
  48060. */
  48061. 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;
  48062. }
  48063. }
  48064. declare module BABYLON {
  48065. /**
  48066. * Implementation of the DDS Texture Loader.
  48067. * @hidden
  48068. */
  48069. export class _DDSTextureLoader implements IInternalTextureLoader {
  48070. /**
  48071. * Defines wether the loader supports cascade loading the different faces.
  48072. */
  48073. readonly supportCascades: boolean;
  48074. /**
  48075. * This returns if the loader support the current file information.
  48076. * @param extension defines the file extension of the file being loaded
  48077. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48078. * @param fallback defines the fallback internal texture if any
  48079. * @param isBase64 defines whether the texture is encoded as a base64
  48080. * @param isBuffer defines whether the texture data are stored as a buffer
  48081. * @returns true if the loader can load the specified file
  48082. */
  48083. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48084. /**
  48085. * Transform the url before loading if required.
  48086. * @param rootUrl the url of the texture
  48087. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48088. * @returns the transformed texture
  48089. */
  48090. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48091. /**
  48092. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48093. * @param rootUrl the url of the texture
  48094. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48095. * @returns the fallback texture
  48096. */
  48097. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48098. /**
  48099. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48100. * @param data contains the texture data
  48101. * @param texture defines the BabylonJS internal texture
  48102. * @param createPolynomials will be true if polynomials have been requested
  48103. * @param onLoad defines the callback to trigger once the texture is ready
  48104. * @param onError defines the callback to trigger in case of error
  48105. */
  48106. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48107. /**
  48108. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48109. * @param data contains the texture data
  48110. * @param texture defines the BabylonJS internal texture
  48111. * @param callback defines the method to call once ready to upload
  48112. */
  48113. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48114. }
  48115. }
  48116. declare module BABYLON {
  48117. /**
  48118. * Implementation of the ENV Texture Loader.
  48119. * @hidden
  48120. */
  48121. export class _ENVTextureLoader implements IInternalTextureLoader {
  48122. /**
  48123. * Defines wether the loader supports cascade loading the different faces.
  48124. */
  48125. readonly supportCascades: boolean;
  48126. /**
  48127. * This returns if the loader support the current file information.
  48128. * @param extension defines the file extension of the file being loaded
  48129. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48130. * @param fallback defines the fallback internal texture if any
  48131. * @param isBase64 defines whether the texture is encoded as a base64
  48132. * @param isBuffer defines whether the texture data are stored as a buffer
  48133. * @returns true if the loader can load the specified file
  48134. */
  48135. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48136. /**
  48137. * Transform the url before loading if required.
  48138. * @param rootUrl the url of the texture
  48139. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48140. * @returns the transformed texture
  48141. */
  48142. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48143. /**
  48144. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48145. * @param rootUrl the url of the texture
  48146. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48147. * @returns the fallback texture
  48148. */
  48149. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48150. /**
  48151. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48152. * @param data contains the texture data
  48153. * @param texture defines the BabylonJS internal texture
  48154. * @param createPolynomials will be true if polynomials have been requested
  48155. * @param onLoad defines the callback to trigger once the texture is ready
  48156. * @param onError defines the callback to trigger in case of error
  48157. */
  48158. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48159. /**
  48160. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48161. * @param data contains the texture data
  48162. * @param texture defines the BabylonJS internal texture
  48163. * @param callback defines the method to call once ready to upload
  48164. */
  48165. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48166. }
  48167. }
  48168. declare module BABYLON {
  48169. /**
  48170. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48171. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48172. */
  48173. export class KhronosTextureContainer {
  48174. /** contents of the KTX container file */
  48175. arrayBuffer: any;
  48176. private static HEADER_LEN;
  48177. private static COMPRESSED_2D;
  48178. private static COMPRESSED_3D;
  48179. private static TEX_2D;
  48180. private static TEX_3D;
  48181. /**
  48182. * Gets the openGL type
  48183. */
  48184. glType: number;
  48185. /**
  48186. * Gets the openGL type size
  48187. */
  48188. glTypeSize: number;
  48189. /**
  48190. * Gets the openGL format
  48191. */
  48192. glFormat: number;
  48193. /**
  48194. * Gets the openGL internal format
  48195. */
  48196. glInternalFormat: number;
  48197. /**
  48198. * Gets the base internal format
  48199. */
  48200. glBaseInternalFormat: number;
  48201. /**
  48202. * Gets image width in pixel
  48203. */
  48204. pixelWidth: number;
  48205. /**
  48206. * Gets image height in pixel
  48207. */
  48208. pixelHeight: number;
  48209. /**
  48210. * Gets image depth in pixels
  48211. */
  48212. pixelDepth: number;
  48213. /**
  48214. * Gets the number of array elements
  48215. */
  48216. numberOfArrayElements: number;
  48217. /**
  48218. * Gets the number of faces
  48219. */
  48220. numberOfFaces: number;
  48221. /**
  48222. * Gets the number of mipmap levels
  48223. */
  48224. numberOfMipmapLevels: number;
  48225. /**
  48226. * Gets the bytes of key value data
  48227. */
  48228. bytesOfKeyValueData: number;
  48229. /**
  48230. * Gets the load type
  48231. */
  48232. loadType: number;
  48233. /**
  48234. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48235. */
  48236. isInvalid: boolean;
  48237. /**
  48238. * Creates a new KhronosTextureContainer
  48239. * @param arrayBuffer contents of the KTX container file
  48240. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48241. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48242. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48243. */
  48244. constructor(
  48245. /** contents of the KTX container file */
  48246. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48247. /**
  48248. * Uploads KTX content to a Babylon Texture.
  48249. * It is assumed that the texture has already been created & is currently bound
  48250. * @hidden
  48251. */
  48252. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48253. private _upload2DCompressedLevels;
  48254. }
  48255. }
  48256. declare module BABYLON {
  48257. /**
  48258. * Implementation of the KTX Texture Loader.
  48259. * @hidden
  48260. */
  48261. export class _KTXTextureLoader implements IInternalTextureLoader {
  48262. /**
  48263. * Defines wether the loader supports cascade loading the different faces.
  48264. */
  48265. readonly supportCascades: boolean;
  48266. /**
  48267. * This returns if the loader support the current file information.
  48268. * @param extension defines the file extension of the file being loaded
  48269. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48270. * @param fallback defines the fallback internal texture if any
  48271. * @param isBase64 defines whether the texture is encoded as a base64
  48272. * @param isBuffer defines whether the texture data are stored as a buffer
  48273. * @returns true if the loader can load the specified file
  48274. */
  48275. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48276. /**
  48277. * Transform the url before loading if required.
  48278. * @param rootUrl the url of the texture
  48279. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48280. * @returns the transformed texture
  48281. */
  48282. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48283. /**
  48284. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48285. * @param rootUrl the url of the texture
  48286. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48287. * @returns the fallback texture
  48288. */
  48289. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48290. /**
  48291. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48292. * @param data contains the texture data
  48293. * @param texture defines the BabylonJS internal texture
  48294. * @param createPolynomials will be true if polynomials have been requested
  48295. * @param onLoad defines the callback to trigger once the texture is ready
  48296. * @param onError defines the callback to trigger in case of error
  48297. */
  48298. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48299. /**
  48300. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48301. * @param data contains the texture data
  48302. * @param texture defines the BabylonJS internal texture
  48303. * @param callback defines the method to call once ready to upload
  48304. */
  48305. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48306. }
  48307. }
  48308. declare module BABYLON {
  48309. /**
  48310. * Options for the default xr helper
  48311. */
  48312. export class WebXRDefaultExperienceOptions {
  48313. /**
  48314. * Floor meshes that should be used for teleporting
  48315. */
  48316. floorMeshes: Array<AbstractMesh>;
  48317. }
  48318. /**
  48319. * Default experience which provides a similar setup to the previous webVRExperience
  48320. */
  48321. export class WebXRDefaultExperience {
  48322. /**
  48323. * Base experience
  48324. */
  48325. baseExperience: WebXRExperienceHelper;
  48326. /**
  48327. * Input experience extension
  48328. */
  48329. input: WebXRInput;
  48330. /**
  48331. * Loads the controller models
  48332. */
  48333. controllerModelLoader: WebXRControllerModelLoader;
  48334. /**
  48335. * Enables laser pointer and selection
  48336. */
  48337. pointerSelection: WebXRControllerPointerSelection;
  48338. /**
  48339. * Enables teleportation
  48340. */
  48341. teleportation: WebXRControllerTeleportation;
  48342. /**
  48343. * Enables ui for enetering/exiting xr
  48344. */
  48345. enterExitUI: WebXREnterExitUI;
  48346. /**
  48347. * Default output canvas xr should render to
  48348. */
  48349. outputCanvas: WebXRManagedOutputCanvas;
  48350. /**
  48351. * Creates the default xr experience
  48352. * @param scene scene
  48353. * @param options options for basic configuration
  48354. * @returns resulting WebXRDefaultExperience
  48355. */
  48356. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48357. private constructor();
  48358. /**
  48359. * DIsposes of the experience helper
  48360. */
  48361. dispose(): void;
  48362. }
  48363. }
  48364. declare module BABYLON {
  48365. /** @hidden */
  48366. export var _forceSceneHelpersToBundle: boolean;
  48367. interface Scene {
  48368. /**
  48369. * Creates a default light for the scene.
  48370. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48371. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48372. */
  48373. createDefaultLight(replace?: boolean): void;
  48374. /**
  48375. * Creates a default camera for the scene.
  48376. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48377. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48378. * @param replace has default false, when true replaces the active camera in the scene
  48379. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48380. */
  48381. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48382. /**
  48383. * Creates a default camera and a default light.
  48384. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48385. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48386. * @param replace has the default false, when true replaces the active camera/light in the scene
  48387. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48388. */
  48389. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48390. /**
  48391. * Creates a new sky box
  48392. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48393. * @param environmentTexture defines the texture to use as environment texture
  48394. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48395. * @param scale defines the overall scale of the skybox
  48396. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48397. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48398. * @returns a new mesh holding the sky box
  48399. */
  48400. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48401. /**
  48402. * Creates a new environment
  48403. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48404. * @param options defines the options you can use to configure the environment
  48405. * @returns the new EnvironmentHelper
  48406. */
  48407. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48408. /**
  48409. * Creates a new VREXperienceHelper
  48410. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48411. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48412. * @returns a new VREXperienceHelper
  48413. */
  48414. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48415. /**
  48416. * Creates a new WebXRDefaultExperience
  48417. * @see http://doc.babylonjs.com/how_to/webxr
  48418. * @param options experience options
  48419. * @returns a promise for a new WebXRDefaultExperience
  48420. */
  48421. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48422. }
  48423. }
  48424. declare module BABYLON {
  48425. /**
  48426. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48427. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48428. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48429. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48430. */
  48431. export class VideoDome extends TransformNode {
  48432. /**
  48433. * Define the video source as a Monoscopic panoramic 360 video.
  48434. */
  48435. static readonly MODE_MONOSCOPIC: number;
  48436. /**
  48437. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48438. */
  48439. static readonly MODE_TOPBOTTOM: number;
  48440. /**
  48441. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48442. */
  48443. static readonly MODE_SIDEBYSIDE: number;
  48444. private _halfDome;
  48445. private _useDirectMapping;
  48446. /**
  48447. * The video texture being displayed on the sphere
  48448. */
  48449. protected _videoTexture: VideoTexture;
  48450. /**
  48451. * Gets the video texture being displayed on the sphere
  48452. */
  48453. readonly videoTexture: VideoTexture;
  48454. /**
  48455. * The skybox material
  48456. */
  48457. protected _material: BackgroundMaterial;
  48458. /**
  48459. * The surface used for the skybox
  48460. */
  48461. protected _mesh: Mesh;
  48462. /**
  48463. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48464. */
  48465. private _halfDomeMask;
  48466. /**
  48467. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48468. * Also see the options.resolution property.
  48469. */
  48470. fovMultiplier: number;
  48471. private _videoMode;
  48472. /**
  48473. * Gets or set the current video mode for the video. It can be:
  48474. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48475. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48476. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48477. */
  48478. videoMode: number;
  48479. /**
  48480. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48481. *
  48482. */
  48483. /**
  48484. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48485. */
  48486. halfDome: boolean;
  48487. /**
  48488. * Oberserver used in Stereoscopic VR Mode.
  48489. */
  48490. private _onBeforeCameraRenderObserver;
  48491. /**
  48492. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48493. * @param name Element's name, child elements will append suffixes for their own names.
  48494. * @param urlsOrVideo defines the url(s) or the video element to use
  48495. * @param options An object containing optional or exposed sub element properties
  48496. */
  48497. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48498. resolution?: number;
  48499. clickToPlay?: boolean;
  48500. autoPlay?: boolean;
  48501. loop?: boolean;
  48502. size?: number;
  48503. poster?: string;
  48504. faceForward?: boolean;
  48505. useDirectMapping?: boolean;
  48506. halfDomeMode?: boolean;
  48507. }, scene: Scene);
  48508. private _changeVideoMode;
  48509. /**
  48510. * Releases resources associated with this node.
  48511. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48512. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48513. */
  48514. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48515. }
  48516. }
  48517. declare module BABYLON {
  48518. /**
  48519. * This class can be used to get instrumentation data from a Babylon engine
  48520. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48521. */
  48522. export class EngineInstrumentation implements IDisposable {
  48523. /**
  48524. * Define the instrumented engine.
  48525. */
  48526. engine: Engine;
  48527. private _captureGPUFrameTime;
  48528. private _gpuFrameTimeToken;
  48529. private _gpuFrameTime;
  48530. private _captureShaderCompilationTime;
  48531. private _shaderCompilationTime;
  48532. private _onBeginFrameObserver;
  48533. private _onEndFrameObserver;
  48534. private _onBeforeShaderCompilationObserver;
  48535. private _onAfterShaderCompilationObserver;
  48536. /**
  48537. * Gets the perf counter used for GPU frame time
  48538. */
  48539. readonly gpuFrameTimeCounter: PerfCounter;
  48540. /**
  48541. * Gets the GPU frame time capture status
  48542. */
  48543. /**
  48544. * Enable or disable the GPU frame time capture
  48545. */
  48546. captureGPUFrameTime: boolean;
  48547. /**
  48548. * Gets the perf counter used for shader compilation time
  48549. */
  48550. readonly shaderCompilationTimeCounter: PerfCounter;
  48551. /**
  48552. * Gets the shader compilation time capture status
  48553. */
  48554. /**
  48555. * Enable or disable the shader compilation time capture
  48556. */
  48557. captureShaderCompilationTime: boolean;
  48558. /**
  48559. * Instantiates a new engine instrumentation.
  48560. * This class can be used to get instrumentation data from a Babylon engine
  48561. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48562. * @param engine Defines the engine to instrument
  48563. */
  48564. constructor(
  48565. /**
  48566. * Define the instrumented engine.
  48567. */
  48568. engine: Engine);
  48569. /**
  48570. * Dispose and release associated resources.
  48571. */
  48572. dispose(): void;
  48573. }
  48574. }
  48575. declare module BABYLON {
  48576. /**
  48577. * This class can be used to get instrumentation data from a Babylon engine
  48578. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48579. */
  48580. export class SceneInstrumentation implements IDisposable {
  48581. /**
  48582. * Defines the scene to instrument
  48583. */
  48584. scene: Scene;
  48585. private _captureActiveMeshesEvaluationTime;
  48586. private _activeMeshesEvaluationTime;
  48587. private _captureRenderTargetsRenderTime;
  48588. private _renderTargetsRenderTime;
  48589. private _captureFrameTime;
  48590. private _frameTime;
  48591. private _captureRenderTime;
  48592. private _renderTime;
  48593. private _captureInterFrameTime;
  48594. private _interFrameTime;
  48595. private _captureParticlesRenderTime;
  48596. private _particlesRenderTime;
  48597. private _captureSpritesRenderTime;
  48598. private _spritesRenderTime;
  48599. private _capturePhysicsTime;
  48600. private _physicsTime;
  48601. private _captureAnimationsTime;
  48602. private _animationsTime;
  48603. private _captureCameraRenderTime;
  48604. private _cameraRenderTime;
  48605. private _onBeforeActiveMeshesEvaluationObserver;
  48606. private _onAfterActiveMeshesEvaluationObserver;
  48607. private _onBeforeRenderTargetsRenderObserver;
  48608. private _onAfterRenderTargetsRenderObserver;
  48609. private _onAfterRenderObserver;
  48610. private _onBeforeDrawPhaseObserver;
  48611. private _onAfterDrawPhaseObserver;
  48612. private _onBeforeAnimationsObserver;
  48613. private _onBeforeParticlesRenderingObserver;
  48614. private _onAfterParticlesRenderingObserver;
  48615. private _onBeforeSpritesRenderingObserver;
  48616. private _onAfterSpritesRenderingObserver;
  48617. private _onBeforePhysicsObserver;
  48618. private _onAfterPhysicsObserver;
  48619. private _onAfterAnimationsObserver;
  48620. private _onBeforeCameraRenderObserver;
  48621. private _onAfterCameraRenderObserver;
  48622. /**
  48623. * Gets the perf counter used for active meshes evaluation time
  48624. */
  48625. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48626. /**
  48627. * Gets the active meshes evaluation time capture status
  48628. */
  48629. /**
  48630. * Enable or disable the active meshes evaluation time capture
  48631. */
  48632. captureActiveMeshesEvaluationTime: boolean;
  48633. /**
  48634. * Gets the perf counter used for render targets render time
  48635. */
  48636. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48637. /**
  48638. * Gets the render targets render time capture status
  48639. */
  48640. /**
  48641. * Enable or disable the render targets render time capture
  48642. */
  48643. captureRenderTargetsRenderTime: boolean;
  48644. /**
  48645. * Gets the perf counter used for particles render time
  48646. */
  48647. readonly particlesRenderTimeCounter: PerfCounter;
  48648. /**
  48649. * Gets the particles render time capture status
  48650. */
  48651. /**
  48652. * Enable or disable the particles render time capture
  48653. */
  48654. captureParticlesRenderTime: boolean;
  48655. /**
  48656. * Gets the perf counter used for sprites render time
  48657. */
  48658. readonly spritesRenderTimeCounter: PerfCounter;
  48659. /**
  48660. * Gets the sprites render time capture status
  48661. */
  48662. /**
  48663. * Enable or disable the sprites render time capture
  48664. */
  48665. captureSpritesRenderTime: boolean;
  48666. /**
  48667. * Gets the perf counter used for physics time
  48668. */
  48669. readonly physicsTimeCounter: PerfCounter;
  48670. /**
  48671. * Gets the physics time capture status
  48672. */
  48673. /**
  48674. * Enable or disable the physics time capture
  48675. */
  48676. capturePhysicsTime: boolean;
  48677. /**
  48678. * Gets the perf counter used for animations time
  48679. */
  48680. readonly animationsTimeCounter: PerfCounter;
  48681. /**
  48682. * Gets the animations time capture status
  48683. */
  48684. /**
  48685. * Enable or disable the animations time capture
  48686. */
  48687. captureAnimationsTime: boolean;
  48688. /**
  48689. * Gets the perf counter used for frame time capture
  48690. */
  48691. readonly frameTimeCounter: PerfCounter;
  48692. /**
  48693. * Gets the frame time capture status
  48694. */
  48695. /**
  48696. * Enable or disable the frame time capture
  48697. */
  48698. captureFrameTime: boolean;
  48699. /**
  48700. * Gets the perf counter used for inter-frames time capture
  48701. */
  48702. readonly interFrameTimeCounter: PerfCounter;
  48703. /**
  48704. * Gets the inter-frames time capture status
  48705. */
  48706. /**
  48707. * Enable or disable the inter-frames time capture
  48708. */
  48709. captureInterFrameTime: boolean;
  48710. /**
  48711. * Gets the perf counter used for render time capture
  48712. */
  48713. readonly renderTimeCounter: PerfCounter;
  48714. /**
  48715. * Gets the render time capture status
  48716. */
  48717. /**
  48718. * Enable or disable the render time capture
  48719. */
  48720. captureRenderTime: boolean;
  48721. /**
  48722. * Gets the perf counter used for camera render time capture
  48723. */
  48724. readonly cameraRenderTimeCounter: PerfCounter;
  48725. /**
  48726. * Gets the camera render time capture status
  48727. */
  48728. /**
  48729. * Enable or disable the camera render time capture
  48730. */
  48731. captureCameraRenderTime: boolean;
  48732. /**
  48733. * Gets the perf counter used for draw calls
  48734. */
  48735. readonly drawCallsCounter: PerfCounter;
  48736. /**
  48737. * Instantiates a new scene instrumentation.
  48738. * This class can be used to get instrumentation data from a Babylon engine
  48739. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48740. * @param scene Defines the scene to instrument
  48741. */
  48742. constructor(
  48743. /**
  48744. * Defines the scene to instrument
  48745. */
  48746. scene: Scene);
  48747. /**
  48748. * Dispose and release associated resources.
  48749. */
  48750. dispose(): void;
  48751. }
  48752. }
  48753. declare module BABYLON {
  48754. /** @hidden */
  48755. export var glowMapGenerationPixelShader: {
  48756. name: string;
  48757. shader: string;
  48758. };
  48759. }
  48760. declare module BABYLON {
  48761. /** @hidden */
  48762. export var glowMapGenerationVertexShader: {
  48763. name: string;
  48764. shader: string;
  48765. };
  48766. }
  48767. declare module BABYLON {
  48768. /**
  48769. * Effect layer options. This helps customizing the behaviour
  48770. * of the effect layer.
  48771. */
  48772. export interface IEffectLayerOptions {
  48773. /**
  48774. * Multiplication factor apply to the canvas size to compute the render target size
  48775. * used to generated the objects (the smaller the faster).
  48776. */
  48777. mainTextureRatio: number;
  48778. /**
  48779. * Enforces a fixed size texture to ensure effect stability across devices.
  48780. */
  48781. mainTextureFixedSize?: number;
  48782. /**
  48783. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48784. */
  48785. alphaBlendingMode: number;
  48786. /**
  48787. * The camera attached to the layer.
  48788. */
  48789. camera: Nullable<Camera>;
  48790. /**
  48791. * The rendering group to draw the layer in.
  48792. */
  48793. renderingGroupId: number;
  48794. }
  48795. /**
  48796. * The effect layer Helps adding post process effect blended with the main pass.
  48797. *
  48798. * This can be for instance use to generate glow or higlight effects on the scene.
  48799. *
  48800. * The effect layer class can not be used directly and is intented to inherited from to be
  48801. * customized per effects.
  48802. */
  48803. export abstract class EffectLayer {
  48804. private _vertexBuffers;
  48805. private _indexBuffer;
  48806. private _cachedDefines;
  48807. private _effectLayerMapGenerationEffect;
  48808. private _effectLayerOptions;
  48809. private _mergeEffect;
  48810. protected _scene: Scene;
  48811. protected _engine: Engine;
  48812. protected _maxSize: number;
  48813. protected _mainTextureDesiredSize: ISize;
  48814. protected _mainTexture: RenderTargetTexture;
  48815. protected _shouldRender: boolean;
  48816. protected _postProcesses: PostProcess[];
  48817. protected _textures: BaseTexture[];
  48818. protected _emissiveTextureAndColor: {
  48819. texture: Nullable<BaseTexture>;
  48820. color: Color4;
  48821. };
  48822. /**
  48823. * The name of the layer
  48824. */
  48825. name: string;
  48826. /**
  48827. * The clear color of the texture used to generate the glow map.
  48828. */
  48829. neutralColor: Color4;
  48830. /**
  48831. * Specifies wether the highlight layer is enabled or not.
  48832. */
  48833. isEnabled: boolean;
  48834. /**
  48835. * Gets the camera attached to the layer.
  48836. */
  48837. readonly camera: Nullable<Camera>;
  48838. /**
  48839. * Gets the rendering group id the layer should render in.
  48840. */
  48841. renderingGroupId: number;
  48842. /**
  48843. * An event triggered when the effect layer has been disposed.
  48844. */
  48845. onDisposeObservable: Observable<EffectLayer>;
  48846. /**
  48847. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48848. */
  48849. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48850. /**
  48851. * An event triggered when the generated texture is being merged in the scene.
  48852. */
  48853. onBeforeComposeObservable: Observable<EffectLayer>;
  48854. /**
  48855. * An event triggered when the generated texture has been merged in the scene.
  48856. */
  48857. onAfterComposeObservable: Observable<EffectLayer>;
  48858. /**
  48859. * An event triggered when the efffect layer changes its size.
  48860. */
  48861. onSizeChangedObservable: Observable<EffectLayer>;
  48862. /** @hidden */
  48863. static _SceneComponentInitialization: (scene: Scene) => void;
  48864. /**
  48865. * Instantiates a new effect Layer and references it in the scene.
  48866. * @param name The name of the layer
  48867. * @param scene The scene to use the layer in
  48868. */
  48869. constructor(
  48870. /** The Friendly of the effect in the scene */
  48871. name: string, scene: Scene);
  48872. /**
  48873. * Get the effect name of the layer.
  48874. * @return The effect name
  48875. */
  48876. abstract getEffectName(): string;
  48877. /**
  48878. * Checks for the readiness of the element composing the layer.
  48879. * @param subMesh the mesh to check for
  48880. * @param useInstances specify wether or not to use instances to render the mesh
  48881. * @return true if ready otherwise, false
  48882. */
  48883. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48884. /**
  48885. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48886. * @returns true if the effect requires stencil during the main canvas render pass.
  48887. */
  48888. abstract needStencil(): boolean;
  48889. /**
  48890. * Create the merge effect. This is the shader use to blit the information back
  48891. * to the main canvas at the end of the scene rendering.
  48892. * @returns The effect containing the shader used to merge the effect on the main canvas
  48893. */
  48894. protected abstract _createMergeEffect(): Effect;
  48895. /**
  48896. * Creates the render target textures and post processes used in the effect layer.
  48897. */
  48898. protected abstract _createTextureAndPostProcesses(): void;
  48899. /**
  48900. * Implementation specific of rendering the generating effect on the main canvas.
  48901. * @param effect The effect used to render through
  48902. */
  48903. protected abstract _internalRender(effect: Effect): void;
  48904. /**
  48905. * Sets the required values for both the emissive texture and and the main color.
  48906. */
  48907. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48908. /**
  48909. * Free any resources and references associated to a mesh.
  48910. * Internal use
  48911. * @param mesh The mesh to free.
  48912. */
  48913. abstract _disposeMesh(mesh: Mesh): void;
  48914. /**
  48915. * Serializes this layer (Glow or Highlight for example)
  48916. * @returns a serialized layer object
  48917. */
  48918. abstract serialize?(): any;
  48919. /**
  48920. * Initializes the effect layer with the required options.
  48921. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48922. */
  48923. protected _init(options: Partial<IEffectLayerOptions>): void;
  48924. /**
  48925. * Generates the index buffer of the full screen quad blending to the main canvas.
  48926. */
  48927. private _generateIndexBuffer;
  48928. /**
  48929. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48930. */
  48931. private _generateVertexBuffer;
  48932. /**
  48933. * Sets the main texture desired size which is the closest power of two
  48934. * of the engine canvas size.
  48935. */
  48936. private _setMainTextureSize;
  48937. /**
  48938. * Creates the main texture for the effect layer.
  48939. */
  48940. protected _createMainTexture(): void;
  48941. /**
  48942. * Adds specific effects defines.
  48943. * @param defines The defines to add specifics to.
  48944. */
  48945. protected _addCustomEffectDefines(defines: string[]): void;
  48946. /**
  48947. * Checks for the readiness of the element composing the layer.
  48948. * @param subMesh the mesh to check for
  48949. * @param useInstances specify wether or not to use instances to render the mesh
  48950. * @param emissiveTexture the associated emissive texture used to generate the glow
  48951. * @return true if ready otherwise, false
  48952. */
  48953. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48954. /**
  48955. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48956. */
  48957. render(): void;
  48958. /**
  48959. * Determine if a given mesh will be used in the current effect.
  48960. * @param mesh mesh to test
  48961. * @returns true if the mesh will be used
  48962. */
  48963. hasMesh(mesh: AbstractMesh): boolean;
  48964. /**
  48965. * Returns true if the layer contains information to display, otherwise false.
  48966. * @returns true if the glow layer should be rendered
  48967. */
  48968. shouldRender(): boolean;
  48969. /**
  48970. * Returns true if the mesh should render, otherwise false.
  48971. * @param mesh The mesh to render
  48972. * @returns true if it should render otherwise false
  48973. */
  48974. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48975. /**
  48976. * Returns true if the mesh can be rendered, otherwise false.
  48977. * @param mesh The mesh to render
  48978. * @param material The material used on the mesh
  48979. * @returns true if it can be rendered otherwise false
  48980. */
  48981. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48982. /**
  48983. * Returns true if the mesh should render, otherwise false.
  48984. * @param mesh The mesh to render
  48985. * @returns true if it should render otherwise false
  48986. */
  48987. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48988. /**
  48989. * Renders the submesh passed in parameter to the generation map.
  48990. */
  48991. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48992. /**
  48993. * Rebuild the required buffers.
  48994. * @hidden Internal use only.
  48995. */
  48996. _rebuild(): void;
  48997. /**
  48998. * Dispose only the render target textures and post process.
  48999. */
  49000. private _disposeTextureAndPostProcesses;
  49001. /**
  49002. * Dispose the highlight layer and free resources.
  49003. */
  49004. dispose(): void;
  49005. /**
  49006. * Gets the class name of the effect layer
  49007. * @returns the string with the class name of the effect layer
  49008. */
  49009. getClassName(): string;
  49010. /**
  49011. * Creates an effect layer from parsed effect layer data
  49012. * @param parsedEffectLayer defines effect layer data
  49013. * @param scene defines the current scene
  49014. * @param rootUrl defines the root URL containing the effect layer information
  49015. * @returns a parsed effect Layer
  49016. */
  49017. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49018. }
  49019. }
  49020. declare module BABYLON {
  49021. interface AbstractScene {
  49022. /**
  49023. * The list of effect layers (highlights/glow) added to the scene
  49024. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49025. * @see http://doc.babylonjs.com/how_to/glow_layer
  49026. */
  49027. effectLayers: Array<EffectLayer>;
  49028. /**
  49029. * Removes the given effect layer from this scene.
  49030. * @param toRemove defines the effect layer to remove
  49031. * @returns the index of the removed effect layer
  49032. */
  49033. removeEffectLayer(toRemove: EffectLayer): number;
  49034. /**
  49035. * Adds the given effect layer to this scene
  49036. * @param newEffectLayer defines the effect layer to add
  49037. */
  49038. addEffectLayer(newEffectLayer: EffectLayer): void;
  49039. }
  49040. /**
  49041. * Defines the layer scene component responsible to manage any effect layers
  49042. * in a given scene.
  49043. */
  49044. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49045. /**
  49046. * The component name helpfull to identify the component in the list of scene components.
  49047. */
  49048. readonly name: string;
  49049. /**
  49050. * The scene the component belongs to.
  49051. */
  49052. scene: Scene;
  49053. private _engine;
  49054. private _renderEffects;
  49055. private _needStencil;
  49056. private _previousStencilState;
  49057. /**
  49058. * Creates a new instance of the component for the given scene
  49059. * @param scene Defines the scene to register the component in
  49060. */
  49061. constructor(scene: Scene);
  49062. /**
  49063. * Registers the component in a given scene
  49064. */
  49065. register(): void;
  49066. /**
  49067. * Rebuilds the elements related to this component in case of
  49068. * context lost for instance.
  49069. */
  49070. rebuild(): void;
  49071. /**
  49072. * Serializes the component data to the specified json object
  49073. * @param serializationObject The object to serialize to
  49074. */
  49075. serialize(serializationObject: any): void;
  49076. /**
  49077. * Adds all the elements from the container to the scene
  49078. * @param container the container holding the elements
  49079. */
  49080. addFromContainer(container: AbstractScene): void;
  49081. /**
  49082. * Removes all the elements in the container from the scene
  49083. * @param container contains the elements to remove
  49084. * @param dispose if the removed element should be disposed (default: false)
  49085. */
  49086. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49087. /**
  49088. * Disposes the component and the associated ressources.
  49089. */
  49090. dispose(): void;
  49091. private _isReadyForMesh;
  49092. private _renderMainTexture;
  49093. private _setStencil;
  49094. private _setStencilBack;
  49095. private _draw;
  49096. private _drawCamera;
  49097. private _drawRenderingGroup;
  49098. }
  49099. }
  49100. declare module BABYLON {
  49101. /** @hidden */
  49102. export var glowMapMergePixelShader: {
  49103. name: string;
  49104. shader: string;
  49105. };
  49106. }
  49107. declare module BABYLON {
  49108. /** @hidden */
  49109. export var glowMapMergeVertexShader: {
  49110. name: string;
  49111. shader: string;
  49112. };
  49113. }
  49114. declare module BABYLON {
  49115. interface AbstractScene {
  49116. /**
  49117. * Return a the first highlight layer of the scene with a given name.
  49118. * @param name The name of the highlight layer to look for.
  49119. * @return The highlight layer if found otherwise null.
  49120. */
  49121. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49122. }
  49123. /**
  49124. * Glow layer options. This helps customizing the behaviour
  49125. * of the glow layer.
  49126. */
  49127. export interface IGlowLayerOptions {
  49128. /**
  49129. * Multiplication factor apply to the canvas size to compute the render target size
  49130. * used to generated the glowing objects (the smaller the faster).
  49131. */
  49132. mainTextureRatio: number;
  49133. /**
  49134. * Enforces a fixed size texture to ensure resize independant blur.
  49135. */
  49136. mainTextureFixedSize?: number;
  49137. /**
  49138. * How big is the kernel of the blur texture.
  49139. */
  49140. blurKernelSize: number;
  49141. /**
  49142. * The camera attached to the layer.
  49143. */
  49144. camera: Nullable<Camera>;
  49145. /**
  49146. * Enable MSAA by chosing the number of samples.
  49147. */
  49148. mainTextureSamples?: number;
  49149. /**
  49150. * The rendering group to draw the layer in.
  49151. */
  49152. renderingGroupId: number;
  49153. }
  49154. /**
  49155. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49156. *
  49157. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49158. * glowy meshes to your scene.
  49159. *
  49160. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49161. */
  49162. export class GlowLayer extends EffectLayer {
  49163. /**
  49164. * Effect Name of the layer.
  49165. */
  49166. static readonly EffectName: string;
  49167. /**
  49168. * The default blur kernel size used for the glow.
  49169. */
  49170. static DefaultBlurKernelSize: number;
  49171. /**
  49172. * The default texture size ratio used for the glow.
  49173. */
  49174. static DefaultTextureRatio: number;
  49175. /**
  49176. * Sets the kernel size of the blur.
  49177. */
  49178. /**
  49179. * Gets the kernel size of the blur.
  49180. */
  49181. blurKernelSize: number;
  49182. /**
  49183. * Sets the glow intensity.
  49184. */
  49185. /**
  49186. * Gets the glow intensity.
  49187. */
  49188. intensity: number;
  49189. private _options;
  49190. private _intensity;
  49191. private _horizontalBlurPostprocess1;
  49192. private _verticalBlurPostprocess1;
  49193. private _horizontalBlurPostprocess2;
  49194. private _verticalBlurPostprocess2;
  49195. private _blurTexture1;
  49196. private _blurTexture2;
  49197. private _postProcesses1;
  49198. private _postProcesses2;
  49199. private _includedOnlyMeshes;
  49200. private _excludedMeshes;
  49201. /**
  49202. * Callback used to let the user override the color selection on a per mesh basis
  49203. */
  49204. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49205. /**
  49206. * Callback used to let the user override the texture selection on a per mesh basis
  49207. */
  49208. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49209. /**
  49210. * Instantiates a new glow Layer and references it to the scene.
  49211. * @param name The name of the layer
  49212. * @param scene The scene to use the layer in
  49213. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49214. */
  49215. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49216. /**
  49217. * Get the effect name of the layer.
  49218. * @return The effect name
  49219. */
  49220. getEffectName(): string;
  49221. /**
  49222. * Create the merge effect. This is the shader use to blit the information back
  49223. * to the main canvas at the end of the scene rendering.
  49224. */
  49225. protected _createMergeEffect(): Effect;
  49226. /**
  49227. * Creates the render target textures and post processes used in the glow layer.
  49228. */
  49229. protected _createTextureAndPostProcesses(): void;
  49230. /**
  49231. * Checks for the readiness of the element composing the layer.
  49232. * @param subMesh the mesh to check for
  49233. * @param useInstances specify wether or not to use instances to render the mesh
  49234. * @param emissiveTexture the associated emissive texture used to generate the glow
  49235. * @return true if ready otherwise, false
  49236. */
  49237. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49238. /**
  49239. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49240. */
  49241. needStencil(): boolean;
  49242. /**
  49243. * Returns true if the mesh can be rendered, otherwise false.
  49244. * @param mesh The mesh to render
  49245. * @param material The material used on the mesh
  49246. * @returns true if it can be rendered otherwise false
  49247. */
  49248. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49249. /**
  49250. * Implementation specific of rendering the generating effect on the main canvas.
  49251. * @param effect The effect used to render through
  49252. */
  49253. protected _internalRender(effect: Effect): void;
  49254. /**
  49255. * Sets the required values for both the emissive texture and and the main color.
  49256. */
  49257. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49258. /**
  49259. * Returns true if the mesh should render, otherwise false.
  49260. * @param mesh The mesh to render
  49261. * @returns true if it should render otherwise false
  49262. */
  49263. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49264. /**
  49265. * Adds specific effects defines.
  49266. * @param defines The defines to add specifics to.
  49267. */
  49268. protected _addCustomEffectDefines(defines: string[]): void;
  49269. /**
  49270. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49271. * @param mesh The mesh to exclude from the glow layer
  49272. */
  49273. addExcludedMesh(mesh: Mesh): void;
  49274. /**
  49275. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49276. * @param mesh The mesh to remove
  49277. */
  49278. removeExcludedMesh(mesh: Mesh): void;
  49279. /**
  49280. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49281. * @param mesh The mesh to include in the glow layer
  49282. */
  49283. addIncludedOnlyMesh(mesh: Mesh): void;
  49284. /**
  49285. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49286. * @param mesh The mesh to remove
  49287. */
  49288. removeIncludedOnlyMesh(mesh: Mesh): void;
  49289. /**
  49290. * Determine if a given mesh will be used in the glow layer
  49291. * @param mesh The mesh to test
  49292. * @returns true if the mesh will be highlighted by the current glow layer
  49293. */
  49294. hasMesh(mesh: AbstractMesh): boolean;
  49295. /**
  49296. * Free any resources and references associated to a mesh.
  49297. * Internal use
  49298. * @param mesh The mesh to free.
  49299. * @hidden
  49300. */
  49301. _disposeMesh(mesh: Mesh): void;
  49302. /**
  49303. * Gets the class name of the effect layer
  49304. * @returns the string with the class name of the effect layer
  49305. */
  49306. getClassName(): string;
  49307. /**
  49308. * Serializes this glow layer
  49309. * @returns a serialized glow layer object
  49310. */
  49311. serialize(): any;
  49312. /**
  49313. * Creates a Glow Layer from parsed glow layer data
  49314. * @param parsedGlowLayer defines glow layer data
  49315. * @param scene defines the current scene
  49316. * @param rootUrl defines the root URL containing the glow layer information
  49317. * @returns a parsed Glow Layer
  49318. */
  49319. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49320. }
  49321. }
  49322. declare module BABYLON {
  49323. /** @hidden */
  49324. export var glowBlurPostProcessPixelShader: {
  49325. name: string;
  49326. shader: string;
  49327. };
  49328. }
  49329. declare module BABYLON {
  49330. interface AbstractScene {
  49331. /**
  49332. * Return a the first highlight layer of the scene with a given name.
  49333. * @param name The name of the highlight layer to look for.
  49334. * @return The highlight layer if found otherwise null.
  49335. */
  49336. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49337. }
  49338. /**
  49339. * Highlight layer options. This helps customizing the behaviour
  49340. * of the highlight layer.
  49341. */
  49342. export interface IHighlightLayerOptions {
  49343. /**
  49344. * Multiplication factor apply to the canvas size to compute the render target size
  49345. * used to generated the glowing objects (the smaller the faster).
  49346. */
  49347. mainTextureRatio: number;
  49348. /**
  49349. * Enforces a fixed size texture to ensure resize independant blur.
  49350. */
  49351. mainTextureFixedSize?: number;
  49352. /**
  49353. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49354. * of the picture to blur (the smaller the faster).
  49355. */
  49356. blurTextureSizeRatio: number;
  49357. /**
  49358. * How big in texel of the blur texture is the vertical blur.
  49359. */
  49360. blurVerticalSize: number;
  49361. /**
  49362. * How big in texel of the blur texture is the horizontal blur.
  49363. */
  49364. blurHorizontalSize: number;
  49365. /**
  49366. * Alpha blending mode used to apply the blur. Default is combine.
  49367. */
  49368. alphaBlendingMode: number;
  49369. /**
  49370. * The camera attached to the layer.
  49371. */
  49372. camera: Nullable<Camera>;
  49373. /**
  49374. * Should we display highlight as a solid stroke?
  49375. */
  49376. isStroke?: boolean;
  49377. /**
  49378. * The rendering group to draw the layer in.
  49379. */
  49380. renderingGroupId: number;
  49381. }
  49382. /**
  49383. * The highlight layer Helps adding a glow effect around a mesh.
  49384. *
  49385. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49386. * glowy meshes to your scene.
  49387. *
  49388. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49389. */
  49390. export class HighlightLayer extends EffectLayer {
  49391. name: string;
  49392. /**
  49393. * Effect Name of the highlight layer.
  49394. */
  49395. static readonly EffectName: string;
  49396. /**
  49397. * The neutral color used during the preparation of the glow effect.
  49398. * This is black by default as the blend operation is a blend operation.
  49399. */
  49400. static NeutralColor: Color4;
  49401. /**
  49402. * Stencil value used for glowing meshes.
  49403. */
  49404. static GlowingMeshStencilReference: number;
  49405. /**
  49406. * Stencil value used for the other meshes in the scene.
  49407. */
  49408. static NormalMeshStencilReference: number;
  49409. /**
  49410. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49411. */
  49412. innerGlow: boolean;
  49413. /**
  49414. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49415. */
  49416. outerGlow: boolean;
  49417. /**
  49418. * Specifies the horizontal size of the blur.
  49419. */
  49420. /**
  49421. * Gets the horizontal size of the blur.
  49422. */
  49423. blurHorizontalSize: number;
  49424. /**
  49425. * Specifies the vertical size of the blur.
  49426. */
  49427. /**
  49428. * Gets the vertical size of the blur.
  49429. */
  49430. blurVerticalSize: number;
  49431. /**
  49432. * An event triggered when the highlight layer is being blurred.
  49433. */
  49434. onBeforeBlurObservable: Observable<HighlightLayer>;
  49435. /**
  49436. * An event triggered when the highlight layer has been blurred.
  49437. */
  49438. onAfterBlurObservable: Observable<HighlightLayer>;
  49439. private _instanceGlowingMeshStencilReference;
  49440. private _options;
  49441. private _downSamplePostprocess;
  49442. private _horizontalBlurPostprocess;
  49443. private _verticalBlurPostprocess;
  49444. private _blurTexture;
  49445. private _meshes;
  49446. private _excludedMeshes;
  49447. /**
  49448. * Instantiates a new highlight Layer and references it to the scene..
  49449. * @param name The name of the layer
  49450. * @param scene The scene to use the layer in
  49451. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49452. */
  49453. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49454. /**
  49455. * Get the effect name of the layer.
  49456. * @return The effect name
  49457. */
  49458. getEffectName(): string;
  49459. /**
  49460. * Create the merge effect. This is the shader use to blit the information back
  49461. * to the main canvas at the end of the scene rendering.
  49462. */
  49463. protected _createMergeEffect(): Effect;
  49464. /**
  49465. * Creates the render target textures and post processes used in the highlight layer.
  49466. */
  49467. protected _createTextureAndPostProcesses(): void;
  49468. /**
  49469. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49470. */
  49471. needStencil(): boolean;
  49472. /**
  49473. * Checks for the readiness of the element composing the layer.
  49474. * @param subMesh the mesh to check for
  49475. * @param useInstances specify wether or not to use instances to render the mesh
  49476. * @param emissiveTexture the associated emissive texture used to generate the glow
  49477. * @return true if ready otherwise, false
  49478. */
  49479. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49480. /**
  49481. * Implementation specific of rendering the generating effect on the main canvas.
  49482. * @param effect The effect used to render through
  49483. */
  49484. protected _internalRender(effect: Effect): void;
  49485. /**
  49486. * Returns true if the layer contains information to display, otherwise false.
  49487. */
  49488. shouldRender(): boolean;
  49489. /**
  49490. * Returns true if the mesh should render, otherwise false.
  49491. * @param mesh The mesh to render
  49492. * @returns true if it should render otherwise false
  49493. */
  49494. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49495. /**
  49496. * Sets the required values for both the emissive texture and and the main color.
  49497. */
  49498. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49499. /**
  49500. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49501. * @param mesh The mesh to exclude from the highlight layer
  49502. */
  49503. addExcludedMesh(mesh: Mesh): void;
  49504. /**
  49505. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49506. * @param mesh The mesh to highlight
  49507. */
  49508. removeExcludedMesh(mesh: Mesh): void;
  49509. /**
  49510. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49511. * @param mesh mesh to test
  49512. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49513. */
  49514. hasMesh(mesh: AbstractMesh): boolean;
  49515. /**
  49516. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49517. * @param mesh The mesh to highlight
  49518. * @param color The color of the highlight
  49519. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49520. */
  49521. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49522. /**
  49523. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49524. * @param mesh The mesh to highlight
  49525. */
  49526. removeMesh(mesh: Mesh): void;
  49527. /**
  49528. * Force the stencil to the normal expected value for none glowing parts
  49529. */
  49530. private _defaultStencilReference;
  49531. /**
  49532. * Free any resources and references associated to a mesh.
  49533. * Internal use
  49534. * @param mesh The mesh to free.
  49535. * @hidden
  49536. */
  49537. _disposeMesh(mesh: Mesh): void;
  49538. /**
  49539. * Dispose the highlight layer and free resources.
  49540. */
  49541. dispose(): void;
  49542. /**
  49543. * Gets the class name of the effect layer
  49544. * @returns the string with the class name of the effect layer
  49545. */
  49546. getClassName(): string;
  49547. /**
  49548. * Serializes this Highlight layer
  49549. * @returns a serialized Highlight layer object
  49550. */
  49551. serialize(): any;
  49552. /**
  49553. * Creates a Highlight layer from parsed Highlight layer data
  49554. * @param parsedHightlightLayer defines the Highlight layer data
  49555. * @param scene defines the current scene
  49556. * @param rootUrl defines the root URL containing the Highlight layer information
  49557. * @returns a parsed Highlight layer
  49558. */
  49559. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49560. }
  49561. }
  49562. declare module BABYLON {
  49563. interface AbstractScene {
  49564. /**
  49565. * The list of layers (background and foreground) of the scene
  49566. */
  49567. layers: Array<Layer>;
  49568. }
  49569. /**
  49570. * Defines the layer scene component responsible to manage any layers
  49571. * in a given scene.
  49572. */
  49573. export class LayerSceneComponent implements ISceneComponent {
  49574. /**
  49575. * The component name helpfull to identify the component in the list of scene components.
  49576. */
  49577. readonly name: string;
  49578. /**
  49579. * The scene the component belongs to.
  49580. */
  49581. scene: Scene;
  49582. private _engine;
  49583. /**
  49584. * Creates a new instance of the component for the given scene
  49585. * @param scene Defines the scene to register the component in
  49586. */
  49587. constructor(scene: Scene);
  49588. /**
  49589. * Registers the component in a given scene
  49590. */
  49591. register(): void;
  49592. /**
  49593. * Rebuilds the elements related to this component in case of
  49594. * context lost for instance.
  49595. */
  49596. rebuild(): void;
  49597. /**
  49598. * Disposes the component and the associated ressources.
  49599. */
  49600. dispose(): void;
  49601. private _draw;
  49602. private _drawCameraPredicate;
  49603. private _drawCameraBackground;
  49604. private _drawCameraForeground;
  49605. private _drawRenderTargetPredicate;
  49606. private _drawRenderTargetBackground;
  49607. private _drawRenderTargetForeground;
  49608. /**
  49609. * Adds all the elements from the container to the scene
  49610. * @param container the container holding the elements
  49611. */
  49612. addFromContainer(container: AbstractScene): void;
  49613. /**
  49614. * Removes all the elements in the container from the scene
  49615. * @param container contains the elements to remove
  49616. * @param dispose if the removed element should be disposed (default: false)
  49617. */
  49618. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49619. }
  49620. }
  49621. declare module BABYLON {
  49622. /** @hidden */
  49623. export var layerPixelShader: {
  49624. name: string;
  49625. shader: string;
  49626. };
  49627. }
  49628. declare module BABYLON {
  49629. /** @hidden */
  49630. export var layerVertexShader: {
  49631. name: string;
  49632. shader: string;
  49633. };
  49634. }
  49635. declare module BABYLON {
  49636. /**
  49637. * This represents a full screen 2d layer.
  49638. * This can be useful to display a picture in the background of your scene for instance.
  49639. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49640. */
  49641. export class Layer {
  49642. /**
  49643. * Define the name of the layer.
  49644. */
  49645. name: string;
  49646. /**
  49647. * Define the texture the layer should display.
  49648. */
  49649. texture: Nullable<Texture>;
  49650. /**
  49651. * Is the layer in background or foreground.
  49652. */
  49653. isBackground: boolean;
  49654. /**
  49655. * Define the color of the layer (instead of texture).
  49656. */
  49657. color: Color4;
  49658. /**
  49659. * Define the scale of the layer in order to zoom in out of the texture.
  49660. */
  49661. scale: Vector2;
  49662. /**
  49663. * Define an offset for the layer in order to shift the texture.
  49664. */
  49665. offset: Vector2;
  49666. /**
  49667. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49668. */
  49669. alphaBlendingMode: number;
  49670. /**
  49671. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49672. * Alpha test will not mix with the background color in case of transparency.
  49673. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49674. */
  49675. alphaTest: boolean;
  49676. /**
  49677. * Define a mask to restrict the layer to only some of the scene cameras.
  49678. */
  49679. layerMask: number;
  49680. /**
  49681. * Define the list of render target the layer is visible into.
  49682. */
  49683. renderTargetTextures: RenderTargetTexture[];
  49684. /**
  49685. * Define if the layer is only used in renderTarget or if it also
  49686. * renders in the main frame buffer of the canvas.
  49687. */
  49688. renderOnlyInRenderTargetTextures: boolean;
  49689. private _scene;
  49690. private _vertexBuffers;
  49691. private _indexBuffer;
  49692. private _effect;
  49693. private _alphaTestEffect;
  49694. /**
  49695. * An event triggered when the layer is disposed.
  49696. */
  49697. onDisposeObservable: Observable<Layer>;
  49698. private _onDisposeObserver;
  49699. /**
  49700. * Back compatibility with callback before the onDisposeObservable existed.
  49701. * The set callback will be triggered when the layer has been disposed.
  49702. */
  49703. onDispose: () => void;
  49704. /**
  49705. * An event triggered before rendering the scene
  49706. */
  49707. onBeforeRenderObservable: Observable<Layer>;
  49708. private _onBeforeRenderObserver;
  49709. /**
  49710. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49711. * The set callback will be triggered just before rendering the layer.
  49712. */
  49713. onBeforeRender: () => void;
  49714. /**
  49715. * An event triggered after rendering the scene
  49716. */
  49717. onAfterRenderObservable: Observable<Layer>;
  49718. private _onAfterRenderObserver;
  49719. /**
  49720. * Back compatibility with callback before the onAfterRenderObservable existed.
  49721. * The set callback will be triggered just after rendering the layer.
  49722. */
  49723. onAfterRender: () => void;
  49724. /**
  49725. * Instantiates a new layer.
  49726. * This represents a full screen 2d layer.
  49727. * This can be useful to display a picture in the background of your scene for instance.
  49728. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49729. * @param name Define the name of the layer in the scene
  49730. * @param imgUrl Define the url of the texture to display in the layer
  49731. * @param scene Define the scene the layer belongs to
  49732. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49733. * @param color Defines a color for the layer
  49734. */
  49735. constructor(
  49736. /**
  49737. * Define the name of the layer.
  49738. */
  49739. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49740. private _createIndexBuffer;
  49741. /** @hidden */
  49742. _rebuild(): void;
  49743. /**
  49744. * Renders the layer in the scene.
  49745. */
  49746. render(): void;
  49747. /**
  49748. * Disposes and releases the associated ressources.
  49749. */
  49750. dispose(): void;
  49751. }
  49752. }
  49753. declare module BABYLON {
  49754. /** @hidden */
  49755. export var lensFlarePixelShader: {
  49756. name: string;
  49757. shader: string;
  49758. };
  49759. }
  49760. declare module BABYLON {
  49761. /** @hidden */
  49762. export var lensFlareVertexShader: {
  49763. name: string;
  49764. shader: string;
  49765. };
  49766. }
  49767. declare module BABYLON {
  49768. /**
  49769. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49770. * It is usually composed of several `lensFlare`.
  49771. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49772. */
  49773. export class LensFlareSystem {
  49774. /**
  49775. * Define the name of the lens flare system
  49776. */
  49777. name: string;
  49778. /**
  49779. * List of lens flares used in this system.
  49780. */
  49781. lensFlares: LensFlare[];
  49782. /**
  49783. * Define a limit from the border the lens flare can be visible.
  49784. */
  49785. borderLimit: number;
  49786. /**
  49787. * Define a viewport border we do not want to see the lens flare in.
  49788. */
  49789. viewportBorder: number;
  49790. /**
  49791. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49792. */
  49793. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49794. /**
  49795. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49796. */
  49797. layerMask: number;
  49798. /**
  49799. * Define the id of the lens flare system in the scene.
  49800. * (equal to name by default)
  49801. */
  49802. id: string;
  49803. private _scene;
  49804. private _emitter;
  49805. private _vertexBuffers;
  49806. private _indexBuffer;
  49807. private _effect;
  49808. private _positionX;
  49809. private _positionY;
  49810. private _isEnabled;
  49811. /** @hidden */
  49812. static _SceneComponentInitialization: (scene: Scene) => void;
  49813. /**
  49814. * Instantiates a lens flare system.
  49815. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49816. * It is usually composed of several `lensFlare`.
  49817. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49818. * @param name Define the name of the lens flare system in the scene
  49819. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49820. * @param scene Define the scene the lens flare system belongs to
  49821. */
  49822. constructor(
  49823. /**
  49824. * Define the name of the lens flare system
  49825. */
  49826. name: string, emitter: any, scene: Scene);
  49827. /**
  49828. * Define if the lens flare system is enabled.
  49829. */
  49830. isEnabled: boolean;
  49831. /**
  49832. * Get the scene the effects belongs to.
  49833. * @returns the scene holding the lens flare system
  49834. */
  49835. getScene(): Scene;
  49836. /**
  49837. * Get the emitter of the lens flare system.
  49838. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49839. * @returns the emitter of the lens flare system
  49840. */
  49841. getEmitter(): any;
  49842. /**
  49843. * Set the emitter of the lens flare system.
  49844. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49845. * @param newEmitter Define the new emitter of the system
  49846. */
  49847. setEmitter(newEmitter: any): void;
  49848. /**
  49849. * Get the lens flare system emitter position.
  49850. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49851. * @returns the position
  49852. */
  49853. getEmitterPosition(): Vector3;
  49854. /**
  49855. * @hidden
  49856. */
  49857. computeEffectivePosition(globalViewport: Viewport): boolean;
  49858. /** @hidden */
  49859. _isVisible(): boolean;
  49860. /**
  49861. * @hidden
  49862. */
  49863. render(): boolean;
  49864. /**
  49865. * Dispose and release the lens flare with its associated resources.
  49866. */
  49867. dispose(): void;
  49868. /**
  49869. * Parse a lens flare system from a JSON repressentation
  49870. * @param parsedLensFlareSystem Define the JSON to parse
  49871. * @param scene Define the scene the parsed system should be instantiated in
  49872. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49873. * @returns the parsed system
  49874. */
  49875. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49876. /**
  49877. * Serialize the current Lens Flare System into a JSON representation.
  49878. * @returns the serialized JSON
  49879. */
  49880. serialize(): any;
  49881. }
  49882. }
  49883. declare module BABYLON {
  49884. /**
  49885. * This represents one of the lens effect in a `lensFlareSystem`.
  49886. * It controls one of the indiviual texture used in the effect.
  49887. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49888. */
  49889. export class LensFlare {
  49890. /**
  49891. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49892. */
  49893. size: number;
  49894. /**
  49895. * 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.
  49896. */
  49897. position: number;
  49898. /**
  49899. * Define the lens color.
  49900. */
  49901. color: Color3;
  49902. /**
  49903. * Define the lens texture.
  49904. */
  49905. texture: Nullable<Texture>;
  49906. /**
  49907. * Define the alpha mode to render this particular lens.
  49908. */
  49909. alphaMode: number;
  49910. private _system;
  49911. /**
  49912. * Creates a new Lens Flare.
  49913. * This represents one of the lens effect in a `lensFlareSystem`.
  49914. * It controls one of the indiviual texture used in the effect.
  49915. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49916. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49917. * @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.
  49918. * @param color Define the lens color
  49919. * @param imgUrl Define the lens texture url
  49920. * @param system Define the `lensFlareSystem` this flare is part of
  49921. * @returns The newly created Lens Flare
  49922. */
  49923. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49924. /**
  49925. * Instantiates a new Lens Flare.
  49926. * This represents one of the lens effect in a `lensFlareSystem`.
  49927. * It controls one of the indiviual texture used in the effect.
  49928. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49929. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49930. * @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.
  49931. * @param color Define the lens color
  49932. * @param imgUrl Define the lens texture url
  49933. * @param system Define the `lensFlareSystem` this flare is part of
  49934. */
  49935. constructor(
  49936. /**
  49937. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49938. */
  49939. size: number,
  49940. /**
  49941. * 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.
  49942. */
  49943. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49944. /**
  49945. * Dispose and release the lens flare with its associated resources.
  49946. */
  49947. dispose(): void;
  49948. }
  49949. }
  49950. declare module BABYLON {
  49951. interface AbstractScene {
  49952. /**
  49953. * The list of lens flare system added to the scene
  49954. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49955. */
  49956. lensFlareSystems: Array<LensFlareSystem>;
  49957. /**
  49958. * Removes the given lens flare system from this scene.
  49959. * @param toRemove The lens flare system to remove
  49960. * @returns The index of the removed lens flare system
  49961. */
  49962. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49963. /**
  49964. * Adds the given lens flare system to this scene
  49965. * @param newLensFlareSystem The lens flare system to add
  49966. */
  49967. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49968. /**
  49969. * Gets a lens flare system using its name
  49970. * @param name defines the name to look for
  49971. * @returns the lens flare system or null if not found
  49972. */
  49973. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49974. /**
  49975. * Gets a lens flare system using its id
  49976. * @param id defines the id to look for
  49977. * @returns the lens flare system or null if not found
  49978. */
  49979. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49980. }
  49981. /**
  49982. * Defines the lens flare scene component responsible to manage any lens flares
  49983. * in a given scene.
  49984. */
  49985. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49986. /**
  49987. * The component name helpfull to identify the component in the list of scene components.
  49988. */
  49989. readonly name: string;
  49990. /**
  49991. * The scene the component belongs to.
  49992. */
  49993. scene: Scene;
  49994. /**
  49995. * Creates a new instance of the component for the given scene
  49996. * @param scene Defines the scene to register the component in
  49997. */
  49998. constructor(scene: Scene);
  49999. /**
  50000. * Registers the component in a given scene
  50001. */
  50002. register(): void;
  50003. /**
  50004. * Rebuilds the elements related to this component in case of
  50005. * context lost for instance.
  50006. */
  50007. rebuild(): void;
  50008. /**
  50009. * Adds all the elements from the container to the scene
  50010. * @param container the container holding the elements
  50011. */
  50012. addFromContainer(container: AbstractScene): void;
  50013. /**
  50014. * Removes all the elements in the container from the scene
  50015. * @param container contains the elements to remove
  50016. * @param dispose if the removed element should be disposed (default: false)
  50017. */
  50018. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50019. /**
  50020. * Serializes the component data to the specified json object
  50021. * @param serializationObject The object to serialize to
  50022. */
  50023. serialize(serializationObject: any): void;
  50024. /**
  50025. * Disposes the component and the associated ressources.
  50026. */
  50027. dispose(): void;
  50028. private _draw;
  50029. }
  50030. }
  50031. declare module BABYLON {
  50032. /**
  50033. * Defines the shadow generator component responsible to manage any shadow generators
  50034. * in a given scene.
  50035. */
  50036. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50037. /**
  50038. * The component name helpfull to identify the component in the list of scene components.
  50039. */
  50040. readonly name: string;
  50041. /**
  50042. * The scene the component belongs to.
  50043. */
  50044. scene: Scene;
  50045. /**
  50046. * Creates a new instance of the component for the given scene
  50047. * @param scene Defines the scene to register the component in
  50048. */
  50049. constructor(scene: Scene);
  50050. /**
  50051. * Registers the component in a given scene
  50052. */
  50053. register(): void;
  50054. /**
  50055. * Rebuilds the elements related to this component in case of
  50056. * context lost for instance.
  50057. */
  50058. rebuild(): void;
  50059. /**
  50060. * Serializes the component data to the specified json object
  50061. * @param serializationObject The object to serialize to
  50062. */
  50063. serialize(serializationObject: any): void;
  50064. /**
  50065. * Adds all the elements from the container to the scene
  50066. * @param container the container holding the elements
  50067. */
  50068. addFromContainer(container: AbstractScene): void;
  50069. /**
  50070. * Removes all the elements in the container from the scene
  50071. * @param container contains the elements to remove
  50072. * @param dispose if the removed element should be disposed (default: false)
  50073. */
  50074. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50075. /**
  50076. * Rebuilds the elements related to this component in case of
  50077. * context lost for instance.
  50078. */
  50079. dispose(): void;
  50080. private _gatherRenderTargets;
  50081. }
  50082. }
  50083. declare module BABYLON {
  50084. /**
  50085. * A point light is a light defined by an unique point in world space.
  50086. * The light is emitted in every direction from this point.
  50087. * A good example of a point light is a standard light bulb.
  50088. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50089. */
  50090. export class PointLight extends ShadowLight {
  50091. private _shadowAngle;
  50092. /**
  50093. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50094. * This specifies what angle the shadow will use to be created.
  50095. *
  50096. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50097. */
  50098. /**
  50099. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50100. * This specifies what angle the shadow will use to be created.
  50101. *
  50102. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50103. */
  50104. shadowAngle: number;
  50105. /**
  50106. * Gets the direction if it has been set.
  50107. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50108. */
  50109. /**
  50110. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50111. */
  50112. direction: Vector3;
  50113. /**
  50114. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50115. * A PointLight emits the light in every direction.
  50116. * It can cast shadows.
  50117. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50118. * ```javascript
  50119. * var pointLight = new PointLight("pl", camera.position, scene);
  50120. * ```
  50121. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50122. * @param name The light friendly name
  50123. * @param position The position of the point light in the scene
  50124. * @param scene The scene the lights belongs to
  50125. */
  50126. constructor(name: string, position: Vector3, scene: Scene);
  50127. /**
  50128. * Returns the string "PointLight"
  50129. * @returns the class name
  50130. */
  50131. getClassName(): string;
  50132. /**
  50133. * Returns the integer 0.
  50134. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50135. */
  50136. getTypeID(): number;
  50137. /**
  50138. * Specifies wether or not the shadowmap should be a cube texture.
  50139. * @returns true if the shadowmap needs to be a cube texture.
  50140. */
  50141. needCube(): boolean;
  50142. /**
  50143. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50144. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50145. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50146. */
  50147. getShadowDirection(faceIndex?: number): Vector3;
  50148. /**
  50149. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50150. * - fov = PI / 2
  50151. * - aspect ratio : 1.0
  50152. * - z-near and far equal to the active camera minZ and maxZ.
  50153. * Returns the PointLight.
  50154. */
  50155. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50156. protected _buildUniformLayout(): void;
  50157. /**
  50158. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50159. * @param effect The effect to update
  50160. * @param lightIndex The index of the light in the effect to update
  50161. * @returns The point light
  50162. */
  50163. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50164. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50165. /**
  50166. * Prepares the list of defines specific to the light type.
  50167. * @param defines the list of defines
  50168. * @param lightIndex defines the index of the light for the effect
  50169. */
  50170. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50171. }
  50172. }
  50173. declare module BABYLON {
  50174. /**
  50175. * Header information of HDR texture files.
  50176. */
  50177. export interface HDRInfo {
  50178. /**
  50179. * The height of the texture in pixels.
  50180. */
  50181. height: number;
  50182. /**
  50183. * The width of the texture in pixels.
  50184. */
  50185. width: number;
  50186. /**
  50187. * The index of the beginning of the data in the binary file.
  50188. */
  50189. dataPosition: number;
  50190. }
  50191. /**
  50192. * This groups tools to convert HDR texture to native colors array.
  50193. */
  50194. export class HDRTools {
  50195. private static Ldexp;
  50196. private static Rgbe2float;
  50197. private static readStringLine;
  50198. /**
  50199. * Reads header information from an RGBE texture stored in a native array.
  50200. * More information on this format are available here:
  50201. * https://en.wikipedia.org/wiki/RGBE_image_format
  50202. *
  50203. * @param uint8array The binary file stored in native array.
  50204. * @return The header information.
  50205. */
  50206. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50207. /**
  50208. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50209. * This RGBE texture needs to store the information as a panorama.
  50210. *
  50211. * More information on this format are available here:
  50212. * https://en.wikipedia.org/wiki/RGBE_image_format
  50213. *
  50214. * @param buffer The binary file stored in an array buffer.
  50215. * @param size The expected size of the extracted cubemap.
  50216. * @return The Cube Map information.
  50217. */
  50218. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50219. /**
  50220. * Returns the pixels data extracted from an RGBE texture.
  50221. * This pixels will be stored left to right up to down in the R G B order in one array.
  50222. *
  50223. * More information on this format are available here:
  50224. * https://en.wikipedia.org/wiki/RGBE_image_format
  50225. *
  50226. * @param uint8array The binary file stored in an array buffer.
  50227. * @param hdrInfo The header information of the file.
  50228. * @return The pixels data in RGB right to left up to down order.
  50229. */
  50230. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50231. private static RGBE_ReadPixels_RLE;
  50232. }
  50233. }
  50234. declare module BABYLON {
  50235. /**
  50236. * This represents a texture coming from an HDR input.
  50237. *
  50238. * The only supported format is currently panorama picture stored in RGBE format.
  50239. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50240. */
  50241. export class HDRCubeTexture extends BaseTexture {
  50242. private static _facesMapping;
  50243. private _generateHarmonics;
  50244. private _noMipmap;
  50245. private _textureMatrix;
  50246. private _size;
  50247. private _onLoad;
  50248. private _onError;
  50249. /**
  50250. * The texture URL.
  50251. */
  50252. url: string;
  50253. /**
  50254. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50255. */
  50256. coordinatesMode: number;
  50257. protected _isBlocking: boolean;
  50258. /**
  50259. * Sets wether or not the texture is blocking during loading.
  50260. */
  50261. /**
  50262. * Gets wether or not the texture is blocking during loading.
  50263. */
  50264. isBlocking: boolean;
  50265. protected _rotationY: number;
  50266. /**
  50267. * Sets texture matrix rotation angle around Y axis in radians.
  50268. */
  50269. /**
  50270. * Gets texture matrix rotation angle around Y axis radians.
  50271. */
  50272. rotationY: number;
  50273. /**
  50274. * Gets or sets the center of the bounding box associated with the cube texture
  50275. * It must define where the camera used to render the texture was set
  50276. */
  50277. boundingBoxPosition: Vector3;
  50278. private _boundingBoxSize;
  50279. /**
  50280. * Gets or sets the size of the bounding box associated with the cube texture
  50281. * When defined, the cubemap will switch to local mode
  50282. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50283. * @example https://www.babylonjs-playground.com/#RNASML
  50284. */
  50285. boundingBoxSize: Vector3;
  50286. /**
  50287. * Instantiates an HDRTexture from the following parameters.
  50288. *
  50289. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50290. * @param scene The scene the texture will be used in
  50291. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50292. * @param noMipmap Forces to not generate the mipmap if true
  50293. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50294. * @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)
  50295. * @param reserved Reserved flag for internal use.
  50296. */
  50297. 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>);
  50298. /**
  50299. * Get the current class name of the texture useful for serialization or dynamic coding.
  50300. * @returns "HDRCubeTexture"
  50301. */
  50302. getClassName(): string;
  50303. /**
  50304. * Occurs when the file is raw .hdr file.
  50305. */
  50306. private loadTexture;
  50307. clone(): HDRCubeTexture;
  50308. delayLoad(): void;
  50309. /**
  50310. * Get the texture reflection matrix used to rotate/transform the reflection.
  50311. * @returns the reflection matrix
  50312. */
  50313. getReflectionTextureMatrix(): Matrix;
  50314. /**
  50315. * Set the texture reflection matrix used to rotate/transform the reflection.
  50316. * @param value Define the reflection matrix to set
  50317. */
  50318. setReflectionTextureMatrix(value: Matrix): void;
  50319. /**
  50320. * Parses a JSON representation of an HDR Texture in order to create the texture
  50321. * @param parsedTexture Define the JSON representation
  50322. * @param scene Define the scene the texture should be created in
  50323. * @param rootUrl Define the root url in case we need to load relative dependencies
  50324. * @returns the newly created texture after parsing
  50325. */
  50326. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50327. serialize(): any;
  50328. }
  50329. }
  50330. declare module BABYLON {
  50331. /**
  50332. * Class used to control physics engine
  50333. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50334. */
  50335. export class PhysicsEngine implements IPhysicsEngine {
  50336. private _physicsPlugin;
  50337. /**
  50338. * Global value used to control the smallest number supported by the simulation
  50339. */
  50340. static Epsilon: number;
  50341. private _impostors;
  50342. private _joints;
  50343. /**
  50344. * Gets the gravity vector used by the simulation
  50345. */
  50346. gravity: Vector3;
  50347. /**
  50348. * Factory used to create the default physics plugin.
  50349. * @returns The default physics plugin
  50350. */
  50351. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50352. /**
  50353. * Creates a new Physics Engine
  50354. * @param gravity defines the gravity vector used by the simulation
  50355. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50356. */
  50357. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50358. /**
  50359. * Sets the gravity vector used by the simulation
  50360. * @param gravity defines the gravity vector to use
  50361. */
  50362. setGravity(gravity: Vector3): void;
  50363. /**
  50364. * Set the time step of the physics engine.
  50365. * Default is 1/60.
  50366. * To slow it down, enter 1/600 for example.
  50367. * To speed it up, 1/30
  50368. * @param newTimeStep defines the new timestep to apply to this world.
  50369. */
  50370. setTimeStep(newTimeStep?: number): void;
  50371. /**
  50372. * Get the time step of the physics engine.
  50373. * @returns the current time step
  50374. */
  50375. getTimeStep(): number;
  50376. /**
  50377. * Release all resources
  50378. */
  50379. dispose(): void;
  50380. /**
  50381. * Gets the name of the current physics plugin
  50382. * @returns the name of the plugin
  50383. */
  50384. getPhysicsPluginName(): string;
  50385. /**
  50386. * Adding a new impostor for the impostor tracking.
  50387. * This will be done by the impostor itself.
  50388. * @param impostor the impostor to add
  50389. */
  50390. addImpostor(impostor: PhysicsImpostor): void;
  50391. /**
  50392. * Remove an impostor from the engine.
  50393. * This impostor and its mesh will not longer be updated by the physics engine.
  50394. * @param impostor the impostor to remove
  50395. */
  50396. removeImpostor(impostor: PhysicsImpostor): void;
  50397. /**
  50398. * Add a joint to the physics engine
  50399. * @param mainImpostor defines the main impostor to which the joint is added.
  50400. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50401. * @param joint defines the joint that will connect both impostors.
  50402. */
  50403. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50404. /**
  50405. * Removes a joint from the simulation
  50406. * @param mainImpostor defines the impostor used with the joint
  50407. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50408. * @param joint defines the joint to remove
  50409. */
  50410. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50411. /**
  50412. * Called by the scene. No need to call it.
  50413. * @param delta defines the timespam between frames
  50414. */
  50415. _step(delta: number): void;
  50416. /**
  50417. * Gets the current plugin used to run the simulation
  50418. * @returns current plugin
  50419. */
  50420. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50421. /**
  50422. * Gets the list of physic impostors
  50423. * @returns an array of PhysicsImpostor
  50424. */
  50425. getImpostors(): Array<PhysicsImpostor>;
  50426. /**
  50427. * Gets the impostor for a physics enabled object
  50428. * @param object defines the object impersonated by the impostor
  50429. * @returns the PhysicsImpostor or null if not found
  50430. */
  50431. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50432. /**
  50433. * Gets the impostor for a physics body object
  50434. * @param body defines physics body used by the impostor
  50435. * @returns the PhysicsImpostor or null if not found
  50436. */
  50437. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50438. /**
  50439. * Does a raycast in the physics world
  50440. * @param from when should the ray start?
  50441. * @param to when should the ray end?
  50442. * @returns PhysicsRaycastResult
  50443. */
  50444. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50445. }
  50446. }
  50447. declare module BABYLON {
  50448. /** @hidden */
  50449. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50450. private _useDeltaForWorldStep;
  50451. world: any;
  50452. name: string;
  50453. private _physicsMaterials;
  50454. private _fixedTimeStep;
  50455. private _cannonRaycastResult;
  50456. private _raycastResult;
  50457. private _physicsBodysToRemoveAfterStep;
  50458. BJSCANNON: any;
  50459. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50460. setGravity(gravity: Vector3): void;
  50461. setTimeStep(timeStep: number): void;
  50462. getTimeStep(): number;
  50463. executeStep(delta: number): void;
  50464. private _removeMarkedPhysicsBodiesFromWorld;
  50465. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50466. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50467. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50468. private _processChildMeshes;
  50469. removePhysicsBody(impostor: PhysicsImpostor): void;
  50470. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50471. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50472. private _addMaterial;
  50473. private _checkWithEpsilon;
  50474. private _createShape;
  50475. private _createHeightmap;
  50476. private _minus90X;
  50477. private _plus90X;
  50478. private _tmpPosition;
  50479. private _tmpDeltaPosition;
  50480. private _tmpUnityRotation;
  50481. private _updatePhysicsBodyTransformation;
  50482. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50483. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50484. isSupported(): boolean;
  50485. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50486. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50487. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50488. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50489. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50490. getBodyMass(impostor: PhysicsImpostor): number;
  50491. getBodyFriction(impostor: PhysicsImpostor): number;
  50492. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50493. getBodyRestitution(impostor: PhysicsImpostor): number;
  50494. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50495. sleepBody(impostor: PhysicsImpostor): void;
  50496. wakeUpBody(impostor: PhysicsImpostor): void;
  50497. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50498. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50499. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50500. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50501. getRadius(impostor: PhysicsImpostor): number;
  50502. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50503. dispose(): void;
  50504. private _extendNamespace;
  50505. /**
  50506. * Does a raycast in the physics world
  50507. * @param from when should the ray start?
  50508. * @param to when should the ray end?
  50509. * @returns PhysicsRaycastResult
  50510. */
  50511. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50512. }
  50513. }
  50514. declare module BABYLON {
  50515. /** @hidden */
  50516. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50517. world: any;
  50518. name: string;
  50519. BJSOIMO: any;
  50520. private _raycastResult;
  50521. constructor(iterations?: number, oimoInjection?: any);
  50522. setGravity(gravity: Vector3): void;
  50523. setTimeStep(timeStep: number): void;
  50524. getTimeStep(): number;
  50525. private _tmpImpostorsArray;
  50526. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50527. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50528. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50529. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50530. private _tmpPositionVector;
  50531. removePhysicsBody(impostor: PhysicsImpostor): void;
  50532. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50533. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50534. isSupported(): boolean;
  50535. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50536. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50537. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50538. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50539. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50540. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50541. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50542. getBodyMass(impostor: PhysicsImpostor): number;
  50543. getBodyFriction(impostor: PhysicsImpostor): number;
  50544. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50545. getBodyRestitution(impostor: PhysicsImpostor): number;
  50546. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50547. sleepBody(impostor: PhysicsImpostor): void;
  50548. wakeUpBody(impostor: PhysicsImpostor): void;
  50549. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50550. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50551. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50552. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50553. getRadius(impostor: PhysicsImpostor): number;
  50554. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50555. dispose(): void;
  50556. /**
  50557. * Does a raycast in the physics world
  50558. * @param from when should the ray start?
  50559. * @param to when should the ray end?
  50560. * @returns PhysicsRaycastResult
  50561. */
  50562. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50563. }
  50564. }
  50565. declare module BABYLON {
  50566. /**
  50567. * Class containing static functions to help procedurally build meshes
  50568. */
  50569. export class RibbonBuilder {
  50570. /**
  50571. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50572. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50573. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50574. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50575. * * 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
  50576. * * 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
  50577. * * 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
  50578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50579. * * 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
  50580. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50581. * * 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
  50582. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50583. * * 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
  50584. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50586. * @param name defines the name of the mesh
  50587. * @param options defines the options used to create the mesh
  50588. * @param scene defines the hosting scene
  50589. * @returns the ribbon mesh
  50590. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50591. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50592. */
  50593. static CreateRibbon(name: string, options: {
  50594. pathArray: Vector3[][];
  50595. closeArray?: boolean;
  50596. closePath?: boolean;
  50597. offset?: number;
  50598. updatable?: boolean;
  50599. sideOrientation?: number;
  50600. frontUVs?: Vector4;
  50601. backUVs?: Vector4;
  50602. instance?: Mesh;
  50603. invertUV?: boolean;
  50604. uvs?: Vector2[];
  50605. colors?: Color4[];
  50606. }, scene?: Nullable<Scene>): Mesh;
  50607. }
  50608. }
  50609. declare module BABYLON {
  50610. /**
  50611. * Class containing static functions to help procedurally build meshes
  50612. */
  50613. export class ShapeBuilder {
  50614. /**
  50615. * 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.
  50616. * * 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.
  50617. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50618. * * 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.
  50619. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50620. * * 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
  50621. * * 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
  50622. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50623. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50624. * * 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
  50625. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50627. * @param name defines the name of the mesh
  50628. * @param options defines the options used to create the mesh
  50629. * @param scene defines the hosting scene
  50630. * @returns the extruded shape mesh
  50631. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50632. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50633. */
  50634. static ExtrudeShape(name: string, options: {
  50635. shape: Vector3[];
  50636. path: Vector3[];
  50637. scale?: number;
  50638. rotation?: number;
  50639. cap?: number;
  50640. updatable?: boolean;
  50641. sideOrientation?: number;
  50642. frontUVs?: Vector4;
  50643. backUVs?: Vector4;
  50644. instance?: Mesh;
  50645. invertUV?: boolean;
  50646. }, scene?: Nullable<Scene>): Mesh;
  50647. /**
  50648. * Creates an custom extruded shape mesh.
  50649. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50650. * * 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.
  50651. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50652. * * 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
  50653. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50654. * * 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
  50655. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50656. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50657. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50658. * * 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
  50659. * * 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
  50660. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50662. * * 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
  50663. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50665. * @param name defines the name of the mesh
  50666. * @param options defines the options used to create the mesh
  50667. * @param scene defines the hosting scene
  50668. * @returns the custom extruded shape mesh
  50669. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50670. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50671. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50672. */
  50673. static ExtrudeShapeCustom(name: string, options: {
  50674. shape: Vector3[];
  50675. path: Vector3[];
  50676. scaleFunction?: any;
  50677. rotationFunction?: any;
  50678. ribbonCloseArray?: boolean;
  50679. ribbonClosePath?: boolean;
  50680. cap?: number;
  50681. updatable?: boolean;
  50682. sideOrientation?: number;
  50683. frontUVs?: Vector4;
  50684. backUVs?: Vector4;
  50685. instance?: Mesh;
  50686. invertUV?: boolean;
  50687. }, scene?: Nullable<Scene>): Mesh;
  50688. private static _ExtrudeShapeGeneric;
  50689. }
  50690. }
  50691. declare module BABYLON {
  50692. /**
  50693. * AmmoJS Physics plugin
  50694. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50695. * @see https://github.com/kripken/ammo.js/
  50696. */
  50697. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50698. private _useDeltaForWorldStep;
  50699. /**
  50700. * Reference to the Ammo library
  50701. */
  50702. bjsAMMO: any;
  50703. /**
  50704. * Created ammoJS world which physics bodies are added to
  50705. */
  50706. world: any;
  50707. /**
  50708. * Name of the plugin
  50709. */
  50710. name: string;
  50711. private _timeStep;
  50712. private _fixedTimeStep;
  50713. private _maxSteps;
  50714. private _tmpQuaternion;
  50715. private _tmpAmmoTransform;
  50716. private _tmpAmmoQuaternion;
  50717. private _tmpAmmoConcreteContactResultCallback;
  50718. private _collisionConfiguration;
  50719. private _dispatcher;
  50720. private _overlappingPairCache;
  50721. private _solver;
  50722. private _softBodySolver;
  50723. private _tmpAmmoVectorA;
  50724. private _tmpAmmoVectorB;
  50725. private _tmpAmmoVectorC;
  50726. private _tmpAmmoVectorD;
  50727. private _tmpContactCallbackResult;
  50728. private _tmpAmmoVectorRCA;
  50729. private _tmpAmmoVectorRCB;
  50730. private _raycastResult;
  50731. private static readonly DISABLE_COLLISION_FLAG;
  50732. private static readonly KINEMATIC_FLAG;
  50733. private static readonly DISABLE_DEACTIVATION_FLAG;
  50734. /**
  50735. * Initializes the ammoJS plugin
  50736. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50737. * @param ammoInjection can be used to inject your own ammo reference
  50738. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  50739. */
  50740. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  50741. /**
  50742. * Sets the gravity of the physics world (m/(s^2))
  50743. * @param gravity Gravity to set
  50744. */
  50745. setGravity(gravity: Vector3): void;
  50746. /**
  50747. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50748. * @param timeStep timestep to use in seconds
  50749. */
  50750. setTimeStep(timeStep: number): void;
  50751. /**
  50752. * 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)
  50753. * @param fixedTimeStep fixedTimeStep to use in seconds
  50754. */
  50755. setFixedTimeStep(fixedTimeStep: number): void;
  50756. /**
  50757. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50758. * @param maxSteps the maximum number of steps by the physics engine per frame
  50759. */
  50760. setMaxSteps(maxSteps: number): void;
  50761. /**
  50762. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50763. * @returns the current timestep in seconds
  50764. */
  50765. getTimeStep(): number;
  50766. private _isImpostorInContact;
  50767. private _isImpostorPairInContact;
  50768. private _stepSimulation;
  50769. /**
  50770. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50771. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50772. * After the step the babylon meshes are set to the position of the physics imposters
  50773. * @param delta amount of time to step forward
  50774. * @param impostors array of imposters to update before/after the step
  50775. */
  50776. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50777. /**
  50778. * Update babylon mesh to match physics world object
  50779. * @param impostor imposter to match
  50780. */
  50781. private _afterSoftStep;
  50782. /**
  50783. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50784. * @param impostor imposter to match
  50785. */
  50786. private _ropeStep;
  50787. /**
  50788. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50789. * @param impostor imposter to match
  50790. */
  50791. private _softbodyOrClothStep;
  50792. private _tmpVector;
  50793. private _tmpMatrix;
  50794. /**
  50795. * Applies an impulse on the imposter
  50796. * @param impostor imposter to apply impulse to
  50797. * @param force amount of force to be applied to the imposter
  50798. * @param contactPoint the location to apply the impulse on the imposter
  50799. */
  50800. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50801. /**
  50802. * Applies a force on the imposter
  50803. * @param impostor imposter to apply force
  50804. * @param force amount of force to be applied to the imposter
  50805. * @param contactPoint the location to apply the force on the imposter
  50806. */
  50807. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50808. /**
  50809. * Creates a physics body using the plugin
  50810. * @param impostor the imposter to create the physics body on
  50811. */
  50812. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50813. /**
  50814. * Removes the physics body from the imposter and disposes of the body's memory
  50815. * @param impostor imposter to remove the physics body from
  50816. */
  50817. removePhysicsBody(impostor: PhysicsImpostor): void;
  50818. /**
  50819. * Generates a joint
  50820. * @param impostorJoint the imposter joint to create the joint with
  50821. */
  50822. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50823. /**
  50824. * Removes a joint
  50825. * @param impostorJoint the imposter joint to remove the joint from
  50826. */
  50827. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50828. private _addMeshVerts;
  50829. /**
  50830. * Initialise the soft body vertices to match its object's (mesh) vertices
  50831. * Softbody vertices (nodes) are in world space and to match this
  50832. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50833. * @param impostor to create the softbody for
  50834. */
  50835. private _softVertexData;
  50836. /**
  50837. * Create an impostor's soft body
  50838. * @param impostor to create the softbody for
  50839. */
  50840. private _createSoftbody;
  50841. /**
  50842. * Create cloth for an impostor
  50843. * @param impostor to create the softbody for
  50844. */
  50845. private _createCloth;
  50846. /**
  50847. * Create rope for an impostor
  50848. * @param impostor to create the softbody for
  50849. */
  50850. private _createRope;
  50851. private _addHullVerts;
  50852. private _createShape;
  50853. /**
  50854. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50855. * @param impostor imposter containing the physics body and babylon object
  50856. */
  50857. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50858. /**
  50859. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50860. * @param impostor imposter containing the physics body and babylon object
  50861. * @param newPosition new position
  50862. * @param newRotation new rotation
  50863. */
  50864. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50865. /**
  50866. * If this plugin is supported
  50867. * @returns true if its supported
  50868. */
  50869. isSupported(): boolean;
  50870. /**
  50871. * Sets the linear velocity of the physics body
  50872. * @param impostor imposter to set the velocity on
  50873. * @param velocity velocity to set
  50874. */
  50875. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50876. /**
  50877. * Sets the angular velocity of the physics body
  50878. * @param impostor imposter to set the velocity on
  50879. * @param velocity velocity to set
  50880. */
  50881. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50882. /**
  50883. * gets the linear velocity
  50884. * @param impostor imposter to get linear velocity from
  50885. * @returns linear velocity
  50886. */
  50887. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50888. /**
  50889. * gets the angular velocity
  50890. * @param impostor imposter to get angular velocity from
  50891. * @returns angular velocity
  50892. */
  50893. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50894. /**
  50895. * Sets the mass of physics body
  50896. * @param impostor imposter to set the mass on
  50897. * @param mass mass to set
  50898. */
  50899. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50900. /**
  50901. * Gets the mass of the physics body
  50902. * @param impostor imposter to get the mass from
  50903. * @returns mass
  50904. */
  50905. getBodyMass(impostor: PhysicsImpostor): number;
  50906. /**
  50907. * Gets friction of the impostor
  50908. * @param impostor impostor to get friction from
  50909. * @returns friction value
  50910. */
  50911. getBodyFriction(impostor: PhysicsImpostor): number;
  50912. /**
  50913. * Sets friction of the impostor
  50914. * @param impostor impostor to set friction on
  50915. * @param friction friction value
  50916. */
  50917. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50918. /**
  50919. * Gets restitution of the impostor
  50920. * @param impostor impostor to get restitution from
  50921. * @returns restitution value
  50922. */
  50923. getBodyRestitution(impostor: PhysicsImpostor): number;
  50924. /**
  50925. * Sets resitution of the impostor
  50926. * @param impostor impostor to set resitution on
  50927. * @param restitution resitution value
  50928. */
  50929. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50930. /**
  50931. * Gets pressure inside the impostor
  50932. * @param impostor impostor to get pressure from
  50933. * @returns pressure value
  50934. */
  50935. getBodyPressure(impostor: PhysicsImpostor): number;
  50936. /**
  50937. * Sets pressure inside a soft body impostor
  50938. * Cloth and rope must remain 0 pressure
  50939. * @param impostor impostor to set pressure on
  50940. * @param pressure pressure value
  50941. */
  50942. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50943. /**
  50944. * Gets stiffness of the impostor
  50945. * @param impostor impostor to get stiffness from
  50946. * @returns pressure value
  50947. */
  50948. getBodyStiffness(impostor: PhysicsImpostor): number;
  50949. /**
  50950. * Sets stiffness of the impostor
  50951. * @param impostor impostor to set stiffness on
  50952. * @param stiffness stiffness value from 0 to 1
  50953. */
  50954. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50955. /**
  50956. * Gets velocityIterations of the impostor
  50957. * @param impostor impostor to get velocity iterations from
  50958. * @returns velocityIterations value
  50959. */
  50960. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50961. /**
  50962. * Sets velocityIterations of the impostor
  50963. * @param impostor impostor to set velocity iterations on
  50964. * @param velocityIterations velocityIterations value
  50965. */
  50966. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50967. /**
  50968. * Gets positionIterations of the impostor
  50969. * @param impostor impostor to get position iterations from
  50970. * @returns positionIterations value
  50971. */
  50972. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50973. /**
  50974. * Sets positionIterations of the impostor
  50975. * @param impostor impostor to set position on
  50976. * @param positionIterations positionIterations value
  50977. */
  50978. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50979. /**
  50980. * Append an anchor to a cloth object
  50981. * @param impostor is the cloth impostor to add anchor to
  50982. * @param otherImpostor is the rigid impostor to anchor to
  50983. * @param width ratio across width from 0 to 1
  50984. * @param height ratio up height from 0 to 1
  50985. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50986. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50987. */
  50988. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50989. /**
  50990. * Append an hook to a rope object
  50991. * @param impostor is the rope impostor to add hook to
  50992. * @param otherImpostor is the rigid impostor to hook to
  50993. * @param length ratio along the rope from 0 to 1
  50994. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50995. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50996. */
  50997. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50998. /**
  50999. * Sleeps the physics body and stops it from being active
  51000. * @param impostor impostor to sleep
  51001. */
  51002. sleepBody(impostor: PhysicsImpostor): void;
  51003. /**
  51004. * Activates the physics body
  51005. * @param impostor impostor to activate
  51006. */
  51007. wakeUpBody(impostor: PhysicsImpostor): void;
  51008. /**
  51009. * Updates the distance parameters of the joint
  51010. * @param joint joint to update
  51011. * @param maxDistance maximum distance of the joint
  51012. * @param minDistance minimum distance of the joint
  51013. */
  51014. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51015. /**
  51016. * Sets a motor on the joint
  51017. * @param joint joint to set motor on
  51018. * @param speed speed of the motor
  51019. * @param maxForce maximum force of the motor
  51020. * @param motorIndex index of the motor
  51021. */
  51022. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51023. /**
  51024. * Sets the motors limit
  51025. * @param joint joint to set limit on
  51026. * @param upperLimit upper limit
  51027. * @param lowerLimit lower limit
  51028. */
  51029. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51030. /**
  51031. * Syncs the position and rotation of a mesh with the impostor
  51032. * @param mesh mesh to sync
  51033. * @param impostor impostor to update the mesh with
  51034. */
  51035. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51036. /**
  51037. * Gets the radius of the impostor
  51038. * @param impostor impostor to get radius from
  51039. * @returns the radius
  51040. */
  51041. getRadius(impostor: PhysicsImpostor): number;
  51042. /**
  51043. * Gets the box size of the impostor
  51044. * @param impostor impostor to get box size from
  51045. * @param result the resulting box size
  51046. */
  51047. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51048. /**
  51049. * Disposes of the impostor
  51050. */
  51051. dispose(): void;
  51052. /**
  51053. * Does a raycast in the physics world
  51054. * @param from when should the ray start?
  51055. * @param to when should the ray end?
  51056. * @returns PhysicsRaycastResult
  51057. */
  51058. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51059. }
  51060. }
  51061. declare module BABYLON {
  51062. interface AbstractScene {
  51063. /**
  51064. * The list of reflection probes added to the scene
  51065. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51066. */
  51067. reflectionProbes: Array<ReflectionProbe>;
  51068. /**
  51069. * Removes the given reflection probe from this scene.
  51070. * @param toRemove The reflection probe to remove
  51071. * @returns The index of the removed reflection probe
  51072. */
  51073. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51074. /**
  51075. * Adds the given reflection probe to this scene.
  51076. * @param newReflectionProbe The reflection probe to add
  51077. */
  51078. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51079. }
  51080. /**
  51081. * Class used to generate realtime reflection / refraction cube textures
  51082. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51083. */
  51084. export class ReflectionProbe {
  51085. /** defines the name of the probe */
  51086. name: string;
  51087. private _scene;
  51088. private _renderTargetTexture;
  51089. private _projectionMatrix;
  51090. private _viewMatrix;
  51091. private _target;
  51092. private _add;
  51093. private _attachedMesh;
  51094. private _invertYAxis;
  51095. /** Gets or sets probe position (center of the cube map) */
  51096. position: Vector3;
  51097. /**
  51098. * Creates a new reflection probe
  51099. * @param name defines the name of the probe
  51100. * @param size defines the texture resolution (for each face)
  51101. * @param scene defines the hosting scene
  51102. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51103. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51104. */
  51105. constructor(
  51106. /** defines the name of the probe */
  51107. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51108. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51109. samples: number;
  51110. /** Gets or sets the refresh rate to use (on every frame by default) */
  51111. refreshRate: number;
  51112. /**
  51113. * Gets the hosting scene
  51114. * @returns a Scene
  51115. */
  51116. getScene(): Scene;
  51117. /** Gets the internal CubeTexture used to render to */
  51118. readonly cubeTexture: RenderTargetTexture;
  51119. /** Gets the list of meshes to render */
  51120. readonly renderList: Nullable<AbstractMesh[]>;
  51121. /**
  51122. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51123. * @param mesh defines the mesh to attach to
  51124. */
  51125. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51126. /**
  51127. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51128. * @param renderingGroupId The rendering group id corresponding to its index
  51129. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51130. */
  51131. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51132. /**
  51133. * Clean all associated resources
  51134. */
  51135. dispose(): void;
  51136. /**
  51137. * Converts the reflection probe information to a readable string for debug purpose.
  51138. * @param fullDetails Supports for multiple levels of logging within scene loading
  51139. * @returns the human readable reflection probe info
  51140. */
  51141. toString(fullDetails?: boolean): string;
  51142. /**
  51143. * Get the class name of the relfection probe.
  51144. * @returns "ReflectionProbe"
  51145. */
  51146. getClassName(): string;
  51147. /**
  51148. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51149. * @returns The JSON representation of the texture
  51150. */
  51151. serialize(): any;
  51152. /**
  51153. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51154. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51155. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51156. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51157. * @returns The parsed reflection probe if successful
  51158. */
  51159. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51160. }
  51161. }
  51162. declare module BABYLON {
  51163. /** @hidden */
  51164. export var _BabylonLoaderRegistered: boolean;
  51165. }
  51166. declare module BABYLON {
  51167. /**
  51168. * The Physically based simple base material of BJS.
  51169. *
  51170. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51171. * It is used as the base class for both the specGloss and metalRough conventions.
  51172. */
  51173. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51174. /**
  51175. * Number of Simultaneous lights allowed on the material.
  51176. */
  51177. maxSimultaneousLights: number;
  51178. /**
  51179. * If sets to true, disables all the lights affecting the material.
  51180. */
  51181. disableLighting: boolean;
  51182. /**
  51183. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51184. */
  51185. environmentTexture: BaseTexture;
  51186. /**
  51187. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51188. */
  51189. invertNormalMapX: boolean;
  51190. /**
  51191. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51192. */
  51193. invertNormalMapY: boolean;
  51194. /**
  51195. * Normal map used in the model.
  51196. */
  51197. normalTexture: BaseTexture;
  51198. /**
  51199. * Emissivie color used to self-illuminate the model.
  51200. */
  51201. emissiveColor: Color3;
  51202. /**
  51203. * Emissivie texture used to self-illuminate the model.
  51204. */
  51205. emissiveTexture: BaseTexture;
  51206. /**
  51207. * Occlusion Channel Strenght.
  51208. */
  51209. occlusionStrength: number;
  51210. /**
  51211. * Occlusion Texture of the material (adding extra occlusion effects).
  51212. */
  51213. occlusionTexture: BaseTexture;
  51214. /**
  51215. * Defines the alpha limits in alpha test mode.
  51216. */
  51217. alphaCutOff: number;
  51218. /**
  51219. * Gets the current double sided mode.
  51220. */
  51221. /**
  51222. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51223. */
  51224. doubleSided: boolean;
  51225. /**
  51226. * Stores the pre-calculated light information of a mesh in a texture.
  51227. */
  51228. lightmapTexture: BaseTexture;
  51229. /**
  51230. * If true, the light map contains occlusion information instead of lighting info.
  51231. */
  51232. useLightmapAsShadowmap: boolean;
  51233. /**
  51234. * Instantiates a new PBRMaterial instance.
  51235. *
  51236. * @param name The material name
  51237. * @param scene The scene the material will be use in.
  51238. */
  51239. constructor(name: string, scene: Scene);
  51240. getClassName(): string;
  51241. }
  51242. }
  51243. declare module BABYLON {
  51244. /**
  51245. * The PBR material of BJS following the metal roughness convention.
  51246. *
  51247. * This fits to the PBR convention in the GLTF definition:
  51248. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51249. */
  51250. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51251. /**
  51252. * The base color has two different interpretations depending on the value of metalness.
  51253. * When the material is a metal, the base color is the specific measured reflectance value
  51254. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51255. * of the material.
  51256. */
  51257. baseColor: Color3;
  51258. /**
  51259. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51260. * well as opacity information in the alpha channel.
  51261. */
  51262. baseTexture: BaseTexture;
  51263. /**
  51264. * Specifies the metallic scalar value of the material.
  51265. * Can also be used to scale the metalness values of the metallic texture.
  51266. */
  51267. metallic: number;
  51268. /**
  51269. * Specifies the roughness scalar value of the material.
  51270. * Can also be used to scale the roughness values of the metallic texture.
  51271. */
  51272. roughness: number;
  51273. /**
  51274. * Texture containing both the metallic value in the B channel and the
  51275. * roughness value in the G channel to keep better precision.
  51276. */
  51277. metallicRoughnessTexture: BaseTexture;
  51278. /**
  51279. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51280. *
  51281. * @param name The material name
  51282. * @param scene The scene the material will be use in.
  51283. */
  51284. constructor(name: string, scene: Scene);
  51285. /**
  51286. * Return the currrent class name of the material.
  51287. */
  51288. getClassName(): string;
  51289. /**
  51290. * Makes a duplicate of the current material.
  51291. * @param name - name to use for the new material.
  51292. */
  51293. clone(name: string): PBRMetallicRoughnessMaterial;
  51294. /**
  51295. * Serialize the material to a parsable JSON object.
  51296. */
  51297. serialize(): any;
  51298. /**
  51299. * Parses a JSON object correponding to the serialize function.
  51300. */
  51301. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51302. }
  51303. }
  51304. declare module BABYLON {
  51305. /**
  51306. * The PBR material of BJS following the specular glossiness convention.
  51307. *
  51308. * This fits to the PBR convention in the GLTF definition:
  51309. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51310. */
  51311. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51312. /**
  51313. * Specifies the diffuse color of the material.
  51314. */
  51315. diffuseColor: Color3;
  51316. /**
  51317. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51318. * channel.
  51319. */
  51320. diffuseTexture: BaseTexture;
  51321. /**
  51322. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51323. */
  51324. specularColor: Color3;
  51325. /**
  51326. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51327. */
  51328. glossiness: number;
  51329. /**
  51330. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51331. */
  51332. specularGlossinessTexture: BaseTexture;
  51333. /**
  51334. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51335. *
  51336. * @param name The material name
  51337. * @param scene The scene the material will be use in.
  51338. */
  51339. constructor(name: string, scene: Scene);
  51340. /**
  51341. * Return the currrent class name of the material.
  51342. */
  51343. getClassName(): string;
  51344. /**
  51345. * Makes a duplicate of the current material.
  51346. * @param name - name to use for the new material.
  51347. */
  51348. clone(name: string): PBRSpecularGlossinessMaterial;
  51349. /**
  51350. * Serialize the material to a parsable JSON object.
  51351. */
  51352. serialize(): any;
  51353. /**
  51354. * Parses a JSON object correponding to the serialize function.
  51355. */
  51356. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51357. }
  51358. }
  51359. declare module BABYLON {
  51360. /**
  51361. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51362. * It can help converting any input color in a desired output one. This can then be used to create effects
  51363. * from sepia, black and white to sixties or futuristic rendering...
  51364. *
  51365. * The only supported format is currently 3dl.
  51366. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51367. */
  51368. export class ColorGradingTexture extends BaseTexture {
  51369. /**
  51370. * The current texture matrix. (will always be identity in color grading texture)
  51371. */
  51372. private _textureMatrix;
  51373. /**
  51374. * The texture URL.
  51375. */
  51376. url: string;
  51377. /**
  51378. * Empty line regex stored for GC.
  51379. */
  51380. private static _noneEmptyLineRegex;
  51381. private _engine;
  51382. /**
  51383. * Instantiates a ColorGradingTexture from the following parameters.
  51384. *
  51385. * @param url The location of the color gradind data (currently only supporting 3dl)
  51386. * @param scene The scene the texture will be used in
  51387. */
  51388. constructor(url: string, scene: Scene);
  51389. /**
  51390. * Returns the texture matrix used in most of the material.
  51391. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51392. */
  51393. getTextureMatrix(): Matrix;
  51394. /**
  51395. * Occurs when the file being loaded is a .3dl LUT file.
  51396. */
  51397. private load3dlTexture;
  51398. /**
  51399. * Starts the loading process of the texture.
  51400. */
  51401. private loadTexture;
  51402. /**
  51403. * Clones the color gradind texture.
  51404. */
  51405. clone(): ColorGradingTexture;
  51406. /**
  51407. * Called during delayed load for textures.
  51408. */
  51409. delayLoad(): void;
  51410. /**
  51411. * Parses a color grading texture serialized by Babylon.
  51412. * @param parsedTexture The texture information being parsedTexture
  51413. * @param scene The scene to load the texture in
  51414. * @param rootUrl The root url of the data assets to load
  51415. * @return A color gradind texture
  51416. */
  51417. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51418. /**
  51419. * Serializes the LUT texture to json format.
  51420. */
  51421. serialize(): any;
  51422. }
  51423. }
  51424. declare module BABYLON {
  51425. /**
  51426. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51427. */
  51428. export class EquiRectangularCubeTexture extends BaseTexture {
  51429. /** The six faces of the cube. */
  51430. private static _FacesMapping;
  51431. private _noMipmap;
  51432. private _onLoad;
  51433. private _onError;
  51434. /** The size of the cubemap. */
  51435. private _size;
  51436. /** The buffer of the image. */
  51437. private _buffer;
  51438. /** The width of the input image. */
  51439. private _width;
  51440. /** The height of the input image. */
  51441. private _height;
  51442. /** The URL to the image. */
  51443. url: string;
  51444. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51445. coordinatesMode: number;
  51446. /**
  51447. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51448. * @param url The location of the image
  51449. * @param scene The scene the texture will be used in
  51450. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51451. * @param noMipmap Forces to not generate the mipmap if true
  51452. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51453. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51454. * @param onLoad — defines a callback called when texture is loaded
  51455. * @param onError — defines a callback called if there is an error
  51456. */
  51457. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51458. /**
  51459. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51460. */
  51461. private loadImage;
  51462. /**
  51463. * Convert the image buffer into a cubemap and create a CubeTexture.
  51464. */
  51465. private loadTexture;
  51466. /**
  51467. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51468. * @param buffer The ArrayBuffer that should be converted.
  51469. * @returns The buffer as Float32Array.
  51470. */
  51471. private getFloat32ArrayFromArrayBuffer;
  51472. /**
  51473. * Get the current class name of the texture useful for serialization or dynamic coding.
  51474. * @returns "EquiRectangularCubeTexture"
  51475. */
  51476. getClassName(): string;
  51477. /**
  51478. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51479. * @returns A clone of the current EquiRectangularCubeTexture.
  51480. */
  51481. clone(): EquiRectangularCubeTexture;
  51482. }
  51483. }
  51484. declare module BABYLON {
  51485. /**
  51486. * Based on jsTGALoader - Javascript loader for TGA file
  51487. * By Vincent Thibault
  51488. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51489. */
  51490. export class TGATools {
  51491. private static _TYPE_INDEXED;
  51492. private static _TYPE_RGB;
  51493. private static _TYPE_GREY;
  51494. private static _TYPE_RLE_INDEXED;
  51495. private static _TYPE_RLE_RGB;
  51496. private static _TYPE_RLE_GREY;
  51497. private static _ORIGIN_MASK;
  51498. private static _ORIGIN_SHIFT;
  51499. private static _ORIGIN_BL;
  51500. private static _ORIGIN_BR;
  51501. private static _ORIGIN_UL;
  51502. private static _ORIGIN_UR;
  51503. /**
  51504. * Gets the header of a TGA file
  51505. * @param data defines the TGA data
  51506. * @returns the header
  51507. */
  51508. static GetTGAHeader(data: Uint8Array): any;
  51509. /**
  51510. * Uploads TGA content to a Babylon Texture
  51511. * @hidden
  51512. */
  51513. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51514. /** @hidden */
  51515. 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;
  51516. /** @hidden */
  51517. 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;
  51518. /** @hidden */
  51519. 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;
  51520. /** @hidden */
  51521. 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;
  51522. /** @hidden */
  51523. 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;
  51524. /** @hidden */
  51525. 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;
  51526. }
  51527. }
  51528. declare module BABYLON {
  51529. /**
  51530. * Implementation of the TGA Texture Loader.
  51531. * @hidden
  51532. */
  51533. export class _TGATextureLoader implements IInternalTextureLoader {
  51534. /**
  51535. * Defines wether the loader supports cascade loading the different faces.
  51536. */
  51537. readonly supportCascades: boolean;
  51538. /**
  51539. * This returns if the loader support the current file information.
  51540. * @param extension defines the file extension of the file being loaded
  51541. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51542. * @param fallback defines the fallback internal texture if any
  51543. * @param isBase64 defines whether the texture is encoded as a base64
  51544. * @param isBuffer defines whether the texture data are stored as a buffer
  51545. * @returns true if the loader can load the specified file
  51546. */
  51547. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51548. /**
  51549. * Transform the url before loading if required.
  51550. * @param rootUrl the url of the texture
  51551. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51552. * @returns the transformed texture
  51553. */
  51554. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51555. /**
  51556. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51557. * @param rootUrl the url of the texture
  51558. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51559. * @returns the fallback texture
  51560. */
  51561. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51562. /**
  51563. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51564. * @param data contains the texture data
  51565. * @param texture defines the BabylonJS internal texture
  51566. * @param createPolynomials will be true if polynomials have been requested
  51567. * @param onLoad defines the callback to trigger once the texture is ready
  51568. * @param onError defines the callback to trigger in case of error
  51569. */
  51570. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51571. /**
  51572. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51573. * @param data contains the texture data
  51574. * @param texture defines the BabylonJS internal texture
  51575. * @param callback defines the method to call once ready to upload
  51576. */
  51577. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51578. }
  51579. }
  51580. declare module BABYLON {
  51581. /**
  51582. * Info about the .basis files
  51583. */
  51584. class BasisFileInfo {
  51585. /**
  51586. * If the file has alpha
  51587. */
  51588. hasAlpha: boolean;
  51589. /**
  51590. * Info about each image of the basis file
  51591. */
  51592. images: Array<{
  51593. levels: Array<{
  51594. width: number;
  51595. height: number;
  51596. transcodedPixels: ArrayBufferView;
  51597. }>;
  51598. }>;
  51599. }
  51600. /**
  51601. * Result of transcoding a basis file
  51602. */
  51603. class TranscodeResult {
  51604. /**
  51605. * Info about the .basis file
  51606. */
  51607. fileInfo: BasisFileInfo;
  51608. /**
  51609. * Format to use when loading the file
  51610. */
  51611. format: number;
  51612. }
  51613. /**
  51614. * Configuration options for the Basis transcoder
  51615. */
  51616. export class BasisTranscodeConfiguration {
  51617. /**
  51618. * Supported compression formats used to determine the supported output format of the transcoder
  51619. */
  51620. supportedCompressionFormats?: {
  51621. /**
  51622. * etc1 compression format
  51623. */
  51624. etc1?: boolean;
  51625. /**
  51626. * s3tc compression format
  51627. */
  51628. s3tc?: boolean;
  51629. /**
  51630. * pvrtc compression format
  51631. */
  51632. pvrtc?: boolean;
  51633. /**
  51634. * etc2 compression format
  51635. */
  51636. etc2?: boolean;
  51637. };
  51638. /**
  51639. * If mipmap levels should be loaded for transcoded images (Default: true)
  51640. */
  51641. loadMipmapLevels?: boolean;
  51642. /**
  51643. * Index of a single image to load (Default: all images)
  51644. */
  51645. loadSingleImage?: number;
  51646. }
  51647. /**
  51648. * Used to load .Basis files
  51649. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  51650. */
  51651. export class BasisTools {
  51652. private static _IgnoreSupportedFormats;
  51653. /**
  51654. * URL to use when loading the basis transcoder
  51655. */
  51656. static JSModuleURL: string;
  51657. /**
  51658. * URL to use when loading the wasm module for the transcoder
  51659. */
  51660. static WasmModuleURL: string;
  51661. /**
  51662. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  51663. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  51664. * @returns internal format corresponding to the Basis format
  51665. */
  51666. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  51667. private static _WorkerPromise;
  51668. private static _Worker;
  51669. private static _actionId;
  51670. private static _CreateWorkerAsync;
  51671. /**
  51672. * Transcodes a loaded image file to compressed pixel data
  51673. * @param imageData image data to transcode
  51674. * @param config configuration options for the transcoding
  51675. * @returns a promise resulting in the transcoded image
  51676. */
  51677. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  51678. /**
  51679. * Loads a texture from the transcode result
  51680. * @param texture texture load to
  51681. * @param transcodeResult the result of transcoding the basis file to load from
  51682. */
  51683. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  51684. }
  51685. }
  51686. declare module BABYLON {
  51687. /**
  51688. * Loader for .basis file format
  51689. */
  51690. export class _BasisTextureLoader implements IInternalTextureLoader {
  51691. /**
  51692. * Defines whether the loader supports cascade loading the different faces.
  51693. */
  51694. readonly supportCascades: boolean;
  51695. /**
  51696. * This returns if the loader support the current file information.
  51697. * @param extension defines the file extension of the file being loaded
  51698. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51699. * @param fallback defines the fallback internal texture if any
  51700. * @param isBase64 defines whether the texture is encoded as a base64
  51701. * @param isBuffer defines whether the texture data are stored as a buffer
  51702. * @returns true if the loader can load the specified file
  51703. */
  51704. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51705. /**
  51706. * Transform the url before loading if required.
  51707. * @param rootUrl the url of the texture
  51708. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51709. * @returns the transformed texture
  51710. */
  51711. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51712. /**
  51713. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51714. * @param rootUrl the url of the texture
  51715. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51716. * @returns the fallback texture
  51717. */
  51718. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51719. /**
  51720. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  51721. * @param data contains the texture data
  51722. * @param texture defines the BabylonJS internal texture
  51723. * @param createPolynomials will be true if polynomials have been requested
  51724. * @param onLoad defines the callback to trigger once the texture is ready
  51725. * @param onError defines the callback to trigger in case of error
  51726. */
  51727. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51728. /**
  51729. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51730. * @param data contains the texture data
  51731. * @param texture defines the BabylonJS internal texture
  51732. * @param callback defines the method to call once ready to upload
  51733. */
  51734. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51735. }
  51736. }
  51737. declare module BABYLON {
  51738. /**
  51739. * 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.
  51740. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51741. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51742. */
  51743. export class CustomProceduralTexture extends ProceduralTexture {
  51744. private _animate;
  51745. private _time;
  51746. private _config;
  51747. private _texturePath;
  51748. /**
  51749. * Instantiates a new Custom Procedural Texture.
  51750. * 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.
  51751. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51752. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51753. * @param name Define the name of the texture
  51754. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51755. * @param size Define the size of the texture to create
  51756. * @param scene Define the scene the texture belongs to
  51757. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51758. * @param generateMipMaps Define if the texture should creates mip maps or not
  51759. */
  51760. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51761. private _loadJson;
  51762. /**
  51763. * Is the texture ready to be used ? (rendered at least once)
  51764. * @returns true if ready, otherwise, false.
  51765. */
  51766. isReady(): boolean;
  51767. /**
  51768. * Render the texture to its associated render target.
  51769. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51770. */
  51771. render(useCameraPostProcess?: boolean): void;
  51772. /**
  51773. * Update the list of dependant textures samplers in the shader.
  51774. */
  51775. updateTextures(): void;
  51776. /**
  51777. * Update the uniform values of the procedural texture in the shader.
  51778. */
  51779. updateShaderUniforms(): void;
  51780. /**
  51781. * Define if the texture animates or not.
  51782. */
  51783. animate: boolean;
  51784. }
  51785. }
  51786. declare module BABYLON {
  51787. /** @hidden */
  51788. export var noisePixelShader: {
  51789. name: string;
  51790. shader: string;
  51791. };
  51792. }
  51793. declare module BABYLON {
  51794. /**
  51795. * Class used to generate noise procedural textures
  51796. */
  51797. export class NoiseProceduralTexture extends ProceduralTexture {
  51798. private _time;
  51799. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51800. brightness: number;
  51801. /** Defines the number of octaves to process */
  51802. octaves: number;
  51803. /** Defines the level of persistence (0.8 by default) */
  51804. persistence: number;
  51805. /** Gets or sets animation speed factor (default is 1) */
  51806. animationSpeedFactor: number;
  51807. /**
  51808. * Creates a new NoiseProceduralTexture
  51809. * @param name defines the name fo the texture
  51810. * @param size defines the size of the texture (default is 256)
  51811. * @param scene defines the hosting scene
  51812. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51813. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51814. */
  51815. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51816. private _updateShaderUniforms;
  51817. protected _getDefines(): string;
  51818. /** Generate the current state of the procedural texture */
  51819. render(useCameraPostProcess?: boolean): void;
  51820. /**
  51821. * Serializes this noise procedural texture
  51822. * @returns a serialized noise procedural texture object
  51823. */
  51824. serialize(): any;
  51825. /**
  51826. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51827. * @param parsedTexture defines parsed texture data
  51828. * @param scene defines the current scene
  51829. * @param rootUrl defines the root URL containing noise procedural texture information
  51830. * @returns a parsed NoiseProceduralTexture
  51831. */
  51832. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51833. }
  51834. }
  51835. declare module BABYLON {
  51836. /**
  51837. * Raw cube texture where the raw buffers are passed in
  51838. */
  51839. export class RawCubeTexture extends CubeTexture {
  51840. /**
  51841. * Creates a cube texture where the raw buffers are passed in.
  51842. * @param scene defines the scene the texture is attached to
  51843. * @param data defines the array of data to use to create each face
  51844. * @param size defines the size of the textures
  51845. * @param format defines the format of the data
  51846. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51847. * @param generateMipMaps defines if the engine should generate the mip levels
  51848. * @param invertY defines if data must be stored with Y axis inverted
  51849. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51850. * @param compression defines the compression used (null by default)
  51851. */
  51852. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51853. /**
  51854. * Updates the raw cube texture.
  51855. * @param data defines the data to store
  51856. * @param format defines the data format
  51857. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51858. * @param invertY defines if data must be stored with Y axis inverted
  51859. * @param compression defines the compression used (null by default)
  51860. * @param level defines which level of the texture to update
  51861. */
  51862. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51863. /**
  51864. * Updates a raw cube texture with RGBD encoded data.
  51865. * @param data defines the array of data [mipmap][face] to use to create each face
  51866. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51867. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51868. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51869. * @returns a promsie that resolves when the operation is complete
  51870. */
  51871. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51872. /**
  51873. * Clones the raw cube texture.
  51874. * @return a new cube texture
  51875. */
  51876. clone(): CubeTexture;
  51877. /** @hidden */
  51878. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51879. }
  51880. }
  51881. declare module BABYLON {
  51882. /**
  51883. * Class used to store 3D textures containing user data
  51884. */
  51885. export class RawTexture3D extends Texture {
  51886. /** Gets or sets the texture format to use */
  51887. format: number;
  51888. private _engine;
  51889. /**
  51890. * Create a new RawTexture3D
  51891. * @param data defines the data of the texture
  51892. * @param width defines the width of the texture
  51893. * @param height defines the height of the texture
  51894. * @param depth defines the depth of the texture
  51895. * @param format defines the texture format to use
  51896. * @param scene defines the hosting scene
  51897. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51898. * @param invertY defines if texture must be stored with Y axis inverted
  51899. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51900. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51901. */
  51902. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51903. /** Gets or sets the texture format to use */
  51904. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51905. /**
  51906. * Update the texture with new data
  51907. * @param data defines the data to store in the texture
  51908. */
  51909. update(data: ArrayBufferView): void;
  51910. }
  51911. }
  51912. declare module BABYLON {
  51913. /**
  51914. * Creates a refraction texture used by refraction channel of the standard material.
  51915. * It is like a mirror but to see through a material.
  51916. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51917. */
  51918. export class RefractionTexture extends RenderTargetTexture {
  51919. /**
  51920. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51921. * 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.
  51922. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51923. */
  51924. refractionPlane: Plane;
  51925. /**
  51926. * Define how deep under the surface we should see.
  51927. */
  51928. depth: number;
  51929. /**
  51930. * Creates a refraction texture used by refraction channel of the standard material.
  51931. * It is like a mirror but to see through a material.
  51932. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51933. * @param name Define the texture name
  51934. * @param size Define the size of the underlying texture
  51935. * @param scene Define the scene the refraction belongs to
  51936. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51937. */
  51938. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51939. /**
  51940. * Clone the refraction texture.
  51941. * @returns the cloned texture
  51942. */
  51943. clone(): RefractionTexture;
  51944. /**
  51945. * Serialize the texture to a JSON representation you could use in Parse later on
  51946. * @returns the serialized JSON representation
  51947. */
  51948. serialize(): any;
  51949. }
  51950. }
  51951. declare module BABYLON {
  51952. /**
  51953. * Defines the options related to the creation of an HtmlElementTexture
  51954. */
  51955. export interface IHtmlElementTextureOptions {
  51956. /**
  51957. * Defines wether mip maps should be created or not.
  51958. */
  51959. generateMipMaps?: boolean;
  51960. /**
  51961. * Defines the sampling mode of the texture.
  51962. */
  51963. samplingMode?: number;
  51964. /**
  51965. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51966. */
  51967. engine: Nullable<Engine>;
  51968. /**
  51969. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51970. */
  51971. scene: Nullable<Scene>;
  51972. }
  51973. /**
  51974. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51975. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51976. * is automatically managed.
  51977. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51978. * in your application.
  51979. *
  51980. * As the update is not automatic, you need to call them manually.
  51981. */
  51982. export class HtmlElementTexture extends BaseTexture {
  51983. /**
  51984. * The texture URL.
  51985. */
  51986. element: HTMLVideoElement | HTMLCanvasElement;
  51987. private static readonly DefaultOptions;
  51988. private _textureMatrix;
  51989. private _engine;
  51990. private _isVideo;
  51991. private _generateMipMaps;
  51992. private _samplingMode;
  51993. /**
  51994. * Instantiates a HtmlElementTexture from the following parameters.
  51995. *
  51996. * @param name Defines the name of the texture
  51997. * @param element Defines the video or canvas the texture is filled with
  51998. * @param options Defines the other none mandatory texture creation options
  51999. */
  52000. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52001. private _createInternalTexture;
  52002. /**
  52003. * Returns the texture matrix used in most of the material.
  52004. */
  52005. getTextureMatrix(): Matrix;
  52006. /**
  52007. * Updates the content of the texture.
  52008. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52009. */
  52010. update(invertY?: Nullable<boolean>): void;
  52011. }
  52012. }
  52013. declare module BABYLON {
  52014. /**
  52015. * Enum used to define the target of a block
  52016. */
  52017. export enum NodeMaterialBlockTargets {
  52018. /** Vertex shader */
  52019. Vertex = 1,
  52020. /** Fragment shader */
  52021. Fragment = 2,
  52022. /** Neutral */
  52023. Neutral = 4,
  52024. /** Vertex and Fragment */
  52025. VertexAndFragment = 3
  52026. }
  52027. }
  52028. declare module BABYLON {
  52029. /**
  52030. * Defines the kind of connection point for node based material
  52031. */
  52032. export enum NodeMaterialBlockConnectionPointTypes {
  52033. /** Float */
  52034. Float = 1,
  52035. /** Int */
  52036. Int = 2,
  52037. /** Vector2 */
  52038. Vector2 = 4,
  52039. /** Vector3 */
  52040. Vector3 = 8,
  52041. /** Vector4 */
  52042. Vector4 = 16,
  52043. /** Color3 */
  52044. Color3 = 32,
  52045. /** Color4 */
  52046. Color4 = 64,
  52047. /** Matrix */
  52048. Matrix = 128,
  52049. /** Detect type based on connection */
  52050. AutoDetect = 1024,
  52051. /** Output type that will be defined by input type */
  52052. BasedOnInput = 2048
  52053. }
  52054. }
  52055. declare module BABYLON {
  52056. /**
  52057. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52058. */
  52059. export enum NodeMaterialBlockConnectionPointMode {
  52060. /** Value is an uniform */
  52061. Uniform = 0,
  52062. /** Value is a mesh attribute */
  52063. Attribute = 1,
  52064. /** Value is a varying between vertex and fragment shaders */
  52065. Varying = 2,
  52066. /** Mode is undefined */
  52067. Undefined = 3
  52068. }
  52069. }
  52070. declare module BABYLON {
  52071. /**
  52072. * Enum used to define system values e.g. values automatically provided by the system
  52073. */
  52074. export enum NodeMaterialSystemValues {
  52075. /** World */
  52076. World = 1,
  52077. /** View */
  52078. View = 2,
  52079. /** Projection */
  52080. Projection = 3,
  52081. /** ViewProjection */
  52082. ViewProjection = 4,
  52083. /** WorldView */
  52084. WorldView = 5,
  52085. /** WorldViewProjection */
  52086. WorldViewProjection = 6,
  52087. /** CameraPosition */
  52088. CameraPosition = 7,
  52089. /** Fog Color */
  52090. FogColor = 8
  52091. }
  52092. }
  52093. declare module BABYLON {
  52094. /**
  52095. * Root class for all node material optimizers
  52096. */
  52097. export class NodeMaterialOptimizer {
  52098. /**
  52099. * Function used to optimize a NodeMaterial graph
  52100. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52101. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52102. */
  52103. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52104. }
  52105. }
  52106. declare module BABYLON {
  52107. /**
  52108. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  52109. */
  52110. export class TransformBlock extends NodeMaterialBlock {
  52111. /**
  52112. * Defines the value to use to complement W value to transform it to a Vector4
  52113. */
  52114. complementW: number;
  52115. /**
  52116. * Defines the value to use to complement z value to transform it to a Vector4
  52117. */
  52118. complementZ: number;
  52119. /**
  52120. * Creates a new TransformBlock
  52121. * @param name defines the block name
  52122. */
  52123. constructor(name: string);
  52124. /**
  52125. * Gets the current class name
  52126. * @returns the class name
  52127. */
  52128. getClassName(): string;
  52129. /**
  52130. * Gets the vector input
  52131. */
  52132. readonly vector: NodeMaterialConnectionPoint;
  52133. /**
  52134. * Gets the output component
  52135. */
  52136. readonly output: NodeMaterialConnectionPoint;
  52137. /**
  52138. * Gets the matrix transform input
  52139. */
  52140. readonly transform: NodeMaterialConnectionPoint;
  52141. protected _buildBlock(state: NodeMaterialBuildState): this;
  52142. serialize(): any;
  52143. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52144. protected _dumpPropertiesCode(): string;
  52145. }
  52146. }
  52147. declare module BABYLON {
  52148. /**
  52149. * Block used to output the vertex position
  52150. */
  52151. export class VertexOutputBlock extends NodeMaterialBlock {
  52152. /**
  52153. * Creates a new VertexOutputBlock
  52154. * @param name defines the block name
  52155. */
  52156. constructor(name: string);
  52157. /**
  52158. * Gets the current class name
  52159. * @returns the class name
  52160. */
  52161. getClassName(): string;
  52162. /**
  52163. * Gets the vector input component
  52164. */
  52165. readonly vector: NodeMaterialConnectionPoint;
  52166. protected _buildBlock(state: NodeMaterialBuildState): this;
  52167. }
  52168. }
  52169. declare module BABYLON {
  52170. /**
  52171. * Block used to output the final color
  52172. */
  52173. export class FragmentOutputBlock extends NodeMaterialBlock {
  52174. /**
  52175. * Create a new FragmentOutputBlock
  52176. * @param name defines the block name
  52177. */
  52178. constructor(name: string);
  52179. /**
  52180. * Gets the current class name
  52181. * @returns the class name
  52182. */
  52183. getClassName(): string;
  52184. /**
  52185. * Gets the rgba input component
  52186. */
  52187. readonly rgba: NodeMaterialConnectionPoint;
  52188. /**
  52189. * Gets the rgb input component
  52190. */
  52191. readonly rgb: NodeMaterialConnectionPoint;
  52192. /**
  52193. * Gets the a input component
  52194. */
  52195. readonly a: NodeMaterialConnectionPoint;
  52196. protected _buildBlock(state: NodeMaterialBuildState): this;
  52197. }
  52198. }
  52199. declare module BABYLON {
  52200. /**
  52201. * Block used to read a reflection texture from a sampler
  52202. */
  52203. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52204. private _define3DName;
  52205. private _defineCubicName;
  52206. private _defineExplicitName;
  52207. private _defineProjectionName;
  52208. private _defineLocalCubicName;
  52209. private _defineSphericalName;
  52210. private _definePlanarName;
  52211. private _defineEquirectangularName;
  52212. private _defineMirroredEquirectangularFixedName;
  52213. private _defineEquirectangularFixedName;
  52214. private _defineSkyboxName;
  52215. private _cubeSamplerName;
  52216. private _2DSamplerName;
  52217. private _positionUVWName;
  52218. private _directionWName;
  52219. private _reflectionCoordsName;
  52220. private _reflection2DCoordsName;
  52221. private _reflectionColorName;
  52222. private _reflectionMatrixName;
  52223. /**
  52224. * Gets or sets the texture associated with the node
  52225. */
  52226. texture: Nullable<BaseTexture>;
  52227. /**
  52228. * Create a new TextureBlock
  52229. * @param name defines the block name
  52230. */
  52231. constructor(name: string);
  52232. /**
  52233. * Gets the current class name
  52234. * @returns the class name
  52235. */
  52236. getClassName(): string;
  52237. /**
  52238. * Gets the world position input component
  52239. */
  52240. readonly position: NodeMaterialConnectionPoint;
  52241. /**
  52242. * Gets the world position input component
  52243. */
  52244. readonly worldPosition: NodeMaterialConnectionPoint;
  52245. /**
  52246. * Gets the world normal input component
  52247. */
  52248. readonly worldNormal: NodeMaterialConnectionPoint;
  52249. /**
  52250. * Gets the world input component
  52251. */
  52252. readonly world: NodeMaterialConnectionPoint;
  52253. /**
  52254. * Gets the camera (or eye) position component
  52255. */
  52256. readonly cameraPosition: NodeMaterialConnectionPoint;
  52257. /**
  52258. * Gets the view input component
  52259. */
  52260. readonly view: NodeMaterialConnectionPoint;
  52261. /**
  52262. * Gets the rgb output component
  52263. */
  52264. readonly rgb: NodeMaterialConnectionPoint;
  52265. /**
  52266. * Gets the r output component
  52267. */
  52268. readonly r: NodeMaterialConnectionPoint;
  52269. /**
  52270. * Gets the g output component
  52271. */
  52272. readonly g: NodeMaterialConnectionPoint;
  52273. /**
  52274. * Gets the b output component
  52275. */
  52276. readonly b: NodeMaterialConnectionPoint;
  52277. autoConfigure(material: NodeMaterial): void;
  52278. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52279. isReady(): boolean;
  52280. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52281. private _injectVertexCode;
  52282. private _writeOutput;
  52283. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52284. serialize(): any;
  52285. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52286. }
  52287. }
  52288. declare module BABYLON {
  52289. /**
  52290. * Interface used to configure the node material editor
  52291. */
  52292. export interface INodeMaterialEditorOptions {
  52293. /** Define the URl to load node editor script */
  52294. editorURL?: string;
  52295. }
  52296. /** @hidden */
  52297. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52298. /** BONES */
  52299. NUM_BONE_INFLUENCERS: number;
  52300. BonesPerMesh: number;
  52301. BONETEXTURE: boolean;
  52302. /** MORPH TARGETS */
  52303. MORPHTARGETS: boolean;
  52304. MORPHTARGETS_NORMAL: boolean;
  52305. MORPHTARGETS_TANGENT: boolean;
  52306. MORPHTARGETS_UV: boolean;
  52307. NUM_MORPH_INFLUENCERS: number;
  52308. /** IMAGE PROCESSING */
  52309. IMAGEPROCESSING: boolean;
  52310. VIGNETTE: boolean;
  52311. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52312. VIGNETTEBLENDMODEOPAQUE: boolean;
  52313. TONEMAPPING: boolean;
  52314. TONEMAPPING_ACES: boolean;
  52315. CONTRAST: boolean;
  52316. EXPOSURE: boolean;
  52317. COLORCURVES: boolean;
  52318. COLORGRADING: boolean;
  52319. COLORGRADING3D: boolean;
  52320. SAMPLER3DGREENDEPTH: boolean;
  52321. SAMPLER3DBGRMAP: boolean;
  52322. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52323. /** MISC. */
  52324. BUMPDIRECTUV: number;
  52325. constructor();
  52326. setValue(name: string, value: boolean): void;
  52327. }
  52328. /**
  52329. * Class used to configure NodeMaterial
  52330. */
  52331. export interface INodeMaterialOptions {
  52332. /**
  52333. * Defines if blocks should emit comments
  52334. */
  52335. emitComments: boolean;
  52336. }
  52337. /**
  52338. * Class used to create a node based material built by assembling shader blocks
  52339. */
  52340. export class NodeMaterial extends PushMaterial {
  52341. private static _BuildIdGenerator;
  52342. private _options;
  52343. private _vertexCompilationState;
  52344. private _fragmentCompilationState;
  52345. private _sharedData;
  52346. private _buildId;
  52347. private _buildWasSuccessful;
  52348. private _cachedWorldViewMatrix;
  52349. private _cachedWorldViewProjectionMatrix;
  52350. private _optimizers;
  52351. private _animationFrame;
  52352. /** Define the URl to load node editor script */
  52353. static EditorURL: string;
  52354. private BJSNODEMATERIALEDITOR;
  52355. /** Get the inspector from bundle or global */
  52356. private _getGlobalNodeMaterialEditor;
  52357. /**
  52358. * 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)
  52359. */
  52360. ignoreAlpha: boolean;
  52361. /**
  52362. * Defines the maximum number of lights that can be used in the material
  52363. */
  52364. maxSimultaneousLights: number;
  52365. /**
  52366. * Observable raised when the material is built
  52367. */
  52368. onBuildObservable: Observable<NodeMaterial>;
  52369. /**
  52370. * Gets or sets the root nodes of the material vertex shader
  52371. */
  52372. _vertexOutputNodes: NodeMaterialBlock[];
  52373. /**
  52374. * Gets or sets the root nodes of the material fragment (pixel) shader
  52375. */
  52376. _fragmentOutputNodes: NodeMaterialBlock[];
  52377. /** Gets or sets options to control the node material overall behavior */
  52378. options: INodeMaterialOptions;
  52379. /**
  52380. * Default configuration related to image processing available in the standard Material.
  52381. */
  52382. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52383. /**
  52384. * Gets the image processing configuration used either in this material.
  52385. */
  52386. /**
  52387. * Sets the Default image processing configuration used either in the this material.
  52388. *
  52389. * If sets to null, the scene one is in use.
  52390. */
  52391. imageProcessingConfiguration: ImageProcessingConfiguration;
  52392. /**
  52393. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52394. */
  52395. attachedBlocks: NodeMaterialBlock[];
  52396. /**
  52397. * Create a new node based material
  52398. * @param name defines the material name
  52399. * @param scene defines the hosting scene
  52400. * @param options defines creation option
  52401. */
  52402. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52403. /**
  52404. * Gets the current class name of the material e.g. "NodeMaterial"
  52405. * @returns the class name
  52406. */
  52407. getClassName(): string;
  52408. /**
  52409. * Keep track of the image processing observer to allow dispose and replace.
  52410. */
  52411. private _imageProcessingObserver;
  52412. /**
  52413. * Attaches a new image processing configuration to the Standard Material.
  52414. * @param configuration
  52415. */
  52416. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52417. /**
  52418. * Get a block by its name
  52419. * @param name defines the name of the block to retrieve
  52420. * @returns the required block or null if not found
  52421. */
  52422. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52423. /**
  52424. * Get a block by its name
  52425. * @param predicate defines the predicate used to find the good candidate
  52426. * @returns the required block or null if not found
  52427. */
  52428. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52429. /**
  52430. * Get an input block by its name
  52431. * @param predicate defines the predicate used to find the good candidate
  52432. * @returns the required input block or null if not found
  52433. */
  52434. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52435. /**
  52436. * Gets the list of input blocks attached to this material
  52437. * @returns an array of InputBlocks
  52438. */
  52439. getInputBlocks(): InputBlock[];
  52440. /**
  52441. * Adds a new optimizer to the list of optimizers
  52442. * @param optimizer defines the optimizers to add
  52443. * @returns the current material
  52444. */
  52445. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52446. /**
  52447. * Remove an optimizer from the list of optimizers
  52448. * @param optimizer defines the optimizers to remove
  52449. * @returns the current material
  52450. */
  52451. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52452. /**
  52453. * Add a new block to the list of output nodes
  52454. * @param node defines the node to add
  52455. * @returns the current material
  52456. */
  52457. addOutputNode(node: NodeMaterialBlock): this;
  52458. /**
  52459. * Remove a block from the list of root nodes
  52460. * @param node defines the node to remove
  52461. * @returns the current material
  52462. */
  52463. removeOutputNode(node: NodeMaterialBlock): this;
  52464. private _addVertexOutputNode;
  52465. private _removeVertexOutputNode;
  52466. private _addFragmentOutputNode;
  52467. private _removeFragmentOutputNode;
  52468. /**
  52469. * Specifies if the material will require alpha blending
  52470. * @returns a boolean specifying if alpha blending is needed
  52471. */
  52472. needAlphaBlending(): boolean;
  52473. /**
  52474. * Specifies if this material should be rendered in alpha test mode
  52475. * @returns a boolean specifying if an alpha test is needed.
  52476. */
  52477. needAlphaTesting(): boolean;
  52478. private _initializeBlock;
  52479. private _resetDualBlocks;
  52480. /**
  52481. * Build the material and generates the inner effect
  52482. * @param verbose defines if the build should log activity
  52483. */
  52484. build(verbose?: boolean): void;
  52485. /**
  52486. * Runs an otpimization phase to try to improve the shader code
  52487. */
  52488. optimize(): void;
  52489. private _prepareDefinesForAttributes;
  52490. /**
  52491. * Get if the submesh is ready to be used and all its information available.
  52492. * Child classes can use it to update shaders
  52493. * @param mesh defines the mesh to check
  52494. * @param subMesh defines which submesh to check
  52495. * @param useInstances specifies that instances should be used
  52496. * @returns a boolean indicating that the submesh is ready or not
  52497. */
  52498. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52499. /**
  52500. * Get a string representing the shaders built by the current node graph
  52501. */
  52502. readonly compiledShaders: string;
  52503. /**
  52504. * Binds the world matrix to the material
  52505. * @param world defines the world transformation matrix
  52506. */
  52507. bindOnlyWorldMatrix(world: Matrix): void;
  52508. /**
  52509. * Binds the submesh to this material by preparing the effect and shader to draw
  52510. * @param world defines the world transformation matrix
  52511. * @param mesh defines the mesh containing the submesh
  52512. * @param subMesh defines the submesh to bind the material to
  52513. */
  52514. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52515. /**
  52516. * Gets the active textures from the material
  52517. * @returns an array of textures
  52518. */
  52519. getActiveTextures(): BaseTexture[];
  52520. /**
  52521. * Gets the list of texture blocks
  52522. * @returns an array of texture blocks
  52523. */
  52524. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52525. /**
  52526. * Specifies if the material uses a texture
  52527. * @param texture defines the texture to check against the material
  52528. * @returns a boolean specifying if the material uses the texture
  52529. */
  52530. hasTexture(texture: BaseTexture): boolean;
  52531. /**
  52532. * Disposes the material
  52533. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52534. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52535. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52536. */
  52537. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52538. /** Creates the node editor window. */
  52539. private _createNodeEditor;
  52540. /**
  52541. * Launch the node material editor
  52542. * @param config Define the configuration of the editor
  52543. * @return a promise fulfilled when the node editor is visible
  52544. */
  52545. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52546. /**
  52547. * Clear the current material
  52548. */
  52549. clear(): void;
  52550. /**
  52551. * Clear the current material and set it to a default state
  52552. */
  52553. setToDefault(): void;
  52554. /**
  52555. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  52556. * @param url defines the url to load from
  52557. * @returns a promise that will fullfil when the material is fully loaded
  52558. */
  52559. loadAsync(url: string): Promise<unknown>;
  52560. private _gatherBlocks;
  52561. /**
  52562. * Generate a string containing the code declaration required to create an equivalent of this material
  52563. * @returns a string
  52564. */
  52565. generateCode(): string;
  52566. /**
  52567. * Serializes this material in a JSON representation
  52568. * @returns the serialized material object
  52569. */
  52570. serialize(): any;
  52571. private _restoreConnections;
  52572. /**
  52573. * Clear the current graph and load a new one from a serialization object
  52574. * @param source defines the JSON representation of the material
  52575. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52576. */
  52577. loadFromSerialization(source: any, rootUrl?: string): void;
  52578. /**
  52579. * Creates a node material from parsed material data
  52580. * @param source defines the JSON representation of the material
  52581. * @param scene defines the hosting scene
  52582. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52583. * @returns a new node material
  52584. */
  52585. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  52586. /**
  52587. * Creates a new node material set to default basic configuration
  52588. * @param name defines the name of the material
  52589. * @param scene defines the hosting scene
  52590. * @returns a new NodeMaterial
  52591. */
  52592. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  52593. }
  52594. }
  52595. declare module BABYLON {
  52596. /**
  52597. * Block used to read a texture from a sampler
  52598. */
  52599. export class TextureBlock extends NodeMaterialBlock {
  52600. private _defineName;
  52601. private _samplerName;
  52602. private _transformedUVName;
  52603. private _textureTransformName;
  52604. private _textureInfoName;
  52605. private _mainUVName;
  52606. private _mainUVDefineName;
  52607. /**
  52608. * Gets or sets the texture associated with the node
  52609. */
  52610. texture: Nullable<Texture>;
  52611. /**
  52612. * Create a new TextureBlock
  52613. * @param name defines the block name
  52614. */
  52615. constructor(name: string);
  52616. /**
  52617. * Gets the current class name
  52618. * @returns the class name
  52619. */
  52620. getClassName(): string;
  52621. /**
  52622. * Gets the uv input component
  52623. */
  52624. readonly uv: NodeMaterialConnectionPoint;
  52625. /**
  52626. * Gets the rgba output component
  52627. */
  52628. readonly rgba: NodeMaterialConnectionPoint;
  52629. /**
  52630. * Gets the rgb output component
  52631. */
  52632. readonly rgb: NodeMaterialConnectionPoint;
  52633. /**
  52634. * Gets the r output component
  52635. */
  52636. readonly r: NodeMaterialConnectionPoint;
  52637. /**
  52638. * Gets the g output component
  52639. */
  52640. readonly g: NodeMaterialConnectionPoint;
  52641. /**
  52642. * Gets the b output component
  52643. */
  52644. readonly b: NodeMaterialConnectionPoint;
  52645. /**
  52646. * Gets the a output component
  52647. */
  52648. readonly a: NodeMaterialConnectionPoint;
  52649. readonly target: NodeMaterialBlockTargets;
  52650. autoConfigure(material: NodeMaterial): void;
  52651. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52652. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52653. isReady(): boolean;
  52654. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52655. private readonly _isMixed;
  52656. private _injectVertexCode;
  52657. private _writeOutput;
  52658. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52659. protected _dumpPropertiesCode(): string;
  52660. serialize(): any;
  52661. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52662. }
  52663. }
  52664. declare module BABYLON {
  52665. /**
  52666. * Class used to store shared data between 2 NodeMaterialBuildState
  52667. */
  52668. export class NodeMaterialBuildStateSharedData {
  52669. /**
  52670. * Gets the list of emitted varyings
  52671. */
  52672. temps: string[];
  52673. /**
  52674. * Gets the list of emitted varyings
  52675. */
  52676. varyings: string[];
  52677. /**
  52678. * Gets the varying declaration string
  52679. */
  52680. varyingDeclaration: string;
  52681. /**
  52682. * Input blocks
  52683. */
  52684. inputBlocks: InputBlock[];
  52685. /**
  52686. * Input blocks
  52687. */
  52688. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  52689. /**
  52690. * Bindable blocks (Blocks that need to set data to the effect)
  52691. */
  52692. bindableBlocks: NodeMaterialBlock[];
  52693. /**
  52694. * List of blocks that can provide a compilation fallback
  52695. */
  52696. blocksWithFallbacks: NodeMaterialBlock[];
  52697. /**
  52698. * List of blocks that can provide a define update
  52699. */
  52700. blocksWithDefines: NodeMaterialBlock[];
  52701. /**
  52702. * List of blocks that can provide a repeatable content
  52703. */
  52704. repeatableContentBlocks: NodeMaterialBlock[];
  52705. /**
  52706. * List of blocks that can provide a dynamic list of uniforms
  52707. */
  52708. dynamicUniformBlocks: NodeMaterialBlock[];
  52709. /**
  52710. * List of blocks that can block the isReady function for the material
  52711. */
  52712. blockingBlocks: NodeMaterialBlock[];
  52713. /**
  52714. * Gets the list of animated inputs
  52715. */
  52716. animatedInputs: InputBlock[];
  52717. /**
  52718. * Build Id used to avoid multiple recompilations
  52719. */
  52720. buildId: number;
  52721. /** List of emitted variables */
  52722. variableNames: {
  52723. [key: string]: number;
  52724. };
  52725. /** List of emitted defines */
  52726. defineNames: {
  52727. [key: string]: number;
  52728. };
  52729. /** Should emit comments? */
  52730. emitComments: boolean;
  52731. /** Emit build activity */
  52732. verbose: boolean;
  52733. /** Gets or sets the hosting scene */
  52734. scene: Scene;
  52735. /**
  52736. * Gets the compilation hints emitted at compilation time
  52737. */
  52738. hints: {
  52739. needWorldViewMatrix: boolean;
  52740. needWorldViewProjectionMatrix: boolean;
  52741. needAlphaBlending: boolean;
  52742. needAlphaTesting: boolean;
  52743. };
  52744. /**
  52745. * List of compilation checks
  52746. */
  52747. checks: {
  52748. emitVertex: boolean;
  52749. emitFragment: boolean;
  52750. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52751. };
  52752. /** Creates a new shared data */
  52753. constructor();
  52754. /**
  52755. * Emits console errors and exceptions if there is a failing check
  52756. */
  52757. emitErrors(): void;
  52758. }
  52759. }
  52760. declare module BABYLON {
  52761. /**
  52762. * Class used to store node based material build state
  52763. */
  52764. export class NodeMaterialBuildState {
  52765. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  52766. supportUniformBuffers: boolean;
  52767. /**
  52768. * Gets the list of emitted attributes
  52769. */
  52770. attributes: string[];
  52771. /**
  52772. * Gets the list of emitted uniforms
  52773. */
  52774. uniforms: string[];
  52775. /**
  52776. * Gets the list of emitted constants
  52777. */
  52778. constants: string[];
  52779. /**
  52780. * Gets the list of emitted uniform buffers
  52781. */
  52782. uniformBuffers: string[];
  52783. /**
  52784. * Gets the list of emitted samplers
  52785. */
  52786. samplers: string[];
  52787. /**
  52788. * Gets the list of emitted functions
  52789. */
  52790. functions: {
  52791. [key: string]: string;
  52792. };
  52793. /**
  52794. * Gets the list of emitted extensions
  52795. */
  52796. extensions: {
  52797. [key: string]: string;
  52798. };
  52799. /**
  52800. * Gets the target of the compilation state
  52801. */
  52802. target: NodeMaterialBlockTargets;
  52803. /**
  52804. * Gets the list of emitted counters
  52805. */
  52806. counters: {
  52807. [key: string]: number;
  52808. };
  52809. /**
  52810. * Shared data between multiple NodeMaterialBuildState instances
  52811. */
  52812. sharedData: NodeMaterialBuildStateSharedData;
  52813. /** @hidden */
  52814. _vertexState: NodeMaterialBuildState;
  52815. /** @hidden */
  52816. _attributeDeclaration: string;
  52817. /** @hidden */
  52818. _uniformDeclaration: string;
  52819. /** @hidden */
  52820. _constantDeclaration: string;
  52821. /** @hidden */
  52822. _samplerDeclaration: string;
  52823. /** @hidden */
  52824. _varyingTransfer: string;
  52825. private _repeatableContentAnchorIndex;
  52826. /** @hidden */
  52827. _builtCompilationString: string;
  52828. /**
  52829. * Gets the emitted compilation strings
  52830. */
  52831. compilationString: string;
  52832. /**
  52833. * Finalize the compilation strings
  52834. * @param state defines the current compilation state
  52835. */
  52836. finalize(state: NodeMaterialBuildState): void;
  52837. /** @hidden */
  52838. readonly _repeatableContentAnchor: string;
  52839. /** @hidden */
  52840. _getFreeVariableName(prefix: string): string;
  52841. /** @hidden */
  52842. _getFreeDefineName(prefix: string): string;
  52843. /** @hidden */
  52844. _excludeVariableName(name: string): void;
  52845. /** @hidden */
  52846. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52847. /** @hidden */
  52848. _emitExtension(name: string, extension: string): void;
  52849. /** @hidden */
  52850. _emitFunction(name: string, code: string, comments: string): void;
  52851. /** @hidden */
  52852. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52853. replaceStrings?: {
  52854. search: RegExp;
  52855. replace: string;
  52856. }[];
  52857. repeatKey?: string;
  52858. }): string;
  52859. /** @hidden */
  52860. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52861. repeatKey?: string;
  52862. removeAttributes?: boolean;
  52863. removeUniforms?: boolean;
  52864. removeVaryings?: boolean;
  52865. removeIfDef?: boolean;
  52866. replaceStrings?: {
  52867. search: RegExp;
  52868. replace: string;
  52869. }[];
  52870. }, storeKey?: string): void;
  52871. /** @hidden */
  52872. _registerTempVariable(name: string): boolean;
  52873. /** @hidden */
  52874. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52875. /** @hidden */
  52876. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52877. }
  52878. }
  52879. declare module BABYLON {
  52880. /**
  52881. * Defines a block that can be used inside a node based material
  52882. */
  52883. export class NodeMaterialBlock {
  52884. private _buildId;
  52885. private _buildTarget;
  52886. private _target;
  52887. private _isFinalMerger;
  52888. private _isInput;
  52889. /** @hidden */
  52890. _codeVariableName: string;
  52891. /** @hidden */
  52892. _inputs: NodeMaterialConnectionPoint[];
  52893. /** @hidden */
  52894. _outputs: NodeMaterialConnectionPoint[];
  52895. /** @hidden */
  52896. _preparationId: number;
  52897. /**
  52898. * Gets or sets the name of the block
  52899. */
  52900. name: string;
  52901. /**
  52902. * Gets or sets the unique id of the node
  52903. */
  52904. uniqueId: number;
  52905. /**
  52906. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52907. */
  52908. readonly isFinalMerger: boolean;
  52909. /**
  52910. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52911. */
  52912. readonly isInput: boolean;
  52913. /**
  52914. * Gets or sets the build Id
  52915. */
  52916. buildId: number;
  52917. /**
  52918. * Gets or sets the target of the block
  52919. */
  52920. target: NodeMaterialBlockTargets;
  52921. /**
  52922. * Gets the list of input points
  52923. */
  52924. readonly inputs: NodeMaterialConnectionPoint[];
  52925. /** Gets the list of output points */
  52926. readonly outputs: NodeMaterialConnectionPoint[];
  52927. /**
  52928. * Find an input by its name
  52929. * @param name defines the name of the input to look for
  52930. * @returns the input or null if not found
  52931. */
  52932. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52933. /**
  52934. * Find an output by its name
  52935. * @param name defines the name of the outputto look for
  52936. * @returns the output or null if not found
  52937. */
  52938. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52939. /**
  52940. * Creates a new NodeMaterialBlock
  52941. * @param name defines the block name
  52942. * @param target defines the target of that block (Vertex by default)
  52943. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52944. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52945. */
  52946. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52947. /**
  52948. * Initialize the block and prepare the context for build
  52949. * @param state defines the state that will be used for the build
  52950. */
  52951. initialize(state: NodeMaterialBuildState): void;
  52952. /**
  52953. * Bind data to effect. Will only be called for blocks with isBindable === true
  52954. * @param effect defines the effect to bind data to
  52955. * @param nodeMaterial defines the hosting NodeMaterial
  52956. * @param mesh defines the mesh that will be rendered
  52957. */
  52958. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52959. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52960. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52961. protected _writeFloat(value: number): string;
  52962. /**
  52963. * Gets the current class name e.g. "NodeMaterialBlock"
  52964. * @returns the class name
  52965. */
  52966. getClassName(): string;
  52967. /**
  52968. * Register a new input. Must be called inside a block constructor
  52969. * @param name defines the connection point name
  52970. * @param type defines the connection point type
  52971. * @param isOptional defines a boolean indicating that this input can be omitted
  52972. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52973. * @returns the current block
  52974. */
  52975. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52976. /**
  52977. * Register a new output. Must be called inside a block constructor
  52978. * @param name defines the connection point name
  52979. * @param type defines the connection point type
  52980. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52981. * @returns the current block
  52982. */
  52983. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52984. /**
  52985. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52986. * @param forOutput defines an optional connection point to check compatibility with
  52987. * @returns the first available input or null
  52988. */
  52989. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52990. /**
  52991. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52992. * @param forBlock defines an optional block to check compatibility with
  52993. * @returns the first available input or null
  52994. */
  52995. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52996. /**
  52997. * Gets the sibling of the given output
  52998. * @param current defines the current output
  52999. * @returns the next output in the list or null
  53000. */
  53001. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  53002. /**
  53003. * Connect current block with another block
  53004. * @param other defines the block to connect with
  53005. * @param options define the various options to help pick the right connections
  53006. * @returns the current block
  53007. */
  53008. connectTo(other: NodeMaterialBlock, options?: {
  53009. input?: string;
  53010. output?: string;
  53011. outputSwizzle?: string;
  53012. }): this | undefined;
  53013. protected _buildBlock(state: NodeMaterialBuildState): void;
  53014. /**
  53015. * Add uniforms, samplers and uniform buffers at compilation time
  53016. * @param state defines the state to update
  53017. * @param nodeMaterial defines the node material requesting the update
  53018. * @param defines defines the material defines to update
  53019. */
  53020. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53021. /**
  53022. * Add potential fallbacks if shader compilation fails
  53023. * @param mesh defines the mesh to be rendered
  53024. * @param fallbacks defines the current prioritized list of fallbacks
  53025. */
  53026. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53027. /**
  53028. * Initialize defines for shader compilation
  53029. * @param mesh defines the mesh to be rendered
  53030. * @param nodeMaterial defines the node material requesting the update
  53031. * @param defines defines the material defines to update
  53032. * @param useInstances specifies that instances should be used
  53033. */
  53034. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53035. /**
  53036. * Update defines for shader compilation
  53037. * @param mesh defines the mesh to be rendered
  53038. * @param nodeMaterial defines the node material requesting the update
  53039. * @param defines defines the material defines to update
  53040. * @param useInstances specifies that instances should be used
  53041. */
  53042. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53043. /**
  53044. * Lets the block try to connect some inputs automatically
  53045. * @param material defines the hosting NodeMaterial
  53046. */
  53047. autoConfigure(material: NodeMaterial): void;
  53048. /**
  53049. * Function called when a block is declared as repeatable content generator
  53050. * @param vertexShaderState defines the current compilation state for the vertex shader
  53051. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53052. * @param mesh defines the mesh to be rendered
  53053. * @param defines defines the material defines to update
  53054. */
  53055. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53056. /**
  53057. * Checks if the block is ready
  53058. * @param mesh defines the mesh to be rendered
  53059. * @param nodeMaterial defines the node material requesting the update
  53060. * @param defines defines the material defines to update
  53061. * @param useInstances specifies that instances should be used
  53062. * @returns true if the block is ready
  53063. */
  53064. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53065. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  53066. private _processBuild;
  53067. /**
  53068. * Compile the current node and generate the shader code
  53069. * @param state defines the current compilation state (uniforms, samplers, current string)
  53070. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  53071. * @returns true if already built
  53072. */
  53073. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  53074. protected _inputRename(name: string): string;
  53075. protected _outputRename(name: string): string;
  53076. protected _dumpPropertiesCode(): string;
  53077. /** @hidden */
  53078. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53079. /**
  53080. * Clone the current block to a new identical block
  53081. * @param scene defines the hosting scene
  53082. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53083. * @returns a copy of the current block
  53084. */
  53085. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53086. /**
  53087. * Serializes this block in a JSON representation
  53088. * @returns the serialized block object
  53089. */
  53090. serialize(): any;
  53091. /** @hidden */
  53092. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53093. }
  53094. }
  53095. declare module BABYLON {
  53096. /**
  53097. * Enum defining the type of animations supported by InputBlock
  53098. */
  53099. export enum AnimatedInputBlockTypes {
  53100. /** No animation */
  53101. None = 0,
  53102. /** Time based animation. Will only work for floats */
  53103. Time = 1
  53104. }
  53105. }
  53106. declare module BABYLON {
  53107. /**
  53108. * Block used to expose an input value
  53109. */
  53110. export class InputBlock extends NodeMaterialBlock {
  53111. private _mode;
  53112. private _associatedVariableName;
  53113. private _storedValue;
  53114. private _valueCallback;
  53115. private _type;
  53116. private _animationType;
  53117. /** Gets or set a value used to limit the range of float values */
  53118. min: number;
  53119. /** Gets or set a value used to limit the range of float values */
  53120. max: number;
  53121. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  53122. matrixMode: number;
  53123. /** @hidden */
  53124. _systemValue: Nullable<NodeMaterialSystemValues>;
  53125. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53126. visibleInInspector: boolean;
  53127. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  53128. isConstant: boolean;
  53129. /**
  53130. * Gets or sets the connection point type (default is float)
  53131. */
  53132. readonly type: NodeMaterialBlockConnectionPointTypes;
  53133. /**
  53134. * Creates a new InputBlock
  53135. * @param name defines the block name
  53136. * @param target defines the target of that block (Vertex by default)
  53137. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53138. */
  53139. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53140. /**
  53141. * Gets the output component
  53142. */
  53143. readonly output: NodeMaterialConnectionPoint;
  53144. /**
  53145. * Set the source of this connection point to a vertex attribute
  53146. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53147. * @returns the current connection point
  53148. */
  53149. setAsAttribute(attributeName?: string): InputBlock;
  53150. /**
  53151. * Set the source of this connection point to a system value
  53152. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53153. * @returns the current connection point
  53154. */
  53155. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53156. /**
  53157. * Gets or sets the value of that point.
  53158. * Please note that this value will be ignored if valueCallback is defined
  53159. */
  53160. value: any;
  53161. /**
  53162. * Gets or sets a callback used to get the value of that point.
  53163. * Please note that setting this value will force the connection point to ignore the value property
  53164. */
  53165. valueCallback: () => any;
  53166. /**
  53167. * Gets or sets the associated variable name in the shader
  53168. */
  53169. associatedVariableName: string;
  53170. /** Gets or sets the type of animation applied to the input */
  53171. animationType: AnimatedInputBlockTypes;
  53172. /**
  53173. * Gets a boolean indicating that this connection point not defined yet
  53174. */
  53175. readonly isUndefined: boolean;
  53176. /**
  53177. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53178. * In this case the connection point name must be the name of the uniform to use.
  53179. * Can only be set on inputs
  53180. */
  53181. isUniform: boolean;
  53182. /**
  53183. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53184. * In this case the connection point name must be the name of the attribute to use
  53185. * Can only be set on inputs
  53186. */
  53187. isAttribute: boolean;
  53188. /**
  53189. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53190. * Can only be set on exit points
  53191. */
  53192. isVarying: boolean;
  53193. /**
  53194. * Gets a boolean indicating that the current connection point is a system value
  53195. */
  53196. readonly isSystemValue: boolean;
  53197. /**
  53198. * Gets or sets the current well known value or null if not defined as a system value
  53199. */
  53200. systemValue: Nullable<NodeMaterialSystemValues>;
  53201. /**
  53202. * Gets the current class name
  53203. * @returns the class name
  53204. */
  53205. getClassName(): string;
  53206. /**
  53207. * Animate the input if animationType !== None
  53208. * @param scene defines the rendering scene
  53209. */
  53210. animate(scene: Scene): void;
  53211. private _emitDefine;
  53212. initialize(state: NodeMaterialBuildState): void;
  53213. /**
  53214. * Set the input block to its default value (based on its type)
  53215. */
  53216. setDefaultValue(): void;
  53217. private _emitConstant;
  53218. private _emit;
  53219. /** @hidden */
  53220. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53221. /** @hidden */
  53222. _transmit(effect: Effect, scene: Scene): void;
  53223. protected _buildBlock(state: NodeMaterialBuildState): void;
  53224. protected _dumpPropertiesCode(): string;
  53225. serialize(): any;
  53226. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53227. }
  53228. }
  53229. declare module BABYLON {
  53230. /**
  53231. * Defines a connection point for a block
  53232. */
  53233. export class NodeMaterialConnectionPoint {
  53234. /** @hidden */
  53235. _ownerBlock: NodeMaterialBlock;
  53236. /** @hidden */
  53237. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53238. private _endpoints;
  53239. private _associatedVariableName;
  53240. /** @hidden */
  53241. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53242. /** @hidden */
  53243. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53244. private _type;
  53245. /** @hidden */
  53246. _enforceAssociatedVariableName: boolean;
  53247. /**
  53248. * Gets or sets the additional types supported by this connection point
  53249. */
  53250. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53251. /**
  53252. * Gets or sets the additional types excluded by this connection point
  53253. */
  53254. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53255. /**
  53256. * Gets or sets the associated variable name in the shader
  53257. */
  53258. associatedVariableName: string;
  53259. /**
  53260. * Gets or sets the connection point type (default is float)
  53261. */
  53262. type: NodeMaterialBlockConnectionPointTypes;
  53263. /**
  53264. * Gets or sets the connection point name
  53265. */
  53266. name: string;
  53267. /**
  53268. * Gets or sets a boolean indicating that this connection point can be omitted
  53269. */
  53270. isOptional: boolean;
  53271. /**
  53272. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53273. */
  53274. define: string;
  53275. /** Gets or sets the target of that connection point */
  53276. target: NodeMaterialBlockTargets;
  53277. /**
  53278. * Gets a boolean indicating that the current point is connected
  53279. */
  53280. readonly isConnected: boolean;
  53281. /**
  53282. * Gets a boolean indicating that the current point is connected to an input block
  53283. */
  53284. readonly isConnectedToInputBlock: boolean;
  53285. /**
  53286. * Gets a the connected input block (if any)
  53287. */
  53288. readonly connectInputBlock: Nullable<InputBlock>;
  53289. /** Get the other side of the connection (if any) */
  53290. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53291. /** Get the block that owns this connection point */
  53292. readonly ownerBlock: NodeMaterialBlock;
  53293. /** Get the block connected on the other side of this connection (if any) */
  53294. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53295. /** Get the block connected on the endpoints of this connection (if any) */
  53296. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53297. /** Gets the list of connected endpoints */
  53298. readonly endpoints: NodeMaterialConnectionPoint[];
  53299. /** Gets a boolean indicating if that output point is connected to at least one input */
  53300. readonly hasEndpoints: boolean;
  53301. /**
  53302. * Creates a new connection point
  53303. * @param name defines the connection point name
  53304. * @param ownerBlock defines the block hosting this connection point
  53305. */
  53306. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53307. /**
  53308. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53309. * @returns the class name
  53310. */
  53311. getClassName(): string;
  53312. /**
  53313. * Gets an boolean indicating if the current point can be connected to another point
  53314. * @param connectionPoint defines the other connection point
  53315. * @returns true if the connection is possible
  53316. */
  53317. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53318. /**
  53319. * Connect this point to another connection point
  53320. * @param connectionPoint defines the other connection point
  53321. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53322. * @returns the current connection point
  53323. */
  53324. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53325. /**
  53326. * Disconnect this point from one of his endpoint
  53327. * @param endpoint defines the other connection point
  53328. * @returns the current connection point
  53329. */
  53330. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53331. /**
  53332. * Serializes this point in a JSON representation
  53333. * @returns the serialized point object
  53334. */
  53335. serialize(): any;
  53336. }
  53337. }
  53338. declare module BABYLON {
  53339. /**
  53340. * Block used to add support for vertex skinning (bones)
  53341. */
  53342. export class BonesBlock extends NodeMaterialBlock {
  53343. /**
  53344. * Creates a new BonesBlock
  53345. * @param name defines the block name
  53346. */
  53347. constructor(name: string);
  53348. /**
  53349. * Initialize the block and prepare the context for build
  53350. * @param state defines the state that will be used for the build
  53351. */
  53352. initialize(state: NodeMaterialBuildState): void;
  53353. /**
  53354. * Gets the current class name
  53355. * @returns the class name
  53356. */
  53357. getClassName(): string;
  53358. /**
  53359. * Gets the matrix indices input component
  53360. */
  53361. readonly matricesIndices: NodeMaterialConnectionPoint;
  53362. /**
  53363. * Gets the matrix weights input component
  53364. */
  53365. readonly matricesWeights: NodeMaterialConnectionPoint;
  53366. /**
  53367. * Gets the extra matrix indices input component
  53368. */
  53369. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53370. /**
  53371. * Gets the extra matrix weights input component
  53372. */
  53373. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53374. /**
  53375. * Gets the world input component
  53376. */
  53377. readonly world: NodeMaterialConnectionPoint;
  53378. /**
  53379. * Gets the output component
  53380. */
  53381. readonly output: NodeMaterialConnectionPoint;
  53382. autoConfigure(material: NodeMaterial): void;
  53383. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53384. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53385. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53386. protected _buildBlock(state: NodeMaterialBuildState): this;
  53387. }
  53388. }
  53389. declare module BABYLON {
  53390. /**
  53391. * Block used to add support for instances
  53392. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53393. */
  53394. export class InstancesBlock extends NodeMaterialBlock {
  53395. /**
  53396. * Creates a new InstancesBlock
  53397. * @param name defines the block name
  53398. */
  53399. constructor(name: string);
  53400. /**
  53401. * Gets the current class name
  53402. * @returns the class name
  53403. */
  53404. getClassName(): string;
  53405. /**
  53406. * Gets the first world row input component
  53407. */
  53408. readonly world0: NodeMaterialConnectionPoint;
  53409. /**
  53410. * Gets the second world row input component
  53411. */
  53412. readonly world1: NodeMaterialConnectionPoint;
  53413. /**
  53414. * Gets the third world row input component
  53415. */
  53416. readonly world2: NodeMaterialConnectionPoint;
  53417. /**
  53418. * Gets the forth world row input component
  53419. */
  53420. readonly world3: NodeMaterialConnectionPoint;
  53421. /**
  53422. * Gets the world input component
  53423. */
  53424. readonly world: NodeMaterialConnectionPoint;
  53425. /**
  53426. * Gets the output component
  53427. */
  53428. readonly output: NodeMaterialConnectionPoint;
  53429. autoConfigure(material: NodeMaterial): void;
  53430. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53431. protected _buildBlock(state: NodeMaterialBuildState): this;
  53432. }
  53433. }
  53434. declare module BABYLON {
  53435. /**
  53436. * Block used to add morph targets support to vertex shader
  53437. */
  53438. export class MorphTargetsBlock extends NodeMaterialBlock {
  53439. private _repeatableContentAnchor;
  53440. private _repeatebleContentGenerated;
  53441. /**
  53442. * Create a new MorphTargetsBlock
  53443. * @param name defines the block name
  53444. */
  53445. constructor(name: string);
  53446. /**
  53447. * Gets the current class name
  53448. * @returns the class name
  53449. */
  53450. getClassName(): string;
  53451. /**
  53452. * Gets the position input component
  53453. */
  53454. readonly position: NodeMaterialConnectionPoint;
  53455. /**
  53456. * Gets the normal input component
  53457. */
  53458. readonly normal: NodeMaterialConnectionPoint;
  53459. /**
  53460. * Gets the tangent input component
  53461. */
  53462. readonly tangent: NodeMaterialConnectionPoint;
  53463. /**
  53464. * Gets the tangent input component
  53465. */
  53466. readonly uv: NodeMaterialConnectionPoint;
  53467. /**
  53468. * Gets the position output component
  53469. */
  53470. readonly positionOutput: NodeMaterialConnectionPoint;
  53471. /**
  53472. * Gets the normal output component
  53473. */
  53474. readonly normalOutput: NodeMaterialConnectionPoint;
  53475. /**
  53476. * Gets the tangent output component
  53477. */
  53478. readonly tangentOutput: NodeMaterialConnectionPoint;
  53479. /**
  53480. * Gets the tangent output component
  53481. */
  53482. readonly uvOutput: NodeMaterialConnectionPoint;
  53483. initialize(state: NodeMaterialBuildState): void;
  53484. autoConfigure(material: NodeMaterial): void;
  53485. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53486. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53487. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53488. protected _buildBlock(state: NodeMaterialBuildState): this;
  53489. }
  53490. }
  53491. declare module BABYLON {
  53492. /**
  53493. * Block used to get data information from a light
  53494. */
  53495. export class LightInformationBlock extends NodeMaterialBlock {
  53496. private _lightDataUniformName;
  53497. private _lightColorUniformName;
  53498. private _lightTypeDefineName;
  53499. /**
  53500. * Gets or sets the light associated with this block
  53501. */
  53502. light: Nullable<Light>;
  53503. /**
  53504. * Creates a new LightInformationBlock
  53505. * @param name defines the block name
  53506. */
  53507. constructor(name: string);
  53508. /**
  53509. * Gets the current class name
  53510. * @returns the class name
  53511. */
  53512. getClassName(): string;
  53513. /**
  53514. * Gets the world position input component
  53515. */
  53516. readonly worldPosition: NodeMaterialConnectionPoint;
  53517. /**
  53518. * Gets the direction output component
  53519. */
  53520. readonly direction: NodeMaterialConnectionPoint;
  53521. /**
  53522. * Gets the direction output component
  53523. */
  53524. readonly color: NodeMaterialConnectionPoint;
  53525. /**
  53526. * Gets the direction output component
  53527. */
  53528. readonly intensity: NodeMaterialConnectionPoint;
  53529. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53530. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53531. protected _buildBlock(state: NodeMaterialBuildState): this;
  53532. serialize(): any;
  53533. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53534. }
  53535. }
  53536. declare module BABYLON {
  53537. /**
  53538. * Block used to add image processing support to fragment shader
  53539. */
  53540. export class ImageProcessingBlock extends NodeMaterialBlock {
  53541. /**
  53542. * Create a new ImageProcessingBlock
  53543. * @param name defines the block name
  53544. */
  53545. constructor(name: string);
  53546. /**
  53547. * Gets the current class name
  53548. * @returns the class name
  53549. */
  53550. getClassName(): string;
  53551. /**
  53552. * Gets the color input component
  53553. */
  53554. readonly color: NodeMaterialConnectionPoint;
  53555. /**
  53556. * Gets the output component
  53557. */
  53558. readonly output: NodeMaterialConnectionPoint;
  53559. /**
  53560. * Initialize the block and prepare the context for build
  53561. * @param state defines the state that will be used for the build
  53562. */
  53563. initialize(state: NodeMaterialBuildState): void;
  53564. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53565. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53566. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53567. protected _buildBlock(state: NodeMaterialBuildState): this;
  53568. }
  53569. }
  53570. declare module BABYLON {
  53571. /**
  53572. * Block used to pertub normals based on a normal map
  53573. */
  53574. export class PerturbNormalBlock extends NodeMaterialBlock {
  53575. private _tangentSpaceParameterName;
  53576. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  53577. invertX: boolean;
  53578. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  53579. invertY: boolean;
  53580. /**
  53581. * Create a new PerturbNormalBlock
  53582. * @param name defines the block name
  53583. */
  53584. constructor(name: string);
  53585. /**
  53586. * Gets the current class name
  53587. * @returns the class name
  53588. */
  53589. getClassName(): string;
  53590. /**
  53591. * Gets the world position input component
  53592. */
  53593. readonly worldPosition: NodeMaterialConnectionPoint;
  53594. /**
  53595. * Gets the world normal input component
  53596. */
  53597. readonly worldNormal: NodeMaterialConnectionPoint;
  53598. /**
  53599. * Gets the uv input component
  53600. */
  53601. readonly uv: NodeMaterialConnectionPoint;
  53602. /**
  53603. * Gets the normal map color input component
  53604. */
  53605. readonly normalMapColor: NodeMaterialConnectionPoint;
  53606. /**
  53607. * Gets the strength input component
  53608. */
  53609. readonly strength: NodeMaterialConnectionPoint;
  53610. /**
  53611. * Gets the output component
  53612. */
  53613. readonly output: NodeMaterialConnectionPoint;
  53614. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53615. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53616. autoConfigure(material: NodeMaterial): void;
  53617. protected _buildBlock(state: NodeMaterialBuildState): this;
  53618. protected _dumpPropertiesCode(): string;
  53619. serialize(): any;
  53620. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53621. }
  53622. }
  53623. declare module BABYLON {
  53624. /**
  53625. * Block used to discard a pixel if a value is smaller than a cutoff
  53626. */
  53627. export class DiscardBlock extends NodeMaterialBlock {
  53628. /**
  53629. * Create a new DiscardBlock
  53630. * @param name defines the block name
  53631. */
  53632. constructor(name: string);
  53633. /**
  53634. * Gets the current class name
  53635. * @returns the class name
  53636. */
  53637. getClassName(): string;
  53638. /**
  53639. * Gets the color input component
  53640. */
  53641. readonly value: NodeMaterialConnectionPoint;
  53642. /**
  53643. * Gets the cutoff input component
  53644. */
  53645. readonly cutoff: NodeMaterialConnectionPoint;
  53646. protected _buildBlock(state: NodeMaterialBuildState): this;
  53647. }
  53648. }
  53649. declare module BABYLON {
  53650. /**
  53651. * Block used to add support for scene fog
  53652. */
  53653. export class FogBlock extends NodeMaterialBlock {
  53654. private _fogDistanceName;
  53655. private _fogParameters;
  53656. /**
  53657. * Create a new FogBlock
  53658. * @param name defines the block name
  53659. */
  53660. constructor(name: string);
  53661. /**
  53662. * Gets the current class name
  53663. * @returns the class name
  53664. */
  53665. getClassName(): string;
  53666. /**
  53667. * Gets the world position input component
  53668. */
  53669. readonly worldPosition: NodeMaterialConnectionPoint;
  53670. /**
  53671. * Gets the view input component
  53672. */
  53673. readonly view: NodeMaterialConnectionPoint;
  53674. /**
  53675. * Gets the color input component
  53676. */
  53677. readonly input: NodeMaterialConnectionPoint;
  53678. /**
  53679. * Gets the fog color input component
  53680. */
  53681. readonly fogColor: NodeMaterialConnectionPoint;
  53682. /**
  53683. * Gets the output component
  53684. */
  53685. readonly output: NodeMaterialConnectionPoint;
  53686. autoConfigure(material: NodeMaterial): void;
  53687. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53688. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53689. protected _buildBlock(state: NodeMaterialBuildState): this;
  53690. }
  53691. }
  53692. declare module BABYLON {
  53693. /**
  53694. * Block used to add light in the fragment shader
  53695. */
  53696. export class LightBlock extends NodeMaterialBlock {
  53697. private _lightId;
  53698. /**
  53699. * Gets or sets the light associated with this block
  53700. */
  53701. light: Nullable<Light>;
  53702. /**
  53703. * Create a new LightBlock
  53704. * @param name defines the block name
  53705. */
  53706. constructor(name: string);
  53707. /**
  53708. * Gets the current class name
  53709. * @returns the class name
  53710. */
  53711. getClassName(): string;
  53712. /**
  53713. * Gets the world position input component
  53714. */
  53715. readonly worldPosition: NodeMaterialConnectionPoint;
  53716. /**
  53717. * Gets the world normal input component
  53718. */
  53719. readonly worldNormal: NodeMaterialConnectionPoint;
  53720. /**
  53721. * Gets the camera (or eye) position component
  53722. */
  53723. readonly cameraPosition: NodeMaterialConnectionPoint;
  53724. /**
  53725. * Gets the glossiness component
  53726. */
  53727. readonly glossiness: NodeMaterialConnectionPoint;
  53728. /**
  53729. * Gets the diffuse output component
  53730. */
  53731. readonly diffuseOutput: NodeMaterialConnectionPoint;
  53732. /**
  53733. * Gets the specular output component
  53734. */
  53735. readonly specularOutput: NodeMaterialConnectionPoint;
  53736. autoConfigure(material: NodeMaterial): void;
  53737. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53738. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53739. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53740. private _injectVertexCode;
  53741. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53742. serialize(): any;
  53743. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53744. }
  53745. }
  53746. declare module BABYLON {
  53747. /**
  53748. * Block used to multiply 2 values
  53749. */
  53750. export class MultiplyBlock extends NodeMaterialBlock {
  53751. /**
  53752. * Creates a new MultiplyBlock
  53753. * @param name defines the block name
  53754. */
  53755. constructor(name: string);
  53756. /**
  53757. * Gets the current class name
  53758. * @returns the class name
  53759. */
  53760. getClassName(): string;
  53761. /**
  53762. * Gets the left operand input component
  53763. */
  53764. readonly left: NodeMaterialConnectionPoint;
  53765. /**
  53766. * Gets the right operand input component
  53767. */
  53768. readonly right: NodeMaterialConnectionPoint;
  53769. /**
  53770. * Gets the output component
  53771. */
  53772. readonly output: NodeMaterialConnectionPoint;
  53773. protected _buildBlock(state: NodeMaterialBuildState): this;
  53774. }
  53775. }
  53776. declare module BABYLON {
  53777. /**
  53778. * Block used to add 2 vectors
  53779. */
  53780. export class AddBlock extends NodeMaterialBlock {
  53781. /**
  53782. * Creates a new AddBlock
  53783. * @param name defines the block name
  53784. */
  53785. constructor(name: string);
  53786. /**
  53787. * Gets the current class name
  53788. * @returns the class name
  53789. */
  53790. getClassName(): string;
  53791. /**
  53792. * Gets the left operand input component
  53793. */
  53794. readonly left: NodeMaterialConnectionPoint;
  53795. /**
  53796. * Gets the right operand input component
  53797. */
  53798. readonly right: NodeMaterialConnectionPoint;
  53799. /**
  53800. * Gets the output component
  53801. */
  53802. readonly output: NodeMaterialConnectionPoint;
  53803. protected _buildBlock(state: NodeMaterialBuildState): this;
  53804. }
  53805. }
  53806. declare module BABYLON {
  53807. /**
  53808. * Block used to scale a vector by a float
  53809. */
  53810. export class ScaleBlock extends NodeMaterialBlock {
  53811. /**
  53812. * Creates a new ScaleBlock
  53813. * @param name defines the block name
  53814. */
  53815. constructor(name: string);
  53816. /**
  53817. * Gets the current class name
  53818. * @returns the class name
  53819. */
  53820. getClassName(): string;
  53821. /**
  53822. * Gets the input component
  53823. */
  53824. readonly input: NodeMaterialConnectionPoint;
  53825. /**
  53826. * Gets the factor input component
  53827. */
  53828. readonly factor: NodeMaterialConnectionPoint;
  53829. /**
  53830. * Gets the output component
  53831. */
  53832. readonly output: NodeMaterialConnectionPoint;
  53833. protected _buildBlock(state: NodeMaterialBuildState): this;
  53834. }
  53835. }
  53836. declare module BABYLON {
  53837. /**
  53838. * Block used to clamp a float
  53839. */
  53840. export class ClampBlock extends NodeMaterialBlock {
  53841. /** Gets or sets the minimum range */
  53842. minimum: number;
  53843. /** Gets or sets the maximum range */
  53844. maximum: number;
  53845. /**
  53846. * Creates a new ClampBlock
  53847. * @param name defines the block name
  53848. */
  53849. constructor(name: string);
  53850. /**
  53851. * Gets the current class name
  53852. * @returns the class name
  53853. */
  53854. getClassName(): string;
  53855. /**
  53856. * Gets the value input component
  53857. */
  53858. readonly value: NodeMaterialConnectionPoint;
  53859. /**
  53860. * Gets the output component
  53861. */
  53862. readonly output: NodeMaterialConnectionPoint;
  53863. protected _buildBlock(state: NodeMaterialBuildState): this;
  53864. protected _dumpPropertiesCode(): string;
  53865. serialize(): any;
  53866. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53867. }
  53868. }
  53869. declare module BABYLON {
  53870. /**
  53871. * Block used to apply a cross product between 2 vectors
  53872. */
  53873. export class CrossBlock extends NodeMaterialBlock {
  53874. /**
  53875. * Creates a new CrossBlock
  53876. * @param name defines the block name
  53877. */
  53878. constructor(name: string);
  53879. /**
  53880. * Gets the current class name
  53881. * @returns the class name
  53882. */
  53883. getClassName(): string;
  53884. /**
  53885. * Gets the left operand input component
  53886. */
  53887. readonly left: NodeMaterialConnectionPoint;
  53888. /**
  53889. * Gets the right operand input component
  53890. */
  53891. readonly right: NodeMaterialConnectionPoint;
  53892. /**
  53893. * Gets the output component
  53894. */
  53895. readonly output: NodeMaterialConnectionPoint;
  53896. protected _buildBlock(state: NodeMaterialBuildState): this;
  53897. }
  53898. }
  53899. declare module BABYLON {
  53900. /**
  53901. * Block used to apply a dot product between 2 vectors
  53902. */
  53903. export class DotBlock extends NodeMaterialBlock {
  53904. /**
  53905. * Creates a new DotBlock
  53906. * @param name defines the block name
  53907. */
  53908. constructor(name: string);
  53909. /**
  53910. * Gets the current class name
  53911. * @returns the class name
  53912. */
  53913. getClassName(): string;
  53914. /**
  53915. * Gets the left operand input component
  53916. */
  53917. readonly left: NodeMaterialConnectionPoint;
  53918. /**
  53919. * Gets the right operand input component
  53920. */
  53921. readonly right: NodeMaterialConnectionPoint;
  53922. /**
  53923. * Gets the output component
  53924. */
  53925. readonly output: NodeMaterialConnectionPoint;
  53926. protected _buildBlock(state: NodeMaterialBuildState): this;
  53927. }
  53928. }
  53929. declare module BABYLON {
  53930. /**
  53931. * Block used to remap a float from a range to a new one
  53932. */
  53933. export class RemapBlock extends NodeMaterialBlock {
  53934. /**
  53935. * Gets or sets the source range
  53936. */
  53937. sourceRange: Vector2;
  53938. /**
  53939. * Gets or sets the target range
  53940. */
  53941. targetRange: Vector2;
  53942. /**
  53943. * Creates a new RemapBlock
  53944. * @param name defines the block name
  53945. */
  53946. constructor(name: string);
  53947. /**
  53948. * Gets the current class name
  53949. * @returns the class name
  53950. */
  53951. getClassName(): string;
  53952. /**
  53953. * Gets the input component
  53954. */
  53955. readonly input: NodeMaterialConnectionPoint;
  53956. /**
  53957. * Gets the source min input component
  53958. */
  53959. readonly sourceMin: NodeMaterialConnectionPoint;
  53960. /**
  53961. * Gets the source max input component
  53962. */
  53963. readonly sourceMax: NodeMaterialConnectionPoint;
  53964. /**
  53965. * Gets the target min input component
  53966. */
  53967. readonly targetMin: NodeMaterialConnectionPoint;
  53968. /**
  53969. * Gets the target max input component
  53970. */
  53971. readonly targetMax: NodeMaterialConnectionPoint;
  53972. /**
  53973. * Gets the output component
  53974. */
  53975. readonly output: NodeMaterialConnectionPoint;
  53976. protected _buildBlock(state: NodeMaterialBuildState): this;
  53977. protected _dumpPropertiesCode(): string;
  53978. serialize(): any;
  53979. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53980. }
  53981. }
  53982. declare module BABYLON {
  53983. /**
  53984. * Block used to normalize a vector
  53985. */
  53986. export class NormalizeBlock extends NodeMaterialBlock {
  53987. /**
  53988. * Creates a new NormalizeBlock
  53989. * @param name defines the block name
  53990. */
  53991. constructor(name: string);
  53992. /**
  53993. * Gets the current class name
  53994. * @returns the class name
  53995. */
  53996. getClassName(): string;
  53997. /**
  53998. * Gets the input component
  53999. */
  54000. readonly input: NodeMaterialConnectionPoint;
  54001. /**
  54002. * Gets the output component
  54003. */
  54004. readonly output: NodeMaterialConnectionPoint;
  54005. protected _buildBlock(state: NodeMaterialBuildState): this;
  54006. }
  54007. }
  54008. declare module BABYLON {
  54009. /**
  54010. * Operations supported by the Trigonometry block
  54011. */
  54012. export enum TrigonometryBlockOperations {
  54013. /** Cos */
  54014. Cos = 0,
  54015. /** Sin */
  54016. Sin = 1,
  54017. /** Abs */
  54018. Abs = 2,
  54019. /** Exp */
  54020. Exp = 3,
  54021. /** Exp2 */
  54022. Exp2 = 4,
  54023. /** Round */
  54024. Round = 5,
  54025. /** Floor */
  54026. Floor = 6,
  54027. /** Ceiling */
  54028. Ceiling = 7,
  54029. /** Square root */
  54030. Sqrt = 8
  54031. }
  54032. /**
  54033. * Block used to apply trigonometry operation to floats
  54034. */
  54035. export class TrigonometryBlock extends NodeMaterialBlock {
  54036. /**
  54037. * Gets or sets the operation applied by the block
  54038. */
  54039. operation: TrigonometryBlockOperations;
  54040. /**
  54041. * Creates a new TrigonometryBlock
  54042. * @param name defines the block name
  54043. */
  54044. constructor(name: string);
  54045. /**
  54046. * Gets the current class name
  54047. * @returns the class name
  54048. */
  54049. getClassName(): string;
  54050. /**
  54051. * Gets the input component
  54052. */
  54053. readonly input: NodeMaterialConnectionPoint;
  54054. /**
  54055. * Gets the output component
  54056. */
  54057. readonly output: NodeMaterialConnectionPoint;
  54058. protected _buildBlock(state: NodeMaterialBuildState): this;
  54059. serialize(): any;
  54060. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54061. }
  54062. }
  54063. declare module BABYLON {
  54064. /**
  54065. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54066. */
  54067. export class ColorMergerBlock extends NodeMaterialBlock {
  54068. /**
  54069. * Create a new ColorMergerBlock
  54070. * @param name defines the block name
  54071. */
  54072. constructor(name: string);
  54073. /**
  54074. * Gets the current class name
  54075. * @returns the class name
  54076. */
  54077. getClassName(): string;
  54078. /**
  54079. * Gets the r component (input)
  54080. */
  54081. readonly r: NodeMaterialConnectionPoint;
  54082. /**
  54083. * Gets the g component (input)
  54084. */
  54085. readonly g: NodeMaterialConnectionPoint;
  54086. /**
  54087. * Gets the b component (input)
  54088. */
  54089. readonly b: NodeMaterialConnectionPoint;
  54090. /**
  54091. * Gets the a component (input)
  54092. */
  54093. readonly a: NodeMaterialConnectionPoint;
  54094. /**
  54095. * Gets the rgba component (output)
  54096. */
  54097. readonly rgba: NodeMaterialConnectionPoint;
  54098. /**
  54099. * Gets the rgb component (output)
  54100. */
  54101. readonly rgb: NodeMaterialConnectionPoint;
  54102. protected _buildBlock(state: NodeMaterialBuildState): this;
  54103. }
  54104. }
  54105. declare module BABYLON {
  54106. /**
  54107. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54108. */
  54109. export class VectorMergerBlock extends NodeMaterialBlock {
  54110. /**
  54111. * Create a new VectorMergerBlock
  54112. * @param name defines the block name
  54113. */
  54114. constructor(name: string);
  54115. /**
  54116. * Gets the current class name
  54117. * @returns the class name
  54118. */
  54119. getClassName(): string;
  54120. /**
  54121. * Gets the x component (input)
  54122. */
  54123. readonly x: NodeMaterialConnectionPoint;
  54124. /**
  54125. * Gets the y component (input)
  54126. */
  54127. readonly y: NodeMaterialConnectionPoint;
  54128. /**
  54129. * Gets the z component (input)
  54130. */
  54131. readonly z: NodeMaterialConnectionPoint;
  54132. /**
  54133. * Gets the w component (input)
  54134. */
  54135. readonly w: NodeMaterialConnectionPoint;
  54136. /**
  54137. * Gets the xyzw component (output)
  54138. */
  54139. readonly xyzw: NodeMaterialConnectionPoint;
  54140. /**
  54141. * Gets the xyz component (output)
  54142. */
  54143. readonly xyz: NodeMaterialConnectionPoint;
  54144. /**
  54145. * Gets the xy component (output)
  54146. */
  54147. readonly xy: NodeMaterialConnectionPoint;
  54148. protected _buildBlock(state: NodeMaterialBuildState): this;
  54149. }
  54150. }
  54151. declare module BABYLON {
  54152. /**
  54153. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54154. */
  54155. export class ColorSplitterBlock extends NodeMaterialBlock {
  54156. /**
  54157. * Create a new ColorSplitterBlock
  54158. * @param name defines the block name
  54159. */
  54160. constructor(name: string);
  54161. /**
  54162. * Gets the current class name
  54163. * @returns the class name
  54164. */
  54165. getClassName(): string;
  54166. /**
  54167. * Gets the rgba component (input)
  54168. */
  54169. readonly rgba: NodeMaterialConnectionPoint;
  54170. /**
  54171. * Gets the rgb component (input)
  54172. */
  54173. readonly rgbIn: NodeMaterialConnectionPoint;
  54174. /**
  54175. * Gets the rgb component (output)
  54176. */
  54177. readonly rgbOut: NodeMaterialConnectionPoint;
  54178. /**
  54179. * Gets the r component (output)
  54180. */
  54181. readonly r: NodeMaterialConnectionPoint;
  54182. /**
  54183. * Gets the g component (output)
  54184. */
  54185. readonly g: NodeMaterialConnectionPoint;
  54186. /**
  54187. * Gets the b component (output)
  54188. */
  54189. readonly b: NodeMaterialConnectionPoint;
  54190. /**
  54191. * Gets the a component (output)
  54192. */
  54193. readonly a: NodeMaterialConnectionPoint;
  54194. protected _inputRename(name: string): string;
  54195. protected _outputRename(name: string): string;
  54196. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54197. }
  54198. }
  54199. declare module BABYLON {
  54200. /**
  54201. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54202. */
  54203. export class VectorSplitterBlock extends NodeMaterialBlock {
  54204. /**
  54205. * Create a new VectorSplitterBlock
  54206. * @param name defines the block name
  54207. */
  54208. constructor(name: string);
  54209. /**
  54210. * Gets the current class name
  54211. * @returns the class name
  54212. */
  54213. getClassName(): string;
  54214. /**
  54215. * Gets the xyzw component (input)
  54216. */
  54217. readonly xyzw: NodeMaterialConnectionPoint;
  54218. /**
  54219. * Gets the xyz component (input)
  54220. */
  54221. readonly xyzIn: NodeMaterialConnectionPoint;
  54222. /**
  54223. * Gets the xy component (input)
  54224. */
  54225. readonly xyIn: NodeMaterialConnectionPoint;
  54226. /**
  54227. * Gets the xyz component (output)
  54228. */
  54229. readonly xyzOut: NodeMaterialConnectionPoint;
  54230. /**
  54231. * Gets the xy component (output)
  54232. */
  54233. readonly xyOut: NodeMaterialConnectionPoint;
  54234. /**
  54235. * Gets the x component (output)
  54236. */
  54237. readonly x: NodeMaterialConnectionPoint;
  54238. /**
  54239. * Gets the y component (output)
  54240. */
  54241. readonly y: NodeMaterialConnectionPoint;
  54242. /**
  54243. * Gets the z component (output)
  54244. */
  54245. readonly z: NodeMaterialConnectionPoint;
  54246. /**
  54247. * Gets the w component (output)
  54248. */
  54249. readonly w: NodeMaterialConnectionPoint;
  54250. protected _inputRename(name: string): string;
  54251. protected _outputRename(name: string): string;
  54252. protected _buildBlock(state: NodeMaterialBuildState): this;
  54253. }
  54254. }
  54255. declare module BABYLON {
  54256. /**
  54257. * Block used to lerp 2 values
  54258. */
  54259. export class LerpBlock extends NodeMaterialBlock {
  54260. /**
  54261. * Creates a new LerpBlock
  54262. * @param name defines the block name
  54263. */
  54264. constructor(name: string);
  54265. /**
  54266. * Gets the current class name
  54267. * @returns the class name
  54268. */
  54269. getClassName(): string;
  54270. /**
  54271. * Gets the left operand input component
  54272. */
  54273. readonly left: NodeMaterialConnectionPoint;
  54274. /**
  54275. * Gets the right operand input component
  54276. */
  54277. readonly right: NodeMaterialConnectionPoint;
  54278. /**
  54279. * Gets the gradient operand input component
  54280. */
  54281. readonly gradient: NodeMaterialConnectionPoint;
  54282. /**
  54283. * Gets the output component
  54284. */
  54285. readonly output: NodeMaterialConnectionPoint;
  54286. protected _buildBlock(state: NodeMaterialBuildState): this;
  54287. }
  54288. }
  54289. declare module BABYLON {
  54290. /**
  54291. * Block used to divide 2 vectors
  54292. */
  54293. export class DivideBlock extends NodeMaterialBlock {
  54294. /**
  54295. * Creates a new DivideBlock
  54296. * @param name defines the block name
  54297. */
  54298. constructor(name: string);
  54299. /**
  54300. * Gets the current class name
  54301. * @returns the class name
  54302. */
  54303. getClassName(): string;
  54304. /**
  54305. * Gets the left operand input component
  54306. */
  54307. readonly left: NodeMaterialConnectionPoint;
  54308. /**
  54309. * Gets the right operand input component
  54310. */
  54311. readonly right: NodeMaterialConnectionPoint;
  54312. /**
  54313. * Gets the output component
  54314. */
  54315. readonly output: NodeMaterialConnectionPoint;
  54316. protected _buildBlock(state: NodeMaterialBuildState): this;
  54317. }
  54318. }
  54319. declare module BABYLON {
  54320. /**
  54321. * Block used to subtract 2 vectors
  54322. */
  54323. export class SubtractBlock extends NodeMaterialBlock {
  54324. /**
  54325. * Creates a new SubtractBlock
  54326. * @param name defines the block name
  54327. */
  54328. constructor(name: string);
  54329. /**
  54330. * Gets the current class name
  54331. * @returns the class name
  54332. */
  54333. getClassName(): string;
  54334. /**
  54335. * Gets the left operand input component
  54336. */
  54337. readonly left: NodeMaterialConnectionPoint;
  54338. /**
  54339. * Gets the right operand input component
  54340. */
  54341. readonly right: NodeMaterialConnectionPoint;
  54342. /**
  54343. * Gets the output component
  54344. */
  54345. readonly output: NodeMaterialConnectionPoint;
  54346. protected _buildBlock(state: NodeMaterialBuildState): this;
  54347. }
  54348. }
  54349. declare module BABYLON {
  54350. /**
  54351. * Block used to step a value
  54352. */
  54353. export class StepBlock extends NodeMaterialBlock {
  54354. /**
  54355. * Creates a new AddBlock
  54356. * @param name defines the block name
  54357. */
  54358. constructor(name: string);
  54359. /**
  54360. * Gets the current class name
  54361. * @returns the class name
  54362. */
  54363. getClassName(): string;
  54364. /**
  54365. * Gets the value operand input component
  54366. */
  54367. readonly value: NodeMaterialConnectionPoint;
  54368. /**
  54369. * Gets the edge operand input component
  54370. */
  54371. readonly edge: NodeMaterialConnectionPoint;
  54372. /**
  54373. * Gets the output component
  54374. */
  54375. readonly output: NodeMaterialConnectionPoint;
  54376. protected _buildBlock(state: NodeMaterialBuildState): this;
  54377. }
  54378. }
  54379. declare module BABYLON {
  54380. /**
  54381. * Block used to get the opposite (1 - x) of a value
  54382. */
  54383. export class OneMinusBlock extends NodeMaterialBlock {
  54384. /**
  54385. * Creates a new OneMinusBlock
  54386. * @param name defines the block name
  54387. */
  54388. constructor(name: string);
  54389. /**
  54390. * Gets the current class name
  54391. * @returns the class name
  54392. */
  54393. getClassName(): string;
  54394. /**
  54395. * Gets the input component
  54396. */
  54397. readonly input: NodeMaterialConnectionPoint;
  54398. /**
  54399. * Gets the output component
  54400. */
  54401. readonly output: NodeMaterialConnectionPoint;
  54402. protected _buildBlock(state: NodeMaterialBuildState): this;
  54403. }
  54404. }
  54405. declare module BABYLON {
  54406. /**
  54407. * Block used to get the view direction
  54408. */
  54409. export class ViewDirectionBlock extends NodeMaterialBlock {
  54410. /**
  54411. * Creates a new ViewDirectionBlock
  54412. * @param name defines the block name
  54413. */
  54414. constructor(name: string);
  54415. /**
  54416. * Gets the current class name
  54417. * @returns the class name
  54418. */
  54419. getClassName(): string;
  54420. /**
  54421. * Gets the world position component
  54422. */
  54423. readonly worldPosition: NodeMaterialConnectionPoint;
  54424. /**
  54425. * Gets the camera position component
  54426. */
  54427. readonly cameraPosition: NodeMaterialConnectionPoint;
  54428. /**
  54429. * Gets the output component
  54430. */
  54431. readonly output: NodeMaterialConnectionPoint;
  54432. autoConfigure(material: NodeMaterial): void;
  54433. protected _buildBlock(state: NodeMaterialBuildState): this;
  54434. }
  54435. }
  54436. declare module BABYLON {
  54437. /**
  54438. * Block used to compute fresnel value
  54439. */
  54440. export class FresnelBlock extends NodeMaterialBlock {
  54441. /**
  54442. * Create a new FresnelBlock
  54443. * @param name defines the block name
  54444. */
  54445. constructor(name: string);
  54446. /**
  54447. * Gets the current class name
  54448. * @returns the class name
  54449. */
  54450. getClassName(): string;
  54451. /**
  54452. * Gets the world normal input component
  54453. */
  54454. readonly worldNormal: NodeMaterialConnectionPoint;
  54455. /**
  54456. * Gets the view direction input component
  54457. */
  54458. readonly viewDirection: NodeMaterialConnectionPoint;
  54459. /**
  54460. * Gets the bias input component
  54461. */
  54462. readonly bias: NodeMaterialConnectionPoint;
  54463. /**
  54464. * Gets the camera (or eye) position component
  54465. */
  54466. readonly power: NodeMaterialConnectionPoint;
  54467. /**
  54468. * Gets the fresnel output component
  54469. */
  54470. readonly fresnel: NodeMaterialConnectionPoint;
  54471. autoConfigure(material: NodeMaterial): void;
  54472. protected _buildBlock(state: NodeMaterialBuildState): this;
  54473. }
  54474. }
  54475. declare module BABYLON {
  54476. /**
  54477. * Block used to get the max of 2 values
  54478. */
  54479. export class MaxBlock extends NodeMaterialBlock {
  54480. /**
  54481. * Creates a new MaxBlock
  54482. * @param name defines the block name
  54483. */
  54484. constructor(name: string);
  54485. /**
  54486. * Gets the current class name
  54487. * @returns the class name
  54488. */
  54489. getClassName(): string;
  54490. /**
  54491. * Gets the left operand input component
  54492. */
  54493. readonly left: NodeMaterialConnectionPoint;
  54494. /**
  54495. * Gets the right operand input component
  54496. */
  54497. readonly right: NodeMaterialConnectionPoint;
  54498. /**
  54499. * Gets the output component
  54500. */
  54501. readonly output: NodeMaterialConnectionPoint;
  54502. protected _buildBlock(state: NodeMaterialBuildState): this;
  54503. }
  54504. }
  54505. declare module BABYLON {
  54506. /**
  54507. * Block used to get the min of 2 values
  54508. */
  54509. export class MinBlock extends NodeMaterialBlock {
  54510. /**
  54511. * Creates a new MinBlock
  54512. * @param name defines the block name
  54513. */
  54514. constructor(name: string);
  54515. /**
  54516. * Gets the current class name
  54517. * @returns the class name
  54518. */
  54519. getClassName(): string;
  54520. /**
  54521. * Gets the left operand input component
  54522. */
  54523. readonly left: NodeMaterialConnectionPoint;
  54524. /**
  54525. * Gets the right operand input component
  54526. */
  54527. readonly right: NodeMaterialConnectionPoint;
  54528. /**
  54529. * Gets the output component
  54530. */
  54531. readonly output: NodeMaterialConnectionPoint;
  54532. protected _buildBlock(state: NodeMaterialBuildState): this;
  54533. }
  54534. }
  54535. declare module BABYLON {
  54536. /**
  54537. * Block used to get the distance between 2 values
  54538. */
  54539. export class DistanceBlock extends NodeMaterialBlock {
  54540. /**
  54541. * Creates a new DistanceBlock
  54542. * @param name defines the block name
  54543. */
  54544. constructor(name: string);
  54545. /**
  54546. * Gets the current class name
  54547. * @returns the class name
  54548. */
  54549. getClassName(): string;
  54550. /**
  54551. * Gets the left operand input component
  54552. */
  54553. readonly left: NodeMaterialConnectionPoint;
  54554. /**
  54555. * Gets the right operand input component
  54556. */
  54557. readonly right: NodeMaterialConnectionPoint;
  54558. /**
  54559. * Gets the output component
  54560. */
  54561. readonly output: NodeMaterialConnectionPoint;
  54562. protected _buildBlock(state: NodeMaterialBuildState): this;
  54563. }
  54564. }
  54565. declare module BABYLON {
  54566. /**
  54567. * Block used to get the length of a vector
  54568. */
  54569. export class LengthBlock extends NodeMaterialBlock {
  54570. /**
  54571. * Creates a new LengthBlock
  54572. * @param name defines the block name
  54573. */
  54574. constructor(name: string);
  54575. /**
  54576. * Gets the current class name
  54577. * @returns the class name
  54578. */
  54579. getClassName(): string;
  54580. /**
  54581. * Gets the value input component
  54582. */
  54583. readonly value: NodeMaterialConnectionPoint;
  54584. /**
  54585. * Gets the output component
  54586. */
  54587. readonly output: NodeMaterialConnectionPoint;
  54588. protected _buildBlock(state: NodeMaterialBuildState): this;
  54589. }
  54590. }
  54591. declare module BABYLON {
  54592. /**
  54593. * Block used to get negative version of a value (i.e. x * -1)
  54594. */
  54595. export class NegateBlock extends NodeMaterialBlock {
  54596. /**
  54597. * Creates a new NegateBlock
  54598. * @param name defines the block name
  54599. */
  54600. constructor(name: string);
  54601. /**
  54602. * Gets the current class name
  54603. * @returns the class name
  54604. */
  54605. getClassName(): string;
  54606. /**
  54607. * Gets the value input component
  54608. */
  54609. readonly value: NodeMaterialConnectionPoint;
  54610. /**
  54611. * Gets the output component
  54612. */
  54613. readonly output: NodeMaterialConnectionPoint;
  54614. protected _buildBlock(state: NodeMaterialBuildState): this;
  54615. }
  54616. }
  54617. declare module BABYLON {
  54618. /**
  54619. * Block used to get the value of the first parameter raised to the power of the second
  54620. */
  54621. export class PowBlock extends NodeMaterialBlock {
  54622. /**
  54623. * Creates a new PowBlock
  54624. * @param name defines the block name
  54625. */
  54626. constructor(name: string);
  54627. /**
  54628. * Gets the current class name
  54629. * @returns the class name
  54630. */
  54631. getClassName(): string;
  54632. /**
  54633. * Gets the value operand input component
  54634. */
  54635. readonly value: NodeMaterialConnectionPoint;
  54636. /**
  54637. * Gets the power operand input component
  54638. */
  54639. readonly power: NodeMaterialConnectionPoint;
  54640. /**
  54641. * Gets the output component
  54642. */
  54643. readonly output: NodeMaterialConnectionPoint;
  54644. protected _buildBlock(state: NodeMaterialBuildState): this;
  54645. }
  54646. }
  54647. declare module BABYLON {
  54648. /**
  54649. * Block used to get a random number
  54650. */
  54651. export class RandomNumberBlock extends NodeMaterialBlock {
  54652. /**
  54653. * Creates a new RandomNumberBlock
  54654. * @param name defines the block name
  54655. */
  54656. constructor(name: string);
  54657. /**
  54658. * Gets the current class name
  54659. * @returns the class name
  54660. */
  54661. getClassName(): string;
  54662. /**
  54663. * Gets the seed input component
  54664. */
  54665. readonly seed: NodeMaterialConnectionPoint;
  54666. /**
  54667. * Gets the output component
  54668. */
  54669. readonly output: NodeMaterialConnectionPoint;
  54670. protected _buildBlock(state: NodeMaterialBuildState): this;
  54671. }
  54672. }
  54673. declare module BABYLON {
  54674. /**
  54675. * Effect Render Options
  54676. */
  54677. export interface IEffectRendererOptions {
  54678. /**
  54679. * Defines the vertices positions.
  54680. */
  54681. positions?: number[];
  54682. /**
  54683. * Defines the indices.
  54684. */
  54685. indices?: number[];
  54686. }
  54687. /**
  54688. * Helper class to render one or more effects
  54689. */
  54690. export class EffectRenderer {
  54691. private engine;
  54692. private static _DefaultOptions;
  54693. private _vertexBuffers;
  54694. private _indexBuffer;
  54695. private _ringBufferIndex;
  54696. private _ringScreenBuffer;
  54697. private _fullscreenViewport;
  54698. private _getNextFrameBuffer;
  54699. /**
  54700. * Creates an effect renderer
  54701. * @param engine the engine to use for rendering
  54702. * @param options defines the options of the effect renderer
  54703. */
  54704. constructor(engine: Engine, options?: IEffectRendererOptions);
  54705. /**
  54706. * Sets the current viewport in normalized coordinates 0-1
  54707. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  54708. */
  54709. setViewport(viewport?: Viewport): void;
  54710. /**
  54711. * Binds the embedded attributes buffer to the effect.
  54712. * @param effect Defines the effect to bind the attributes for
  54713. */
  54714. bindBuffers(effect: Effect): void;
  54715. /**
  54716. * Sets the current effect wrapper to use during draw.
  54717. * The effect needs to be ready before calling this api.
  54718. * This also sets the default full screen position attribute.
  54719. * @param effectWrapper Defines the effect to draw with
  54720. */
  54721. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  54722. /**
  54723. * Draws a full screen quad.
  54724. */
  54725. draw(): void;
  54726. /**
  54727. * renders one or more effects to a specified texture
  54728. * @param effectWrappers list of effects to renderer
  54729. * @param outputTexture texture to draw to, if null it will render to the screen
  54730. */
  54731. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  54732. /**
  54733. * Disposes of the effect renderer
  54734. */
  54735. dispose(): void;
  54736. }
  54737. /**
  54738. * Options to create an EffectWrapper
  54739. */
  54740. interface EffectWrapperCreationOptions {
  54741. /**
  54742. * Engine to use to create the effect
  54743. */
  54744. engine: Engine;
  54745. /**
  54746. * Fragment shader for the effect
  54747. */
  54748. fragmentShader: string;
  54749. /**
  54750. * Vertex shader for the effect
  54751. */
  54752. vertexShader?: string;
  54753. /**
  54754. * Attributes to use in the shader
  54755. */
  54756. attributeNames?: Array<string>;
  54757. /**
  54758. * Uniforms to use in the shader
  54759. */
  54760. uniformNames?: Array<string>;
  54761. /**
  54762. * Texture sampler names to use in the shader
  54763. */
  54764. samplerNames?: Array<string>;
  54765. /**
  54766. * The friendly name of the effect displayed in Spector.
  54767. */
  54768. name?: string;
  54769. }
  54770. /**
  54771. * Wraps an effect to be used for rendering
  54772. */
  54773. export class EffectWrapper {
  54774. /**
  54775. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  54776. */
  54777. onApplyObservable: Observable<{}>;
  54778. /**
  54779. * The underlying effect
  54780. */
  54781. effect: Effect;
  54782. /**
  54783. * Creates an effect to be renderer
  54784. * @param creationOptions options to create the effect
  54785. */
  54786. constructor(creationOptions: EffectWrapperCreationOptions);
  54787. /**
  54788. * Disposes of the effect wrapper
  54789. */
  54790. dispose(): void;
  54791. }
  54792. }
  54793. declare module BABYLON {
  54794. /**
  54795. * Helper class to push actions to a pool of workers.
  54796. */
  54797. export class WorkerPool implements IDisposable {
  54798. private _workerInfos;
  54799. private _pendingActions;
  54800. /**
  54801. * Constructor
  54802. * @param workers Array of workers to use for actions
  54803. */
  54804. constructor(workers: Array<Worker>);
  54805. /**
  54806. * Terminates all workers and clears any pending actions.
  54807. */
  54808. dispose(): void;
  54809. /**
  54810. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54811. * pended until a worker has completed its action.
  54812. * @param action The action to perform. Call onComplete when the action is complete.
  54813. */
  54814. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54815. private _execute;
  54816. }
  54817. }
  54818. declare module BABYLON {
  54819. /**
  54820. * Configuration for Draco compression
  54821. */
  54822. export interface IDracoCompressionConfiguration {
  54823. /**
  54824. * Configuration for the decoder.
  54825. */
  54826. decoder: {
  54827. /**
  54828. * The url to the WebAssembly module.
  54829. */
  54830. wasmUrl?: string;
  54831. /**
  54832. * The url to the WebAssembly binary.
  54833. */
  54834. wasmBinaryUrl?: string;
  54835. /**
  54836. * The url to the fallback JavaScript module.
  54837. */
  54838. fallbackUrl?: string;
  54839. };
  54840. }
  54841. /**
  54842. * Draco compression (https://google.github.io/draco/)
  54843. *
  54844. * This class wraps the Draco module.
  54845. *
  54846. * **Encoder**
  54847. *
  54848. * The encoder is not currently implemented.
  54849. *
  54850. * **Decoder**
  54851. *
  54852. * 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.
  54853. *
  54854. * To update the configuration, use the following code:
  54855. * ```javascript
  54856. * DracoCompression.Configuration = {
  54857. * decoder: {
  54858. * wasmUrl: "<url to the WebAssembly library>",
  54859. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54860. * fallbackUrl: "<url to the fallback JavaScript library>",
  54861. * }
  54862. * };
  54863. * ```
  54864. *
  54865. * 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.
  54866. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54867. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54868. *
  54869. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54870. * ```javascript
  54871. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54872. * ```
  54873. *
  54874. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54875. */
  54876. export class DracoCompression implements IDisposable {
  54877. private _workerPoolPromise?;
  54878. private _decoderModulePromise?;
  54879. /**
  54880. * The configuration. Defaults to the following urls:
  54881. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54882. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54883. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54884. */
  54885. static Configuration: IDracoCompressionConfiguration;
  54886. /**
  54887. * Returns true if the decoder configuration is available.
  54888. */
  54889. static readonly DecoderAvailable: boolean;
  54890. /**
  54891. * Default number of workers to create when creating the draco compression object.
  54892. */
  54893. static DefaultNumWorkers: number;
  54894. private static GetDefaultNumWorkers;
  54895. private static _Default;
  54896. /**
  54897. * Default instance for the draco compression object.
  54898. */
  54899. static readonly Default: DracoCompression;
  54900. /**
  54901. * Constructor
  54902. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54903. */
  54904. constructor(numWorkers?: number);
  54905. /**
  54906. * Stop all async operations and release resources.
  54907. */
  54908. dispose(): void;
  54909. /**
  54910. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54911. * @returns a promise that resolves when ready
  54912. */
  54913. whenReadyAsync(): Promise<void>;
  54914. /**
  54915. * Decode Draco compressed mesh data to vertex data.
  54916. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54917. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54918. * @returns A promise that resolves with the decoded vertex data
  54919. */
  54920. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54921. [kind: string]: number;
  54922. }): Promise<VertexData>;
  54923. }
  54924. }
  54925. declare module BABYLON {
  54926. /**
  54927. * Class for building Constructive Solid Geometry
  54928. */
  54929. export class CSG {
  54930. private polygons;
  54931. /**
  54932. * The world matrix
  54933. */
  54934. matrix: Matrix;
  54935. /**
  54936. * Stores the position
  54937. */
  54938. position: Vector3;
  54939. /**
  54940. * Stores the rotation
  54941. */
  54942. rotation: Vector3;
  54943. /**
  54944. * Stores the rotation quaternion
  54945. */
  54946. rotationQuaternion: Nullable<Quaternion>;
  54947. /**
  54948. * Stores the scaling vector
  54949. */
  54950. scaling: Vector3;
  54951. /**
  54952. * Convert the Mesh to CSG
  54953. * @param mesh The Mesh to convert to CSG
  54954. * @returns A new CSG from the Mesh
  54955. */
  54956. static FromMesh(mesh: Mesh): CSG;
  54957. /**
  54958. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54959. * @param polygons Polygons used to construct a CSG solid
  54960. */
  54961. private static FromPolygons;
  54962. /**
  54963. * Clones, or makes a deep copy, of the CSG
  54964. * @returns A new CSG
  54965. */
  54966. clone(): CSG;
  54967. /**
  54968. * Unions this CSG with another CSG
  54969. * @param csg The CSG to union against this CSG
  54970. * @returns The unioned CSG
  54971. */
  54972. union(csg: CSG): CSG;
  54973. /**
  54974. * Unions this CSG with another CSG in place
  54975. * @param csg The CSG to union against this CSG
  54976. */
  54977. unionInPlace(csg: CSG): void;
  54978. /**
  54979. * Subtracts this CSG with another CSG
  54980. * @param csg The CSG to subtract against this CSG
  54981. * @returns A new CSG
  54982. */
  54983. subtract(csg: CSG): CSG;
  54984. /**
  54985. * Subtracts this CSG with another CSG in place
  54986. * @param csg The CSG to subtact against this CSG
  54987. */
  54988. subtractInPlace(csg: CSG): void;
  54989. /**
  54990. * Intersect this CSG with another CSG
  54991. * @param csg The CSG to intersect against this CSG
  54992. * @returns A new CSG
  54993. */
  54994. intersect(csg: CSG): CSG;
  54995. /**
  54996. * Intersects this CSG with another CSG in place
  54997. * @param csg The CSG to intersect against this CSG
  54998. */
  54999. intersectInPlace(csg: CSG): void;
  55000. /**
  55001. * Return a new CSG solid with solid and empty space switched. This solid is
  55002. * not modified.
  55003. * @returns A new CSG solid with solid and empty space switched
  55004. */
  55005. inverse(): CSG;
  55006. /**
  55007. * Inverses the CSG in place
  55008. */
  55009. inverseInPlace(): void;
  55010. /**
  55011. * This is used to keep meshes transformations so they can be restored
  55012. * when we build back a Babylon Mesh
  55013. * NB : All CSG operations are performed in world coordinates
  55014. * @param csg The CSG to copy the transform attributes from
  55015. * @returns This CSG
  55016. */
  55017. copyTransformAttributes(csg: CSG): CSG;
  55018. /**
  55019. * Build Raw mesh from CSG
  55020. * Coordinates here are in world space
  55021. * @param name The name of the mesh geometry
  55022. * @param scene The Scene
  55023. * @param keepSubMeshes Specifies if the submeshes should be kept
  55024. * @returns A new Mesh
  55025. */
  55026. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55027. /**
  55028. * Build Mesh from CSG taking material and transforms into account
  55029. * @param name The name of the Mesh
  55030. * @param material The material of the Mesh
  55031. * @param scene The Scene
  55032. * @param keepSubMeshes Specifies if submeshes should be kept
  55033. * @returns The new Mesh
  55034. */
  55035. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55036. }
  55037. }
  55038. declare module BABYLON {
  55039. /**
  55040. * Class used to create a trail following a mesh
  55041. */
  55042. export class TrailMesh extends Mesh {
  55043. private _generator;
  55044. private _autoStart;
  55045. private _running;
  55046. private _diameter;
  55047. private _length;
  55048. private _sectionPolygonPointsCount;
  55049. private _sectionVectors;
  55050. private _sectionNormalVectors;
  55051. private _beforeRenderObserver;
  55052. /**
  55053. * @constructor
  55054. * @param name The value used by scene.getMeshByName() to do a lookup.
  55055. * @param generator The mesh to generate a trail.
  55056. * @param scene The scene to add this mesh to.
  55057. * @param diameter Diameter of trailing mesh. Default is 1.
  55058. * @param length Length of trailing mesh. Default is 60.
  55059. * @param autoStart Automatically start trailing mesh. Default true.
  55060. */
  55061. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55062. /**
  55063. * "TrailMesh"
  55064. * @returns "TrailMesh"
  55065. */
  55066. getClassName(): string;
  55067. private _createMesh;
  55068. /**
  55069. * Start trailing mesh.
  55070. */
  55071. start(): void;
  55072. /**
  55073. * Stop trailing mesh.
  55074. */
  55075. stop(): void;
  55076. /**
  55077. * Update trailing mesh geometry.
  55078. */
  55079. update(): void;
  55080. /**
  55081. * Returns a new TrailMesh object.
  55082. * @param name is a string, the name given to the new mesh
  55083. * @param newGenerator use new generator object for cloned trail mesh
  55084. * @returns a new mesh
  55085. */
  55086. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55087. /**
  55088. * Serializes this trail mesh
  55089. * @param serializationObject object to write serialization to
  55090. */
  55091. serialize(serializationObject: any): void;
  55092. /**
  55093. * Parses a serialized trail mesh
  55094. * @param parsedMesh the serialized mesh
  55095. * @param scene the scene to create the trail mesh in
  55096. * @returns the created trail mesh
  55097. */
  55098. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55099. }
  55100. }
  55101. declare module BABYLON {
  55102. /**
  55103. * Class containing static functions to help procedurally build meshes
  55104. */
  55105. export class TiledBoxBuilder {
  55106. /**
  55107. * Creates a box mesh
  55108. * 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)
  55109. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55111. * * 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
  55112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55113. * @param name defines the name of the mesh
  55114. * @param options defines the options used to create the mesh
  55115. * @param scene defines the hosting scene
  55116. * @returns the box mesh
  55117. */
  55118. static CreateTiledBox(name: string, options: {
  55119. pattern?: number;
  55120. width?: number;
  55121. height?: number;
  55122. depth?: number;
  55123. tileSize?: number;
  55124. tileWidth?: number;
  55125. tileHeight?: number;
  55126. alignHorizontal?: number;
  55127. alignVertical?: number;
  55128. faceUV?: Vector4[];
  55129. faceColors?: Color4[];
  55130. sideOrientation?: number;
  55131. updatable?: boolean;
  55132. }, scene?: Nullable<Scene>): Mesh;
  55133. }
  55134. }
  55135. declare module BABYLON {
  55136. /**
  55137. * Class containing static functions to help procedurally build meshes
  55138. */
  55139. export class TorusKnotBuilder {
  55140. /**
  55141. * Creates a torus knot mesh
  55142. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55143. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55144. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55145. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55147. * * 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
  55148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55149. * @param name defines the name of the mesh
  55150. * @param options defines the options used to create the mesh
  55151. * @param scene defines the hosting scene
  55152. * @returns the torus knot mesh
  55153. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55154. */
  55155. static CreateTorusKnot(name: string, options: {
  55156. radius?: number;
  55157. tube?: number;
  55158. radialSegments?: number;
  55159. tubularSegments?: number;
  55160. p?: number;
  55161. q?: number;
  55162. updatable?: boolean;
  55163. sideOrientation?: number;
  55164. frontUVs?: Vector4;
  55165. backUVs?: Vector4;
  55166. }, scene: any): Mesh;
  55167. }
  55168. }
  55169. declare module BABYLON {
  55170. /**
  55171. * Polygon
  55172. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55173. */
  55174. export class Polygon {
  55175. /**
  55176. * Creates a rectangle
  55177. * @param xmin bottom X coord
  55178. * @param ymin bottom Y coord
  55179. * @param xmax top X coord
  55180. * @param ymax top Y coord
  55181. * @returns points that make the resulting rectation
  55182. */
  55183. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55184. /**
  55185. * Creates a circle
  55186. * @param radius radius of circle
  55187. * @param cx scale in x
  55188. * @param cy scale in y
  55189. * @param numberOfSides number of sides that make up the circle
  55190. * @returns points that make the resulting circle
  55191. */
  55192. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55193. /**
  55194. * Creates a polygon from input string
  55195. * @param input Input polygon data
  55196. * @returns the parsed points
  55197. */
  55198. static Parse(input: string): Vector2[];
  55199. /**
  55200. * Starts building a polygon from x and y coordinates
  55201. * @param x x coordinate
  55202. * @param y y coordinate
  55203. * @returns the started path2
  55204. */
  55205. static StartingAt(x: number, y: number): Path2;
  55206. }
  55207. /**
  55208. * Builds a polygon
  55209. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55210. */
  55211. export class PolygonMeshBuilder {
  55212. private _points;
  55213. private _outlinepoints;
  55214. private _holes;
  55215. private _name;
  55216. private _scene;
  55217. private _epoints;
  55218. private _eholes;
  55219. private _addToepoint;
  55220. /**
  55221. * Babylon reference to the earcut plugin.
  55222. */
  55223. bjsEarcut: any;
  55224. /**
  55225. * Creates a PolygonMeshBuilder
  55226. * @param name name of the builder
  55227. * @param contours Path of the polygon
  55228. * @param scene scene to add to when creating the mesh
  55229. * @param earcutInjection can be used to inject your own earcut reference
  55230. */
  55231. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55232. /**
  55233. * Adds a whole within the polygon
  55234. * @param hole Array of points defining the hole
  55235. * @returns this
  55236. */
  55237. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55238. /**
  55239. * Creates the polygon
  55240. * @param updatable If the mesh should be updatable
  55241. * @param depth The depth of the mesh created
  55242. * @returns the created mesh
  55243. */
  55244. build(updatable?: boolean, depth?: number): Mesh;
  55245. /**
  55246. * Creates the polygon
  55247. * @param depth The depth of the mesh created
  55248. * @returns the created VertexData
  55249. */
  55250. buildVertexData(depth?: number): VertexData;
  55251. /**
  55252. * Adds a side to the polygon
  55253. * @param positions points that make the polygon
  55254. * @param normals normals of the polygon
  55255. * @param uvs uvs of the polygon
  55256. * @param indices indices of the polygon
  55257. * @param bounds bounds of the polygon
  55258. * @param points points of the polygon
  55259. * @param depth depth of the polygon
  55260. * @param flip flip of the polygon
  55261. */
  55262. private addSide;
  55263. }
  55264. }
  55265. declare module BABYLON {
  55266. /**
  55267. * Class containing static functions to help procedurally build meshes
  55268. */
  55269. export class PolygonBuilder {
  55270. /**
  55271. * Creates a polygon mesh
  55272. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55273. * * 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
  55274. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55276. * * 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)
  55277. * * Remember you can only change the shape positions, not their number when updating a polygon
  55278. * @param name defines the name of the mesh
  55279. * @param options defines the options used to create the mesh
  55280. * @param scene defines the hosting scene
  55281. * @param earcutInjection can be used to inject your own earcut reference
  55282. * @returns the polygon mesh
  55283. */
  55284. static CreatePolygon(name: string, options: {
  55285. shape: Vector3[];
  55286. holes?: Vector3[][];
  55287. depth?: number;
  55288. faceUV?: Vector4[];
  55289. faceColors?: Color4[];
  55290. updatable?: boolean;
  55291. sideOrientation?: number;
  55292. frontUVs?: Vector4;
  55293. backUVs?: Vector4;
  55294. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55295. /**
  55296. * Creates an extruded polygon mesh, with depth in the Y direction.
  55297. * * 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)
  55298. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55299. * @param name defines the name of the mesh
  55300. * @param options defines the options used to create the mesh
  55301. * @param scene defines the hosting scene
  55302. * @param earcutInjection can be used to inject your own earcut reference
  55303. * @returns the polygon mesh
  55304. */
  55305. static ExtrudePolygon(name: string, options: {
  55306. shape: Vector3[];
  55307. holes?: Vector3[][];
  55308. depth?: number;
  55309. faceUV?: Vector4[];
  55310. faceColors?: Color4[];
  55311. updatable?: boolean;
  55312. sideOrientation?: number;
  55313. frontUVs?: Vector4;
  55314. backUVs?: Vector4;
  55315. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55316. }
  55317. }
  55318. declare module BABYLON {
  55319. /**
  55320. * Class containing static functions to help procedurally build meshes
  55321. */
  55322. export class LatheBuilder {
  55323. /**
  55324. * Creates lathe mesh.
  55325. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55326. * * 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
  55327. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55328. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55329. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55330. * * 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
  55331. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55332. * * 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
  55333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55334. * * 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
  55335. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55337. * @param name defines the name of the mesh
  55338. * @param options defines the options used to create the mesh
  55339. * @param scene defines the hosting scene
  55340. * @returns the lathe mesh
  55341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55342. */
  55343. static CreateLathe(name: string, options: {
  55344. shape: Vector3[];
  55345. radius?: number;
  55346. tessellation?: number;
  55347. clip?: number;
  55348. arc?: number;
  55349. closed?: boolean;
  55350. updatable?: boolean;
  55351. sideOrientation?: number;
  55352. frontUVs?: Vector4;
  55353. backUVs?: Vector4;
  55354. cap?: number;
  55355. invertUV?: boolean;
  55356. }, scene?: Nullable<Scene>): Mesh;
  55357. }
  55358. }
  55359. declare module BABYLON {
  55360. /**
  55361. * Class containing static functions to help procedurally build meshes
  55362. */
  55363. export class TiledPlaneBuilder {
  55364. /**
  55365. * Creates a tiled plane mesh
  55366. * * The parameter `pattern` will, depending on value, do nothing or
  55367. * * * flip (reflect about central vertical) alternate tiles across and up
  55368. * * * flip every tile on alternate rows
  55369. * * * rotate (180 degs) alternate tiles across and up
  55370. * * * rotate every tile on alternate rows
  55371. * * * flip and rotate alternate tiles across and up
  55372. * * * flip and rotate every tile on alternate rows
  55373. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55374. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55375. * * 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
  55376. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55377. * * 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)
  55378. * * 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)
  55379. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55380. * @param name defines the name of the mesh
  55381. * @param options defines the options used to create the mesh
  55382. * @param scene defines the hosting scene
  55383. * @returns the box mesh
  55384. */
  55385. static CreateTiledPlane(name: string, options: {
  55386. pattern?: number;
  55387. tileSize?: number;
  55388. tileWidth?: number;
  55389. tileHeight?: number;
  55390. size?: number;
  55391. width?: number;
  55392. height?: number;
  55393. alignHorizontal?: number;
  55394. alignVertical?: number;
  55395. sideOrientation?: number;
  55396. frontUVs?: Vector4;
  55397. backUVs?: Vector4;
  55398. updatable?: boolean;
  55399. }, scene?: Nullable<Scene>): Mesh;
  55400. }
  55401. }
  55402. declare module BABYLON {
  55403. /**
  55404. * Class containing static functions to help procedurally build meshes
  55405. */
  55406. export class TubeBuilder {
  55407. /**
  55408. * Creates a tube mesh.
  55409. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55410. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55411. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55412. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55413. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55414. * * 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)
  55415. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55416. * * 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
  55417. * * 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
  55418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55419. * * 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
  55420. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55422. * @param name defines the name of the mesh
  55423. * @param options defines the options used to create the mesh
  55424. * @param scene defines the hosting scene
  55425. * @returns the tube mesh
  55426. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55427. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55428. */
  55429. static CreateTube(name: string, options: {
  55430. path: Vector3[];
  55431. radius?: number;
  55432. tessellation?: number;
  55433. radiusFunction?: {
  55434. (i: number, distance: number): number;
  55435. };
  55436. cap?: number;
  55437. arc?: number;
  55438. updatable?: boolean;
  55439. sideOrientation?: number;
  55440. frontUVs?: Vector4;
  55441. backUVs?: Vector4;
  55442. instance?: Mesh;
  55443. invertUV?: boolean;
  55444. }, scene?: Nullable<Scene>): Mesh;
  55445. }
  55446. }
  55447. declare module BABYLON {
  55448. /**
  55449. * Class containing static functions to help procedurally build meshes
  55450. */
  55451. export class IcoSphereBuilder {
  55452. /**
  55453. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55454. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55455. * * 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`)
  55456. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55457. * * 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
  55458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55459. * * 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
  55460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55461. * @param name defines the name of the mesh
  55462. * @param options defines the options used to create the mesh
  55463. * @param scene defines the hosting scene
  55464. * @returns the icosahedron mesh
  55465. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55466. */
  55467. static CreateIcoSphere(name: string, options: {
  55468. radius?: number;
  55469. radiusX?: number;
  55470. radiusY?: number;
  55471. radiusZ?: number;
  55472. flat?: boolean;
  55473. subdivisions?: number;
  55474. sideOrientation?: number;
  55475. frontUVs?: Vector4;
  55476. backUVs?: Vector4;
  55477. updatable?: boolean;
  55478. }, scene?: Nullable<Scene>): Mesh;
  55479. }
  55480. }
  55481. declare module BABYLON {
  55482. /**
  55483. * Class containing static functions to help procedurally build meshes
  55484. */
  55485. export class DecalBuilder {
  55486. /**
  55487. * Creates a decal mesh.
  55488. * 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
  55489. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55490. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55491. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55492. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55493. * @param name defines the name of the mesh
  55494. * @param sourceMesh defines the mesh where the decal must be applied
  55495. * @param options defines the options used to create the mesh
  55496. * @param scene defines the hosting scene
  55497. * @returns the decal mesh
  55498. * @see https://doc.babylonjs.com/how_to/decals
  55499. */
  55500. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55501. position?: Vector3;
  55502. normal?: Vector3;
  55503. size?: Vector3;
  55504. angle?: number;
  55505. }): Mesh;
  55506. }
  55507. }
  55508. declare module BABYLON {
  55509. /**
  55510. * Class containing static functions to help procedurally build meshes
  55511. */
  55512. export class MeshBuilder {
  55513. /**
  55514. * Creates a box mesh
  55515. * * The parameter `size` sets the size (float) of each box side (default 1)
  55516. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55517. * * 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)
  55518. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55520. * * 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
  55521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55522. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55523. * @param name defines the name of the mesh
  55524. * @param options defines the options used to create the mesh
  55525. * @param scene defines the hosting scene
  55526. * @returns the box mesh
  55527. */
  55528. static CreateBox(name: string, options: {
  55529. size?: number;
  55530. width?: number;
  55531. height?: number;
  55532. depth?: number;
  55533. faceUV?: Vector4[];
  55534. faceColors?: Color4[];
  55535. sideOrientation?: number;
  55536. frontUVs?: Vector4;
  55537. backUVs?: Vector4;
  55538. updatable?: boolean;
  55539. }, scene?: Nullable<Scene>): Mesh;
  55540. /**
  55541. * Creates a tiled box mesh
  55542. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55544. * @param name defines the name of the mesh
  55545. * @param options defines the options used to create the mesh
  55546. * @param scene defines the hosting scene
  55547. * @returns the tiled box mesh
  55548. */
  55549. static CreateTiledBox(name: string, options: {
  55550. pattern?: number;
  55551. size?: number;
  55552. width?: number;
  55553. height?: number;
  55554. depth: number;
  55555. tileSize?: number;
  55556. tileWidth?: number;
  55557. tileHeight?: number;
  55558. faceUV?: Vector4[];
  55559. faceColors?: Color4[];
  55560. alignHorizontal?: number;
  55561. alignVertical?: number;
  55562. sideOrientation?: number;
  55563. updatable?: boolean;
  55564. }, scene?: Nullable<Scene>): Mesh;
  55565. /**
  55566. * Creates a sphere mesh
  55567. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55568. * * 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`)
  55569. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55570. * * 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
  55571. * * 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)
  55572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55573. * * 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
  55574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55575. * @param name defines the name of the mesh
  55576. * @param options defines the options used to create the mesh
  55577. * @param scene defines the hosting scene
  55578. * @returns the sphere mesh
  55579. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55580. */
  55581. static CreateSphere(name: string, options: {
  55582. segments?: number;
  55583. diameter?: number;
  55584. diameterX?: number;
  55585. diameterY?: number;
  55586. diameterZ?: number;
  55587. arc?: number;
  55588. slice?: number;
  55589. sideOrientation?: number;
  55590. frontUVs?: Vector4;
  55591. backUVs?: Vector4;
  55592. updatable?: boolean;
  55593. }, scene?: Nullable<Scene>): Mesh;
  55594. /**
  55595. * Creates a plane polygonal mesh. By default, this is a disc
  55596. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55597. * * 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
  55598. * * 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
  55599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55600. * * 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
  55601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55602. * @param name defines the name of the mesh
  55603. * @param options defines the options used to create the mesh
  55604. * @param scene defines the hosting scene
  55605. * @returns the plane polygonal mesh
  55606. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55607. */
  55608. static CreateDisc(name: string, options: {
  55609. radius?: number;
  55610. tessellation?: number;
  55611. arc?: number;
  55612. updatable?: boolean;
  55613. sideOrientation?: number;
  55614. frontUVs?: Vector4;
  55615. backUVs?: Vector4;
  55616. }, scene?: Nullable<Scene>): Mesh;
  55617. /**
  55618. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55619. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55620. * * 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`)
  55621. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55622. * * 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
  55623. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55624. * * 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
  55625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55626. * @param name defines the name of the mesh
  55627. * @param options defines the options used to create the mesh
  55628. * @param scene defines the hosting scene
  55629. * @returns the icosahedron mesh
  55630. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55631. */
  55632. static CreateIcoSphere(name: string, options: {
  55633. radius?: number;
  55634. radiusX?: number;
  55635. radiusY?: number;
  55636. radiusZ?: number;
  55637. flat?: boolean;
  55638. subdivisions?: number;
  55639. sideOrientation?: number;
  55640. frontUVs?: Vector4;
  55641. backUVs?: Vector4;
  55642. updatable?: boolean;
  55643. }, scene?: Nullable<Scene>): Mesh;
  55644. /**
  55645. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55646. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55647. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55648. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55649. * * 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
  55650. * * 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
  55651. * * 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
  55652. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55653. * * 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
  55654. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55655. * * 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
  55656. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55657. * * 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
  55658. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55660. * @param name defines the name of the mesh
  55661. * @param options defines the options used to create the mesh
  55662. * @param scene defines the hosting scene
  55663. * @returns the ribbon mesh
  55664. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55665. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55666. */
  55667. static CreateRibbon(name: string, options: {
  55668. pathArray: Vector3[][];
  55669. closeArray?: boolean;
  55670. closePath?: boolean;
  55671. offset?: number;
  55672. updatable?: boolean;
  55673. sideOrientation?: number;
  55674. frontUVs?: Vector4;
  55675. backUVs?: Vector4;
  55676. instance?: Mesh;
  55677. invertUV?: boolean;
  55678. uvs?: Vector2[];
  55679. colors?: Color4[];
  55680. }, scene?: Nullable<Scene>): Mesh;
  55681. /**
  55682. * Creates a cylinder or a cone mesh
  55683. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55684. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55685. * * 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.
  55686. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55687. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55688. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55689. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55690. * * 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).
  55691. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55692. * * 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).
  55693. * * 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
  55694. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55695. * * 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
  55696. * * 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.
  55697. * * If `enclose` is false, a ring surface is one element.
  55698. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55699. * * 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
  55700. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55701. * * 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
  55702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55703. * @param name defines the name of the mesh
  55704. * @param options defines the options used to create the mesh
  55705. * @param scene defines the hosting scene
  55706. * @returns the cylinder mesh
  55707. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55708. */
  55709. static CreateCylinder(name: string, options: {
  55710. height?: number;
  55711. diameterTop?: number;
  55712. diameterBottom?: number;
  55713. diameter?: number;
  55714. tessellation?: number;
  55715. subdivisions?: number;
  55716. arc?: number;
  55717. faceColors?: Color4[];
  55718. faceUV?: Vector4[];
  55719. updatable?: boolean;
  55720. hasRings?: boolean;
  55721. enclose?: boolean;
  55722. cap?: number;
  55723. sideOrientation?: number;
  55724. frontUVs?: Vector4;
  55725. backUVs?: Vector4;
  55726. }, scene?: Nullable<Scene>): Mesh;
  55727. /**
  55728. * Creates a torus mesh
  55729. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55730. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55731. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55733. * * 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
  55734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55735. * @param name defines the name of the mesh
  55736. * @param options defines the options used to create the mesh
  55737. * @param scene defines the hosting scene
  55738. * @returns the torus mesh
  55739. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55740. */
  55741. static CreateTorus(name: string, options: {
  55742. diameter?: number;
  55743. thickness?: number;
  55744. tessellation?: number;
  55745. updatable?: boolean;
  55746. sideOrientation?: number;
  55747. frontUVs?: Vector4;
  55748. backUVs?: Vector4;
  55749. }, scene?: Nullable<Scene>): Mesh;
  55750. /**
  55751. * Creates a torus knot mesh
  55752. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55753. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55754. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55755. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55757. * * 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
  55758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55759. * @param name defines the name of the mesh
  55760. * @param options defines the options used to create the mesh
  55761. * @param scene defines the hosting scene
  55762. * @returns the torus knot mesh
  55763. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55764. */
  55765. static CreateTorusKnot(name: string, options: {
  55766. radius?: number;
  55767. tube?: number;
  55768. radialSegments?: number;
  55769. tubularSegments?: number;
  55770. p?: number;
  55771. q?: number;
  55772. updatable?: boolean;
  55773. sideOrientation?: number;
  55774. frontUVs?: Vector4;
  55775. backUVs?: Vector4;
  55776. }, scene?: Nullable<Scene>): Mesh;
  55777. /**
  55778. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55779. * * 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
  55780. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55781. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55782. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55783. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55784. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55785. * * 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
  55786. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55788. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55789. * @param name defines the name of the new line system
  55790. * @param options defines the options used to create the line system
  55791. * @param scene defines the hosting scene
  55792. * @returns a new line system mesh
  55793. */
  55794. static CreateLineSystem(name: string, options: {
  55795. lines: Vector3[][];
  55796. updatable?: boolean;
  55797. instance?: Nullable<LinesMesh>;
  55798. colors?: Nullable<Color4[][]>;
  55799. useVertexAlpha?: boolean;
  55800. }, scene: Nullable<Scene>): LinesMesh;
  55801. /**
  55802. * Creates a line mesh
  55803. * 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
  55804. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55805. * * The parameter `points` is an array successive Vector3
  55806. * * 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
  55807. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55808. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55809. * * When updating an instance, remember that only point positions can change, not the number of points
  55810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55811. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55812. * @param name defines the name of the new line system
  55813. * @param options defines the options used to create the line system
  55814. * @param scene defines the hosting scene
  55815. * @returns a new line mesh
  55816. */
  55817. static CreateLines(name: string, options: {
  55818. points: Vector3[];
  55819. updatable?: boolean;
  55820. instance?: Nullable<LinesMesh>;
  55821. colors?: Color4[];
  55822. useVertexAlpha?: boolean;
  55823. }, scene?: Nullable<Scene>): LinesMesh;
  55824. /**
  55825. * Creates a dashed line mesh
  55826. * * 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
  55827. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55828. * * The parameter `points` is an array successive Vector3
  55829. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55830. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55831. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55832. * * 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
  55833. * * When updating an instance, remember that only point positions can change, not the number of points
  55834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55835. * @param name defines the name of the mesh
  55836. * @param options defines the options used to create the mesh
  55837. * @param scene defines the hosting scene
  55838. * @returns the dashed line mesh
  55839. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55840. */
  55841. static CreateDashedLines(name: string, options: {
  55842. points: Vector3[];
  55843. dashSize?: number;
  55844. gapSize?: number;
  55845. dashNb?: number;
  55846. updatable?: boolean;
  55847. instance?: LinesMesh;
  55848. }, scene?: Nullable<Scene>): LinesMesh;
  55849. /**
  55850. * 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.
  55851. * * 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.
  55852. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55853. * * 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.
  55854. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55855. * * 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
  55856. * * 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
  55857. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55858. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55859. * * 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
  55860. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55862. * @param name defines the name of the mesh
  55863. * @param options defines the options used to create the mesh
  55864. * @param scene defines the hosting scene
  55865. * @returns the extruded shape mesh
  55866. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55867. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55868. */
  55869. static ExtrudeShape(name: string, options: {
  55870. shape: Vector3[];
  55871. path: Vector3[];
  55872. scale?: number;
  55873. rotation?: number;
  55874. cap?: number;
  55875. updatable?: boolean;
  55876. sideOrientation?: number;
  55877. frontUVs?: Vector4;
  55878. backUVs?: Vector4;
  55879. instance?: Mesh;
  55880. invertUV?: boolean;
  55881. }, scene?: Nullable<Scene>): Mesh;
  55882. /**
  55883. * Creates an custom extruded shape mesh.
  55884. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55885. * * 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.
  55886. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55887. * * 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
  55888. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55889. * * 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
  55890. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55891. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55892. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55893. * * 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
  55894. * * 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
  55895. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55897. * * 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
  55898. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55900. * @param name defines the name of the mesh
  55901. * @param options defines the options used to create the mesh
  55902. * @param scene defines the hosting scene
  55903. * @returns the custom extruded shape mesh
  55904. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55905. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55906. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55907. */
  55908. static ExtrudeShapeCustom(name: string, options: {
  55909. shape: Vector3[];
  55910. path: Vector3[];
  55911. scaleFunction?: any;
  55912. rotationFunction?: any;
  55913. ribbonCloseArray?: boolean;
  55914. ribbonClosePath?: boolean;
  55915. cap?: number;
  55916. updatable?: boolean;
  55917. sideOrientation?: number;
  55918. frontUVs?: Vector4;
  55919. backUVs?: Vector4;
  55920. instance?: Mesh;
  55921. invertUV?: boolean;
  55922. }, scene?: Nullable<Scene>): Mesh;
  55923. /**
  55924. * Creates lathe mesh.
  55925. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55926. * * 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
  55927. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55928. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55929. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55930. * * 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
  55931. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55932. * * 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
  55933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55934. * * 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
  55935. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55937. * @param name defines the name of the mesh
  55938. * @param options defines the options used to create the mesh
  55939. * @param scene defines the hosting scene
  55940. * @returns the lathe mesh
  55941. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55942. */
  55943. static CreateLathe(name: string, options: {
  55944. shape: Vector3[];
  55945. radius?: number;
  55946. tessellation?: number;
  55947. clip?: number;
  55948. arc?: number;
  55949. closed?: boolean;
  55950. updatable?: boolean;
  55951. sideOrientation?: number;
  55952. frontUVs?: Vector4;
  55953. backUVs?: Vector4;
  55954. cap?: number;
  55955. invertUV?: boolean;
  55956. }, scene?: Nullable<Scene>): Mesh;
  55957. /**
  55958. * Creates a tiled plane mesh
  55959. * * You can set a limited pattern arrangement with the tiles
  55960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55961. * * 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
  55962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55963. * @param name defines the name of the mesh
  55964. * @param options defines the options used to create the mesh
  55965. * @param scene defines the hosting scene
  55966. * @returns the plane mesh
  55967. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55968. */
  55969. static CreateTiledPlane(name: string, options: {
  55970. pattern?: number;
  55971. tileSize?: number;
  55972. tileWidth?: number;
  55973. tileHeight?: number;
  55974. size?: number;
  55975. width?: number;
  55976. height?: number;
  55977. alignHorizontal?: number;
  55978. alignVertical?: number;
  55979. sideOrientation?: number;
  55980. frontUVs?: Vector4;
  55981. backUVs?: Vector4;
  55982. updatable?: boolean;
  55983. }, scene?: Nullable<Scene>): Mesh;
  55984. /**
  55985. * Creates a plane mesh
  55986. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55987. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55988. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55990. * * 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
  55991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55992. * @param name defines the name of the mesh
  55993. * @param options defines the options used to create the mesh
  55994. * @param scene defines the hosting scene
  55995. * @returns the plane mesh
  55996. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55997. */
  55998. static CreatePlane(name: string, options: {
  55999. size?: number;
  56000. width?: number;
  56001. height?: number;
  56002. sideOrientation?: number;
  56003. frontUVs?: Vector4;
  56004. backUVs?: Vector4;
  56005. updatable?: boolean;
  56006. sourcePlane?: Plane;
  56007. }, scene?: Nullable<Scene>): Mesh;
  56008. /**
  56009. * Creates a ground mesh
  56010. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56011. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56013. * @param name defines the name of the mesh
  56014. * @param options defines the options used to create the mesh
  56015. * @param scene defines the hosting scene
  56016. * @returns the ground mesh
  56017. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56018. */
  56019. static CreateGround(name: string, options: {
  56020. width?: number;
  56021. height?: number;
  56022. subdivisions?: number;
  56023. subdivisionsX?: number;
  56024. subdivisionsY?: number;
  56025. updatable?: boolean;
  56026. }, scene?: Nullable<Scene>): Mesh;
  56027. /**
  56028. * Creates a tiled ground mesh
  56029. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56030. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56031. * * 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
  56032. * * 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
  56033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56034. * @param name defines the name of the mesh
  56035. * @param options defines the options used to create the mesh
  56036. * @param scene defines the hosting scene
  56037. * @returns the tiled ground mesh
  56038. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56039. */
  56040. static CreateTiledGround(name: string, options: {
  56041. xmin: number;
  56042. zmin: number;
  56043. xmax: number;
  56044. zmax: number;
  56045. subdivisions?: {
  56046. w: number;
  56047. h: number;
  56048. };
  56049. precision?: {
  56050. w: number;
  56051. h: number;
  56052. };
  56053. updatable?: boolean;
  56054. }, scene?: Nullable<Scene>): Mesh;
  56055. /**
  56056. * Creates a ground mesh from a height map
  56057. * * The parameter `url` sets the URL of the height map image resource.
  56058. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56059. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56060. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56061. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56062. * * 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.
  56063. * * 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).
  56064. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56066. * @param name defines the name of the mesh
  56067. * @param url defines the url to the height map
  56068. * @param options defines the options used to create the mesh
  56069. * @param scene defines the hosting scene
  56070. * @returns the ground mesh
  56071. * @see https://doc.babylonjs.com/babylon101/height_map
  56072. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56073. */
  56074. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56075. width?: number;
  56076. height?: number;
  56077. subdivisions?: number;
  56078. minHeight?: number;
  56079. maxHeight?: number;
  56080. colorFilter?: Color3;
  56081. alphaFilter?: number;
  56082. updatable?: boolean;
  56083. onReady?: (mesh: GroundMesh) => void;
  56084. }, scene?: Nullable<Scene>): GroundMesh;
  56085. /**
  56086. * Creates a polygon mesh
  56087. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56088. * * 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
  56089. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56091. * * 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)
  56092. * * Remember you can only change the shape positions, not their number when updating a polygon
  56093. * @param name defines the name of the mesh
  56094. * @param options defines the options used to create the mesh
  56095. * @param scene defines the hosting scene
  56096. * @param earcutInjection can be used to inject your own earcut reference
  56097. * @returns the polygon mesh
  56098. */
  56099. static CreatePolygon(name: string, options: {
  56100. shape: Vector3[];
  56101. holes?: Vector3[][];
  56102. depth?: number;
  56103. faceUV?: Vector4[];
  56104. faceColors?: Color4[];
  56105. updatable?: boolean;
  56106. sideOrientation?: number;
  56107. frontUVs?: Vector4;
  56108. backUVs?: Vector4;
  56109. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56110. /**
  56111. * Creates an extruded polygon mesh, with depth in the Y direction.
  56112. * * 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)
  56113. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56114. * @param name defines the name of the mesh
  56115. * @param options defines the options used to create the mesh
  56116. * @param scene defines the hosting scene
  56117. * @param earcutInjection can be used to inject your own earcut reference
  56118. * @returns the polygon mesh
  56119. */
  56120. static ExtrudePolygon(name: string, options: {
  56121. shape: Vector3[];
  56122. holes?: Vector3[][];
  56123. depth?: number;
  56124. faceUV?: Vector4[];
  56125. faceColors?: Color4[];
  56126. updatable?: boolean;
  56127. sideOrientation?: number;
  56128. frontUVs?: Vector4;
  56129. backUVs?: Vector4;
  56130. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56131. /**
  56132. * Creates a tube mesh.
  56133. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56134. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56135. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56136. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56137. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56138. * * 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)
  56139. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56140. * * 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
  56141. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56146. * @param name defines the name of the mesh
  56147. * @param options defines the options used to create the mesh
  56148. * @param scene defines the hosting scene
  56149. * @returns the tube mesh
  56150. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56151. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56152. */
  56153. static CreateTube(name: string, options: {
  56154. path: Vector3[];
  56155. radius?: number;
  56156. tessellation?: number;
  56157. radiusFunction?: {
  56158. (i: number, distance: number): number;
  56159. };
  56160. cap?: number;
  56161. arc?: number;
  56162. updatable?: boolean;
  56163. sideOrientation?: number;
  56164. frontUVs?: Vector4;
  56165. backUVs?: Vector4;
  56166. instance?: Mesh;
  56167. invertUV?: boolean;
  56168. }, scene?: Nullable<Scene>): Mesh;
  56169. /**
  56170. * Creates a polyhedron mesh
  56171. * * 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
  56172. * * The parameter `size` (positive float, default 1) sets the polygon size
  56173. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56174. * * 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`
  56175. * * 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
  56176. * * 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)`)
  56177. * * 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
  56178. * * 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
  56179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56180. * * 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
  56181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56182. * @param name defines the name of the mesh
  56183. * @param options defines the options used to create the mesh
  56184. * @param scene defines the hosting scene
  56185. * @returns the polyhedron mesh
  56186. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56187. */
  56188. static CreatePolyhedron(name: string, options: {
  56189. type?: number;
  56190. size?: number;
  56191. sizeX?: number;
  56192. sizeY?: number;
  56193. sizeZ?: number;
  56194. custom?: any;
  56195. faceUV?: Vector4[];
  56196. faceColors?: Color4[];
  56197. flat?: boolean;
  56198. updatable?: boolean;
  56199. sideOrientation?: number;
  56200. frontUVs?: Vector4;
  56201. backUVs?: Vector4;
  56202. }, scene?: Nullable<Scene>): Mesh;
  56203. /**
  56204. * Creates a decal mesh.
  56205. * 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
  56206. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56207. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56208. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56209. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56210. * @param name defines the name of the mesh
  56211. * @param sourceMesh defines the mesh where the decal must be applied
  56212. * @param options defines the options used to create the mesh
  56213. * @param scene defines the hosting scene
  56214. * @returns the decal mesh
  56215. * @see https://doc.babylonjs.com/how_to/decals
  56216. */
  56217. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56218. position?: Vector3;
  56219. normal?: Vector3;
  56220. size?: Vector3;
  56221. angle?: number;
  56222. }): Mesh;
  56223. }
  56224. }
  56225. declare module BABYLON {
  56226. /**
  56227. * A simplifier interface for future simplification implementations
  56228. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56229. */
  56230. export interface ISimplifier {
  56231. /**
  56232. * Simplification of a given mesh according to the given settings.
  56233. * Since this requires computation, it is assumed that the function runs async.
  56234. * @param settings The settings of the simplification, including quality and distance
  56235. * @param successCallback A callback that will be called after the mesh was simplified.
  56236. * @param errorCallback in case of an error, this callback will be called. optional.
  56237. */
  56238. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56239. }
  56240. /**
  56241. * Expected simplification settings.
  56242. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56243. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56244. */
  56245. export interface ISimplificationSettings {
  56246. /**
  56247. * Gets or sets the expected quality
  56248. */
  56249. quality: number;
  56250. /**
  56251. * Gets or sets the distance when this optimized version should be used
  56252. */
  56253. distance: number;
  56254. /**
  56255. * Gets an already optimized mesh
  56256. */
  56257. optimizeMesh?: boolean;
  56258. }
  56259. /**
  56260. * Class used to specify simplification options
  56261. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56262. */
  56263. export class SimplificationSettings implements ISimplificationSettings {
  56264. /** expected quality */
  56265. quality: number;
  56266. /** distance when this optimized version should be used */
  56267. distance: number;
  56268. /** already optimized mesh */
  56269. optimizeMesh?: boolean | undefined;
  56270. /**
  56271. * Creates a SimplificationSettings
  56272. * @param quality expected quality
  56273. * @param distance distance when this optimized version should be used
  56274. * @param optimizeMesh already optimized mesh
  56275. */
  56276. constructor(
  56277. /** expected quality */
  56278. quality: number,
  56279. /** distance when this optimized version should be used */
  56280. distance: number,
  56281. /** already optimized mesh */
  56282. optimizeMesh?: boolean | undefined);
  56283. }
  56284. /**
  56285. * Interface used to define a simplification task
  56286. */
  56287. export interface ISimplificationTask {
  56288. /**
  56289. * Array of settings
  56290. */
  56291. settings: Array<ISimplificationSettings>;
  56292. /**
  56293. * Simplification type
  56294. */
  56295. simplificationType: SimplificationType;
  56296. /**
  56297. * Mesh to simplify
  56298. */
  56299. mesh: Mesh;
  56300. /**
  56301. * Callback called on success
  56302. */
  56303. successCallback?: () => void;
  56304. /**
  56305. * Defines if parallel processing can be used
  56306. */
  56307. parallelProcessing: boolean;
  56308. }
  56309. /**
  56310. * Queue used to order the simplification tasks
  56311. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56312. */
  56313. export class SimplificationQueue {
  56314. private _simplificationArray;
  56315. /**
  56316. * Gets a boolean indicating that the process is still running
  56317. */
  56318. running: boolean;
  56319. /**
  56320. * Creates a new queue
  56321. */
  56322. constructor();
  56323. /**
  56324. * Adds a new simplification task
  56325. * @param task defines a task to add
  56326. */
  56327. addTask(task: ISimplificationTask): void;
  56328. /**
  56329. * Execute next task
  56330. */
  56331. executeNext(): void;
  56332. /**
  56333. * Execute a simplification task
  56334. * @param task defines the task to run
  56335. */
  56336. runSimplification(task: ISimplificationTask): void;
  56337. private getSimplifier;
  56338. }
  56339. /**
  56340. * The implemented types of simplification
  56341. * At the moment only Quadratic Error Decimation is implemented
  56342. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56343. */
  56344. export enum SimplificationType {
  56345. /** Quadratic error decimation */
  56346. QUADRATIC = 0
  56347. }
  56348. }
  56349. declare module BABYLON {
  56350. interface Scene {
  56351. /** @hidden (Backing field) */
  56352. _simplificationQueue: SimplificationQueue;
  56353. /**
  56354. * Gets or sets the simplification queue attached to the scene
  56355. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56356. */
  56357. simplificationQueue: SimplificationQueue;
  56358. }
  56359. interface Mesh {
  56360. /**
  56361. * Simplify the mesh according to the given array of settings.
  56362. * Function will return immediately and will simplify async
  56363. * @param settings a collection of simplification settings
  56364. * @param parallelProcessing should all levels calculate parallel or one after the other
  56365. * @param simplificationType the type of simplification to run
  56366. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56367. * @returns the current mesh
  56368. */
  56369. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56370. }
  56371. /**
  56372. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56373. * created in a scene
  56374. */
  56375. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56376. /**
  56377. * The component name helpfull to identify the component in the list of scene components.
  56378. */
  56379. readonly name: string;
  56380. /**
  56381. * The scene the component belongs to.
  56382. */
  56383. scene: Scene;
  56384. /**
  56385. * Creates a new instance of the component for the given scene
  56386. * @param scene Defines the scene to register the component in
  56387. */
  56388. constructor(scene: Scene);
  56389. /**
  56390. * Registers the component in a given scene
  56391. */
  56392. register(): void;
  56393. /**
  56394. * Rebuilds the elements related to this component in case of
  56395. * context lost for instance.
  56396. */
  56397. rebuild(): void;
  56398. /**
  56399. * Disposes the component and the associated ressources
  56400. */
  56401. dispose(): void;
  56402. private _beforeCameraUpdate;
  56403. }
  56404. }
  56405. declare module BABYLON {
  56406. /**
  56407. * Navigation plugin interface to add navigation constrained by a navigation mesh
  56408. */
  56409. export interface INavigationEnginePlugin {
  56410. /**
  56411. * plugin name
  56412. */
  56413. name: string;
  56414. /**
  56415. * Creates a navigation mesh
  56416. * @param meshes array of all the geometry used to compute the navigatio mesh
  56417. * @param parameters bunch of parameters used to filter geometry
  56418. */
  56419. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56420. /**
  56421. * Create a navigation mesh debug mesh
  56422. * @param scene is where the mesh will be added
  56423. * @returns debug display mesh
  56424. */
  56425. createDebugNavMesh(scene: Scene): Mesh;
  56426. /**
  56427. * Get a navigation mesh constrained position, closest to the parameter position
  56428. * @param position world position
  56429. * @returns the closest point to position constrained by the navigation mesh
  56430. */
  56431. getClosestPoint(position: Vector3): Vector3;
  56432. /**
  56433. * Get a navigation mesh constrained position, within a particular radius
  56434. * @param position world position
  56435. * @param maxRadius the maximum distance to the constrained world position
  56436. * @returns the closest point to position constrained by the navigation mesh
  56437. */
  56438. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56439. /**
  56440. * Compute the final position from a segment made of destination-position
  56441. * @param position world position
  56442. * @param destination world position
  56443. * @returns the resulting point along the navmesh
  56444. */
  56445. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56446. /**
  56447. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56448. * @param start world position
  56449. * @param end world position
  56450. * @returns array containing world position composing the path
  56451. */
  56452. computePath(start: Vector3, end: Vector3): Vector3[];
  56453. /**
  56454. * If this plugin is supported
  56455. * @returns true if plugin is supported
  56456. */
  56457. isSupported(): boolean;
  56458. /**
  56459. * Create a new Crowd so you can add agents
  56460. * @param maxAgents the maximum agent count in the crowd
  56461. * @param maxAgentRadius the maximum radius an agent can have
  56462. * @param scene to attach the crowd to
  56463. * @returns the crowd you can add agents to
  56464. */
  56465. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56466. /**
  56467. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56468. * The queries will try to find a solution within those bounds
  56469. * default is (1,1,1)
  56470. * @param extent x,y,z value that define the extent around the queries point of reference
  56471. */
  56472. setDefaultQueryExtent(extent: Vector3): void;
  56473. /**
  56474. * Get the Bounding box extent specified by setDefaultQueryExtent
  56475. * @returns the box extent values
  56476. */
  56477. getDefaultQueryExtent(): Vector3;
  56478. /**
  56479. * Release all resources
  56480. */
  56481. dispose(): void;
  56482. }
  56483. /**
  56484. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  56485. */
  56486. export interface ICrowd {
  56487. /**
  56488. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56489. * You can attach anything to that node. The node position is updated in the scene update tick.
  56490. * @param pos world position that will be constrained by the navigation mesh
  56491. * @param parameters agent parameters
  56492. * @param transform hooked to the agent that will be update by the scene
  56493. * @returns agent index
  56494. */
  56495. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56496. /**
  56497. * Returns the agent position in world space
  56498. * @param index agent index returned by addAgent
  56499. * @returns world space position
  56500. */
  56501. getAgentPosition(index: number): Vector3;
  56502. /**
  56503. * Gets the agent velocity in world space
  56504. * @param index agent index returned by addAgent
  56505. * @returns world space velocity
  56506. */
  56507. getAgentVelocity(index: number): Vector3;
  56508. /**
  56509. * remove a particular agent previously created
  56510. * @param index agent index returned by addAgent
  56511. */
  56512. removeAgent(index: number): void;
  56513. /**
  56514. * get the list of all agents attached to this crowd
  56515. * @returns list of agent indices
  56516. */
  56517. getAgents(): number[];
  56518. /**
  56519. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56520. * @param deltaTime in seconds
  56521. */
  56522. update(deltaTime: number): void;
  56523. /**
  56524. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56525. * @param index agent index returned by addAgent
  56526. * @param destination targeted world position
  56527. */
  56528. agentGoto(index: number, destination: Vector3): void;
  56529. /**
  56530. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56531. * The queries will try to find a solution within those bounds
  56532. * default is (1,1,1)
  56533. * @param extent x,y,z value that define the extent around the queries point of reference
  56534. */
  56535. setDefaultQueryExtent(extent: Vector3): void;
  56536. /**
  56537. * Get the Bounding box extent specified by setDefaultQueryExtent
  56538. * @returns the box extent values
  56539. */
  56540. getDefaultQueryExtent(): Vector3;
  56541. /**
  56542. * Release all resources
  56543. */
  56544. dispose(): void;
  56545. }
  56546. /**
  56547. * Configures an agent
  56548. */
  56549. export interface IAgentParameters {
  56550. /**
  56551. * Agent radius. [Limit: >= 0]
  56552. */
  56553. radius: number;
  56554. /**
  56555. * Agent height. [Limit: > 0]
  56556. */
  56557. height: number;
  56558. /**
  56559. * Maximum allowed acceleration. [Limit: >= 0]
  56560. */
  56561. maxAcceleration: number;
  56562. /**
  56563. * Maximum allowed speed. [Limit: >= 0]
  56564. */
  56565. maxSpeed: number;
  56566. /**
  56567. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  56568. */
  56569. collisionQueryRange: number;
  56570. /**
  56571. * The path visibility optimization range. [Limit: > 0]
  56572. */
  56573. pathOptimizationRange: number;
  56574. /**
  56575. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  56576. */
  56577. separationWeight: number;
  56578. }
  56579. /**
  56580. * Configures the navigation mesh creation
  56581. */
  56582. export interface INavMeshParameters {
  56583. /**
  56584. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  56585. */
  56586. cs: number;
  56587. /**
  56588. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  56589. */
  56590. ch: number;
  56591. /**
  56592. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  56593. */
  56594. walkableSlopeAngle: number;
  56595. /**
  56596. * Minimum floor to 'ceiling' height that will still allow the floor area to
  56597. * be considered walkable. [Limit: >= 3] [Units: vx]
  56598. */
  56599. walkableHeight: number;
  56600. /**
  56601. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  56602. */
  56603. walkableClimb: number;
  56604. /**
  56605. * The distance to erode/shrink the walkable area of the heightfield away from
  56606. * obstructions. [Limit: >=0] [Units: vx]
  56607. */
  56608. walkableRadius: number;
  56609. /**
  56610. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  56611. */
  56612. maxEdgeLen: number;
  56613. /**
  56614. * The maximum distance a simplfied contour's border edges should deviate
  56615. * the original raw contour. [Limit: >=0] [Units: vx]
  56616. */
  56617. maxSimplificationError: number;
  56618. /**
  56619. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  56620. */
  56621. minRegionArea: number;
  56622. /**
  56623. * Any regions with a span count smaller than this value will, if possible,
  56624. * be merged with larger regions. [Limit: >=0] [Units: vx]
  56625. */
  56626. mergeRegionArea: number;
  56627. /**
  56628. * The maximum number of vertices allowed for polygons generated during the
  56629. * contour to polygon conversion process. [Limit: >= 3]
  56630. */
  56631. maxVertsPerPoly: number;
  56632. /**
  56633. * Sets the sampling distance to use when generating the detail mesh.
  56634. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  56635. */
  56636. detailSampleDist: number;
  56637. /**
  56638. * The maximum distance the detail mesh surface should deviate from heightfield
  56639. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  56640. */
  56641. detailSampleMaxError: number;
  56642. }
  56643. }
  56644. declare module BABYLON {
  56645. /**
  56646. * RecastJS navigation plugin
  56647. */
  56648. export class RecastJSPlugin implements INavigationEnginePlugin {
  56649. /**
  56650. * Reference to the Recast library
  56651. */
  56652. bjsRECAST: any;
  56653. /**
  56654. * plugin name
  56655. */
  56656. name: string;
  56657. /**
  56658. * the first navmesh created. We might extend this to support multiple navmeshes
  56659. */
  56660. navMesh: any;
  56661. /**
  56662. * Initializes the recastJS plugin
  56663. * @param recastInjection can be used to inject your own recast reference
  56664. */
  56665. constructor(recastInjection?: any);
  56666. /**
  56667. * Creates a navigation mesh
  56668. * @param meshes array of all the geometry used to compute the navigatio mesh
  56669. * @param parameters bunch of parameters used to filter geometry
  56670. */
  56671. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56672. /**
  56673. * Create a navigation mesh debug mesh
  56674. * @param scene is where the mesh will be added
  56675. * @returns debug display mesh
  56676. */
  56677. createDebugNavMesh(scene: Scene): Mesh;
  56678. /**
  56679. * Get a navigation mesh constrained position, closest to the parameter position
  56680. * @param position world position
  56681. * @returns the closest point to position constrained by the navigation mesh
  56682. */
  56683. getClosestPoint(position: Vector3): Vector3;
  56684. /**
  56685. * Get a navigation mesh constrained position, within a particular radius
  56686. * @param position world position
  56687. * @param maxRadius the maximum distance to the constrained world position
  56688. * @returns the closest point to position constrained by the navigation mesh
  56689. */
  56690. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56691. /**
  56692. * Compute the final position from a segment made of destination-position
  56693. * @param position world position
  56694. * @param destination world position
  56695. * @returns the resulting point along the navmesh
  56696. */
  56697. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56698. /**
  56699. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56700. * @param start world position
  56701. * @param end world position
  56702. * @returns array containing world position composing the path
  56703. */
  56704. computePath(start: Vector3, end: Vector3): Vector3[];
  56705. /**
  56706. * Create a new Crowd so you can add agents
  56707. * @param maxAgents the maximum agent count in the crowd
  56708. * @param maxAgentRadius the maximum radius an agent can have
  56709. * @param scene to attach the crowd to
  56710. * @returns the crowd you can add agents to
  56711. */
  56712. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56713. /**
  56714. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56715. * The queries will try to find a solution within those bounds
  56716. * default is (1,1,1)
  56717. * @param extent x,y,z value that define the extent around the queries point of reference
  56718. */
  56719. setDefaultQueryExtent(extent: Vector3): void;
  56720. /**
  56721. * Get the Bounding box extent specified by setDefaultQueryExtent
  56722. * @returns the box extent values
  56723. */
  56724. getDefaultQueryExtent(): Vector3;
  56725. /**
  56726. * Disposes
  56727. */
  56728. dispose(): void;
  56729. /**
  56730. * If this plugin is supported
  56731. * @returns true if plugin is supported
  56732. */
  56733. isSupported(): boolean;
  56734. }
  56735. /**
  56736. * Recast detour crowd implementation
  56737. */
  56738. export class RecastJSCrowd implements ICrowd {
  56739. /**
  56740. * Recast/detour plugin
  56741. */
  56742. bjsRECASTPlugin: RecastJSPlugin;
  56743. /**
  56744. * Link to the detour crowd
  56745. */
  56746. recastCrowd: any;
  56747. /**
  56748. * One transform per agent
  56749. */
  56750. transforms: TransformNode[];
  56751. /**
  56752. * All agents created
  56753. */
  56754. agents: number[];
  56755. /**
  56756. * Link to the scene is kept to unregister the crowd from the scene
  56757. */
  56758. private _scene;
  56759. /**
  56760. * Observer for crowd updates
  56761. */
  56762. private _onBeforeAnimationsObserver;
  56763. /**
  56764. * Constructor
  56765. * @param plugin recastJS plugin
  56766. * @param maxAgents the maximum agent count in the crowd
  56767. * @param maxAgentRadius the maximum radius an agent can have
  56768. * @param scene to attach the crowd to
  56769. * @returns the crowd you can add agents to
  56770. */
  56771. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  56772. /**
  56773. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56774. * You can attach anything to that node. The node position is updated in the scene update tick.
  56775. * @param pos world position that will be constrained by the navigation mesh
  56776. * @param parameters agent parameters
  56777. * @param transform hooked to the agent that will be update by the scene
  56778. * @returns agent index
  56779. */
  56780. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56781. /**
  56782. * Returns the agent position in world space
  56783. * @param index agent index returned by addAgent
  56784. * @returns world space position
  56785. */
  56786. getAgentPosition(index: number): Vector3;
  56787. /**
  56788. * Returns the agent velocity in world space
  56789. * @param index agent index returned by addAgent
  56790. * @returns world space velocity
  56791. */
  56792. getAgentVelocity(index: number): Vector3;
  56793. /**
  56794. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56795. * @param index agent index returned by addAgent
  56796. * @param destination targeted world position
  56797. */
  56798. agentGoto(index: number, destination: Vector3): void;
  56799. /**
  56800. * remove a particular agent previously created
  56801. * @param index agent index returned by addAgent
  56802. */
  56803. removeAgent(index: number): void;
  56804. /**
  56805. * get the list of all agents attached to this crowd
  56806. * @returns list of agent indices
  56807. */
  56808. getAgents(): number[];
  56809. /**
  56810. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56811. * @param deltaTime in seconds
  56812. */
  56813. update(deltaTime: number): void;
  56814. /**
  56815. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56816. * The queries will try to find a solution within those bounds
  56817. * default is (1,1,1)
  56818. * @param extent x,y,z value that define the extent around the queries point of reference
  56819. */
  56820. setDefaultQueryExtent(extent: Vector3): void;
  56821. /**
  56822. * Get the Bounding box extent specified by setDefaultQueryExtent
  56823. * @returns the box extent values
  56824. */
  56825. getDefaultQueryExtent(): Vector3;
  56826. /**
  56827. * Release all resources
  56828. */
  56829. dispose(): void;
  56830. }
  56831. }
  56832. declare module BABYLON {
  56833. /**
  56834. * Class used to enable access to IndexedDB
  56835. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56836. */
  56837. export class Database implements IOfflineProvider {
  56838. private _callbackManifestChecked;
  56839. private _currentSceneUrl;
  56840. private _db;
  56841. private _enableSceneOffline;
  56842. private _enableTexturesOffline;
  56843. private _manifestVersionFound;
  56844. private _mustUpdateRessources;
  56845. private _hasReachedQuota;
  56846. private _isSupported;
  56847. private _idbFactory;
  56848. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56849. private static IsUASupportingBlobStorage;
  56850. /**
  56851. * Gets a boolean indicating if Database storate is enabled (off by default)
  56852. */
  56853. static IDBStorageEnabled: boolean;
  56854. /**
  56855. * Gets a boolean indicating if scene must be saved in the database
  56856. */
  56857. readonly enableSceneOffline: boolean;
  56858. /**
  56859. * Gets a boolean indicating if textures must be saved in the database
  56860. */
  56861. readonly enableTexturesOffline: boolean;
  56862. /**
  56863. * Creates a new Database
  56864. * @param urlToScene defines the url to load the scene
  56865. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56866. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56867. */
  56868. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56869. private static _ParseURL;
  56870. private static _ReturnFullUrlLocation;
  56871. private _checkManifestFile;
  56872. /**
  56873. * Open the database and make it available
  56874. * @param successCallback defines the callback to call on success
  56875. * @param errorCallback defines the callback to call on error
  56876. */
  56877. open(successCallback: () => void, errorCallback: () => void): void;
  56878. /**
  56879. * Loads an image from the database
  56880. * @param url defines the url to load from
  56881. * @param image defines the target DOM image
  56882. */
  56883. loadImage(url: string, image: HTMLImageElement): void;
  56884. private _loadImageFromDBAsync;
  56885. private _saveImageIntoDBAsync;
  56886. private _checkVersionFromDB;
  56887. private _loadVersionFromDBAsync;
  56888. private _saveVersionIntoDBAsync;
  56889. /**
  56890. * Loads a file from database
  56891. * @param url defines the URL to load from
  56892. * @param sceneLoaded defines a callback to call on success
  56893. * @param progressCallBack defines a callback to call when progress changed
  56894. * @param errorCallback defines a callback to call on error
  56895. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56896. */
  56897. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56898. private _loadFileAsync;
  56899. private _saveFileAsync;
  56900. /**
  56901. * Validates if xhr data is correct
  56902. * @param xhr defines the request to validate
  56903. * @param dataType defines the expected data type
  56904. * @returns true if data is correct
  56905. */
  56906. private static _ValidateXHRData;
  56907. }
  56908. }
  56909. declare module BABYLON {
  56910. /** @hidden */
  56911. export var gpuUpdateParticlesPixelShader: {
  56912. name: string;
  56913. shader: string;
  56914. };
  56915. }
  56916. declare module BABYLON {
  56917. /** @hidden */
  56918. export var gpuUpdateParticlesVertexShader: {
  56919. name: string;
  56920. shader: string;
  56921. };
  56922. }
  56923. declare module BABYLON {
  56924. /** @hidden */
  56925. export var clipPlaneFragmentDeclaration2: {
  56926. name: string;
  56927. shader: string;
  56928. };
  56929. }
  56930. declare module BABYLON {
  56931. /** @hidden */
  56932. export var gpuRenderParticlesPixelShader: {
  56933. name: string;
  56934. shader: string;
  56935. };
  56936. }
  56937. declare module BABYLON {
  56938. /** @hidden */
  56939. export var clipPlaneVertexDeclaration2: {
  56940. name: string;
  56941. shader: string;
  56942. };
  56943. }
  56944. declare module BABYLON {
  56945. /** @hidden */
  56946. export var gpuRenderParticlesVertexShader: {
  56947. name: string;
  56948. shader: string;
  56949. };
  56950. }
  56951. declare module BABYLON {
  56952. /**
  56953. * This represents a GPU particle system in Babylon
  56954. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56955. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56956. */
  56957. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56958. /**
  56959. * The layer mask we are rendering the particles through.
  56960. */
  56961. layerMask: number;
  56962. private _capacity;
  56963. private _activeCount;
  56964. private _currentActiveCount;
  56965. private _accumulatedCount;
  56966. private _renderEffect;
  56967. private _updateEffect;
  56968. private _buffer0;
  56969. private _buffer1;
  56970. private _spriteBuffer;
  56971. private _updateVAO;
  56972. private _renderVAO;
  56973. private _targetIndex;
  56974. private _sourceBuffer;
  56975. private _targetBuffer;
  56976. private _engine;
  56977. private _currentRenderId;
  56978. private _started;
  56979. private _stopped;
  56980. private _timeDelta;
  56981. private _randomTexture;
  56982. private _randomTexture2;
  56983. private _attributesStrideSize;
  56984. private _updateEffectOptions;
  56985. private _randomTextureSize;
  56986. private _actualFrame;
  56987. private readonly _rawTextureWidth;
  56988. /**
  56989. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56990. */
  56991. static readonly IsSupported: boolean;
  56992. /**
  56993. * An event triggered when the system is disposed.
  56994. */
  56995. onDisposeObservable: Observable<GPUParticleSystem>;
  56996. /**
  56997. * Gets the maximum number of particles active at the same time.
  56998. * @returns The max number of active particles.
  56999. */
  57000. getCapacity(): number;
  57001. /**
  57002. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57003. * to override the particles.
  57004. */
  57005. forceDepthWrite: boolean;
  57006. /**
  57007. * Gets or set the number of active particles
  57008. */
  57009. activeParticleCount: number;
  57010. private _preWarmDone;
  57011. /**
  57012. * Is this system ready to be used/rendered
  57013. * @return true if the system is ready
  57014. */
  57015. isReady(): boolean;
  57016. /**
  57017. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57018. * @returns True if it has been started, otherwise false.
  57019. */
  57020. isStarted(): boolean;
  57021. /**
  57022. * Starts the particle system and begins to emit
  57023. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57024. */
  57025. start(delay?: number): void;
  57026. /**
  57027. * Stops the particle system.
  57028. */
  57029. stop(): void;
  57030. /**
  57031. * Remove all active particles
  57032. */
  57033. reset(): void;
  57034. /**
  57035. * Returns the string "GPUParticleSystem"
  57036. * @returns a string containing the class name
  57037. */
  57038. getClassName(): string;
  57039. private _colorGradientsTexture;
  57040. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57041. /**
  57042. * Adds a new color gradient
  57043. * @param gradient defines the gradient to use (between 0 and 1)
  57044. * @param color1 defines the color to affect to the specified gradient
  57045. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57046. * @returns the current particle system
  57047. */
  57048. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57049. /**
  57050. * Remove a specific color gradient
  57051. * @param gradient defines the gradient to remove
  57052. * @returns the current particle system
  57053. */
  57054. removeColorGradient(gradient: number): GPUParticleSystem;
  57055. private _angularSpeedGradientsTexture;
  57056. private _sizeGradientsTexture;
  57057. private _velocityGradientsTexture;
  57058. private _limitVelocityGradientsTexture;
  57059. private _dragGradientsTexture;
  57060. private _addFactorGradient;
  57061. /**
  57062. * Adds a new size gradient
  57063. * @param gradient defines the gradient to use (between 0 and 1)
  57064. * @param factor defines the size factor to affect to the specified gradient
  57065. * @returns the current particle system
  57066. */
  57067. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57068. /**
  57069. * Remove a specific size gradient
  57070. * @param gradient defines the gradient to remove
  57071. * @returns the current particle system
  57072. */
  57073. removeSizeGradient(gradient: number): GPUParticleSystem;
  57074. /**
  57075. * Adds a new angular speed gradient
  57076. * @param gradient defines the gradient to use (between 0 and 1)
  57077. * @param factor defines the angular speed to affect to the specified gradient
  57078. * @returns the current particle system
  57079. */
  57080. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57081. /**
  57082. * Remove a specific angular speed gradient
  57083. * @param gradient defines the gradient to remove
  57084. * @returns the current particle system
  57085. */
  57086. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57087. /**
  57088. * Adds a new velocity gradient
  57089. * @param gradient defines the gradient to use (between 0 and 1)
  57090. * @param factor defines the velocity to affect to the specified gradient
  57091. * @returns the current particle system
  57092. */
  57093. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57094. /**
  57095. * Remove a specific velocity gradient
  57096. * @param gradient defines the gradient to remove
  57097. * @returns the current particle system
  57098. */
  57099. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57100. /**
  57101. * Adds a new limit velocity gradient
  57102. * @param gradient defines the gradient to use (between 0 and 1)
  57103. * @param factor defines the limit velocity value to affect to the specified gradient
  57104. * @returns the current particle system
  57105. */
  57106. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57107. /**
  57108. * Remove a specific limit velocity gradient
  57109. * @param gradient defines the gradient to remove
  57110. * @returns the current particle system
  57111. */
  57112. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57113. /**
  57114. * Adds a new drag gradient
  57115. * @param gradient defines the gradient to use (between 0 and 1)
  57116. * @param factor defines the drag value to affect to the specified gradient
  57117. * @returns the current particle system
  57118. */
  57119. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57120. /**
  57121. * Remove a specific drag gradient
  57122. * @param gradient defines the gradient to remove
  57123. * @returns the current particle system
  57124. */
  57125. removeDragGradient(gradient: number): GPUParticleSystem;
  57126. /**
  57127. * Not supported by GPUParticleSystem
  57128. * @param gradient defines the gradient to use (between 0 and 1)
  57129. * @param factor defines the emit rate value to affect to the specified gradient
  57130. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57131. * @returns the current particle system
  57132. */
  57133. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57134. /**
  57135. * Not supported by GPUParticleSystem
  57136. * @param gradient defines the gradient to remove
  57137. * @returns the current particle system
  57138. */
  57139. removeEmitRateGradient(gradient: number): IParticleSystem;
  57140. /**
  57141. * Not supported by GPUParticleSystem
  57142. * @param gradient defines the gradient to use (between 0 and 1)
  57143. * @param factor defines the start size value to affect to the specified gradient
  57144. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57145. * @returns the current particle system
  57146. */
  57147. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57148. /**
  57149. * Not supported by GPUParticleSystem
  57150. * @param gradient defines the gradient to remove
  57151. * @returns the current particle system
  57152. */
  57153. removeStartSizeGradient(gradient: number): IParticleSystem;
  57154. /**
  57155. * Not supported by GPUParticleSystem
  57156. * @param gradient defines the gradient to use (between 0 and 1)
  57157. * @param min defines the color remap minimal range
  57158. * @param max defines the color remap maximal range
  57159. * @returns the current particle system
  57160. */
  57161. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57162. /**
  57163. * Not supported by GPUParticleSystem
  57164. * @param gradient defines the gradient to remove
  57165. * @returns the current particle system
  57166. */
  57167. removeColorRemapGradient(): IParticleSystem;
  57168. /**
  57169. * Not supported by GPUParticleSystem
  57170. * @param gradient defines the gradient to use (between 0 and 1)
  57171. * @param min defines the alpha remap minimal range
  57172. * @param max defines the alpha remap maximal range
  57173. * @returns the current particle system
  57174. */
  57175. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57176. /**
  57177. * Not supported by GPUParticleSystem
  57178. * @param gradient defines the gradient to remove
  57179. * @returns the current particle system
  57180. */
  57181. removeAlphaRemapGradient(): IParticleSystem;
  57182. /**
  57183. * Not supported by GPUParticleSystem
  57184. * @param gradient defines the gradient to use (between 0 and 1)
  57185. * @param color defines the color to affect to the specified gradient
  57186. * @returns the current particle system
  57187. */
  57188. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  57189. /**
  57190. * Not supported by GPUParticleSystem
  57191. * @param gradient defines the gradient to remove
  57192. * @returns the current particle system
  57193. */
  57194. removeRampGradient(): IParticleSystem;
  57195. /**
  57196. * Not supported by GPUParticleSystem
  57197. * @returns the list of ramp gradients
  57198. */
  57199. getRampGradients(): Nullable<Array<Color3Gradient>>;
  57200. /**
  57201. * Not supported by GPUParticleSystem
  57202. * Gets or sets a boolean indicating that ramp gradients must be used
  57203. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  57204. */
  57205. useRampGradients: boolean;
  57206. /**
  57207. * Not supported by GPUParticleSystem
  57208. * @param gradient defines the gradient to use (between 0 and 1)
  57209. * @param factor defines the life time factor to affect to the specified gradient
  57210. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57211. * @returns the current particle system
  57212. */
  57213. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57214. /**
  57215. * Not supported by GPUParticleSystem
  57216. * @param gradient defines the gradient to remove
  57217. * @returns the current particle system
  57218. */
  57219. removeLifeTimeGradient(gradient: number): IParticleSystem;
  57220. /**
  57221. * Instantiates a GPU particle system.
  57222. * 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.
  57223. * @param name The name of the particle system
  57224. * @param options The options used to create the system
  57225. * @param scene The scene the particle system belongs to
  57226. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  57227. */
  57228. constructor(name: string, options: Partial<{
  57229. capacity: number;
  57230. randomTextureSize: number;
  57231. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  57232. protected _reset(): void;
  57233. private _createUpdateVAO;
  57234. private _createRenderVAO;
  57235. private _initialize;
  57236. /** @hidden */
  57237. _recreateUpdateEffect(): void;
  57238. /** @hidden */
  57239. _recreateRenderEffect(): void;
  57240. /**
  57241. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  57242. * @param preWarm defines if we are in the pre-warmimg phase
  57243. */
  57244. animate(preWarm?: boolean): void;
  57245. private _createFactorGradientTexture;
  57246. private _createSizeGradientTexture;
  57247. private _createAngularSpeedGradientTexture;
  57248. private _createVelocityGradientTexture;
  57249. private _createLimitVelocityGradientTexture;
  57250. private _createDragGradientTexture;
  57251. private _createColorGradientTexture;
  57252. /**
  57253. * Renders the particle system in its current state
  57254. * @param preWarm defines if the system should only update the particles but not render them
  57255. * @returns the current number of particles
  57256. */
  57257. render(preWarm?: boolean): number;
  57258. /**
  57259. * Rebuilds the particle system
  57260. */
  57261. rebuild(): void;
  57262. private _releaseBuffers;
  57263. private _releaseVAOs;
  57264. /**
  57265. * Disposes the particle system and free the associated resources
  57266. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  57267. */
  57268. dispose(disposeTexture?: boolean): void;
  57269. /**
  57270. * Clones the particle system.
  57271. * @param name The name of the cloned object
  57272. * @param newEmitter The new emitter to use
  57273. * @returns the cloned particle system
  57274. */
  57275. clone(name: string, newEmitter: any): GPUParticleSystem;
  57276. /**
  57277. * Serializes the particle system to a JSON object.
  57278. * @returns the JSON object
  57279. */
  57280. serialize(): any;
  57281. /**
  57282. * Parses a JSON object to create a GPU particle system.
  57283. * @param parsedParticleSystem The JSON object to parse
  57284. * @param scene The scene to create the particle system in
  57285. * @param rootUrl The root url to use to load external dependencies like texture
  57286. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  57287. * @returns the parsed GPU particle system
  57288. */
  57289. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  57290. }
  57291. }
  57292. declare module BABYLON {
  57293. /**
  57294. * Represents a set of particle systems working together to create a specific effect
  57295. */
  57296. export class ParticleSystemSet implements IDisposable {
  57297. private _emitterCreationOptions;
  57298. private _emitterNode;
  57299. /**
  57300. * Gets the particle system list
  57301. */
  57302. systems: IParticleSystem[];
  57303. /**
  57304. * Gets the emitter node used with this set
  57305. */
  57306. readonly emitterNode: Nullable<TransformNode>;
  57307. /**
  57308. * Creates a new emitter mesh as a sphere
  57309. * @param options defines the options used to create the sphere
  57310. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57311. * @param scene defines the hosting scene
  57312. */
  57313. setEmitterAsSphere(options: {
  57314. diameter: number;
  57315. segments: number;
  57316. color: Color3;
  57317. }, renderingGroupId: number, scene: Scene): void;
  57318. /**
  57319. * Starts all particle systems of the set
  57320. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57321. */
  57322. start(emitter?: AbstractMesh): void;
  57323. /**
  57324. * Release all associated resources
  57325. */
  57326. dispose(): void;
  57327. /**
  57328. * Serialize the set into a JSON compatible object
  57329. * @returns a JSON compatible representation of the set
  57330. */
  57331. serialize(): any;
  57332. /**
  57333. * Parse a new ParticleSystemSet from a serialized source
  57334. * @param data defines a JSON compatible representation of the set
  57335. * @param scene defines the hosting scene
  57336. * @param gpu defines if we want GPU particles or CPU particles
  57337. * @returns a new ParticleSystemSet
  57338. */
  57339. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57340. }
  57341. }
  57342. declare module BABYLON {
  57343. /**
  57344. * This class is made for on one-liner static method to help creating particle system set.
  57345. */
  57346. export class ParticleHelper {
  57347. /**
  57348. * Gets or sets base Assets URL
  57349. */
  57350. static BaseAssetsUrl: string;
  57351. /**
  57352. * Create a default particle system that you can tweak
  57353. * @param emitter defines the emitter to use
  57354. * @param capacity defines the system capacity (default is 500 particles)
  57355. * @param scene defines the hosting scene
  57356. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57357. * @returns the new Particle system
  57358. */
  57359. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57360. /**
  57361. * This is the main static method (one-liner) of this helper to create different particle systems
  57362. * @param type This string represents the type to the particle system to create
  57363. * @param scene The scene where the particle system should live
  57364. * @param gpu If the system will use gpu
  57365. * @returns the ParticleSystemSet created
  57366. */
  57367. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57368. /**
  57369. * Static function used to export a particle system to a ParticleSystemSet variable.
  57370. * Please note that the emitter shape is not exported
  57371. * @param systems defines the particle systems to export
  57372. * @returns the created particle system set
  57373. */
  57374. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57375. }
  57376. }
  57377. declare module BABYLON {
  57378. interface Engine {
  57379. /**
  57380. * Create an effect to use with particle systems.
  57381. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57382. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57383. * @param uniformsNames defines a list of attribute names
  57384. * @param samplers defines an array of string used to represent textures
  57385. * @param defines defines the string containing the defines to use to compile the shaders
  57386. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57387. * @param onCompiled defines a function to call when the effect creation is successful
  57388. * @param onError defines a function to call when the effect creation has failed
  57389. * @returns the new Effect
  57390. */
  57391. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57392. }
  57393. interface Mesh {
  57394. /**
  57395. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57396. * @returns an array of IParticleSystem
  57397. */
  57398. getEmittedParticleSystems(): IParticleSystem[];
  57399. /**
  57400. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57401. * @returns an array of IParticleSystem
  57402. */
  57403. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57404. }
  57405. /**
  57406. * @hidden
  57407. */
  57408. export var _IDoNeedToBeInTheBuild: number;
  57409. }
  57410. declare module BABYLON {
  57411. interface Scene {
  57412. /** @hidden (Backing field) */
  57413. _physicsEngine: Nullable<IPhysicsEngine>;
  57414. /**
  57415. * Gets the current physics engine
  57416. * @returns a IPhysicsEngine or null if none attached
  57417. */
  57418. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57419. /**
  57420. * Enables physics to the current scene
  57421. * @param gravity defines the scene's gravity for the physics engine
  57422. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57423. * @return a boolean indicating if the physics engine was initialized
  57424. */
  57425. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57426. /**
  57427. * Disables and disposes the physics engine associated with the scene
  57428. */
  57429. disablePhysicsEngine(): void;
  57430. /**
  57431. * Gets a boolean indicating if there is an active physics engine
  57432. * @returns a boolean indicating if there is an active physics engine
  57433. */
  57434. isPhysicsEnabled(): boolean;
  57435. /**
  57436. * Deletes a physics compound impostor
  57437. * @param compound defines the compound to delete
  57438. */
  57439. deleteCompoundImpostor(compound: any): void;
  57440. /**
  57441. * An event triggered when physic simulation is about to be run
  57442. */
  57443. onBeforePhysicsObservable: Observable<Scene>;
  57444. /**
  57445. * An event triggered when physic simulation has been done
  57446. */
  57447. onAfterPhysicsObservable: Observable<Scene>;
  57448. }
  57449. interface AbstractMesh {
  57450. /** @hidden */
  57451. _physicsImpostor: Nullable<PhysicsImpostor>;
  57452. /**
  57453. * Gets or sets impostor used for physic simulation
  57454. * @see http://doc.babylonjs.com/features/physics_engine
  57455. */
  57456. physicsImpostor: Nullable<PhysicsImpostor>;
  57457. /**
  57458. * Gets the current physics impostor
  57459. * @see http://doc.babylonjs.com/features/physics_engine
  57460. * @returns a physics impostor or null
  57461. */
  57462. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57463. /** Apply a physic impulse to the mesh
  57464. * @param force defines the force to apply
  57465. * @param contactPoint defines where to apply the force
  57466. * @returns the current mesh
  57467. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57468. */
  57469. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57470. /**
  57471. * Creates a physic joint between two meshes
  57472. * @param otherMesh defines the other mesh to use
  57473. * @param pivot1 defines the pivot to use on this mesh
  57474. * @param pivot2 defines the pivot to use on the other mesh
  57475. * @param options defines additional options (can be plugin dependent)
  57476. * @returns the current mesh
  57477. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57478. */
  57479. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57480. /** @hidden */
  57481. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57482. }
  57483. /**
  57484. * Defines the physics engine scene component responsible to manage a physics engine
  57485. */
  57486. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57487. /**
  57488. * The component name helpful to identify the component in the list of scene components.
  57489. */
  57490. readonly name: string;
  57491. /**
  57492. * The scene the component belongs to.
  57493. */
  57494. scene: Scene;
  57495. /**
  57496. * Creates a new instance of the component for the given scene
  57497. * @param scene Defines the scene to register the component in
  57498. */
  57499. constructor(scene: Scene);
  57500. /**
  57501. * Registers the component in a given scene
  57502. */
  57503. register(): void;
  57504. /**
  57505. * Rebuilds the elements related to this component in case of
  57506. * context lost for instance.
  57507. */
  57508. rebuild(): void;
  57509. /**
  57510. * Disposes the component and the associated ressources
  57511. */
  57512. dispose(): void;
  57513. }
  57514. }
  57515. declare module BABYLON {
  57516. /**
  57517. * A helper for physics simulations
  57518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57519. */
  57520. export class PhysicsHelper {
  57521. private _scene;
  57522. private _physicsEngine;
  57523. /**
  57524. * Initializes the Physics helper
  57525. * @param scene Babylon.js scene
  57526. */
  57527. constructor(scene: Scene);
  57528. /**
  57529. * Applies a radial explosion impulse
  57530. * @param origin the origin of the explosion
  57531. * @param radiusOrEventOptions the radius or the options of radial explosion
  57532. * @param strength the explosion strength
  57533. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57534. * @returns A physics radial explosion event, or null
  57535. */
  57536. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57537. /**
  57538. * Applies a radial explosion force
  57539. * @param origin the origin of the explosion
  57540. * @param radiusOrEventOptions the radius or the options of radial explosion
  57541. * @param strength the explosion strength
  57542. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57543. * @returns A physics radial explosion event, or null
  57544. */
  57545. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57546. /**
  57547. * Creates a gravitational field
  57548. * @param origin the origin of the explosion
  57549. * @param radiusOrEventOptions the radius or the options of radial explosion
  57550. * @param strength the explosion strength
  57551. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57552. * @returns A physics gravitational field event, or null
  57553. */
  57554. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57555. /**
  57556. * Creates a physics updraft event
  57557. * @param origin the origin of the updraft
  57558. * @param radiusOrEventOptions the radius or the options of the updraft
  57559. * @param strength the strength of the updraft
  57560. * @param height the height of the updraft
  57561. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57562. * @returns A physics updraft event, or null
  57563. */
  57564. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57565. /**
  57566. * Creates a physics vortex event
  57567. * @param origin the of the vortex
  57568. * @param radiusOrEventOptions the radius or the options of the vortex
  57569. * @param strength the strength of the vortex
  57570. * @param height the height of the vortex
  57571. * @returns a Physics vortex event, or null
  57572. * A physics vortex event or null
  57573. */
  57574. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57575. }
  57576. /**
  57577. * Represents a physics radial explosion event
  57578. */
  57579. class PhysicsRadialExplosionEvent {
  57580. private _scene;
  57581. private _options;
  57582. private _sphere;
  57583. private _dataFetched;
  57584. /**
  57585. * Initializes a radial explosioin event
  57586. * @param _scene BabylonJS scene
  57587. * @param _options The options for the vortex event
  57588. */
  57589. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57590. /**
  57591. * Returns the data related to the radial explosion event (sphere).
  57592. * @returns The radial explosion event data
  57593. */
  57594. getData(): PhysicsRadialExplosionEventData;
  57595. /**
  57596. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57597. * @param impostor A physics imposter
  57598. * @param origin the origin of the explosion
  57599. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57600. */
  57601. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57602. /**
  57603. * Triggers affecterd impostors callbacks
  57604. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57605. */
  57606. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57607. /**
  57608. * Disposes the sphere.
  57609. * @param force Specifies if the sphere should be disposed by force
  57610. */
  57611. dispose(force?: boolean): void;
  57612. /*** Helpers ***/
  57613. private _prepareSphere;
  57614. private _intersectsWithSphere;
  57615. }
  57616. /**
  57617. * Represents a gravitational field event
  57618. */
  57619. class PhysicsGravitationalFieldEvent {
  57620. private _physicsHelper;
  57621. private _scene;
  57622. private _origin;
  57623. private _options;
  57624. private _tickCallback;
  57625. private _sphere;
  57626. private _dataFetched;
  57627. /**
  57628. * Initializes the physics gravitational field event
  57629. * @param _physicsHelper A physics helper
  57630. * @param _scene BabylonJS scene
  57631. * @param _origin The origin position of the gravitational field event
  57632. * @param _options The options for the vortex event
  57633. */
  57634. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57635. /**
  57636. * Returns the data related to the gravitational field event (sphere).
  57637. * @returns A gravitational field event
  57638. */
  57639. getData(): PhysicsGravitationalFieldEventData;
  57640. /**
  57641. * Enables the gravitational field.
  57642. */
  57643. enable(): void;
  57644. /**
  57645. * Disables the gravitational field.
  57646. */
  57647. disable(): void;
  57648. /**
  57649. * Disposes the sphere.
  57650. * @param force The force to dispose from the gravitational field event
  57651. */
  57652. dispose(force?: boolean): void;
  57653. private _tick;
  57654. }
  57655. /**
  57656. * Represents a physics updraft event
  57657. */
  57658. class PhysicsUpdraftEvent {
  57659. private _scene;
  57660. private _origin;
  57661. private _options;
  57662. private _physicsEngine;
  57663. private _originTop;
  57664. private _originDirection;
  57665. private _tickCallback;
  57666. private _cylinder;
  57667. private _cylinderPosition;
  57668. private _dataFetched;
  57669. /**
  57670. * Initializes the physics updraft event
  57671. * @param _scene BabylonJS scene
  57672. * @param _origin The origin position of the updraft
  57673. * @param _options The options for the updraft event
  57674. */
  57675. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57676. /**
  57677. * Returns the data related to the updraft event (cylinder).
  57678. * @returns A physics updraft event
  57679. */
  57680. getData(): PhysicsUpdraftEventData;
  57681. /**
  57682. * Enables the updraft.
  57683. */
  57684. enable(): void;
  57685. /**
  57686. * Disables the updraft.
  57687. */
  57688. disable(): void;
  57689. /**
  57690. * Disposes the cylinder.
  57691. * @param force Specifies if the updraft should be disposed by force
  57692. */
  57693. dispose(force?: boolean): void;
  57694. private getImpostorHitData;
  57695. private _tick;
  57696. /*** Helpers ***/
  57697. private _prepareCylinder;
  57698. private _intersectsWithCylinder;
  57699. }
  57700. /**
  57701. * Represents a physics vortex event
  57702. */
  57703. class PhysicsVortexEvent {
  57704. private _scene;
  57705. private _origin;
  57706. private _options;
  57707. private _physicsEngine;
  57708. private _originTop;
  57709. private _tickCallback;
  57710. private _cylinder;
  57711. private _cylinderPosition;
  57712. private _dataFetched;
  57713. /**
  57714. * Initializes the physics vortex event
  57715. * @param _scene The BabylonJS scene
  57716. * @param _origin The origin position of the vortex
  57717. * @param _options The options for the vortex event
  57718. */
  57719. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57720. /**
  57721. * Returns the data related to the vortex event (cylinder).
  57722. * @returns The physics vortex event data
  57723. */
  57724. getData(): PhysicsVortexEventData;
  57725. /**
  57726. * Enables the vortex.
  57727. */
  57728. enable(): void;
  57729. /**
  57730. * Disables the cortex.
  57731. */
  57732. disable(): void;
  57733. /**
  57734. * Disposes the sphere.
  57735. * @param force
  57736. */
  57737. dispose(force?: boolean): void;
  57738. private getImpostorHitData;
  57739. private _tick;
  57740. /*** Helpers ***/
  57741. private _prepareCylinder;
  57742. private _intersectsWithCylinder;
  57743. }
  57744. /**
  57745. * Options fot the radial explosion event
  57746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57747. */
  57748. export class PhysicsRadialExplosionEventOptions {
  57749. /**
  57750. * The radius of the sphere for the radial explosion.
  57751. */
  57752. radius: number;
  57753. /**
  57754. * The strenth of the explosion.
  57755. */
  57756. strength: number;
  57757. /**
  57758. * The strenght of the force in correspondence to the distance of the affected object
  57759. */
  57760. falloff: PhysicsRadialImpulseFalloff;
  57761. /**
  57762. * Sphere options for the radial explosion.
  57763. */
  57764. sphere: {
  57765. segments: number;
  57766. diameter: number;
  57767. };
  57768. /**
  57769. * Sphere options for the radial explosion.
  57770. */
  57771. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57772. }
  57773. /**
  57774. * Options fot the updraft event
  57775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57776. */
  57777. export class PhysicsUpdraftEventOptions {
  57778. /**
  57779. * The radius of the cylinder for the vortex
  57780. */
  57781. radius: number;
  57782. /**
  57783. * The strenth of the updraft.
  57784. */
  57785. strength: number;
  57786. /**
  57787. * The height of the cylinder for the updraft.
  57788. */
  57789. height: number;
  57790. /**
  57791. * The mode for the the updraft.
  57792. */
  57793. updraftMode: PhysicsUpdraftMode;
  57794. }
  57795. /**
  57796. * Options fot the vortex event
  57797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57798. */
  57799. export class PhysicsVortexEventOptions {
  57800. /**
  57801. * The radius of the cylinder for the vortex
  57802. */
  57803. radius: number;
  57804. /**
  57805. * The strenth of the vortex.
  57806. */
  57807. strength: number;
  57808. /**
  57809. * The height of the cylinder for the vortex.
  57810. */
  57811. height: number;
  57812. /**
  57813. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57814. */
  57815. centripetalForceThreshold: number;
  57816. /**
  57817. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57818. */
  57819. centripetalForceMultiplier: number;
  57820. /**
  57821. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57822. */
  57823. centrifugalForceMultiplier: number;
  57824. /**
  57825. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57826. */
  57827. updraftForceMultiplier: number;
  57828. }
  57829. /**
  57830. * The strenght of the force in correspondence to the distance of the affected object
  57831. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57832. */
  57833. export enum PhysicsRadialImpulseFalloff {
  57834. /** Defines that impulse is constant in strength across it's whole radius */
  57835. Constant = 0,
  57836. /** Defines that impulse gets weaker if it's further from the origin */
  57837. Linear = 1
  57838. }
  57839. /**
  57840. * The strength of the force in correspondence to the distance of the affected object
  57841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57842. */
  57843. export enum PhysicsUpdraftMode {
  57844. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57845. Center = 0,
  57846. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57847. Perpendicular = 1
  57848. }
  57849. /**
  57850. * Interface for a physics hit data
  57851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57852. */
  57853. export interface PhysicsHitData {
  57854. /**
  57855. * The force applied at the contact point
  57856. */
  57857. force: Vector3;
  57858. /**
  57859. * The contact point
  57860. */
  57861. contactPoint: Vector3;
  57862. /**
  57863. * The distance from the origin to the contact point
  57864. */
  57865. distanceFromOrigin: number;
  57866. }
  57867. /**
  57868. * Interface for radial explosion event data
  57869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57870. */
  57871. export interface PhysicsRadialExplosionEventData {
  57872. /**
  57873. * A sphere used for the radial explosion event
  57874. */
  57875. sphere: Mesh;
  57876. }
  57877. /**
  57878. * Interface for gravitational field event data
  57879. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57880. */
  57881. export interface PhysicsGravitationalFieldEventData {
  57882. /**
  57883. * A sphere mesh used for the gravitational field event
  57884. */
  57885. sphere: Mesh;
  57886. }
  57887. /**
  57888. * Interface for updraft event data
  57889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57890. */
  57891. export interface PhysicsUpdraftEventData {
  57892. /**
  57893. * A cylinder used for the updraft event
  57894. */
  57895. cylinder: Mesh;
  57896. }
  57897. /**
  57898. * Interface for vortex event data
  57899. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57900. */
  57901. export interface PhysicsVortexEventData {
  57902. /**
  57903. * A cylinder used for the vortex event
  57904. */
  57905. cylinder: Mesh;
  57906. }
  57907. /**
  57908. * Interface for an affected physics impostor
  57909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57910. */
  57911. export interface PhysicsAffectedImpostorWithData {
  57912. /**
  57913. * The impostor affected by the effect
  57914. */
  57915. impostor: PhysicsImpostor;
  57916. /**
  57917. * The data about the hit/horce from the explosion
  57918. */
  57919. hitData: PhysicsHitData;
  57920. }
  57921. }
  57922. declare module BABYLON {
  57923. /** @hidden */
  57924. export var blackAndWhitePixelShader: {
  57925. name: string;
  57926. shader: string;
  57927. };
  57928. }
  57929. declare module BABYLON {
  57930. /**
  57931. * Post process used to render in black and white
  57932. */
  57933. export class BlackAndWhitePostProcess extends PostProcess {
  57934. /**
  57935. * Linear about to convert he result to black and white (default: 1)
  57936. */
  57937. degree: number;
  57938. /**
  57939. * Creates a black and white post process
  57940. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57941. * @param name The name of the effect.
  57942. * @param options The required width/height ratio to downsize to before computing the render pass.
  57943. * @param camera The camera to apply the render pass to.
  57944. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57945. * @param engine The engine which the post process will be applied. (default: current engine)
  57946. * @param reusable If the post process can be reused on the same frame. (default: false)
  57947. */
  57948. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57949. }
  57950. }
  57951. declare module BABYLON {
  57952. /**
  57953. * This represents a set of one or more post processes in Babylon.
  57954. * A post process can be used to apply a shader to a texture after it is rendered.
  57955. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57956. */
  57957. export class PostProcessRenderEffect {
  57958. private _postProcesses;
  57959. private _getPostProcesses;
  57960. private _singleInstance;
  57961. private _cameras;
  57962. private _indicesForCamera;
  57963. /**
  57964. * Name of the effect
  57965. * @hidden
  57966. */
  57967. _name: string;
  57968. /**
  57969. * Instantiates a post process render effect.
  57970. * A post process can be used to apply a shader to a texture after it is rendered.
  57971. * @param engine The engine the effect is tied to
  57972. * @param name The name of the effect
  57973. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57974. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57975. */
  57976. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57977. /**
  57978. * Checks if all the post processes in the effect are supported.
  57979. */
  57980. readonly isSupported: boolean;
  57981. /**
  57982. * Updates the current state of the effect
  57983. * @hidden
  57984. */
  57985. _update(): void;
  57986. /**
  57987. * Attaches the effect on cameras
  57988. * @param cameras The camera to attach to.
  57989. * @hidden
  57990. */
  57991. _attachCameras(cameras: Camera): void;
  57992. /**
  57993. * Attaches the effect on cameras
  57994. * @param cameras The camera to attach to.
  57995. * @hidden
  57996. */
  57997. _attachCameras(cameras: Camera[]): void;
  57998. /**
  57999. * Detaches the effect on cameras
  58000. * @param cameras The camera to detatch from.
  58001. * @hidden
  58002. */
  58003. _detachCameras(cameras: Camera): void;
  58004. /**
  58005. * Detatches the effect on cameras
  58006. * @param cameras The camera to detatch from.
  58007. * @hidden
  58008. */
  58009. _detachCameras(cameras: Camera[]): void;
  58010. /**
  58011. * Enables the effect on given cameras
  58012. * @param cameras The camera to enable.
  58013. * @hidden
  58014. */
  58015. _enable(cameras: Camera): void;
  58016. /**
  58017. * Enables the effect on given cameras
  58018. * @param cameras The camera to enable.
  58019. * @hidden
  58020. */
  58021. _enable(cameras: Nullable<Camera[]>): void;
  58022. /**
  58023. * Disables the effect on the given cameras
  58024. * @param cameras The camera to disable.
  58025. * @hidden
  58026. */
  58027. _disable(cameras: Camera): void;
  58028. /**
  58029. * Disables the effect on the given cameras
  58030. * @param cameras The camera to disable.
  58031. * @hidden
  58032. */
  58033. _disable(cameras: Nullable<Camera[]>): void;
  58034. /**
  58035. * Gets a list of the post processes contained in the effect.
  58036. * @param camera The camera to get the post processes on.
  58037. * @returns The list of the post processes in the effect.
  58038. */
  58039. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  58040. }
  58041. }
  58042. declare module BABYLON {
  58043. /** @hidden */
  58044. export var extractHighlightsPixelShader: {
  58045. name: string;
  58046. shader: string;
  58047. };
  58048. }
  58049. declare module BABYLON {
  58050. /**
  58051. * 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.
  58052. */
  58053. export class ExtractHighlightsPostProcess extends PostProcess {
  58054. /**
  58055. * The luminance threshold, pixels below this value will be set to black.
  58056. */
  58057. threshold: number;
  58058. /** @hidden */
  58059. _exposure: number;
  58060. /**
  58061. * Post process which has the input texture to be used when performing highlight extraction
  58062. * @hidden
  58063. */
  58064. _inputPostProcess: Nullable<PostProcess>;
  58065. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58066. }
  58067. }
  58068. declare module BABYLON {
  58069. /** @hidden */
  58070. export var bloomMergePixelShader: {
  58071. name: string;
  58072. shader: string;
  58073. };
  58074. }
  58075. declare module BABYLON {
  58076. /**
  58077. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58078. */
  58079. export class BloomMergePostProcess extends PostProcess {
  58080. /** Weight of the bloom to be added to the original input. */
  58081. weight: number;
  58082. /**
  58083. * Creates a new instance of @see BloomMergePostProcess
  58084. * @param name The name of the effect.
  58085. * @param originalFromInput Post process which's input will be used for the merge.
  58086. * @param blurred Blurred highlights post process which's output will be used.
  58087. * @param weight Weight of the bloom to be added to the original input.
  58088. * @param options The required width/height ratio to downsize to before computing the render pass.
  58089. * @param camera The camera to apply the render pass to.
  58090. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58091. * @param engine The engine which the post process will be applied. (default: current engine)
  58092. * @param reusable If the post process can be reused on the same frame. (default: false)
  58093. * @param textureType Type of textures used when performing the post process. (default: 0)
  58094. * @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)
  58095. */
  58096. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  58097. /** Weight of the bloom to be added to the original input. */
  58098. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58099. }
  58100. }
  58101. declare module BABYLON {
  58102. /**
  58103. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  58104. */
  58105. export class BloomEffect extends PostProcessRenderEffect {
  58106. private bloomScale;
  58107. /**
  58108. * @hidden Internal
  58109. */
  58110. _effects: Array<PostProcess>;
  58111. /**
  58112. * @hidden Internal
  58113. */
  58114. _downscale: ExtractHighlightsPostProcess;
  58115. private _blurX;
  58116. private _blurY;
  58117. private _merge;
  58118. /**
  58119. * The luminance threshold to find bright areas of the image to bloom.
  58120. */
  58121. threshold: number;
  58122. /**
  58123. * The strength of the bloom.
  58124. */
  58125. weight: number;
  58126. /**
  58127. * Specifies the size of the bloom blur kernel, relative to the final output size
  58128. */
  58129. kernel: number;
  58130. /**
  58131. * Creates a new instance of @see BloomEffect
  58132. * @param scene The scene the effect belongs to.
  58133. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  58134. * @param bloomKernel The size of the kernel to be used when applying the blur.
  58135. * @param bloomWeight The the strength of bloom.
  58136. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58137. * @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)
  58138. */
  58139. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  58140. /**
  58141. * Disposes each of the internal effects for a given camera.
  58142. * @param camera The camera to dispose the effect on.
  58143. */
  58144. disposeEffects(camera: Camera): void;
  58145. /**
  58146. * @hidden Internal
  58147. */
  58148. _updateEffects(): void;
  58149. /**
  58150. * Internal
  58151. * @returns if all the contained post processes are ready.
  58152. * @hidden
  58153. */
  58154. _isReady(): boolean;
  58155. }
  58156. }
  58157. declare module BABYLON {
  58158. /** @hidden */
  58159. export var chromaticAberrationPixelShader: {
  58160. name: string;
  58161. shader: string;
  58162. };
  58163. }
  58164. declare module BABYLON {
  58165. /**
  58166. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58167. */
  58168. export class ChromaticAberrationPostProcess extends PostProcess {
  58169. /**
  58170. * The amount of seperation of rgb channels (default: 30)
  58171. */
  58172. aberrationAmount: number;
  58173. /**
  58174. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58175. */
  58176. radialIntensity: number;
  58177. /**
  58178. * 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))
  58179. */
  58180. direction: Vector2;
  58181. /**
  58182. * 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))
  58183. */
  58184. centerPosition: Vector2;
  58185. /**
  58186. * Creates a new instance ChromaticAberrationPostProcess
  58187. * @param name The name of the effect.
  58188. * @param screenWidth The width of the screen to apply the effect on.
  58189. * @param screenHeight The height of the screen to apply the effect on.
  58190. * @param options The required width/height ratio to downsize to before computing the render pass.
  58191. * @param camera The camera to apply the render pass to.
  58192. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58193. * @param engine The engine which the post process will be applied. (default: current engine)
  58194. * @param reusable If the post process can be reused on the same frame. (default: false)
  58195. * @param textureType Type of textures used when performing the post process. (default: 0)
  58196. * @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)
  58197. */
  58198. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58199. }
  58200. }
  58201. declare module BABYLON {
  58202. /** @hidden */
  58203. export var circleOfConfusionPixelShader: {
  58204. name: string;
  58205. shader: string;
  58206. };
  58207. }
  58208. declare module BABYLON {
  58209. /**
  58210. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  58211. */
  58212. export class CircleOfConfusionPostProcess extends PostProcess {
  58213. /**
  58214. * 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.
  58215. */
  58216. lensSize: number;
  58217. /**
  58218. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58219. */
  58220. fStop: number;
  58221. /**
  58222. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58223. */
  58224. focusDistance: number;
  58225. /**
  58226. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58227. */
  58228. focalLength: number;
  58229. private _depthTexture;
  58230. /**
  58231. * Creates a new instance CircleOfConfusionPostProcess
  58232. * @param name The name of the effect.
  58233. * @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.
  58234. * @param options The required width/height ratio to downsize to before computing the render pass.
  58235. * @param camera The camera to apply the render pass to.
  58236. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58237. * @param engine The engine which the post process will be applied. (default: current engine)
  58238. * @param reusable If the post process can be reused on the same frame. (default: false)
  58239. * @param textureType Type of textures used when performing the post process. (default: 0)
  58240. * @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)
  58241. */
  58242. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58243. /**
  58244. * 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.
  58245. */
  58246. depthTexture: RenderTargetTexture;
  58247. }
  58248. }
  58249. declare module BABYLON {
  58250. /** @hidden */
  58251. export var colorCorrectionPixelShader: {
  58252. name: string;
  58253. shader: string;
  58254. };
  58255. }
  58256. declare module BABYLON {
  58257. /**
  58258. *
  58259. * This post-process allows the modification of rendered colors by using
  58260. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58261. *
  58262. * The object needs to be provided an url to a texture containing the color
  58263. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58264. * Use an image editing software to tweak the LUT to match your needs.
  58265. *
  58266. * For an example of a color LUT, see here:
  58267. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58268. * For explanations on color grading, see here:
  58269. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58270. *
  58271. */
  58272. export class ColorCorrectionPostProcess extends PostProcess {
  58273. private _colorTableTexture;
  58274. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58275. }
  58276. }
  58277. declare module BABYLON {
  58278. /** @hidden */
  58279. export var convolutionPixelShader: {
  58280. name: string;
  58281. shader: string;
  58282. };
  58283. }
  58284. declare module BABYLON {
  58285. /**
  58286. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58287. * input texture to perform effects such as edge detection or sharpening
  58288. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58289. */
  58290. export class ConvolutionPostProcess extends PostProcess {
  58291. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58292. kernel: number[];
  58293. /**
  58294. * Creates a new instance ConvolutionPostProcess
  58295. * @param name The name of the effect.
  58296. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58297. * @param options The required width/height ratio to downsize to before computing the render pass.
  58298. * @param camera The camera to apply the render pass to.
  58299. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58300. * @param engine The engine which the post process will be applied. (default: current engine)
  58301. * @param reusable If the post process can be reused on the same frame. (default: false)
  58302. * @param textureType Type of textures used when performing the post process. (default: 0)
  58303. */
  58304. constructor(name: string,
  58305. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58306. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58307. /**
  58308. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58309. */
  58310. static EdgeDetect0Kernel: number[];
  58311. /**
  58312. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58313. */
  58314. static EdgeDetect1Kernel: number[];
  58315. /**
  58316. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58317. */
  58318. static EdgeDetect2Kernel: number[];
  58319. /**
  58320. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58321. */
  58322. static SharpenKernel: number[];
  58323. /**
  58324. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58325. */
  58326. static EmbossKernel: number[];
  58327. /**
  58328. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58329. */
  58330. static GaussianKernel: number[];
  58331. }
  58332. }
  58333. declare module BABYLON {
  58334. /**
  58335. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58336. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58337. * based on samples that have a large difference in distance than the center pixel.
  58338. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58339. */
  58340. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58341. direction: Vector2;
  58342. /**
  58343. * Creates a new instance CircleOfConfusionPostProcess
  58344. * @param name The name of the effect.
  58345. * @param scene The scene the effect belongs to.
  58346. * @param direction The direction the blur should be applied.
  58347. * @param kernel The size of the kernel used to blur.
  58348. * @param options The required width/height ratio to downsize to before computing the render pass.
  58349. * @param camera The camera to apply the render pass to.
  58350. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58351. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58353. * @param engine The engine which the post process will be applied. (default: current engine)
  58354. * @param reusable If the post process can be reused on the same frame. (default: false)
  58355. * @param textureType Type of textures used when performing the post process. (default: 0)
  58356. * @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)
  58357. */
  58358. 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);
  58359. }
  58360. }
  58361. declare module BABYLON {
  58362. /** @hidden */
  58363. export var depthOfFieldMergePixelShader: {
  58364. name: string;
  58365. shader: string;
  58366. };
  58367. }
  58368. declare module BABYLON {
  58369. /**
  58370. * Options to be set when merging outputs from the default pipeline.
  58371. */
  58372. export class DepthOfFieldMergePostProcessOptions {
  58373. /**
  58374. * The original image to merge on top of
  58375. */
  58376. originalFromInput: PostProcess;
  58377. /**
  58378. * Parameters to perform the merge of the depth of field effect
  58379. */
  58380. depthOfField?: {
  58381. circleOfConfusion: PostProcess;
  58382. blurSteps: Array<PostProcess>;
  58383. };
  58384. /**
  58385. * Parameters to perform the merge of bloom effect
  58386. */
  58387. bloom?: {
  58388. blurred: PostProcess;
  58389. weight: number;
  58390. };
  58391. }
  58392. /**
  58393. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58394. */
  58395. export class DepthOfFieldMergePostProcess extends PostProcess {
  58396. private blurSteps;
  58397. /**
  58398. * Creates a new instance of DepthOfFieldMergePostProcess
  58399. * @param name The name of the effect.
  58400. * @param originalFromInput Post process which's input will be used for the merge.
  58401. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58402. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58403. * @param options The required width/height ratio to downsize to before computing the render pass.
  58404. * @param camera The camera to apply the render pass to.
  58405. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58406. * @param engine The engine which the post process will be applied. (default: current engine)
  58407. * @param reusable If the post process can be reused on the same frame. (default: false)
  58408. * @param textureType Type of textures used when performing the post process. (default: 0)
  58409. * @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)
  58410. */
  58411. 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);
  58412. /**
  58413. * Updates the effect with the current post process compile time values and recompiles the shader.
  58414. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58415. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58416. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58417. * @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
  58418. * @param onCompiled Called when the shader has been compiled.
  58419. * @param onError Called if there is an error when compiling a shader.
  58420. */
  58421. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58422. }
  58423. }
  58424. declare module BABYLON {
  58425. /**
  58426. * Specifies the level of max blur that should be applied when using the depth of field effect
  58427. */
  58428. export enum DepthOfFieldEffectBlurLevel {
  58429. /**
  58430. * Subtle blur
  58431. */
  58432. Low = 0,
  58433. /**
  58434. * Medium blur
  58435. */
  58436. Medium = 1,
  58437. /**
  58438. * Large blur
  58439. */
  58440. High = 2
  58441. }
  58442. /**
  58443. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58444. */
  58445. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58446. private _circleOfConfusion;
  58447. /**
  58448. * @hidden Internal, blurs from high to low
  58449. */
  58450. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58451. private _depthOfFieldBlurY;
  58452. private _dofMerge;
  58453. /**
  58454. * @hidden Internal post processes in depth of field effect
  58455. */
  58456. _effects: Array<PostProcess>;
  58457. /**
  58458. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58459. */
  58460. focalLength: number;
  58461. /**
  58462. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58463. */
  58464. fStop: number;
  58465. /**
  58466. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58467. */
  58468. focusDistance: number;
  58469. /**
  58470. * 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.
  58471. */
  58472. lensSize: number;
  58473. /**
  58474. * Creates a new instance DepthOfFieldEffect
  58475. * @param scene The scene the effect belongs to.
  58476. * @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.
  58477. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58478. * @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)
  58479. */
  58480. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58481. /**
  58482. * Get the current class name of the current effet
  58483. * @returns "DepthOfFieldEffect"
  58484. */
  58485. getClassName(): string;
  58486. /**
  58487. * 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.
  58488. */
  58489. depthTexture: RenderTargetTexture;
  58490. /**
  58491. * Disposes each of the internal effects for a given camera.
  58492. * @param camera The camera to dispose the effect on.
  58493. */
  58494. disposeEffects(camera: Camera): void;
  58495. /**
  58496. * @hidden Internal
  58497. */
  58498. _updateEffects(): void;
  58499. /**
  58500. * Internal
  58501. * @returns if all the contained post processes are ready.
  58502. * @hidden
  58503. */
  58504. _isReady(): boolean;
  58505. }
  58506. }
  58507. declare module BABYLON {
  58508. /** @hidden */
  58509. export var displayPassPixelShader: {
  58510. name: string;
  58511. shader: string;
  58512. };
  58513. }
  58514. declare module BABYLON {
  58515. /**
  58516. * DisplayPassPostProcess which produces an output the same as it's input
  58517. */
  58518. export class DisplayPassPostProcess extends PostProcess {
  58519. /**
  58520. * Creates the DisplayPassPostProcess
  58521. * @param name The name of the effect.
  58522. * @param options The required width/height ratio to downsize to before computing the render pass.
  58523. * @param camera The camera to apply the render pass to.
  58524. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58525. * @param engine The engine which the post process will be applied. (default: current engine)
  58526. * @param reusable If the post process can be reused on the same frame. (default: false)
  58527. */
  58528. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58529. }
  58530. }
  58531. declare module BABYLON {
  58532. /** @hidden */
  58533. export var filterPixelShader: {
  58534. name: string;
  58535. shader: string;
  58536. };
  58537. }
  58538. declare module BABYLON {
  58539. /**
  58540. * Applies a kernel filter to the image
  58541. */
  58542. export class FilterPostProcess extends PostProcess {
  58543. /** The matrix to be applied to the image */
  58544. kernelMatrix: Matrix;
  58545. /**
  58546. *
  58547. * @param name The name of the effect.
  58548. * @param kernelMatrix The matrix to be applied to the image
  58549. * @param options The required width/height ratio to downsize to before computing the render pass.
  58550. * @param camera The camera to apply the render pass to.
  58551. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58552. * @param engine The engine which the post process will be applied. (default: current engine)
  58553. * @param reusable If the post process can be reused on the same frame. (default: false)
  58554. */
  58555. constructor(name: string,
  58556. /** The matrix to be applied to the image */
  58557. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58558. }
  58559. }
  58560. declare module BABYLON {
  58561. /** @hidden */
  58562. export var fxaaPixelShader: {
  58563. name: string;
  58564. shader: string;
  58565. };
  58566. }
  58567. declare module BABYLON {
  58568. /** @hidden */
  58569. export var fxaaVertexShader: {
  58570. name: string;
  58571. shader: string;
  58572. };
  58573. }
  58574. declare module BABYLON {
  58575. /**
  58576. * Fxaa post process
  58577. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58578. */
  58579. export class FxaaPostProcess extends PostProcess {
  58580. /** @hidden */
  58581. texelWidth: number;
  58582. /** @hidden */
  58583. texelHeight: number;
  58584. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58585. private _getDefines;
  58586. }
  58587. }
  58588. declare module BABYLON {
  58589. /** @hidden */
  58590. export var grainPixelShader: {
  58591. name: string;
  58592. shader: string;
  58593. };
  58594. }
  58595. declare module BABYLON {
  58596. /**
  58597. * The GrainPostProcess adds noise to the image at mid luminance levels
  58598. */
  58599. export class GrainPostProcess extends PostProcess {
  58600. /**
  58601. * The intensity of the grain added (default: 30)
  58602. */
  58603. intensity: number;
  58604. /**
  58605. * If the grain should be randomized on every frame
  58606. */
  58607. animated: boolean;
  58608. /**
  58609. * Creates a new instance of @see GrainPostProcess
  58610. * @param name The name of the effect.
  58611. * @param options The required width/height ratio to downsize to before computing the render pass.
  58612. * @param camera The camera to apply the render pass to.
  58613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58614. * @param engine The engine which the post process will be applied. (default: current engine)
  58615. * @param reusable If the post process can be reused on the same frame. (default: false)
  58616. * @param textureType Type of textures used when performing the post process. (default: 0)
  58617. * @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)
  58618. */
  58619. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58620. }
  58621. }
  58622. declare module BABYLON {
  58623. /** @hidden */
  58624. export var highlightsPixelShader: {
  58625. name: string;
  58626. shader: string;
  58627. };
  58628. }
  58629. declare module BABYLON {
  58630. /**
  58631. * Extracts highlights from the image
  58632. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58633. */
  58634. export class HighlightsPostProcess extends PostProcess {
  58635. /**
  58636. * Extracts highlights from the image
  58637. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58638. * @param name The name of the effect.
  58639. * @param options The required width/height ratio to downsize to before computing the render pass.
  58640. * @param camera The camera to apply the render pass to.
  58641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58642. * @param engine The engine which the post process will be applied. (default: current engine)
  58643. * @param reusable If the post process can be reused on the same frame. (default: false)
  58644. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58645. */
  58646. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58647. }
  58648. }
  58649. declare module BABYLON {
  58650. /** @hidden */
  58651. export var mrtFragmentDeclaration: {
  58652. name: string;
  58653. shader: string;
  58654. };
  58655. }
  58656. declare module BABYLON {
  58657. /** @hidden */
  58658. export var geometryPixelShader: {
  58659. name: string;
  58660. shader: string;
  58661. };
  58662. }
  58663. declare module BABYLON {
  58664. /** @hidden */
  58665. export var geometryVertexShader: {
  58666. name: string;
  58667. shader: string;
  58668. };
  58669. }
  58670. declare module BABYLON {
  58671. /** @hidden */
  58672. interface ISavedTransformationMatrix {
  58673. world: Matrix;
  58674. viewProjection: Matrix;
  58675. }
  58676. /**
  58677. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58678. */
  58679. export class GeometryBufferRenderer {
  58680. /**
  58681. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58682. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58683. */
  58684. static readonly POSITION_TEXTURE_TYPE: number;
  58685. /**
  58686. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58687. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58688. */
  58689. static readonly VELOCITY_TEXTURE_TYPE: number;
  58690. /**
  58691. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58692. * in order to compute objects velocities when enableVelocity is set to "true"
  58693. * @hidden
  58694. */
  58695. _previousTransformationMatrices: {
  58696. [index: number]: ISavedTransformationMatrix;
  58697. };
  58698. /**
  58699. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58700. * in order to compute objects velocities when enableVelocity is set to "true"
  58701. * @hidden
  58702. */
  58703. _previousBonesTransformationMatrices: {
  58704. [index: number]: Float32Array;
  58705. };
  58706. /**
  58707. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58708. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58709. */
  58710. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58711. private _scene;
  58712. private _multiRenderTarget;
  58713. private _ratio;
  58714. private _enablePosition;
  58715. private _enableVelocity;
  58716. private _positionIndex;
  58717. private _velocityIndex;
  58718. protected _effect: Effect;
  58719. protected _cachedDefines: string;
  58720. /**
  58721. * Set the render list (meshes to be rendered) used in the G buffer.
  58722. */
  58723. renderList: Mesh[];
  58724. /**
  58725. * Gets wether or not G buffer are supported by the running hardware.
  58726. * This requires draw buffer supports
  58727. */
  58728. readonly isSupported: boolean;
  58729. /**
  58730. * Returns the index of the given texture type in the G-Buffer textures array
  58731. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58732. * @returns the index of the given texture type in the G-Buffer textures array
  58733. */
  58734. getTextureIndex(textureType: number): number;
  58735. /**
  58736. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58737. */
  58738. /**
  58739. * Sets whether or not objects positions are enabled for the G buffer.
  58740. */
  58741. enablePosition: boolean;
  58742. /**
  58743. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58744. */
  58745. /**
  58746. * Sets wether or not objects velocities are enabled for the G buffer.
  58747. */
  58748. enableVelocity: boolean;
  58749. /**
  58750. * Gets the scene associated with the buffer.
  58751. */
  58752. readonly scene: Scene;
  58753. /**
  58754. * Gets the ratio used by the buffer during its creation.
  58755. * How big is the buffer related to the main canvas.
  58756. */
  58757. readonly ratio: number;
  58758. /** @hidden */
  58759. static _SceneComponentInitialization: (scene: Scene) => void;
  58760. /**
  58761. * Creates a new G Buffer for the scene
  58762. * @param scene The scene the buffer belongs to
  58763. * @param ratio How big is the buffer related to the main canvas.
  58764. */
  58765. constructor(scene: Scene, ratio?: number);
  58766. /**
  58767. * Checks wether everything is ready to render a submesh to the G buffer.
  58768. * @param subMesh the submesh to check readiness for
  58769. * @param useInstances is the mesh drawn using instance or not
  58770. * @returns true if ready otherwise false
  58771. */
  58772. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58773. /**
  58774. * Gets the current underlying G Buffer.
  58775. * @returns the buffer
  58776. */
  58777. getGBuffer(): MultiRenderTarget;
  58778. /**
  58779. * Gets the number of samples used to render the buffer (anti aliasing).
  58780. */
  58781. /**
  58782. * Sets the number of samples used to render the buffer (anti aliasing).
  58783. */
  58784. samples: number;
  58785. /**
  58786. * Disposes the renderer and frees up associated resources.
  58787. */
  58788. dispose(): void;
  58789. protected _createRenderTargets(): void;
  58790. private _copyBonesTransformationMatrices;
  58791. }
  58792. }
  58793. declare module BABYLON {
  58794. interface Scene {
  58795. /** @hidden (Backing field) */
  58796. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58797. /**
  58798. * Gets or Sets the current geometry buffer associated to the scene.
  58799. */
  58800. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58801. /**
  58802. * Enables a GeometryBufferRender and associates it with the scene
  58803. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58804. * @returns the GeometryBufferRenderer
  58805. */
  58806. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58807. /**
  58808. * Disables the GeometryBufferRender associated with the scene
  58809. */
  58810. disableGeometryBufferRenderer(): void;
  58811. }
  58812. /**
  58813. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58814. * in several rendering techniques.
  58815. */
  58816. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58817. /**
  58818. * The component name helpful to identify the component in the list of scene components.
  58819. */
  58820. readonly name: string;
  58821. /**
  58822. * The scene the component belongs to.
  58823. */
  58824. scene: Scene;
  58825. /**
  58826. * Creates a new instance of the component for the given scene
  58827. * @param scene Defines the scene to register the component in
  58828. */
  58829. constructor(scene: Scene);
  58830. /**
  58831. * Registers the component in a given scene
  58832. */
  58833. register(): void;
  58834. /**
  58835. * Rebuilds the elements related to this component in case of
  58836. * context lost for instance.
  58837. */
  58838. rebuild(): void;
  58839. /**
  58840. * Disposes the component and the associated ressources
  58841. */
  58842. dispose(): void;
  58843. private _gatherRenderTargets;
  58844. }
  58845. }
  58846. declare module BABYLON {
  58847. /** @hidden */
  58848. export var motionBlurPixelShader: {
  58849. name: string;
  58850. shader: string;
  58851. };
  58852. }
  58853. declare module BABYLON {
  58854. /**
  58855. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58856. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58857. * As an example, all you have to do is to create the post-process:
  58858. * var mb = new BABYLON.MotionBlurPostProcess(
  58859. * 'mb', // The name of the effect.
  58860. * scene, // The scene containing the objects to blur according to their velocity.
  58861. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58862. * camera // The camera to apply the render pass to.
  58863. * );
  58864. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58865. */
  58866. export class MotionBlurPostProcess extends PostProcess {
  58867. /**
  58868. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58869. */
  58870. motionStrength: number;
  58871. /**
  58872. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58873. */
  58874. /**
  58875. * Sets the number of iterations to be used for motion blur quality
  58876. */
  58877. motionBlurSamples: number;
  58878. private _motionBlurSamples;
  58879. private _geometryBufferRenderer;
  58880. /**
  58881. * Creates a new instance MotionBlurPostProcess
  58882. * @param name The name of the effect.
  58883. * @param scene The scene containing the objects to blur according to their velocity.
  58884. * @param options The required width/height ratio to downsize to before computing the render pass.
  58885. * @param camera The camera to apply the render pass to.
  58886. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58887. * @param engine The engine which the post process will be applied. (default: current engine)
  58888. * @param reusable If the post process can be reused on the same frame. (default: false)
  58889. * @param textureType Type of textures used when performing the post process. (default: 0)
  58890. * @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)
  58891. */
  58892. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58893. /**
  58894. * Excludes the given skinned mesh from computing bones velocities.
  58895. * 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.
  58896. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58897. */
  58898. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58899. /**
  58900. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58901. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58902. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58903. */
  58904. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58905. /**
  58906. * Disposes the post process.
  58907. * @param camera The camera to dispose the post process on.
  58908. */
  58909. dispose(camera?: Camera): void;
  58910. }
  58911. }
  58912. declare module BABYLON {
  58913. /** @hidden */
  58914. export var refractionPixelShader: {
  58915. name: string;
  58916. shader: string;
  58917. };
  58918. }
  58919. declare module BABYLON {
  58920. /**
  58921. * Post process which applies a refractin texture
  58922. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58923. */
  58924. export class RefractionPostProcess extends PostProcess {
  58925. /** the base color of the refraction (used to taint the rendering) */
  58926. color: Color3;
  58927. /** simulated refraction depth */
  58928. depth: number;
  58929. /** the coefficient of the base color (0 to remove base color tainting) */
  58930. colorLevel: number;
  58931. private _refTexture;
  58932. private _ownRefractionTexture;
  58933. /**
  58934. * Gets or sets the refraction texture
  58935. * Please note that you are responsible for disposing the texture if you set it manually
  58936. */
  58937. refractionTexture: Texture;
  58938. /**
  58939. * Initializes the RefractionPostProcess
  58940. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58941. * @param name The name of the effect.
  58942. * @param refractionTextureUrl Url of the refraction texture to use
  58943. * @param color the base color of the refraction (used to taint the rendering)
  58944. * @param depth simulated refraction depth
  58945. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58946. * @param camera The camera to apply the render pass to.
  58947. * @param options The required width/height ratio to downsize to before computing the render pass.
  58948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58949. * @param engine The engine which the post process will be applied. (default: current engine)
  58950. * @param reusable If the post process can be reused on the same frame. (default: false)
  58951. */
  58952. constructor(name: string, refractionTextureUrl: string,
  58953. /** the base color of the refraction (used to taint the rendering) */
  58954. color: Color3,
  58955. /** simulated refraction depth */
  58956. depth: number,
  58957. /** the coefficient of the base color (0 to remove base color tainting) */
  58958. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58959. /**
  58960. * Disposes of the post process
  58961. * @param camera Camera to dispose post process on
  58962. */
  58963. dispose(camera: Camera): void;
  58964. }
  58965. }
  58966. declare module BABYLON {
  58967. /** @hidden */
  58968. export var sharpenPixelShader: {
  58969. name: string;
  58970. shader: string;
  58971. };
  58972. }
  58973. declare module BABYLON {
  58974. /**
  58975. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58976. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58977. */
  58978. export class SharpenPostProcess extends PostProcess {
  58979. /**
  58980. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58981. */
  58982. colorAmount: number;
  58983. /**
  58984. * How much sharpness should be applied (default: 0.3)
  58985. */
  58986. edgeAmount: number;
  58987. /**
  58988. * Creates a new instance ConvolutionPostProcess
  58989. * @param name The name of the effect.
  58990. * @param options The required width/height ratio to downsize to before computing the render pass.
  58991. * @param camera The camera to apply the render pass to.
  58992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58993. * @param engine The engine which the post process will be applied. (default: current engine)
  58994. * @param reusable If the post process can be reused on the same frame. (default: false)
  58995. * @param textureType Type of textures used when performing the post process. (default: 0)
  58996. * @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)
  58997. */
  58998. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58999. }
  59000. }
  59001. declare module BABYLON {
  59002. /**
  59003. * PostProcessRenderPipeline
  59004. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59005. */
  59006. export class PostProcessRenderPipeline {
  59007. private engine;
  59008. private _renderEffects;
  59009. private _renderEffectsForIsolatedPass;
  59010. /**
  59011. * List of inspectable custom properties (used by the Inspector)
  59012. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  59013. */
  59014. inspectableCustomProperties: IInspectable[];
  59015. /**
  59016. * @hidden
  59017. */
  59018. protected _cameras: Camera[];
  59019. /** @hidden */
  59020. _name: string;
  59021. /**
  59022. * Gets pipeline name
  59023. */
  59024. readonly name: string;
  59025. /**
  59026. * Initializes a PostProcessRenderPipeline
  59027. * @param engine engine to add the pipeline to
  59028. * @param name name of the pipeline
  59029. */
  59030. constructor(engine: Engine, name: string);
  59031. /**
  59032. * Gets the class name
  59033. * @returns "PostProcessRenderPipeline"
  59034. */
  59035. getClassName(): string;
  59036. /**
  59037. * If all the render effects in the pipeline are supported
  59038. */
  59039. readonly isSupported: boolean;
  59040. /**
  59041. * Adds an effect to the pipeline
  59042. * @param renderEffect the effect to add
  59043. */
  59044. addEffect(renderEffect: PostProcessRenderEffect): void;
  59045. /** @hidden */
  59046. _rebuild(): void;
  59047. /** @hidden */
  59048. _enableEffect(renderEffectName: string, cameras: Camera): void;
  59049. /** @hidden */
  59050. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  59051. /** @hidden */
  59052. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59053. /** @hidden */
  59054. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59055. /** @hidden */
  59056. _attachCameras(cameras: Camera, unique: boolean): void;
  59057. /** @hidden */
  59058. _attachCameras(cameras: Camera[], unique: boolean): void;
  59059. /** @hidden */
  59060. _detachCameras(cameras: Camera): void;
  59061. /** @hidden */
  59062. _detachCameras(cameras: Nullable<Camera[]>): void;
  59063. /** @hidden */
  59064. _update(): void;
  59065. /** @hidden */
  59066. _reset(): void;
  59067. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  59068. /**
  59069. * Disposes of the pipeline
  59070. */
  59071. dispose(): void;
  59072. }
  59073. }
  59074. declare module BABYLON {
  59075. /**
  59076. * PostProcessRenderPipelineManager class
  59077. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59078. */
  59079. export class PostProcessRenderPipelineManager {
  59080. private _renderPipelines;
  59081. /**
  59082. * Initializes a PostProcessRenderPipelineManager
  59083. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59084. */
  59085. constructor();
  59086. /**
  59087. * Gets the list of supported render pipelines
  59088. */
  59089. readonly supportedPipelines: PostProcessRenderPipeline[];
  59090. /**
  59091. * Adds a pipeline to the manager
  59092. * @param renderPipeline The pipeline to add
  59093. */
  59094. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59095. /**
  59096. * Attaches a camera to the pipeline
  59097. * @param renderPipelineName The name of the pipeline to attach to
  59098. * @param cameras the camera to attach
  59099. * @param unique if the camera can be attached multiple times to the pipeline
  59100. */
  59101. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59102. /**
  59103. * Detaches a camera from the pipeline
  59104. * @param renderPipelineName The name of the pipeline to detach from
  59105. * @param cameras the camera to detach
  59106. */
  59107. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59108. /**
  59109. * Enables an effect by name on a pipeline
  59110. * @param renderPipelineName the name of the pipeline to enable the effect in
  59111. * @param renderEffectName the name of the effect to enable
  59112. * @param cameras the cameras that the effect should be enabled on
  59113. */
  59114. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59115. /**
  59116. * Disables an effect by name on a pipeline
  59117. * @param renderPipelineName the name of the pipeline to disable the effect in
  59118. * @param renderEffectName the name of the effect to disable
  59119. * @param cameras the cameras that the effect should be disabled on
  59120. */
  59121. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59122. /**
  59123. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59124. */
  59125. update(): void;
  59126. /** @hidden */
  59127. _rebuild(): void;
  59128. /**
  59129. * Disposes of the manager and pipelines
  59130. */
  59131. dispose(): void;
  59132. }
  59133. }
  59134. declare module BABYLON {
  59135. interface Scene {
  59136. /** @hidden (Backing field) */
  59137. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59138. /**
  59139. * Gets the postprocess render pipeline manager
  59140. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59141. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59142. */
  59143. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59144. }
  59145. /**
  59146. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59147. */
  59148. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59149. /**
  59150. * The component name helpfull to identify the component in the list of scene components.
  59151. */
  59152. readonly name: string;
  59153. /**
  59154. * The scene the component belongs to.
  59155. */
  59156. scene: Scene;
  59157. /**
  59158. * Creates a new instance of the component for the given scene
  59159. * @param scene Defines the scene to register the component in
  59160. */
  59161. constructor(scene: Scene);
  59162. /**
  59163. * Registers the component in a given scene
  59164. */
  59165. register(): void;
  59166. /**
  59167. * Rebuilds the elements related to this component in case of
  59168. * context lost for instance.
  59169. */
  59170. rebuild(): void;
  59171. /**
  59172. * Disposes the component and the associated ressources
  59173. */
  59174. dispose(): void;
  59175. private _gatherRenderTargets;
  59176. }
  59177. }
  59178. declare module BABYLON {
  59179. /**
  59180. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59181. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59182. */
  59183. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59184. private _scene;
  59185. private _camerasToBeAttached;
  59186. /**
  59187. * ID of the sharpen post process,
  59188. */
  59189. private readonly SharpenPostProcessId;
  59190. /**
  59191. * @ignore
  59192. * ID of the image processing post process;
  59193. */
  59194. readonly ImageProcessingPostProcessId: string;
  59195. /**
  59196. * @ignore
  59197. * ID of the Fast Approximate Anti-Aliasing post process;
  59198. */
  59199. readonly FxaaPostProcessId: string;
  59200. /**
  59201. * ID of the chromatic aberration post process,
  59202. */
  59203. private readonly ChromaticAberrationPostProcessId;
  59204. /**
  59205. * ID of the grain post process
  59206. */
  59207. private readonly GrainPostProcessId;
  59208. /**
  59209. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59210. */
  59211. sharpen: SharpenPostProcess;
  59212. private _sharpenEffect;
  59213. private bloom;
  59214. /**
  59215. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59216. */
  59217. depthOfField: DepthOfFieldEffect;
  59218. /**
  59219. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59220. */
  59221. fxaa: FxaaPostProcess;
  59222. /**
  59223. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59224. */
  59225. imageProcessing: ImageProcessingPostProcess;
  59226. /**
  59227. * Chromatic aberration post process which will shift rgb colors in the image
  59228. */
  59229. chromaticAberration: ChromaticAberrationPostProcess;
  59230. private _chromaticAberrationEffect;
  59231. /**
  59232. * Grain post process which add noise to the image
  59233. */
  59234. grain: GrainPostProcess;
  59235. private _grainEffect;
  59236. /**
  59237. * Glow post process which adds a glow to emissive areas of the image
  59238. */
  59239. private _glowLayer;
  59240. /**
  59241. * Animations which can be used to tweak settings over a period of time
  59242. */
  59243. animations: Animation[];
  59244. private _imageProcessingConfigurationObserver;
  59245. private _sharpenEnabled;
  59246. private _bloomEnabled;
  59247. private _depthOfFieldEnabled;
  59248. private _depthOfFieldBlurLevel;
  59249. private _fxaaEnabled;
  59250. private _imageProcessingEnabled;
  59251. private _defaultPipelineTextureType;
  59252. private _bloomScale;
  59253. private _chromaticAberrationEnabled;
  59254. private _grainEnabled;
  59255. private _buildAllowed;
  59256. /**
  59257. * Gets active scene
  59258. */
  59259. readonly scene: Scene;
  59260. /**
  59261. * Enable or disable the sharpen process from the pipeline
  59262. */
  59263. sharpenEnabled: boolean;
  59264. private _resizeObserver;
  59265. private _hardwareScaleLevel;
  59266. private _bloomKernel;
  59267. /**
  59268. * Specifies the size of the bloom blur kernel, relative to the final output size
  59269. */
  59270. bloomKernel: number;
  59271. /**
  59272. * Specifies the weight of the bloom in the final rendering
  59273. */
  59274. private _bloomWeight;
  59275. /**
  59276. * Specifies the luma threshold for the area that will be blurred by the bloom
  59277. */
  59278. private _bloomThreshold;
  59279. private _hdr;
  59280. /**
  59281. * The strength of the bloom.
  59282. */
  59283. bloomWeight: number;
  59284. /**
  59285. * The strength of the bloom.
  59286. */
  59287. bloomThreshold: number;
  59288. /**
  59289. * The scale of the bloom, lower value will provide better performance.
  59290. */
  59291. bloomScale: number;
  59292. /**
  59293. * Enable or disable the bloom from the pipeline
  59294. */
  59295. bloomEnabled: boolean;
  59296. private _rebuildBloom;
  59297. /**
  59298. * If the depth of field is enabled.
  59299. */
  59300. depthOfFieldEnabled: boolean;
  59301. /**
  59302. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59303. */
  59304. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59305. /**
  59306. * If the anti aliasing is enabled.
  59307. */
  59308. fxaaEnabled: boolean;
  59309. private _samples;
  59310. /**
  59311. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59312. */
  59313. samples: number;
  59314. /**
  59315. * If image processing is enabled.
  59316. */
  59317. imageProcessingEnabled: boolean;
  59318. /**
  59319. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59320. */
  59321. glowLayerEnabled: boolean;
  59322. /**
  59323. * Gets the glow layer (or null if not defined)
  59324. */
  59325. readonly glowLayer: Nullable<GlowLayer>;
  59326. /**
  59327. * Enable or disable the chromaticAberration process from the pipeline
  59328. */
  59329. chromaticAberrationEnabled: boolean;
  59330. /**
  59331. * Enable or disable the grain process from the pipeline
  59332. */
  59333. grainEnabled: boolean;
  59334. /**
  59335. * @constructor
  59336. * @param name - The rendering pipeline name (default: "")
  59337. * @param hdr - If high dynamic range textures should be used (default: true)
  59338. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59339. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59340. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59341. */
  59342. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59343. /**
  59344. * Get the class name
  59345. * @returns "DefaultRenderingPipeline"
  59346. */
  59347. getClassName(): string;
  59348. /**
  59349. * Force the compilation of the entire pipeline.
  59350. */
  59351. prepare(): void;
  59352. private _hasCleared;
  59353. private _prevPostProcess;
  59354. private _prevPrevPostProcess;
  59355. private _setAutoClearAndTextureSharing;
  59356. private _depthOfFieldSceneObserver;
  59357. private _buildPipeline;
  59358. private _disposePostProcesses;
  59359. /**
  59360. * Adds a camera to the pipeline
  59361. * @param camera the camera to be added
  59362. */
  59363. addCamera(camera: Camera): void;
  59364. /**
  59365. * Removes a camera from the pipeline
  59366. * @param camera the camera to remove
  59367. */
  59368. removeCamera(camera: Camera): void;
  59369. /**
  59370. * Dispose of the pipeline and stop all post processes
  59371. */
  59372. dispose(): void;
  59373. /**
  59374. * Serialize the rendering pipeline (Used when exporting)
  59375. * @returns the serialized object
  59376. */
  59377. serialize(): any;
  59378. /**
  59379. * Parse the serialized pipeline
  59380. * @param source Source pipeline.
  59381. * @param scene The scene to load the pipeline to.
  59382. * @param rootUrl The URL of the serialized pipeline.
  59383. * @returns An instantiated pipeline from the serialized object.
  59384. */
  59385. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59386. }
  59387. }
  59388. declare module BABYLON {
  59389. /** @hidden */
  59390. export var lensHighlightsPixelShader: {
  59391. name: string;
  59392. shader: string;
  59393. };
  59394. }
  59395. declare module BABYLON {
  59396. /** @hidden */
  59397. export var depthOfFieldPixelShader: {
  59398. name: string;
  59399. shader: string;
  59400. };
  59401. }
  59402. declare module BABYLON {
  59403. /**
  59404. * BABYLON.JS Chromatic Aberration GLSL Shader
  59405. * Author: Olivier Guyot
  59406. * Separates very slightly R, G and B colors on the edges of the screen
  59407. * Inspired by Francois Tarlier & Martins Upitis
  59408. */
  59409. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59410. /**
  59411. * @ignore
  59412. * The chromatic aberration PostProcess id in the pipeline
  59413. */
  59414. LensChromaticAberrationEffect: string;
  59415. /**
  59416. * @ignore
  59417. * The highlights enhancing PostProcess id in the pipeline
  59418. */
  59419. HighlightsEnhancingEffect: string;
  59420. /**
  59421. * @ignore
  59422. * The depth-of-field PostProcess id in the pipeline
  59423. */
  59424. LensDepthOfFieldEffect: string;
  59425. private _scene;
  59426. private _depthTexture;
  59427. private _grainTexture;
  59428. private _chromaticAberrationPostProcess;
  59429. private _highlightsPostProcess;
  59430. private _depthOfFieldPostProcess;
  59431. private _edgeBlur;
  59432. private _grainAmount;
  59433. private _chromaticAberration;
  59434. private _distortion;
  59435. private _highlightsGain;
  59436. private _highlightsThreshold;
  59437. private _dofDistance;
  59438. private _dofAperture;
  59439. private _dofDarken;
  59440. private _dofPentagon;
  59441. private _blurNoise;
  59442. /**
  59443. * @constructor
  59444. *
  59445. * Effect parameters are as follow:
  59446. * {
  59447. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59448. * edge_blur: number; // from 0 to x (1 for realism)
  59449. * distortion: number; // from 0 to x (1 for realism)
  59450. * grain_amount: number; // from 0 to 1
  59451. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59452. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59453. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59454. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59455. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59456. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59457. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59458. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59459. * }
  59460. * Note: if an effect parameter is unset, effect is disabled
  59461. *
  59462. * @param name The rendering pipeline name
  59463. * @param parameters - An object containing all parameters (see above)
  59464. * @param scene The scene linked to this pipeline
  59465. * @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)
  59466. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59467. */
  59468. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59469. /**
  59470. * Get the class name
  59471. * @returns "LensRenderingPipeline"
  59472. */
  59473. getClassName(): string;
  59474. /**
  59475. * Gets associated scene
  59476. */
  59477. readonly scene: Scene;
  59478. /**
  59479. * Gets or sets the edge blur
  59480. */
  59481. edgeBlur: number;
  59482. /**
  59483. * Gets or sets the grain amount
  59484. */
  59485. grainAmount: number;
  59486. /**
  59487. * Gets or sets the chromatic aberration amount
  59488. */
  59489. chromaticAberration: number;
  59490. /**
  59491. * Gets or sets the depth of field aperture
  59492. */
  59493. dofAperture: number;
  59494. /**
  59495. * Gets or sets the edge distortion
  59496. */
  59497. edgeDistortion: number;
  59498. /**
  59499. * Gets or sets the depth of field distortion
  59500. */
  59501. dofDistortion: number;
  59502. /**
  59503. * Gets or sets the darken out of focus amount
  59504. */
  59505. darkenOutOfFocus: number;
  59506. /**
  59507. * Gets or sets a boolean indicating if blur noise is enabled
  59508. */
  59509. blurNoise: boolean;
  59510. /**
  59511. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59512. */
  59513. pentagonBokeh: boolean;
  59514. /**
  59515. * Gets or sets the highlight grain amount
  59516. */
  59517. highlightsGain: number;
  59518. /**
  59519. * Gets or sets the highlight threshold
  59520. */
  59521. highlightsThreshold: number;
  59522. /**
  59523. * Sets the amount of blur at the edges
  59524. * @param amount blur amount
  59525. */
  59526. setEdgeBlur(amount: number): void;
  59527. /**
  59528. * Sets edge blur to 0
  59529. */
  59530. disableEdgeBlur(): void;
  59531. /**
  59532. * Sets the amout of grain
  59533. * @param amount Amount of grain
  59534. */
  59535. setGrainAmount(amount: number): void;
  59536. /**
  59537. * Set grain amount to 0
  59538. */
  59539. disableGrain(): void;
  59540. /**
  59541. * Sets the chromatic aberration amount
  59542. * @param amount amount of chromatic aberration
  59543. */
  59544. setChromaticAberration(amount: number): void;
  59545. /**
  59546. * Sets chromatic aberration amount to 0
  59547. */
  59548. disableChromaticAberration(): void;
  59549. /**
  59550. * Sets the EdgeDistortion amount
  59551. * @param amount amount of EdgeDistortion
  59552. */
  59553. setEdgeDistortion(amount: number): void;
  59554. /**
  59555. * Sets edge distortion to 0
  59556. */
  59557. disableEdgeDistortion(): void;
  59558. /**
  59559. * Sets the FocusDistance amount
  59560. * @param amount amount of FocusDistance
  59561. */
  59562. setFocusDistance(amount: number): void;
  59563. /**
  59564. * Disables depth of field
  59565. */
  59566. disableDepthOfField(): void;
  59567. /**
  59568. * Sets the Aperture amount
  59569. * @param amount amount of Aperture
  59570. */
  59571. setAperture(amount: number): void;
  59572. /**
  59573. * Sets the DarkenOutOfFocus amount
  59574. * @param amount amount of DarkenOutOfFocus
  59575. */
  59576. setDarkenOutOfFocus(amount: number): void;
  59577. private _pentagonBokehIsEnabled;
  59578. /**
  59579. * Creates a pentagon bokeh effect
  59580. */
  59581. enablePentagonBokeh(): void;
  59582. /**
  59583. * Disables the pentagon bokeh effect
  59584. */
  59585. disablePentagonBokeh(): void;
  59586. /**
  59587. * Enables noise blur
  59588. */
  59589. enableNoiseBlur(): void;
  59590. /**
  59591. * Disables noise blur
  59592. */
  59593. disableNoiseBlur(): void;
  59594. /**
  59595. * Sets the HighlightsGain amount
  59596. * @param amount amount of HighlightsGain
  59597. */
  59598. setHighlightsGain(amount: number): void;
  59599. /**
  59600. * Sets the HighlightsThreshold amount
  59601. * @param amount amount of HighlightsThreshold
  59602. */
  59603. setHighlightsThreshold(amount: number): void;
  59604. /**
  59605. * Disables highlights
  59606. */
  59607. disableHighlights(): void;
  59608. /**
  59609. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59610. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59611. */
  59612. dispose(disableDepthRender?: boolean): void;
  59613. private _createChromaticAberrationPostProcess;
  59614. private _createHighlightsPostProcess;
  59615. private _createDepthOfFieldPostProcess;
  59616. private _createGrainTexture;
  59617. }
  59618. }
  59619. declare module BABYLON {
  59620. /** @hidden */
  59621. export var ssao2PixelShader: {
  59622. name: string;
  59623. shader: string;
  59624. };
  59625. }
  59626. declare module BABYLON {
  59627. /** @hidden */
  59628. export var ssaoCombinePixelShader: {
  59629. name: string;
  59630. shader: string;
  59631. };
  59632. }
  59633. declare module BABYLON {
  59634. /**
  59635. * Render pipeline to produce ssao effect
  59636. */
  59637. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59638. /**
  59639. * @ignore
  59640. * The PassPostProcess id in the pipeline that contains the original scene color
  59641. */
  59642. SSAOOriginalSceneColorEffect: string;
  59643. /**
  59644. * @ignore
  59645. * The SSAO PostProcess id in the pipeline
  59646. */
  59647. SSAORenderEffect: string;
  59648. /**
  59649. * @ignore
  59650. * The horizontal blur PostProcess id in the pipeline
  59651. */
  59652. SSAOBlurHRenderEffect: string;
  59653. /**
  59654. * @ignore
  59655. * The vertical blur PostProcess id in the pipeline
  59656. */
  59657. SSAOBlurVRenderEffect: string;
  59658. /**
  59659. * @ignore
  59660. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59661. */
  59662. SSAOCombineRenderEffect: string;
  59663. /**
  59664. * The output strength of the SSAO post-process. Default value is 1.0.
  59665. */
  59666. totalStrength: number;
  59667. /**
  59668. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59669. */
  59670. maxZ: number;
  59671. /**
  59672. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59673. */
  59674. minZAspect: number;
  59675. private _samples;
  59676. /**
  59677. * Number of samples used for the SSAO calculations. Default value is 8
  59678. */
  59679. samples: number;
  59680. private _textureSamples;
  59681. /**
  59682. * Number of samples to use for antialiasing
  59683. */
  59684. textureSamples: number;
  59685. /**
  59686. * Ratio object used for SSAO ratio and blur ratio
  59687. */
  59688. private _ratio;
  59689. /**
  59690. * Dynamically generated sphere sampler.
  59691. */
  59692. private _sampleSphere;
  59693. /**
  59694. * Blur filter offsets
  59695. */
  59696. private _samplerOffsets;
  59697. private _expensiveBlur;
  59698. /**
  59699. * If bilateral blur should be used
  59700. */
  59701. expensiveBlur: boolean;
  59702. /**
  59703. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59704. */
  59705. radius: number;
  59706. /**
  59707. * The base color of the SSAO post-process
  59708. * The final result is "base + ssao" between [0, 1]
  59709. */
  59710. base: number;
  59711. /**
  59712. * Support test.
  59713. */
  59714. static readonly IsSupported: boolean;
  59715. private _scene;
  59716. private _depthTexture;
  59717. private _normalTexture;
  59718. private _randomTexture;
  59719. private _originalColorPostProcess;
  59720. private _ssaoPostProcess;
  59721. private _blurHPostProcess;
  59722. private _blurVPostProcess;
  59723. private _ssaoCombinePostProcess;
  59724. private _firstUpdate;
  59725. /**
  59726. * Gets active scene
  59727. */
  59728. readonly scene: Scene;
  59729. /**
  59730. * @constructor
  59731. * @param name The rendering pipeline name
  59732. * @param scene The scene linked to this pipeline
  59733. * @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 }
  59734. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59735. */
  59736. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59737. /**
  59738. * Get the class name
  59739. * @returns "SSAO2RenderingPipeline"
  59740. */
  59741. getClassName(): string;
  59742. /**
  59743. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59744. */
  59745. dispose(disableGeometryBufferRenderer?: boolean): void;
  59746. private _createBlurPostProcess;
  59747. /** @hidden */
  59748. _rebuild(): void;
  59749. private _bits;
  59750. private _radicalInverse_VdC;
  59751. private _hammersley;
  59752. private _hemisphereSample_uniform;
  59753. private _generateHemisphere;
  59754. private _createSSAOPostProcess;
  59755. private _createSSAOCombinePostProcess;
  59756. private _createRandomTexture;
  59757. /**
  59758. * Serialize the rendering pipeline (Used when exporting)
  59759. * @returns the serialized object
  59760. */
  59761. serialize(): any;
  59762. /**
  59763. * Parse the serialized pipeline
  59764. * @param source Source pipeline.
  59765. * @param scene The scene to load the pipeline to.
  59766. * @param rootUrl The URL of the serialized pipeline.
  59767. * @returns An instantiated pipeline from the serialized object.
  59768. */
  59769. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59770. }
  59771. }
  59772. declare module BABYLON {
  59773. /** @hidden */
  59774. export var ssaoPixelShader: {
  59775. name: string;
  59776. shader: string;
  59777. };
  59778. }
  59779. declare module BABYLON {
  59780. /**
  59781. * Render pipeline to produce ssao effect
  59782. */
  59783. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59784. /**
  59785. * @ignore
  59786. * The PassPostProcess id in the pipeline that contains the original scene color
  59787. */
  59788. SSAOOriginalSceneColorEffect: string;
  59789. /**
  59790. * @ignore
  59791. * The SSAO PostProcess id in the pipeline
  59792. */
  59793. SSAORenderEffect: string;
  59794. /**
  59795. * @ignore
  59796. * The horizontal blur PostProcess id in the pipeline
  59797. */
  59798. SSAOBlurHRenderEffect: string;
  59799. /**
  59800. * @ignore
  59801. * The vertical blur PostProcess id in the pipeline
  59802. */
  59803. SSAOBlurVRenderEffect: string;
  59804. /**
  59805. * @ignore
  59806. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59807. */
  59808. SSAOCombineRenderEffect: string;
  59809. /**
  59810. * The output strength of the SSAO post-process. Default value is 1.0.
  59811. */
  59812. totalStrength: number;
  59813. /**
  59814. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59815. */
  59816. radius: number;
  59817. /**
  59818. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59819. * Must not be equal to fallOff and superior to fallOff.
  59820. * Default value is 0.0075
  59821. */
  59822. area: number;
  59823. /**
  59824. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59825. * Must not be equal to area and inferior to area.
  59826. * Default value is 0.000001
  59827. */
  59828. fallOff: number;
  59829. /**
  59830. * The base color of the SSAO post-process
  59831. * The final result is "base + ssao" between [0, 1]
  59832. */
  59833. base: number;
  59834. private _scene;
  59835. private _depthTexture;
  59836. private _randomTexture;
  59837. private _originalColorPostProcess;
  59838. private _ssaoPostProcess;
  59839. private _blurHPostProcess;
  59840. private _blurVPostProcess;
  59841. private _ssaoCombinePostProcess;
  59842. private _firstUpdate;
  59843. /**
  59844. * Gets active scene
  59845. */
  59846. readonly scene: Scene;
  59847. /**
  59848. * @constructor
  59849. * @param name - The rendering pipeline name
  59850. * @param scene - The scene linked to this pipeline
  59851. * @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 }
  59852. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59853. */
  59854. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59855. /**
  59856. * Get the class name
  59857. * @returns "SSAORenderingPipeline"
  59858. */
  59859. getClassName(): string;
  59860. /**
  59861. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59862. */
  59863. dispose(disableDepthRender?: boolean): void;
  59864. private _createBlurPostProcess;
  59865. /** @hidden */
  59866. _rebuild(): void;
  59867. private _createSSAOPostProcess;
  59868. private _createSSAOCombinePostProcess;
  59869. private _createRandomTexture;
  59870. }
  59871. }
  59872. declare module BABYLON {
  59873. /** @hidden */
  59874. export var standardPixelShader: {
  59875. name: string;
  59876. shader: string;
  59877. };
  59878. }
  59879. declare module BABYLON {
  59880. /**
  59881. * Standard rendering pipeline
  59882. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59883. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59884. */
  59885. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59886. /**
  59887. * Public members
  59888. */
  59889. /**
  59890. * Post-process which contains the original scene color before the pipeline applies all the effects
  59891. */
  59892. originalPostProcess: Nullable<PostProcess>;
  59893. /**
  59894. * Post-process used to down scale an image x4
  59895. */
  59896. downSampleX4PostProcess: Nullable<PostProcess>;
  59897. /**
  59898. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59899. */
  59900. brightPassPostProcess: Nullable<PostProcess>;
  59901. /**
  59902. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59903. */
  59904. blurHPostProcesses: PostProcess[];
  59905. /**
  59906. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59907. */
  59908. blurVPostProcesses: PostProcess[];
  59909. /**
  59910. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59911. */
  59912. textureAdderPostProcess: Nullable<PostProcess>;
  59913. /**
  59914. * Post-process used to create volumetric lighting effect
  59915. */
  59916. volumetricLightPostProcess: Nullable<PostProcess>;
  59917. /**
  59918. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59919. */
  59920. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59921. /**
  59922. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59923. */
  59924. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59925. /**
  59926. * Post-process used to merge the volumetric light effect and the real scene color
  59927. */
  59928. volumetricLightMergePostProces: Nullable<PostProcess>;
  59929. /**
  59930. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59931. */
  59932. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59933. /**
  59934. * Base post-process used to calculate the average luminance of the final image for HDR
  59935. */
  59936. luminancePostProcess: Nullable<PostProcess>;
  59937. /**
  59938. * Post-processes used to create down sample post-processes in order to get
  59939. * the average luminance of the final image for HDR
  59940. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59941. */
  59942. luminanceDownSamplePostProcesses: PostProcess[];
  59943. /**
  59944. * Post-process used to create a HDR effect (light adaptation)
  59945. */
  59946. hdrPostProcess: Nullable<PostProcess>;
  59947. /**
  59948. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59949. */
  59950. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59951. /**
  59952. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59953. */
  59954. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59955. /**
  59956. * Post-process used to merge the final HDR post-process and the real scene color
  59957. */
  59958. hdrFinalPostProcess: Nullable<PostProcess>;
  59959. /**
  59960. * Post-process used to create a lens flare effect
  59961. */
  59962. lensFlarePostProcess: Nullable<PostProcess>;
  59963. /**
  59964. * Post-process that merges the result of the lens flare post-process and the real scene color
  59965. */
  59966. lensFlareComposePostProcess: Nullable<PostProcess>;
  59967. /**
  59968. * Post-process used to create a motion blur effect
  59969. */
  59970. motionBlurPostProcess: Nullable<PostProcess>;
  59971. /**
  59972. * Post-process used to create a depth of field effect
  59973. */
  59974. depthOfFieldPostProcess: Nullable<PostProcess>;
  59975. /**
  59976. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59977. */
  59978. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59979. /**
  59980. * Represents the brightness threshold in order to configure the illuminated surfaces
  59981. */
  59982. brightThreshold: number;
  59983. /**
  59984. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59985. */
  59986. blurWidth: number;
  59987. /**
  59988. * Sets if the blur for highlighted surfaces must be only horizontal
  59989. */
  59990. horizontalBlur: boolean;
  59991. /**
  59992. * Gets the overall exposure used by the pipeline
  59993. */
  59994. /**
  59995. * Sets the overall exposure used by the pipeline
  59996. */
  59997. exposure: number;
  59998. /**
  59999. * Texture used typically to simulate "dirty" on camera lens
  60000. */
  60001. lensTexture: Nullable<Texture>;
  60002. /**
  60003. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  60004. */
  60005. volumetricLightCoefficient: number;
  60006. /**
  60007. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  60008. */
  60009. volumetricLightPower: number;
  60010. /**
  60011. * Used the set the blur intensity to smooth the volumetric lights
  60012. */
  60013. volumetricLightBlurScale: number;
  60014. /**
  60015. * Light (spot or directional) used to generate the volumetric lights rays
  60016. * The source light must have a shadow generate so the pipeline can get its
  60017. * depth map
  60018. */
  60019. sourceLight: Nullable<SpotLight | DirectionalLight>;
  60020. /**
  60021. * For eye adaptation, represents the minimum luminance the eye can see
  60022. */
  60023. hdrMinimumLuminance: number;
  60024. /**
  60025. * For eye adaptation, represents the decrease luminance speed
  60026. */
  60027. hdrDecreaseRate: number;
  60028. /**
  60029. * For eye adaptation, represents the increase luminance speed
  60030. */
  60031. hdrIncreaseRate: number;
  60032. /**
  60033. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60034. */
  60035. /**
  60036. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60037. */
  60038. hdrAutoExposure: boolean;
  60039. /**
  60040. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  60041. */
  60042. lensColorTexture: Nullable<Texture>;
  60043. /**
  60044. * The overall strengh for the lens flare effect
  60045. */
  60046. lensFlareStrength: number;
  60047. /**
  60048. * Dispersion coefficient for lens flare ghosts
  60049. */
  60050. lensFlareGhostDispersal: number;
  60051. /**
  60052. * Main lens flare halo width
  60053. */
  60054. lensFlareHaloWidth: number;
  60055. /**
  60056. * Based on the lens distortion effect, defines how much the lens flare result
  60057. * is distorted
  60058. */
  60059. lensFlareDistortionStrength: number;
  60060. /**
  60061. * Configures the blur intensity used for for lens flare (halo)
  60062. */
  60063. lensFlareBlurWidth: number;
  60064. /**
  60065. * Lens star texture must be used to simulate rays on the flares and is available
  60066. * in the documentation
  60067. */
  60068. lensStarTexture: Nullable<Texture>;
  60069. /**
  60070. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60071. * flare effect by taking account of the dirt texture
  60072. */
  60073. lensFlareDirtTexture: Nullable<Texture>;
  60074. /**
  60075. * Represents the focal length for the depth of field effect
  60076. */
  60077. depthOfFieldDistance: number;
  60078. /**
  60079. * Represents the blur intensity for the blurred part of the depth of field effect
  60080. */
  60081. depthOfFieldBlurWidth: number;
  60082. /**
  60083. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60084. */
  60085. /**
  60086. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60087. */
  60088. motionStrength: number;
  60089. /**
  60090. * Gets wether or not the motion blur post-process is object based or screen based.
  60091. */
  60092. /**
  60093. * Sets wether or not the motion blur post-process should be object based or screen based
  60094. */
  60095. objectBasedMotionBlur: boolean;
  60096. /**
  60097. * List of animations for the pipeline (IAnimatable implementation)
  60098. */
  60099. animations: Animation[];
  60100. /**
  60101. * Private members
  60102. */
  60103. private _scene;
  60104. private _currentDepthOfFieldSource;
  60105. private _basePostProcess;
  60106. private _fixedExposure;
  60107. private _currentExposure;
  60108. private _hdrAutoExposure;
  60109. private _hdrCurrentLuminance;
  60110. private _motionStrength;
  60111. private _isObjectBasedMotionBlur;
  60112. private _floatTextureType;
  60113. private _camerasToBeAttached;
  60114. private _ratio;
  60115. private _bloomEnabled;
  60116. private _depthOfFieldEnabled;
  60117. private _vlsEnabled;
  60118. private _lensFlareEnabled;
  60119. private _hdrEnabled;
  60120. private _motionBlurEnabled;
  60121. private _fxaaEnabled;
  60122. private _motionBlurSamples;
  60123. private _volumetricLightStepsCount;
  60124. private _samples;
  60125. /**
  60126. * @ignore
  60127. * Specifies if the bloom pipeline is enabled
  60128. */
  60129. BloomEnabled: boolean;
  60130. /**
  60131. * @ignore
  60132. * Specifies if the depth of field pipeline is enabed
  60133. */
  60134. DepthOfFieldEnabled: boolean;
  60135. /**
  60136. * @ignore
  60137. * Specifies if the lens flare pipeline is enabed
  60138. */
  60139. LensFlareEnabled: boolean;
  60140. /**
  60141. * @ignore
  60142. * Specifies if the HDR pipeline is enabled
  60143. */
  60144. HDREnabled: boolean;
  60145. /**
  60146. * @ignore
  60147. * Specifies if the volumetric lights scattering effect is enabled
  60148. */
  60149. VLSEnabled: boolean;
  60150. /**
  60151. * @ignore
  60152. * Specifies if the motion blur effect is enabled
  60153. */
  60154. MotionBlurEnabled: boolean;
  60155. /**
  60156. * Specifies if anti-aliasing is enabled
  60157. */
  60158. fxaaEnabled: boolean;
  60159. /**
  60160. * Specifies the number of steps used to calculate the volumetric lights
  60161. * Typically in interval [50, 200]
  60162. */
  60163. volumetricLightStepsCount: number;
  60164. /**
  60165. * Specifies the number of samples used for the motion blur effect
  60166. * Typically in interval [16, 64]
  60167. */
  60168. motionBlurSamples: number;
  60169. /**
  60170. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60171. */
  60172. samples: number;
  60173. /**
  60174. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60175. * @constructor
  60176. * @param name The rendering pipeline name
  60177. * @param scene The scene linked to this pipeline
  60178. * @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)
  60179. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60180. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60181. */
  60182. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60183. private _buildPipeline;
  60184. private _createDownSampleX4PostProcess;
  60185. private _createBrightPassPostProcess;
  60186. private _createBlurPostProcesses;
  60187. private _createTextureAdderPostProcess;
  60188. private _createVolumetricLightPostProcess;
  60189. private _createLuminancePostProcesses;
  60190. private _createHdrPostProcess;
  60191. private _createLensFlarePostProcess;
  60192. private _createDepthOfFieldPostProcess;
  60193. private _createMotionBlurPostProcess;
  60194. private _getDepthTexture;
  60195. private _disposePostProcesses;
  60196. /**
  60197. * Dispose of the pipeline and stop all post processes
  60198. */
  60199. dispose(): void;
  60200. /**
  60201. * Serialize the rendering pipeline (Used when exporting)
  60202. * @returns the serialized object
  60203. */
  60204. serialize(): any;
  60205. /**
  60206. * Parse the serialized pipeline
  60207. * @param source Source pipeline.
  60208. * @param scene The scene to load the pipeline to.
  60209. * @param rootUrl The URL of the serialized pipeline.
  60210. * @returns An instantiated pipeline from the serialized object.
  60211. */
  60212. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60213. /**
  60214. * Luminance steps
  60215. */
  60216. static LuminanceSteps: number;
  60217. }
  60218. }
  60219. declare module BABYLON {
  60220. /** @hidden */
  60221. export var tonemapPixelShader: {
  60222. name: string;
  60223. shader: string;
  60224. };
  60225. }
  60226. declare module BABYLON {
  60227. /** Defines operator used for tonemapping */
  60228. export enum TonemappingOperator {
  60229. /** Hable */
  60230. Hable = 0,
  60231. /** Reinhard */
  60232. Reinhard = 1,
  60233. /** HejiDawson */
  60234. HejiDawson = 2,
  60235. /** Photographic */
  60236. Photographic = 3
  60237. }
  60238. /**
  60239. * Defines a post process to apply tone mapping
  60240. */
  60241. export class TonemapPostProcess extends PostProcess {
  60242. private _operator;
  60243. /** Defines the required exposure adjustement */
  60244. exposureAdjustment: number;
  60245. /**
  60246. * Creates a new TonemapPostProcess
  60247. * @param name defines the name of the postprocess
  60248. * @param _operator defines the operator to use
  60249. * @param exposureAdjustment defines the required exposure adjustement
  60250. * @param camera defines the camera to use (can be null)
  60251. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60252. * @param engine defines the hosting engine (can be ignore if camera is set)
  60253. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60254. */
  60255. constructor(name: string, _operator: TonemappingOperator,
  60256. /** Defines the required exposure adjustement */
  60257. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60258. }
  60259. }
  60260. declare module BABYLON {
  60261. /** @hidden */
  60262. export var depthVertexShader: {
  60263. name: string;
  60264. shader: string;
  60265. };
  60266. }
  60267. declare module BABYLON {
  60268. /** @hidden */
  60269. export var volumetricLightScatteringPixelShader: {
  60270. name: string;
  60271. shader: string;
  60272. };
  60273. }
  60274. declare module BABYLON {
  60275. /** @hidden */
  60276. export var volumetricLightScatteringPassVertexShader: {
  60277. name: string;
  60278. shader: string;
  60279. };
  60280. }
  60281. declare module BABYLON {
  60282. /** @hidden */
  60283. export var volumetricLightScatteringPassPixelShader: {
  60284. name: string;
  60285. shader: string;
  60286. };
  60287. }
  60288. declare module BABYLON {
  60289. /**
  60290. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60291. */
  60292. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60293. private _volumetricLightScatteringPass;
  60294. private _volumetricLightScatteringRTT;
  60295. private _viewPort;
  60296. private _screenCoordinates;
  60297. private _cachedDefines;
  60298. /**
  60299. * If not undefined, the mesh position is computed from the attached node position
  60300. */
  60301. attachedNode: {
  60302. position: Vector3;
  60303. };
  60304. /**
  60305. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60306. */
  60307. customMeshPosition: Vector3;
  60308. /**
  60309. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60310. */
  60311. useCustomMeshPosition: boolean;
  60312. /**
  60313. * If the post-process should inverse the light scattering direction
  60314. */
  60315. invert: boolean;
  60316. /**
  60317. * The internal mesh used by the post-process
  60318. */
  60319. mesh: Mesh;
  60320. /**
  60321. * @hidden
  60322. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60323. */
  60324. useDiffuseColor: boolean;
  60325. /**
  60326. * Array containing the excluded meshes not rendered in the internal pass
  60327. */
  60328. excludedMeshes: AbstractMesh[];
  60329. /**
  60330. * Controls the overall intensity of the post-process
  60331. */
  60332. exposure: number;
  60333. /**
  60334. * Dissipates each sample's contribution in range [0, 1]
  60335. */
  60336. decay: number;
  60337. /**
  60338. * Controls the overall intensity of each sample
  60339. */
  60340. weight: number;
  60341. /**
  60342. * Controls the density of each sample
  60343. */
  60344. density: number;
  60345. /**
  60346. * @constructor
  60347. * @param name The post-process name
  60348. * @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)
  60349. * @param camera The camera that the post-process will be attached to
  60350. * @param mesh The mesh used to create the light scattering
  60351. * @param samples The post-process quality, default 100
  60352. * @param samplingModeThe post-process filtering mode
  60353. * @param engine The babylon engine
  60354. * @param reusable If the post-process is reusable
  60355. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60356. */
  60357. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60358. /**
  60359. * Returns the string "VolumetricLightScatteringPostProcess"
  60360. * @returns "VolumetricLightScatteringPostProcess"
  60361. */
  60362. getClassName(): string;
  60363. private _isReady;
  60364. /**
  60365. * Sets the new light position for light scattering effect
  60366. * @param position The new custom light position
  60367. */
  60368. setCustomMeshPosition(position: Vector3): void;
  60369. /**
  60370. * Returns the light position for light scattering effect
  60371. * @return Vector3 The custom light position
  60372. */
  60373. getCustomMeshPosition(): Vector3;
  60374. /**
  60375. * Disposes the internal assets and detaches the post-process from the camera
  60376. */
  60377. dispose(camera: Camera): void;
  60378. /**
  60379. * Returns the render target texture used by the post-process
  60380. * @return the render target texture used by the post-process
  60381. */
  60382. getPass(): RenderTargetTexture;
  60383. private _meshExcluded;
  60384. private _createPass;
  60385. private _updateMeshScreenCoordinates;
  60386. /**
  60387. * Creates a default mesh for the Volumeric Light Scattering post-process
  60388. * @param name The mesh name
  60389. * @param scene The scene where to create the mesh
  60390. * @return the default mesh
  60391. */
  60392. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60393. }
  60394. }
  60395. declare module BABYLON {
  60396. interface Scene {
  60397. /** @hidden (Backing field) */
  60398. _boundingBoxRenderer: BoundingBoxRenderer;
  60399. /** @hidden (Backing field) */
  60400. _forceShowBoundingBoxes: boolean;
  60401. /**
  60402. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60403. */
  60404. forceShowBoundingBoxes: boolean;
  60405. /**
  60406. * Gets the bounding box renderer associated with the scene
  60407. * @returns a BoundingBoxRenderer
  60408. */
  60409. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60410. }
  60411. interface AbstractMesh {
  60412. /** @hidden (Backing field) */
  60413. _showBoundingBox: boolean;
  60414. /**
  60415. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60416. */
  60417. showBoundingBox: boolean;
  60418. }
  60419. /**
  60420. * Component responsible of rendering the bounding box of the meshes in a scene.
  60421. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60422. */
  60423. export class BoundingBoxRenderer implements ISceneComponent {
  60424. /**
  60425. * The component name helpfull to identify the component in the list of scene components.
  60426. */
  60427. readonly name: string;
  60428. /**
  60429. * The scene the component belongs to.
  60430. */
  60431. scene: Scene;
  60432. /**
  60433. * Color of the bounding box lines placed in front of an object
  60434. */
  60435. frontColor: Color3;
  60436. /**
  60437. * Color of the bounding box lines placed behind an object
  60438. */
  60439. backColor: Color3;
  60440. /**
  60441. * Defines if the renderer should show the back lines or not
  60442. */
  60443. showBackLines: boolean;
  60444. /**
  60445. * @hidden
  60446. */
  60447. renderList: SmartArray<BoundingBox>;
  60448. private _colorShader;
  60449. private _vertexBuffers;
  60450. private _indexBuffer;
  60451. private _fillIndexBuffer;
  60452. private _fillIndexData;
  60453. /**
  60454. * Instantiates a new bounding box renderer in a scene.
  60455. * @param scene the scene the renderer renders in
  60456. */
  60457. constructor(scene: Scene);
  60458. /**
  60459. * Registers the component in a given scene
  60460. */
  60461. register(): void;
  60462. private _evaluateSubMesh;
  60463. private _activeMesh;
  60464. private _prepareRessources;
  60465. private _createIndexBuffer;
  60466. /**
  60467. * Rebuilds the elements related to this component in case of
  60468. * context lost for instance.
  60469. */
  60470. rebuild(): void;
  60471. /**
  60472. * @hidden
  60473. */
  60474. reset(): void;
  60475. /**
  60476. * Render the bounding boxes of a specific rendering group
  60477. * @param renderingGroupId defines the rendering group to render
  60478. */
  60479. render(renderingGroupId: number): void;
  60480. /**
  60481. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60482. * @param mesh Define the mesh to render the occlusion bounding box for
  60483. */
  60484. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60485. /**
  60486. * Dispose and release the resources attached to this renderer.
  60487. */
  60488. dispose(): void;
  60489. }
  60490. }
  60491. declare module BABYLON {
  60492. /** @hidden */
  60493. export var depthPixelShader: {
  60494. name: string;
  60495. shader: string;
  60496. };
  60497. }
  60498. declare module BABYLON {
  60499. /**
  60500. * This represents a depth renderer in Babylon.
  60501. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60502. */
  60503. export class DepthRenderer {
  60504. private _scene;
  60505. private _depthMap;
  60506. private _effect;
  60507. private readonly _storeNonLinearDepth;
  60508. private readonly _clearColor;
  60509. /** Get if the depth renderer is using packed depth or not */
  60510. readonly isPacked: boolean;
  60511. private _cachedDefines;
  60512. private _camera;
  60513. /**
  60514. * Specifiess that the depth renderer will only be used within
  60515. * the camera it is created for.
  60516. * This can help forcing its rendering during the camera processing.
  60517. */
  60518. useOnlyInActiveCamera: boolean;
  60519. /** @hidden */
  60520. static _SceneComponentInitialization: (scene: Scene) => void;
  60521. /**
  60522. * Instantiates a depth renderer
  60523. * @param scene The scene the renderer belongs to
  60524. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60525. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60526. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60527. */
  60528. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60529. /**
  60530. * Creates the depth rendering effect and checks if the effect is ready.
  60531. * @param subMesh The submesh to be used to render the depth map of
  60532. * @param useInstances If multiple world instances should be used
  60533. * @returns if the depth renderer is ready to render the depth map
  60534. */
  60535. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60536. /**
  60537. * Gets the texture which the depth map will be written to.
  60538. * @returns The depth map texture
  60539. */
  60540. getDepthMap(): RenderTargetTexture;
  60541. /**
  60542. * Disposes of the depth renderer.
  60543. */
  60544. dispose(): void;
  60545. }
  60546. }
  60547. declare module BABYLON {
  60548. interface Scene {
  60549. /** @hidden (Backing field) */
  60550. _depthRenderer: {
  60551. [id: string]: DepthRenderer;
  60552. };
  60553. /**
  60554. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60555. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60556. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60557. * @returns the created depth renderer
  60558. */
  60559. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  60560. /**
  60561. * Disables a depth renderer for a given camera
  60562. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60563. */
  60564. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60565. }
  60566. /**
  60567. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60568. * in several rendering techniques.
  60569. */
  60570. export class DepthRendererSceneComponent implements ISceneComponent {
  60571. /**
  60572. * The component name helpfull to identify the component in the list of scene components.
  60573. */
  60574. readonly name: string;
  60575. /**
  60576. * The scene the component belongs to.
  60577. */
  60578. scene: Scene;
  60579. /**
  60580. * Creates a new instance of the component for the given scene
  60581. * @param scene Defines the scene to register the component in
  60582. */
  60583. constructor(scene: Scene);
  60584. /**
  60585. * Registers the component in a given scene
  60586. */
  60587. register(): void;
  60588. /**
  60589. * Rebuilds the elements related to this component in case of
  60590. * context lost for instance.
  60591. */
  60592. rebuild(): void;
  60593. /**
  60594. * Disposes the component and the associated ressources
  60595. */
  60596. dispose(): void;
  60597. private _gatherRenderTargets;
  60598. private _gatherActiveCameraRenderTargets;
  60599. }
  60600. }
  60601. declare module BABYLON {
  60602. /** @hidden */
  60603. export var outlinePixelShader: {
  60604. name: string;
  60605. shader: string;
  60606. };
  60607. }
  60608. declare module BABYLON {
  60609. /** @hidden */
  60610. export var outlineVertexShader: {
  60611. name: string;
  60612. shader: string;
  60613. };
  60614. }
  60615. declare module BABYLON {
  60616. interface Scene {
  60617. /** @hidden */
  60618. _outlineRenderer: OutlineRenderer;
  60619. /**
  60620. * Gets the outline renderer associated with the scene
  60621. * @returns a OutlineRenderer
  60622. */
  60623. getOutlineRenderer(): OutlineRenderer;
  60624. }
  60625. interface AbstractMesh {
  60626. /** @hidden (Backing field) */
  60627. _renderOutline: boolean;
  60628. /**
  60629. * Gets or sets a boolean indicating if the outline must be rendered as well
  60630. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60631. */
  60632. renderOutline: boolean;
  60633. /** @hidden (Backing field) */
  60634. _renderOverlay: boolean;
  60635. /**
  60636. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60637. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60638. */
  60639. renderOverlay: boolean;
  60640. }
  60641. /**
  60642. * This class is responsible to draw bothe outline/overlay of meshes.
  60643. * It should not be used directly but through the available method on mesh.
  60644. */
  60645. export class OutlineRenderer implements ISceneComponent {
  60646. /**
  60647. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60648. */
  60649. private static _StencilReference;
  60650. /**
  60651. * The name of the component. Each component must have a unique name.
  60652. */
  60653. name: string;
  60654. /**
  60655. * The scene the component belongs to.
  60656. */
  60657. scene: Scene;
  60658. /**
  60659. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60660. */
  60661. zOffset: number;
  60662. private _engine;
  60663. private _effect;
  60664. private _cachedDefines;
  60665. private _savedDepthWrite;
  60666. /**
  60667. * Instantiates a new outline renderer. (There could be only one per scene).
  60668. * @param scene Defines the scene it belongs to
  60669. */
  60670. constructor(scene: Scene);
  60671. /**
  60672. * Register the component to one instance of a scene.
  60673. */
  60674. register(): void;
  60675. /**
  60676. * Rebuilds the elements related to this component in case of
  60677. * context lost for instance.
  60678. */
  60679. rebuild(): void;
  60680. /**
  60681. * Disposes the component and the associated ressources.
  60682. */
  60683. dispose(): void;
  60684. /**
  60685. * Renders the outline in the canvas.
  60686. * @param subMesh Defines the sumesh to render
  60687. * @param batch Defines the batch of meshes in case of instances
  60688. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60689. */
  60690. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60691. /**
  60692. * Returns whether or not the outline renderer is ready for a given submesh.
  60693. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60694. * @param subMesh Defines the submesh to check readyness for
  60695. * @param useInstances Defines wheter wee are trying to render instances or not
  60696. * @returns true if ready otherwise false
  60697. */
  60698. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60699. private _beforeRenderingMesh;
  60700. private _afterRenderingMesh;
  60701. }
  60702. }
  60703. declare module BABYLON {
  60704. /**
  60705. * Class used to manage multiple sprites of different sizes on the same spritesheet
  60706. * @see http://doc.babylonjs.com/babylon101/sprites
  60707. */
  60708. export class SpritePackedManager extends SpriteManager {
  60709. /** defines the packed manager's name */
  60710. name: string;
  60711. /**
  60712. * Creates a new sprite manager from a packed sprite sheet
  60713. * @param name defines the manager's name
  60714. * @param imgUrl defines the sprite sheet url
  60715. * @param capacity defines the maximum allowed number of sprites
  60716. * @param scene defines the hosting scene
  60717. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  60718. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  60719. * @param samplingMode defines the smapling mode to use with spritesheet
  60720. * @param fromPacked set to true; do not alter
  60721. */
  60722. constructor(
  60723. /** defines the packed manager's name */
  60724. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  60725. }
  60726. }
  60727. declare module BABYLON {
  60728. /**
  60729. * Defines the list of states available for a task inside a AssetsManager
  60730. */
  60731. export enum AssetTaskState {
  60732. /**
  60733. * Initialization
  60734. */
  60735. INIT = 0,
  60736. /**
  60737. * Running
  60738. */
  60739. RUNNING = 1,
  60740. /**
  60741. * Done
  60742. */
  60743. DONE = 2,
  60744. /**
  60745. * Error
  60746. */
  60747. ERROR = 3
  60748. }
  60749. /**
  60750. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60751. */
  60752. export abstract class AbstractAssetTask {
  60753. /**
  60754. * Task name
  60755. */ name: string;
  60756. /**
  60757. * Callback called when the task is successful
  60758. */
  60759. onSuccess: (task: any) => void;
  60760. /**
  60761. * Callback called when the task is not successful
  60762. */
  60763. onError: (task: any, message?: string, exception?: any) => void;
  60764. /**
  60765. * Creates a new AssetsManager
  60766. * @param name defines the name of the task
  60767. */
  60768. constructor(
  60769. /**
  60770. * Task name
  60771. */ name: string);
  60772. private _isCompleted;
  60773. private _taskState;
  60774. private _errorObject;
  60775. /**
  60776. * Get if the task is completed
  60777. */
  60778. readonly isCompleted: boolean;
  60779. /**
  60780. * Gets the current state of the task
  60781. */
  60782. readonly taskState: AssetTaskState;
  60783. /**
  60784. * Gets the current error object (if task is in error)
  60785. */
  60786. readonly errorObject: {
  60787. message?: string;
  60788. exception?: any;
  60789. };
  60790. /**
  60791. * Internal only
  60792. * @hidden
  60793. */
  60794. _setErrorObject(message?: string, exception?: any): void;
  60795. /**
  60796. * Execute the current task
  60797. * @param scene defines the scene where you want your assets to be loaded
  60798. * @param onSuccess is a callback called when the task is successfully executed
  60799. * @param onError is a callback called if an error occurs
  60800. */
  60801. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60802. /**
  60803. * Execute the current task
  60804. * @param scene defines the scene where you want your assets to be loaded
  60805. * @param onSuccess is a callback called when the task is successfully executed
  60806. * @param onError is a callback called if an error occurs
  60807. */
  60808. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60809. /**
  60810. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60811. * This can be used with failed tasks that have the reason for failure fixed.
  60812. */
  60813. reset(): void;
  60814. private onErrorCallback;
  60815. private onDoneCallback;
  60816. }
  60817. /**
  60818. * Define the interface used by progress events raised during assets loading
  60819. */
  60820. export interface IAssetsProgressEvent {
  60821. /**
  60822. * Defines the number of remaining tasks to process
  60823. */
  60824. remainingCount: number;
  60825. /**
  60826. * Defines the total number of tasks
  60827. */
  60828. totalCount: number;
  60829. /**
  60830. * Defines the task that was just processed
  60831. */
  60832. task: AbstractAssetTask;
  60833. }
  60834. /**
  60835. * Class used to share progress information about assets loading
  60836. */
  60837. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60838. /**
  60839. * Defines the number of remaining tasks to process
  60840. */
  60841. remainingCount: number;
  60842. /**
  60843. * Defines the total number of tasks
  60844. */
  60845. totalCount: number;
  60846. /**
  60847. * Defines the task that was just processed
  60848. */
  60849. task: AbstractAssetTask;
  60850. /**
  60851. * Creates a AssetsProgressEvent
  60852. * @param remainingCount defines the number of remaining tasks to process
  60853. * @param totalCount defines the total number of tasks
  60854. * @param task defines the task that was just processed
  60855. */
  60856. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60857. }
  60858. /**
  60859. * Define a task used by AssetsManager to load meshes
  60860. */
  60861. export class MeshAssetTask extends AbstractAssetTask {
  60862. /**
  60863. * Defines the name of the task
  60864. */
  60865. name: string;
  60866. /**
  60867. * Defines the list of mesh's names you want to load
  60868. */
  60869. meshesNames: any;
  60870. /**
  60871. * Defines the root url to use as a base to load your meshes and associated resources
  60872. */
  60873. rootUrl: string;
  60874. /**
  60875. * Defines the filename of the scene to load from
  60876. */
  60877. sceneFilename: string;
  60878. /**
  60879. * Gets the list of loaded meshes
  60880. */
  60881. loadedMeshes: Array<AbstractMesh>;
  60882. /**
  60883. * Gets the list of loaded particle systems
  60884. */
  60885. loadedParticleSystems: Array<IParticleSystem>;
  60886. /**
  60887. * Gets the list of loaded skeletons
  60888. */
  60889. loadedSkeletons: Array<Skeleton>;
  60890. /**
  60891. * Gets the list of loaded animation groups
  60892. */
  60893. loadedAnimationGroups: Array<AnimationGroup>;
  60894. /**
  60895. * Callback called when the task is successful
  60896. */
  60897. onSuccess: (task: MeshAssetTask) => void;
  60898. /**
  60899. * Callback called when the task is successful
  60900. */
  60901. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60902. /**
  60903. * Creates a new MeshAssetTask
  60904. * @param name defines the name of the task
  60905. * @param meshesNames defines the list of mesh's names you want to load
  60906. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60907. * @param sceneFilename defines the filename of the scene to load from
  60908. */
  60909. constructor(
  60910. /**
  60911. * Defines the name of the task
  60912. */
  60913. name: string,
  60914. /**
  60915. * Defines the list of mesh's names you want to load
  60916. */
  60917. meshesNames: any,
  60918. /**
  60919. * Defines the root url to use as a base to load your meshes and associated resources
  60920. */
  60921. rootUrl: string,
  60922. /**
  60923. * Defines the filename of the scene to load from
  60924. */
  60925. sceneFilename: string);
  60926. /**
  60927. * Execute the current task
  60928. * @param scene defines the scene where you want your assets to be loaded
  60929. * @param onSuccess is a callback called when the task is successfully executed
  60930. * @param onError is a callback called if an error occurs
  60931. */
  60932. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60933. }
  60934. /**
  60935. * Define a task used by AssetsManager to load text content
  60936. */
  60937. export class TextFileAssetTask extends AbstractAssetTask {
  60938. /**
  60939. * Defines the name of the task
  60940. */
  60941. name: string;
  60942. /**
  60943. * Defines the location of the file to load
  60944. */
  60945. url: string;
  60946. /**
  60947. * Gets the loaded text string
  60948. */
  60949. text: string;
  60950. /**
  60951. * Callback called when the task is successful
  60952. */
  60953. onSuccess: (task: TextFileAssetTask) => void;
  60954. /**
  60955. * Callback called when the task is successful
  60956. */
  60957. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60958. /**
  60959. * Creates a new TextFileAssetTask object
  60960. * @param name defines the name of the task
  60961. * @param url defines the location of the file to load
  60962. */
  60963. constructor(
  60964. /**
  60965. * Defines the name of the task
  60966. */
  60967. name: string,
  60968. /**
  60969. * Defines the location of the file to load
  60970. */
  60971. url: string);
  60972. /**
  60973. * Execute the current task
  60974. * @param scene defines the scene where you want your assets to be loaded
  60975. * @param onSuccess is a callback called when the task is successfully executed
  60976. * @param onError is a callback called if an error occurs
  60977. */
  60978. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60979. }
  60980. /**
  60981. * Define a task used by AssetsManager to load binary data
  60982. */
  60983. export class BinaryFileAssetTask extends AbstractAssetTask {
  60984. /**
  60985. * Defines the name of the task
  60986. */
  60987. name: string;
  60988. /**
  60989. * Defines the location of the file to load
  60990. */
  60991. url: string;
  60992. /**
  60993. * Gets the lodaded data (as an array buffer)
  60994. */
  60995. data: ArrayBuffer;
  60996. /**
  60997. * Callback called when the task is successful
  60998. */
  60999. onSuccess: (task: BinaryFileAssetTask) => void;
  61000. /**
  61001. * Callback called when the task is successful
  61002. */
  61003. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61004. /**
  61005. * Creates a new BinaryFileAssetTask object
  61006. * @param name defines the name of the new task
  61007. * @param url defines the location of the file to load
  61008. */
  61009. constructor(
  61010. /**
  61011. * Defines the name of the task
  61012. */
  61013. name: string,
  61014. /**
  61015. * Defines the location of the file to load
  61016. */
  61017. url: string);
  61018. /**
  61019. * Execute the current task
  61020. * @param scene defines the scene where you want your assets to be loaded
  61021. * @param onSuccess is a callback called when the task is successfully executed
  61022. * @param onError is a callback called if an error occurs
  61023. */
  61024. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61025. }
  61026. /**
  61027. * Define a task used by AssetsManager to load images
  61028. */
  61029. export class ImageAssetTask extends AbstractAssetTask {
  61030. /**
  61031. * Defines the name of the task
  61032. */
  61033. name: string;
  61034. /**
  61035. * Defines the location of the image to load
  61036. */
  61037. url: string;
  61038. /**
  61039. * Gets the loaded images
  61040. */
  61041. image: HTMLImageElement;
  61042. /**
  61043. * Callback called when the task is successful
  61044. */
  61045. onSuccess: (task: ImageAssetTask) => void;
  61046. /**
  61047. * Callback called when the task is successful
  61048. */
  61049. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61050. /**
  61051. * Creates a new ImageAssetTask
  61052. * @param name defines the name of the task
  61053. * @param url defines the location of the image to load
  61054. */
  61055. constructor(
  61056. /**
  61057. * Defines the name of the task
  61058. */
  61059. name: string,
  61060. /**
  61061. * Defines the location of the image to load
  61062. */
  61063. url: string);
  61064. /**
  61065. * Execute the current task
  61066. * @param scene defines the scene where you want your assets to be loaded
  61067. * @param onSuccess is a callback called when the task is successfully executed
  61068. * @param onError is a callback called if an error occurs
  61069. */
  61070. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61071. }
  61072. /**
  61073. * Defines the interface used by texture loading tasks
  61074. */
  61075. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61076. /**
  61077. * Gets the loaded texture
  61078. */
  61079. texture: TEX;
  61080. }
  61081. /**
  61082. * Define a task used by AssetsManager to load 2D textures
  61083. */
  61084. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61085. /**
  61086. * Defines the name of the task
  61087. */
  61088. name: string;
  61089. /**
  61090. * Defines the location of the file to load
  61091. */
  61092. url: string;
  61093. /**
  61094. * Defines if mipmap should not be generated (default is false)
  61095. */
  61096. noMipmap?: boolean | undefined;
  61097. /**
  61098. * Defines if texture must be inverted on Y axis (default is false)
  61099. */
  61100. invertY?: boolean | undefined;
  61101. /**
  61102. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61103. */
  61104. samplingMode: number;
  61105. /**
  61106. * Gets the loaded texture
  61107. */
  61108. texture: Texture;
  61109. /**
  61110. * Callback called when the task is successful
  61111. */
  61112. onSuccess: (task: TextureAssetTask) => void;
  61113. /**
  61114. * Callback called when the task is successful
  61115. */
  61116. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61117. /**
  61118. * Creates a new TextureAssetTask object
  61119. * @param name defines the name of the task
  61120. * @param url defines the location of the file to load
  61121. * @param noMipmap defines if mipmap should not be generated (default is false)
  61122. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61123. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61124. */
  61125. constructor(
  61126. /**
  61127. * Defines the name of the task
  61128. */
  61129. name: string,
  61130. /**
  61131. * Defines the location of the file to load
  61132. */
  61133. url: string,
  61134. /**
  61135. * Defines if mipmap should not be generated (default is false)
  61136. */
  61137. noMipmap?: boolean | undefined,
  61138. /**
  61139. * Defines if texture must be inverted on Y axis (default is false)
  61140. */
  61141. invertY?: boolean | undefined,
  61142. /**
  61143. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61144. */
  61145. samplingMode?: number);
  61146. /**
  61147. * Execute the current task
  61148. * @param scene defines the scene where you want your assets to be loaded
  61149. * @param onSuccess is a callback called when the task is successfully executed
  61150. * @param onError is a callback called if an error occurs
  61151. */
  61152. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61153. }
  61154. /**
  61155. * Define a task used by AssetsManager to load cube textures
  61156. */
  61157. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61158. /**
  61159. * Defines the name of the task
  61160. */
  61161. name: string;
  61162. /**
  61163. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61164. */
  61165. url: string;
  61166. /**
  61167. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61168. */
  61169. extensions?: string[] | undefined;
  61170. /**
  61171. * Defines if mipmaps should not be generated (default is false)
  61172. */
  61173. noMipmap?: boolean | undefined;
  61174. /**
  61175. * Defines the explicit list of files (undefined by default)
  61176. */
  61177. files?: string[] | undefined;
  61178. /**
  61179. * Gets the loaded texture
  61180. */
  61181. texture: CubeTexture;
  61182. /**
  61183. * Callback called when the task is successful
  61184. */
  61185. onSuccess: (task: CubeTextureAssetTask) => void;
  61186. /**
  61187. * Callback called when the task is successful
  61188. */
  61189. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61190. /**
  61191. * Creates a new CubeTextureAssetTask
  61192. * @param name defines the name of the task
  61193. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61194. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61195. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61196. * @param files defines the explicit list of files (undefined by default)
  61197. */
  61198. constructor(
  61199. /**
  61200. * Defines the name of the task
  61201. */
  61202. name: string,
  61203. /**
  61204. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61205. */
  61206. url: string,
  61207. /**
  61208. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61209. */
  61210. extensions?: string[] | undefined,
  61211. /**
  61212. * Defines if mipmaps should not be generated (default is false)
  61213. */
  61214. noMipmap?: boolean | undefined,
  61215. /**
  61216. * Defines the explicit list of files (undefined by default)
  61217. */
  61218. files?: string[] | undefined);
  61219. /**
  61220. * Execute the current task
  61221. * @param scene defines the scene where you want your assets to be loaded
  61222. * @param onSuccess is a callback called when the task is successfully executed
  61223. * @param onError is a callback called if an error occurs
  61224. */
  61225. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61226. }
  61227. /**
  61228. * Define a task used by AssetsManager to load HDR cube textures
  61229. */
  61230. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61231. /**
  61232. * Defines the name of the task
  61233. */
  61234. name: string;
  61235. /**
  61236. * Defines the location of the file to load
  61237. */
  61238. url: string;
  61239. /**
  61240. * Defines the desired size (the more it increases the longer the generation will be)
  61241. */
  61242. size: number;
  61243. /**
  61244. * Defines if mipmaps should not be generated (default is false)
  61245. */
  61246. noMipmap: boolean;
  61247. /**
  61248. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61249. */
  61250. generateHarmonics: boolean;
  61251. /**
  61252. * 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)
  61253. */
  61254. gammaSpace: boolean;
  61255. /**
  61256. * Internal Use Only
  61257. */
  61258. reserved: boolean;
  61259. /**
  61260. * Gets the loaded texture
  61261. */
  61262. texture: HDRCubeTexture;
  61263. /**
  61264. * Callback called when the task is successful
  61265. */
  61266. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61267. /**
  61268. * Callback called when the task is successful
  61269. */
  61270. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61271. /**
  61272. * Creates a new HDRCubeTextureAssetTask object
  61273. * @param name defines the name of the task
  61274. * @param url defines the location of the file to load
  61275. * @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.
  61276. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61277. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61278. * @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)
  61279. * @param reserved Internal use only
  61280. */
  61281. constructor(
  61282. /**
  61283. * Defines the name of the task
  61284. */
  61285. name: string,
  61286. /**
  61287. * Defines the location of the file to load
  61288. */
  61289. url: string,
  61290. /**
  61291. * Defines the desired size (the more it increases the longer the generation will be)
  61292. */
  61293. size: number,
  61294. /**
  61295. * Defines if mipmaps should not be generated (default is false)
  61296. */
  61297. noMipmap?: boolean,
  61298. /**
  61299. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61300. */
  61301. generateHarmonics?: boolean,
  61302. /**
  61303. * 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)
  61304. */
  61305. gammaSpace?: boolean,
  61306. /**
  61307. * Internal Use Only
  61308. */
  61309. reserved?: boolean);
  61310. /**
  61311. * Execute the current task
  61312. * @param scene defines the scene where you want your assets to be loaded
  61313. * @param onSuccess is a callback called when the task is successfully executed
  61314. * @param onError is a callback called if an error occurs
  61315. */
  61316. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61317. }
  61318. /**
  61319. * Define a task used by AssetsManager to load Equirectangular cube textures
  61320. */
  61321. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61322. /**
  61323. * Defines the name of the task
  61324. */
  61325. name: string;
  61326. /**
  61327. * Defines the location of the file to load
  61328. */
  61329. url: string;
  61330. /**
  61331. * Defines the desired size (the more it increases the longer the generation will be)
  61332. */
  61333. size: number;
  61334. /**
  61335. * Defines if mipmaps should not be generated (default is false)
  61336. */
  61337. noMipmap: boolean;
  61338. /**
  61339. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61340. * but the standard material would require them in Gamma space) (default is true)
  61341. */
  61342. gammaSpace: boolean;
  61343. /**
  61344. * Gets the loaded texture
  61345. */
  61346. texture: EquiRectangularCubeTexture;
  61347. /**
  61348. * Callback called when the task is successful
  61349. */
  61350. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61351. /**
  61352. * Callback called when the task is successful
  61353. */
  61354. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61355. /**
  61356. * Creates a new EquiRectangularCubeTextureAssetTask object
  61357. * @param name defines the name of the task
  61358. * @param url defines the location of the file to load
  61359. * @param size defines the desired size (the more it increases the longer the generation will be)
  61360. * If the size is omitted this implies you are using a preprocessed cubemap.
  61361. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61362. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61363. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61364. * (default is true)
  61365. */
  61366. constructor(
  61367. /**
  61368. * Defines the name of the task
  61369. */
  61370. name: string,
  61371. /**
  61372. * Defines the location of the file to load
  61373. */
  61374. url: string,
  61375. /**
  61376. * Defines the desired size (the more it increases the longer the generation will be)
  61377. */
  61378. size: number,
  61379. /**
  61380. * Defines if mipmaps should not be generated (default is false)
  61381. */
  61382. noMipmap?: boolean,
  61383. /**
  61384. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61385. * but the standard material would require them in Gamma space) (default is true)
  61386. */
  61387. gammaSpace?: boolean);
  61388. /**
  61389. * Execute the current task
  61390. * @param scene defines the scene where you want your assets to be loaded
  61391. * @param onSuccess is a callback called when the task is successfully executed
  61392. * @param onError is a callback called if an error occurs
  61393. */
  61394. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61395. }
  61396. /**
  61397. * This class can be used to easily import assets into a scene
  61398. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61399. */
  61400. export class AssetsManager {
  61401. private _scene;
  61402. private _isLoading;
  61403. protected _tasks: AbstractAssetTask[];
  61404. protected _waitingTasksCount: number;
  61405. protected _totalTasksCount: number;
  61406. /**
  61407. * Callback called when all tasks are processed
  61408. */
  61409. onFinish: (tasks: AbstractAssetTask[]) => void;
  61410. /**
  61411. * Callback called when a task is successful
  61412. */
  61413. onTaskSuccess: (task: AbstractAssetTask) => void;
  61414. /**
  61415. * Callback called when a task had an error
  61416. */
  61417. onTaskError: (task: AbstractAssetTask) => void;
  61418. /**
  61419. * Callback called when a task is done (whatever the result is)
  61420. */
  61421. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61422. /**
  61423. * Observable called when all tasks are processed
  61424. */
  61425. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61426. /**
  61427. * Observable called when a task had an error
  61428. */
  61429. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61430. /**
  61431. * Observable called when all tasks were executed
  61432. */
  61433. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61434. /**
  61435. * Observable called when a task is done (whatever the result is)
  61436. */
  61437. onProgressObservable: Observable<IAssetsProgressEvent>;
  61438. /**
  61439. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61440. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61441. */
  61442. useDefaultLoadingScreen: boolean;
  61443. /**
  61444. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61445. * when all assets have been downloaded.
  61446. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61447. */
  61448. autoHideLoadingUI: boolean;
  61449. /**
  61450. * Creates a new AssetsManager
  61451. * @param scene defines the scene to work on
  61452. */
  61453. constructor(scene: Scene);
  61454. /**
  61455. * Add a MeshAssetTask to the list of active tasks
  61456. * @param taskName defines the name of the new task
  61457. * @param meshesNames defines the name of meshes to load
  61458. * @param rootUrl defines the root url to use to locate files
  61459. * @param sceneFilename defines the filename of the scene file
  61460. * @returns a new MeshAssetTask object
  61461. */
  61462. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61463. /**
  61464. * Add a TextFileAssetTask to the list of active tasks
  61465. * @param taskName defines the name of the new task
  61466. * @param url defines the url of the file to load
  61467. * @returns a new TextFileAssetTask object
  61468. */
  61469. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61470. /**
  61471. * Add a BinaryFileAssetTask to the list of active tasks
  61472. * @param taskName defines the name of the new task
  61473. * @param url defines the url of the file to load
  61474. * @returns a new BinaryFileAssetTask object
  61475. */
  61476. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61477. /**
  61478. * Add a ImageAssetTask to the list of active tasks
  61479. * @param taskName defines the name of the new task
  61480. * @param url defines the url of the file to load
  61481. * @returns a new ImageAssetTask object
  61482. */
  61483. addImageTask(taskName: string, url: string): ImageAssetTask;
  61484. /**
  61485. * Add a TextureAssetTask to the list of active tasks
  61486. * @param taskName defines the name of the new task
  61487. * @param url defines the url of the file to load
  61488. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61489. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61490. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61491. * @returns a new TextureAssetTask object
  61492. */
  61493. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61494. /**
  61495. * Add a CubeTextureAssetTask to the list of active tasks
  61496. * @param taskName defines the name of the new task
  61497. * @param url defines the url of the file to load
  61498. * @param extensions defines the extension to use to load the cube map (can be null)
  61499. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61500. * @param files defines the list of files to load (can be null)
  61501. * @returns a new CubeTextureAssetTask object
  61502. */
  61503. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61504. /**
  61505. *
  61506. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61507. * @param taskName defines the name of the new task
  61508. * @param url defines the url of the file to load
  61509. * @param size defines the size you want for the cubemap (can be null)
  61510. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61511. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61512. * @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)
  61513. * @param reserved Internal use only
  61514. * @returns a new HDRCubeTextureAssetTask object
  61515. */
  61516. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61517. /**
  61518. *
  61519. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61520. * @param taskName defines the name of the new task
  61521. * @param url defines the url of the file to load
  61522. * @param size defines the size you want for the cubemap (can be null)
  61523. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61524. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61525. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61526. * @returns a new EquiRectangularCubeTextureAssetTask object
  61527. */
  61528. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61529. /**
  61530. * Remove a task from the assets manager.
  61531. * @param task the task to remove
  61532. */
  61533. removeTask(task: AbstractAssetTask): void;
  61534. private _decreaseWaitingTasksCount;
  61535. private _runTask;
  61536. /**
  61537. * Reset the AssetsManager and remove all tasks
  61538. * @return the current instance of the AssetsManager
  61539. */
  61540. reset(): AssetsManager;
  61541. /**
  61542. * Start the loading process
  61543. * @return the current instance of the AssetsManager
  61544. */
  61545. load(): AssetsManager;
  61546. /**
  61547. * Start the loading process as an async operation
  61548. * @return a promise returning the list of failed tasks
  61549. */
  61550. loadAsync(): Promise<void>;
  61551. }
  61552. }
  61553. declare module BABYLON {
  61554. /**
  61555. * Wrapper class for promise with external resolve and reject.
  61556. */
  61557. export class Deferred<T> {
  61558. /**
  61559. * The promise associated with this deferred object.
  61560. */
  61561. readonly promise: Promise<T>;
  61562. private _resolve;
  61563. private _reject;
  61564. /**
  61565. * The resolve method of the promise associated with this deferred object.
  61566. */
  61567. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61568. /**
  61569. * The reject method of the promise associated with this deferred object.
  61570. */
  61571. readonly reject: (reason?: any) => void;
  61572. /**
  61573. * Constructor for this deferred object.
  61574. */
  61575. constructor();
  61576. }
  61577. }
  61578. declare module BABYLON {
  61579. /**
  61580. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61581. */
  61582. export class MeshExploder {
  61583. private _centerMesh;
  61584. private _meshes;
  61585. private _meshesOrigins;
  61586. private _toCenterVectors;
  61587. private _scaledDirection;
  61588. private _newPosition;
  61589. private _centerPosition;
  61590. /**
  61591. * Explodes meshes from a center mesh.
  61592. * @param meshes The meshes to explode.
  61593. * @param centerMesh The mesh to be center of explosion.
  61594. */
  61595. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61596. private _setCenterMesh;
  61597. /**
  61598. * Get class name
  61599. * @returns "MeshExploder"
  61600. */
  61601. getClassName(): string;
  61602. /**
  61603. * "Exploded meshes"
  61604. * @returns Array of meshes with the centerMesh at index 0.
  61605. */
  61606. getMeshes(): Array<Mesh>;
  61607. /**
  61608. * Explodes meshes giving a specific direction
  61609. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61610. */
  61611. explode(direction?: number): void;
  61612. }
  61613. }
  61614. declare module BABYLON {
  61615. /**
  61616. * Class used to help managing file picking and drag'n'drop
  61617. */
  61618. export class FilesInput {
  61619. /**
  61620. * List of files ready to be loaded
  61621. */
  61622. static readonly FilesToLoad: {
  61623. [key: string]: File;
  61624. };
  61625. /**
  61626. * Callback called when a file is processed
  61627. */
  61628. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61629. private _engine;
  61630. private _currentScene;
  61631. private _sceneLoadedCallback;
  61632. private _progressCallback;
  61633. private _additionalRenderLoopLogicCallback;
  61634. private _textureLoadingCallback;
  61635. private _startingProcessingFilesCallback;
  61636. private _onReloadCallback;
  61637. private _errorCallback;
  61638. private _elementToMonitor;
  61639. private _sceneFileToLoad;
  61640. private _filesToLoad;
  61641. /**
  61642. * Creates a new FilesInput
  61643. * @param engine defines the rendering engine
  61644. * @param scene defines the hosting scene
  61645. * @param sceneLoadedCallback callback called when scene is loaded
  61646. * @param progressCallback callback called to track progress
  61647. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61648. * @param textureLoadingCallback callback called when a texture is loading
  61649. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61650. * @param onReloadCallback callback called when a reload is requested
  61651. * @param errorCallback callback call if an error occurs
  61652. */
  61653. 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);
  61654. private _dragEnterHandler;
  61655. private _dragOverHandler;
  61656. private _dropHandler;
  61657. /**
  61658. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61659. * @param elementToMonitor defines the DOM element to track
  61660. */
  61661. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61662. /**
  61663. * Release all associated resources
  61664. */
  61665. dispose(): void;
  61666. private renderFunction;
  61667. private drag;
  61668. private drop;
  61669. private _traverseFolder;
  61670. private _processFiles;
  61671. /**
  61672. * Load files from a drop event
  61673. * @param event defines the drop event to use as source
  61674. */
  61675. loadFiles(event: any): void;
  61676. private _processReload;
  61677. /**
  61678. * Reload the current scene from the loaded files
  61679. */
  61680. reload(): void;
  61681. }
  61682. }
  61683. declare module BABYLON {
  61684. /**
  61685. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61686. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61687. */
  61688. export class SceneOptimization {
  61689. /**
  61690. * Defines the priority of this optimization (0 by default which means first in the list)
  61691. */
  61692. priority: number;
  61693. /**
  61694. * Gets a string describing the action executed by the current optimization
  61695. * @returns description string
  61696. */
  61697. getDescription(): string;
  61698. /**
  61699. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61700. * @param scene defines the current scene where to apply this optimization
  61701. * @param optimizer defines the current optimizer
  61702. * @returns true if everything that can be done was applied
  61703. */
  61704. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61705. /**
  61706. * Creates the SceneOptimization object
  61707. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61708. * @param desc defines the description associated with the optimization
  61709. */
  61710. constructor(
  61711. /**
  61712. * Defines the priority of this optimization (0 by default which means first in the list)
  61713. */
  61714. priority?: number);
  61715. }
  61716. /**
  61717. * Defines an optimization used to reduce the size of render target textures
  61718. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61719. */
  61720. export class TextureOptimization extends SceneOptimization {
  61721. /**
  61722. * Defines the priority of this optimization (0 by default which means first in the list)
  61723. */
  61724. priority: number;
  61725. /**
  61726. * 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
  61727. */
  61728. maximumSize: number;
  61729. /**
  61730. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61731. */
  61732. step: number;
  61733. /**
  61734. * Gets a string describing the action executed by the current optimization
  61735. * @returns description string
  61736. */
  61737. getDescription(): string;
  61738. /**
  61739. * Creates the TextureOptimization object
  61740. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61741. * @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
  61742. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61743. */
  61744. constructor(
  61745. /**
  61746. * Defines the priority of this optimization (0 by default which means first in the list)
  61747. */
  61748. priority?: number,
  61749. /**
  61750. * 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
  61751. */
  61752. maximumSize?: number,
  61753. /**
  61754. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61755. */
  61756. step?: number);
  61757. /**
  61758. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61759. * @param scene defines the current scene where to apply this optimization
  61760. * @param optimizer defines the current optimizer
  61761. * @returns true if everything that can be done was applied
  61762. */
  61763. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61764. }
  61765. /**
  61766. * Defines an optimization used to increase or decrease the rendering resolution
  61767. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61768. */
  61769. export class HardwareScalingOptimization extends SceneOptimization {
  61770. /**
  61771. * Defines the priority of this optimization (0 by default which means first in the list)
  61772. */
  61773. priority: number;
  61774. /**
  61775. * Defines the maximum scale to use (2 by default)
  61776. */
  61777. maximumScale: number;
  61778. /**
  61779. * Defines the step to use between two passes (0.5 by default)
  61780. */
  61781. step: number;
  61782. private _currentScale;
  61783. private _directionOffset;
  61784. /**
  61785. * Gets a string describing the action executed by the current optimization
  61786. * @return description string
  61787. */
  61788. getDescription(): string;
  61789. /**
  61790. * Creates the HardwareScalingOptimization object
  61791. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61792. * @param maximumScale defines the maximum scale to use (2 by default)
  61793. * @param step defines the step to use between two passes (0.5 by default)
  61794. */
  61795. constructor(
  61796. /**
  61797. * Defines the priority of this optimization (0 by default which means first in the list)
  61798. */
  61799. priority?: number,
  61800. /**
  61801. * Defines the maximum scale to use (2 by default)
  61802. */
  61803. maximumScale?: number,
  61804. /**
  61805. * Defines the step to use between two passes (0.5 by default)
  61806. */
  61807. step?: number);
  61808. /**
  61809. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61810. * @param scene defines the current scene where to apply this optimization
  61811. * @param optimizer defines the current optimizer
  61812. * @returns true if everything that can be done was applied
  61813. */
  61814. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61815. }
  61816. /**
  61817. * Defines an optimization used to remove shadows
  61818. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61819. */
  61820. export class ShadowsOptimization extends SceneOptimization {
  61821. /**
  61822. * Gets a string describing the action executed by the current optimization
  61823. * @return description string
  61824. */
  61825. getDescription(): string;
  61826. /**
  61827. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61828. * @param scene defines the current scene where to apply this optimization
  61829. * @param optimizer defines the current optimizer
  61830. * @returns true if everything that can be done was applied
  61831. */
  61832. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61833. }
  61834. /**
  61835. * Defines an optimization used to turn post-processes off
  61836. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61837. */
  61838. export class PostProcessesOptimization extends SceneOptimization {
  61839. /**
  61840. * Gets a string describing the action executed by the current optimization
  61841. * @return description string
  61842. */
  61843. getDescription(): string;
  61844. /**
  61845. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61846. * @param scene defines the current scene where to apply this optimization
  61847. * @param optimizer defines the current optimizer
  61848. * @returns true if everything that can be done was applied
  61849. */
  61850. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61851. }
  61852. /**
  61853. * Defines an optimization used to turn lens flares off
  61854. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61855. */
  61856. export class LensFlaresOptimization extends SceneOptimization {
  61857. /**
  61858. * Gets a string describing the action executed by the current optimization
  61859. * @return description string
  61860. */
  61861. getDescription(): string;
  61862. /**
  61863. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61864. * @param scene defines the current scene where to apply this optimization
  61865. * @param optimizer defines the current optimizer
  61866. * @returns true if everything that can be done was applied
  61867. */
  61868. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61869. }
  61870. /**
  61871. * Defines an optimization based on user defined callback.
  61872. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61873. */
  61874. export class CustomOptimization extends SceneOptimization {
  61875. /**
  61876. * Callback called to apply the custom optimization.
  61877. */
  61878. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61879. /**
  61880. * Callback called to get custom description
  61881. */
  61882. onGetDescription: () => string;
  61883. /**
  61884. * Gets a string describing the action executed by the current optimization
  61885. * @returns description string
  61886. */
  61887. getDescription(): string;
  61888. /**
  61889. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61890. * @param scene defines the current scene where to apply this optimization
  61891. * @param optimizer defines the current optimizer
  61892. * @returns true if everything that can be done was applied
  61893. */
  61894. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61895. }
  61896. /**
  61897. * Defines an optimization used to turn particles off
  61898. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61899. */
  61900. export class ParticlesOptimization extends SceneOptimization {
  61901. /**
  61902. * Gets a string describing the action executed by the current optimization
  61903. * @return description string
  61904. */
  61905. getDescription(): string;
  61906. /**
  61907. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61908. * @param scene defines the current scene where to apply this optimization
  61909. * @param optimizer defines the current optimizer
  61910. * @returns true if everything that can be done was applied
  61911. */
  61912. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61913. }
  61914. /**
  61915. * Defines an optimization used to turn render targets off
  61916. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61917. */
  61918. export class RenderTargetsOptimization extends SceneOptimization {
  61919. /**
  61920. * Gets a string describing the action executed by the current optimization
  61921. * @return description string
  61922. */
  61923. getDescription(): string;
  61924. /**
  61925. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61926. * @param scene defines the current scene where to apply this optimization
  61927. * @param optimizer defines the current optimizer
  61928. * @returns true if everything that can be done was applied
  61929. */
  61930. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61931. }
  61932. /**
  61933. * Defines an optimization used to merge meshes with compatible materials
  61934. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61935. */
  61936. export class MergeMeshesOptimization extends SceneOptimization {
  61937. private static _UpdateSelectionTree;
  61938. /**
  61939. * Gets or sets a boolean which defines if optimization octree has to be updated
  61940. */
  61941. /**
  61942. * Gets or sets a boolean which defines if optimization octree has to be updated
  61943. */
  61944. static UpdateSelectionTree: boolean;
  61945. /**
  61946. * Gets a string describing the action executed by the current optimization
  61947. * @return description string
  61948. */
  61949. getDescription(): string;
  61950. private _canBeMerged;
  61951. /**
  61952. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61953. * @param scene defines the current scene where to apply this optimization
  61954. * @param optimizer defines the current optimizer
  61955. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61956. * @returns true if everything that can be done was applied
  61957. */
  61958. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61959. }
  61960. /**
  61961. * Defines a list of options used by SceneOptimizer
  61962. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61963. */
  61964. export class SceneOptimizerOptions {
  61965. /**
  61966. * Defines the target frame rate to reach (60 by default)
  61967. */
  61968. targetFrameRate: number;
  61969. /**
  61970. * Defines the interval between two checkes (2000ms by default)
  61971. */
  61972. trackerDuration: number;
  61973. /**
  61974. * Gets the list of optimizations to apply
  61975. */
  61976. optimizations: SceneOptimization[];
  61977. /**
  61978. * Creates a new list of options used by SceneOptimizer
  61979. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61980. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61981. */
  61982. constructor(
  61983. /**
  61984. * Defines the target frame rate to reach (60 by default)
  61985. */
  61986. targetFrameRate?: number,
  61987. /**
  61988. * Defines the interval between two checkes (2000ms by default)
  61989. */
  61990. trackerDuration?: number);
  61991. /**
  61992. * Add a new optimization
  61993. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61994. * @returns the current SceneOptimizerOptions
  61995. */
  61996. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61997. /**
  61998. * Add a new custom optimization
  61999. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62000. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62001. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62002. * @returns the current SceneOptimizerOptions
  62003. */
  62004. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62005. /**
  62006. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62007. * @param targetFrameRate defines the target frame rate (60 by default)
  62008. * @returns a SceneOptimizerOptions object
  62009. */
  62010. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62011. /**
  62012. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62013. * @param targetFrameRate defines the target frame rate (60 by default)
  62014. * @returns a SceneOptimizerOptions object
  62015. */
  62016. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62017. /**
  62018. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62019. * @param targetFrameRate defines the target frame rate (60 by default)
  62020. * @returns a SceneOptimizerOptions object
  62021. */
  62022. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62023. }
  62024. /**
  62025. * Class used to run optimizations in order to reach a target frame rate
  62026. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62027. */
  62028. export class SceneOptimizer implements IDisposable {
  62029. private _isRunning;
  62030. private _options;
  62031. private _scene;
  62032. private _currentPriorityLevel;
  62033. private _targetFrameRate;
  62034. private _trackerDuration;
  62035. private _currentFrameRate;
  62036. private _sceneDisposeObserver;
  62037. private _improvementMode;
  62038. /**
  62039. * Defines an observable called when the optimizer reaches the target frame rate
  62040. */
  62041. onSuccessObservable: Observable<SceneOptimizer>;
  62042. /**
  62043. * Defines an observable called when the optimizer enables an optimization
  62044. */
  62045. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62046. /**
  62047. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62048. */
  62049. onFailureObservable: Observable<SceneOptimizer>;
  62050. /**
  62051. * Gets a boolean indicating if the optimizer is in improvement mode
  62052. */
  62053. readonly isInImprovementMode: boolean;
  62054. /**
  62055. * Gets the current priority level (0 at start)
  62056. */
  62057. readonly currentPriorityLevel: number;
  62058. /**
  62059. * Gets the current frame rate checked by the SceneOptimizer
  62060. */
  62061. readonly currentFrameRate: number;
  62062. /**
  62063. * Gets or sets the current target frame rate (60 by default)
  62064. */
  62065. /**
  62066. * Gets or sets the current target frame rate (60 by default)
  62067. */
  62068. targetFrameRate: number;
  62069. /**
  62070. * Gets or sets the current interval between two checks (every 2000ms by default)
  62071. */
  62072. /**
  62073. * Gets or sets the current interval between two checks (every 2000ms by default)
  62074. */
  62075. trackerDuration: number;
  62076. /**
  62077. * Gets the list of active optimizations
  62078. */
  62079. readonly optimizations: SceneOptimization[];
  62080. /**
  62081. * Creates a new SceneOptimizer
  62082. * @param scene defines the scene to work on
  62083. * @param options defines the options to use with the SceneOptimizer
  62084. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62085. * @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)
  62086. */
  62087. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62088. /**
  62089. * Stops the current optimizer
  62090. */
  62091. stop(): void;
  62092. /**
  62093. * Reset the optimizer to initial step (current priority level = 0)
  62094. */
  62095. reset(): void;
  62096. /**
  62097. * Start the optimizer. By default it will try to reach a specific framerate
  62098. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62099. */
  62100. start(): void;
  62101. private _checkCurrentState;
  62102. /**
  62103. * Release all resources
  62104. */
  62105. dispose(): void;
  62106. /**
  62107. * Helper function to create a SceneOptimizer with one single line of code
  62108. * @param scene defines the scene to work on
  62109. * @param options defines the options to use with the SceneOptimizer
  62110. * @param onSuccess defines a callback to call on success
  62111. * @param onFailure defines a callback to call on failure
  62112. * @returns the new SceneOptimizer object
  62113. */
  62114. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62115. }
  62116. }
  62117. declare module BABYLON {
  62118. /**
  62119. * Class used to serialize a scene into a string
  62120. */
  62121. export class SceneSerializer {
  62122. /**
  62123. * Clear cache used by a previous serialization
  62124. */
  62125. static ClearCache(): void;
  62126. /**
  62127. * Serialize a scene into a JSON compatible object
  62128. * @param scene defines the scene to serialize
  62129. * @returns a JSON compatible object
  62130. */
  62131. static Serialize(scene: Scene): any;
  62132. /**
  62133. * Serialize a mesh into a JSON compatible object
  62134. * @param toSerialize defines the mesh to serialize
  62135. * @param withParents defines if parents must be serialized as well
  62136. * @param withChildren defines if children must be serialized as well
  62137. * @returns a JSON compatible object
  62138. */
  62139. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62140. }
  62141. }
  62142. declare module BABYLON {
  62143. /**
  62144. * Class used to host texture specific utilities
  62145. */
  62146. export class TextureTools {
  62147. /**
  62148. * Uses the GPU to create a copy texture rescaled at a given size
  62149. * @param texture Texture to copy from
  62150. * @param width defines the desired width
  62151. * @param height defines the desired height
  62152. * @param useBilinearMode defines if bilinear mode has to be used
  62153. * @return the generated texture
  62154. */
  62155. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62156. }
  62157. }
  62158. declare module BABYLON {
  62159. /**
  62160. * This represents the different options available for the video capture.
  62161. */
  62162. export interface VideoRecorderOptions {
  62163. /** Defines the mime type of the video. */
  62164. mimeType: string;
  62165. /** Defines the FPS the video should be recorded at. */
  62166. fps: number;
  62167. /** Defines the chunk size for the recording data. */
  62168. recordChunckSize: number;
  62169. /** The audio tracks to attach to the recording. */
  62170. audioTracks?: MediaStreamTrack[];
  62171. }
  62172. /**
  62173. * This can help with recording videos from BabylonJS.
  62174. * This is based on the available WebRTC functionalities of the browser.
  62175. *
  62176. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62177. */
  62178. export class VideoRecorder {
  62179. private static readonly _defaultOptions;
  62180. /**
  62181. * Returns whether or not the VideoRecorder is available in your browser.
  62182. * @param engine Defines the Babylon Engine.
  62183. * @returns true if supported otherwise false.
  62184. */
  62185. static IsSupported(engine: Engine): boolean;
  62186. private readonly _options;
  62187. private _canvas;
  62188. private _mediaRecorder;
  62189. private _recordedChunks;
  62190. private _fileName;
  62191. private _resolve;
  62192. private _reject;
  62193. /**
  62194. * True when a recording is already in progress.
  62195. */
  62196. readonly isRecording: boolean;
  62197. /**
  62198. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62199. * @param engine Defines the BabylonJS Engine you wish to record.
  62200. * @param options Defines options that can be used to customize the capture.
  62201. */
  62202. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62203. /**
  62204. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62205. */
  62206. stopRecording(): void;
  62207. /**
  62208. * Starts recording the canvas for a max duration specified in parameters.
  62209. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62210. * If null no automatic download will start and you can rely on the promise to get the data back.
  62211. * @param maxDuration Defines the maximum recording time in seconds.
  62212. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62213. * @return A promise callback at the end of the recording with the video data in Blob.
  62214. */
  62215. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62216. /**
  62217. * Releases internal resources used during the recording.
  62218. */
  62219. dispose(): void;
  62220. private _handleDataAvailable;
  62221. private _handleError;
  62222. private _handleStop;
  62223. }
  62224. }
  62225. declare module BABYLON {
  62226. /**
  62227. * Class containing a set of static utilities functions for screenshots
  62228. */
  62229. export class ScreenshotTools {
  62230. /**
  62231. * Captures a screenshot of the current rendering
  62232. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62233. * @param engine defines the rendering engine
  62234. * @param camera defines the source camera
  62235. * @param size This parameter can be set to a single number or to an object with the
  62236. * following (optional) properties: precision, width, height. If a single number is passed,
  62237. * it will be used for both width and height. If an object is passed, the screenshot size
  62238. * will be derived from the parameters. The precision property is a multiplier allowing
  62239. * rendering at a higher or lower resolution
  62240. * @param successCallback defines the callback receives a single parameter which contains the
  62241. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62242. * src parameter of an <img> to display it
  62243. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62244. * Check your browser for supported MIME types
  62245. */
  62246. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  62247. /**
  62248. * Captures a screenshot of the current rendering
  62249. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62250. * @param engine defines the rendering engine
  62251. * @param camera defines the source camera
  62252. * @param size This parameter can be set to a single number or to an object with the
  62253. * following (optional) properties: precision, width, height. If a single number is passed,
  62254. * it will be used for both width and height. If an object is passed, the screenshot size
  62255. * will be derived from the parameters. The precision property is a multiplier allowing
  62256. * rendering at a higher or lower resolution
  62257. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62258. * Check your browser for supported MIME types
  62259. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62260. * to the src parameter of an <img> to display it
  62261. */
  62262. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  62263. /**
  62264. * Generates an image screenshot from the specified camera.
  62265. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62266. * @param engine The engine to use for rendering
  62267. * @param camera The camera to use for rendering
  62268. * @param size This parameter can be set to a single number or to an object with the
  62269. * following (optional) properties: precision, width, height. If a single number is passed,
  62270. * it will be used for both width and height. If an object is passed, the screenshot size
  62271. * will be derived from the parameters. The precision property is a multiplier allowing
  62272. * rendering at a higher or lower resolution
  62273. * @param successCallback The callback receives a single parameter which contains the
  62274. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62275. * src parameter of an <img> to display it
  62276. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62277. * Check your browser for supported MIME types
  62278. * @param samples Texture samples (default: 1)
  62279. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62280. * @param fileName A name for for the downloaded file.
  62281. */
  62282. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62283. /**
  62284. * Generates an image screenshot from the specified camera.
  62285. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62286. * @param engine The engine to use for rendering
  62287. * @param camera The camera to use for rendering
  62288. * @param size This parameter can be set to a single number or to an object with the
  62289. * following (optional) properties: precision, width, height. If a single number is passed,
  62290. * it will be used for both width and height. If an object is passed, the screenshot size
  62291. * will be derived from the parameters. The precision property is a multiplier allowing
  62292. * rendering at a higher or lower resolution
  62293. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62294. * Check your browser for supported MIME types
  62295. * @param samples Texture samples (default: 1)
  62296. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62297. * @param fileName A name for for the downloaded file.
  62298. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62299. * to the src parameter of an <img> to display it
  62300. */
  62301. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  62302. /**
  62303. * Gets height and width for screenshot size
  62304. * @private
  62305. */
  62306. private static _getScreenshotSize;
  62307. }
  62308. }
  62309. declare module BABYLON {
  62310. /**
  62311. * A cursor which tracks a point on a path
  62312. */
  62313. export class PathCursor {
  62314. private path;
  62315. /**
  62316. * Stores path cursor callbacks for when an onchange event is triggered
  62317. */
  62318. private _onchange;
  62319. /**
  62320. * The value of the path cursor
  62321. */
  62322. value: number;
  62323. /**
  62324. * The animation array of the path cursor
  62325. */
  62326. animations: Animation[];
  62327. /**
  62328. * Initializes the path cursor
  62329. * @param path The path to track
  62330. */
  62331. constructor(path: Path2);
  62332. /**
  62333. * Gets the cursor point on the path
  62334. * @returns A point on the path cursor at the cursor location
  62335. */
  62336. getPoint(): Vector3;
  62337. /**
  62338. * Moves the cursor ahead by the step amount
  62339. * @param step The amount to move the cursor forward
  62340. * @returns This path cursor
  62341. */
  62342. moveAhead(step?: number): PathCursor;
  62343. /**
  62344. * Moves the cursor behind by the step amount
  62345. * @param step The amount to move the cursor back
  62346. * @returns This path cursor
  62347. */
  62348. moveBack(step?: number): PathCursor;
  62349. /**
  62350. * Moves the cursor by the step amount
  62351. * If the step amount is greater than one, an exception is thrown
  62352. * @param step The amount to move the cursor
  62353. * @returns This path cursor
  62354. */
  62355. move(step: number): PathCursor;
  62356. /**
  62357. * Ensures that the value is limited between zero and one
  62358. * @returns This path cursor
  62359. */
  62360. private ensureLimits;
  62361. /**
  62362. * Runs onchange callbacks on change (used by the animation engine)
  62363. * @returns This path cursor
  62364. */
  62365. private raiseOnChange;
  62366. /**
  62367. * Executes a function on change
  62368. * @param f A path cursor onchange callback
  62369. * @returns This path cursor
  62370. */
  62371. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62372. }
  62373. }
  62374. declare module BABYLON {
  62375. /** @hidden */
  62376. export var blurPixelShader: {
  62377. name: string;
  62378. shader: string;
  62379. };
  62380. }
  62381. declare module BABYLON {
  62382. /** @hidden */
  62383. export var pointCloudVertexDeclaration: {
  62384. name: string;
  62385. shader: string;
  62386. };
  62387. }
  62388. // Mixins
  62389. interface Window {
  62390. mozIndexedDB: IDBFactory;
  62391. webkitIndexedDB: IDBFactory;
  62392. msIndexedDB: IDBFactory;
  62393. webkitURL: typeof URL;
  62394. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62395. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62396. WebGLRenderingContext: WebGLRenderingContext;
  62397. MSGesture: MSGesture;
  62398. CANNON: any;
  62399. AudioContext: AudioContext;
  62400. webkitAudioContext: AudioContext;
  62401. PointerEvent: any;
  62402. Math: Math;
  62403. Uint8Array: Uint8ArrayConstructor;
  62404. Float32Array: Float32ArrayConstructor;
  62405. mozURL: typeof URL;
  62406. msURL: typeof URL;
  62407. VRFrameData: any; // WebVR, from specs 1.1
  62408. DracoDecoderModule: any;
  62409. setImmediate(handler: (...args: any[]) => void): number;
  62410. }
  62411. interface HTMLCanvasElement {
  62412. requestPointerLock(): void;
  62413. msRequestPointerLock?(): void;
  62414. mozRequestPointerLock?(): void;
  62415. webkitRequestPointerLock?(): void;
  62416. /** Track wether a record is in progress */
  62417. isRecording: boolean;
  62418. /** Capture Stream method defined by some browsers */
  62419. captureStream(fps?: number): MediaStream;
  62420. }
  62421. interface CanvasRenderingContext2D {
  62422. msImageSmoothingEnabled: boolean;
  62423. }
  62424. interface MouseEvent {
  62425. mozMovementX: number;
  62426. mozMovementY: number;
  62427. webkitMovementX: number;
  62428. webkitMovementY: number;
  62429. msMovementX: number;
  62430. msMovementY: number;
  62431. }
  62432. interface Navigator {
  62433. mozGetVRDevices: (any: any) => any;
  62434. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62435. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62436. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62437. webkitGetGamepads(): Gamepad[];
  62438. msGetGamepads(): Gamepad[];
  62439. webkitGamepads(): Gamepad[];
  62440. }
  62441. interface HTMLVideoElement {
  62442. mozSrcObject: any;
  62443. }
  62444. interface Math {
  62445. fround(x: number): number;
  62446. imul(a: number, b: number): number;
  62447. }
  62448. interface WebGLRenderingContext {
  62449. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62450. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62451. vertexAttribDivisor(index: number, divisor: number): void;
  62452. createVertexArray(): any;
  62453. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62454. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62455. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62456. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62457. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62458. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62459. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62460. // Queries
  62461. createQuery(): WebGLQuery;
  62462. deleteQuery(query: WebGLQuery): void;
  62463. beginQuery(target: number, query: WebGLQuery): void;
  62464. endQuery(target: number): void;
  62465. getQueryParameter(query: WebGLQuery, pname: number): any;
  62466. getQuery(target: number, pname: number): any;
  62467. MAX_SAMPLES: number;
  62468. RGBA8: number;
  62469. READ_FRAMEBUFFER: number;
  62470. DRAW_FRAMEBUFFER: number;
  62471. UNIFORM_BUFFER: number;
  62472. HALF_FLOAT_OES: number;
  62473. RGBA16F: number;
  62474. RGBA32F: number;
  62475. R32F: number;
  62476. RG32F: number;
  62477. RGB32F: number;
  62478. R16F: number;
  62479. RG16F: number;
  62480. RGB16F: number;
  62481. RED: number;
  62482. RG: number;
  62483. R8: number;
  62484. RG8: number;
  62485. UNSIGNED_INT_24_8: number;
  62486. DEPTH24_STENCIL8: number;
  62487. MIN: number;
  62488. MAX: number;
  62489. /* Multiple Render Targets */
  62490. drawBuffers(buffers: number[]): void;
  62491. readBuffer(src: number): void;
  62492. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62493. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62494. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62495. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62496. // Occlusion Query
  62497. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62498. ANY_SAMPLES_PASSED: number;
  62499. QUERY_RESULT_AVAILABLE: number;
  62500. QUERY_RESULT: number;
  62501. }
  62502. interface WebGLProgram {
  62503. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62504. }
  62505. interface EXT_disjoint_timer_query {
  62506. QUERY_COUNTER_BITS_EXT: number;
  62507. TIME_ELAPSED_EXT: number;
  62508. TIMESTAMP_EXT: number;
  62509. GPU_DISJOINT_EXT: number;
  62510. QUERY_RESULT_EXT: number;
  62511. QUERY_RESULT_AVAILABLE_EXT: number;
  62512. queryCounterEXT(query: WebGLQuery, target: number): void;
  62513. createQueryEXT(): WebGLQuery;
  62514. beginQueryEXT(target: number, query: WebGLQuery): void;
  62515. endQueryEXT(target: number): void;
  62516. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62517. deleteQueryEXT(query: WebGLQuery): void;
  62518. }
  62519. interface WebGLUniformLocation {
  62520. _currentState: any;
  62521. }
  62522. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62523. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62524. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62525. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62526. interface WebGLRenderingContext {
  62527. readonly RASTERIZER_DISCARD: number;
  62528. readonly DEPTH_COMPONENT24: number;
  62529. readonly TEXTURE_3D: number;
  62530. readonly TEXTURE_2D_ARRAY: number;
  62531. readonly TEXTURE_COMPARE_FUNC: number;
  62532. readonly TEXTURE_COMPARE_MODE: number;
  62533. readonly COMPARE_REF_TO_TEXTURE: number;
  62534. readonly TEXTURE_WRAP_R: number;
  62535. readonly HALF_FLOAT: number;
  62536. readonly RGB8: number;
  62537. readonly RED_INTEGER: number;
  62538. readonly RG_INTEGER: number;
  62539. readonly RGB_INTEGER: number;
  62540. readonly RGBA_INTEGER: number;
  62541. readonly R8_SNORM: number;
  62542. readonly RG8_SNORM: number;
  62543. readonly RGB8_SNORM: number;
  62544. readonly RGBA8_SNORM: number;
  62545. readonly R8I: number;
  62546. readonly RG8I: number;
  62547. readonly RGB8I: number;
  62548. readonly RGBA8I: number;
  62549. readonly R8UI: number;
  62550. readonly RG8UI: number;
  62551. readonly RGB8UI: number;
  62552. readonly RGBA8UI: number;
  62553. readonly R16I: number;
  62554. readonly RG16I: number;
  62555. readonly RGB16I: number;
  62556. readonly RGBA16I: number;
  62557. readonly R16UI: number;
  62558. readonly RG16UI: number;
  62559. readonly RGB16UI: number;
  62560. readonly RGBA16UI: number;
  62561. readonly R32I: number;
  62562. readonly RG32I: number;
  62563. readonly RGB32I: number;
  62564. readonly RGBA32I: number;
  62565. readonly R32UI: number;
  62566. readonly RG32UI: number;
  62567. readonly RGB32UI: number;
  62568. readonly RGBA32UI: number;
  62569. readonly RGB10_A2UI: number;
  62570. readonly R11F_G11F_B10F: number;
  62571. readonly RGB9_E5: number;
  62572. readonly RGB10_A2: number;
  62573. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62574. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62575. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62576. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62577. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62578. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62579. 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;
  62580. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62581. readonly TRANSFORM_FEEDBACK: number;
  62582. readonly INTERLEAVED_ATTRIBS: number;
  62583. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62584. createTransformFeedback(): WebGLTransformFeedback;
  62585. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62586. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62587. beginTransformFeedback(primitiveMode: number): void;
  62588. endTransformFeedback(): void;
  62589. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62590. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62591. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62592. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62593. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62594. }
  62595. interface ImageBitmap {
  62596. readonly width: number;
  62597. readonly height: number;
  62598. close(): void;
  62599. }
  62600. interface WebGLQuery extends WebGLObject {
  62601. }
  62602. declare var WebGLQuery: {
  62603. prototype: WebGLQuery;
  62604. new(): WebGLQuery;
  62605. };
  62606. interface WebGLSampler extends WebGLObject {
  62607. }
  62608. declare var WebGLSampler: {
  62609. prototype: WebGLSampler;
  62610. new(): WebGLSampler;
  62611. };
  62612. interface WebGLSync extends WebGLObject {
  62613. }
  62614. declare var WebGLSync: {
  62615. prototype: WebGLSync;
  62616. new(): WebGLSync;
  62617. };
  62618. interface WebGLTransformFeedback extends WebGLObject {
  62619. }
  62620. declare var WebGLTransformFeedback: {
  62621. prototype: WebGLTransformFeedback;
  62622. new(): WebGLTransformFeedback;
  62623. };
  62624. interface WebGLVertexArrayObject extends WebGLObject {
  62625. }
  62626. declare var WebGLVertexArrayObject: {
  62627. prototype: WebGLVertexArrayObject;
  62628. new(): WebGLVertexArrayObject;
  62629. };
  62630. // Type definitions for WebVR API
  62631. // Project: https://w3c.github.io/webvr/
  62632. // Definitions by: six a <https://github.com/lostfictions>
  62633. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62634. interface VRDisplay extends EventTarget {
  62635. /**
  62636. * Dictionary of capabilities describing the VRDisplay.
  62637. */
  62638. readonly capabilities: VRDisplayCapabilities;
  62639. /**
  62640. * z-depth defining the far plane of the eye view frustum
  62641. * enables mapping of values in the render target depth
  62642. * attachment to scene coordinates. Initially set to 10000.0.
  62643. */
  62644. depthFar: number;
  62645. /**
  62646. * z-depth defining the near plane of the eye view frustum
  62647. * enables mapping of values in the render target depth
  62648. * attachment to scene coordinates. Initially set to 0.01.
  62649. */
  62650. depthNear: number;
  62651. /**
  62652. * An identifier for this distinct VRDisplay. Used as an
  62653. * association point in the Gamepad API.
  62654. */
  62655. readonly displayId: number;
  62656. /**
  62657. * A display name, a user-readable name identifying it.
  62658. */
  62659. readonly displayName: string;
  62660. readonly isConnected: boolean;
  62661. readonly isPresenting: boolean;
  62662. /**
  62663. * If this VRDisplay supports room-scale experiences, the optional
  62664. * stage attribute contains details on the room-scale parameters.
  62665. */
  62666. readonly stageParameters: VRStageParameters | null;
  62667. /**
  62668. * Passing the value returned by `requestAnimationFrame` to
  62669. * `cancelAnimationFrame` will unregister the callback.
  62670. * @param handle Define the hanle of the request to cancel
  62671. */
  62672. cancelAnimationFrame(handle: number): void;
  62673. /**
  62674. * Stops presenting to the VRDisplay.
  62675. * @returns a promise to know when it stopped
  62676. */
  62677. exitPresent(): Promise<void>;
  62678. /**
  62679. * Return the current VREyeParameters for the given eye.
  62680. * @param whichEye Define the eye we want the parameter for
  62681. * @returns the eye parameters
  62682. */
  62683. getEyeParameters(whichEye: string): VREyeParameters;
  62684. /**
  62685. * Populates the passed VRFrameData with the information required to render
  62686. * the current frame.
  62687. * @param frameData Define the data structure to populate
  62688. * @returns true if ok otherwise false
  62689. */
  62690. getFrameData(frameData: VRFrameData): boolean;
  62691. /**
  62692. * Get the layers currently being presented.
  62693. * @returns the list of VR layers
  62694. */
  62695. getLayers(): VRLayer[];
  62696. /**
  62697. * Return a VRPose containing the future predicted pose of the VRDisplay
  62698. * when the current frame will be presented. The value returned will not
  62699. * change until JavaScript has returned control to the browser.
  62700. *
  62701. * The VRPose will contain the position, orientation, velocity,
  62702. * and acceleration of each of these properties.
  62703. * @returns the pose object
  62704. */
  62705. getPose(): VRPose;
  62706. /**
  62707. * Return the current instantaneous pose of the VRDisplay, with no
  62708. * prediction applied.
  62709. * @returns the current instantaneous pose
  62710. */
  62711. getImmediatePose(): VRPose;
  62712. /**
  62713. * The callback passed to `requestAnimationFrame` will be called
  62714. * any time a new frame should be rendered. When the VRDisplay is
  62715. * presenting the callback will be called at the native refresh
  62716. * rate of the HMD. When not presenting this function acts
  62717. * identically to how window.requestAnimationFrame acts. Content should
  62718. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62719. * asynchronously from other displays and at differing refresh rates.
  62720. * @param callback Define the eaction to run next frame
  62721. * @returns the request handle it
  62722. */
  62723. requestAnimationFrame(callback: FrameRequestCallback): number;
  62724. /**
  62725. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62726. * Repeat calls while already presenting will update the VRLayers being displayed.
  62727. * @param layers Define the list of layer to present
  62728. * @returns a promise to know when the request has been fulfilled
  62729. */
  62730. requestPresent(layers: VRLayer[]): Promise<void>;
  62731. /**
  62732. * Reset the pose for this display, treating its current position and
  62733. * orientation as the "origin/zero" values. VRPose.position,
  62734. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62735. * updated when calling resetPose(). This should be called in only
  62736. * sitting-space experiences.
  62737. */
  62738. resetPose(): void;
  62739. /**
  62740. * The VRLayer provided to the VRDisplay will be captured and presented
  62741. * in the HMD. Calling this function has the same effect on the source
  62742. * canvas as any other operation that uses its source image, and canvases
  62743. * created without preserveDrawingBuffer set to true will be cleared.
  62744. * @param pose Define the pose to submit
  62745. */
  62746. submitFrame(pose?: VRPose): void;
  62747. }
  62748. declare var VRDisplay: {
  62749. prototype: VRDisplay;
  62750. new(): VRDisplay;
  62751. };
  62752. interface VRLayer {
  62753. leftBounds?: number[] | Float32Array | null;
  62754. rightBounds?: number[] | Float32Array | null;
  62755. source?: HTMLCanvasElement | null;
  62756. }
  62757. interface VRDisplayCapabilities {
  62758. readonly canPresent: boolean;
  62759. readonly hasExternalDisplay: boolean;
  62760. readonly hasOrientation: boolean;
  62761. readonly hasPosition: boolean;
  62762. readonly maxLayers: number;
  62763. }
  62764. interface VREyeParameters {
  62765. /** @deprecated */
  62766. readonly fieldOfView: VRFieldOfView;
  62767. readonly offset: Float32Array;
  62768. readonly renderHeight: number;
  62769. readonly renderWidth: number;
  62770. }
  62771. interface VRFieldOfView {
  62772. readonly downDegrees: number;
  62773. readonly leftDegrees: number;
  62774. readonly rightDegrees: number;
  62775. readonly upDegrees: number;
  62776. }
  62777. interface VRFrameData {
  62778. readonly leftProjectionMatrix: Float32Array;
  62779. readonly leftViewMatrix: Float32Array;
  62780. readonly pose: VRPose;
  62781. readonly rightProjectionMatrix: Float32Array;
  62782. readonly rightViewMatrix: Float32Array;
  62783. readonly timestamp: number;
  62784. }
  62785. interface VRPose {
  62786. readonly angularAcceleration: Float32Array | null;
  62787. readonly angularVelocity: Float32Array | null;
  62788. readonly linearAcceleration: Float32Array | null;
  62789. readonly linearVelocity: Float32Array | null;
  62790. readonly orientation: Float32Array | null;
  62791. readonly position: Float32Array | null;
  62792. readonly timestamp: number;
  62793. }
  62794. interface VRStageParameters {
  62795. sittingToStandingTransform?: Float32Array;
  62796. sizeX?: number;
  62797. sizeY?: number;
  62798. }
  62799. interface Navigator {
  62800. getVRDisplays(): Promise<VRDisplay[]>;
  62801. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62802. }
  62803. interface Window {
  62804. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62805. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62806. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62807. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62808. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62809. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62810. }
  62811. interface Gamepad {
  62812. readonly displayId: number;
  62813. }
  62814. type XRSessionMode =
  62815. | "inline"
  62816. | "immersive-vr"
  62817. | "immersive-ar";
  62818. type XRReferenceSpaceType =
  62819. | "viewer"
  62820. | "local"
  62821. | "local-floor"
  62822. | "bounded-floor"
  62823. | "unbounded";
  62824. type XREnvironmentBlendMode =
  62825. | "opaque"
  62826. | "additive"
  62827. | "alpha-blend";
  62828. type XRVisibilityState =
  62829. | "visible"
  62830. | "visible-blurred"
  62831. | "hidden";
  62832. type XRHandedness =
  62833. | "none"
  62834. | "left"
  62835. | "right";
  62836. type XRTargetRayMode =
  62837. | "gaze"
  62838. | "tracked-pointer"
  62839. | "screen";
  62840. type XREye =
  62841. | "none"
  62842. | "left"
  62843. | "right";
  62844. interface XRSpace extends EventTarget {
  62845. }
  62846. interface XRRenderState {
  62847. depthNear?: number;
  62848. depthFar?: number;
  62849. inlineVerticalFieldOfView?: number;
  62850. baseLayer?: XRWebGLLayer;
  62851. }
  62852. interface XRInputSource {
  62853. handedness: XRHandedness;
  62854. targetRayMode: XRTargetRayMode;
  62855. targetRaySpace: XRSpace;
  62856. gripSpace: XRSpace | undefined;
  62857. gamepad: Gamepad | undefined;
  62858. profiles: Array<string>;
  62859. }
  62860. interface XRSession {
  62861. addEventListener: Function;
  62862. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  62863. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  62864. requestAnimationFrame: Function;
  62865. end(): Promise<void>;
  62866. renderState: XRRenderState;
  62867. inputSources: Array<XRInputSource>;
  62868. }
  62869. interface XRReferenceSpace extends XRSpace {
  62870. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  62871. onreset: any;
  62872. }
  62873. interface XRFrame {
  62874. session: XRSession;
  62875. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  62876. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  62877. }
  62878. interface XRViewerPose extends XRPose {
  62879. views: Array<XRView>;
  62880. }
  62881. interface XRPose {
  62882. transform: XRRigidTransform;
  62883. emulatedPosition: boolean;
  62884. }
  62885. declare var XRWebGLLayer: {
  62886. prototype: XRWebGLLayer;
  62887. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  62888. };
  62889. interface XRWebGLLayer {
  62890. framebuffer: WebGLFramebuffer;
  62891. framebufferWidth: number;
  62892. framebufferHeight: number;
  62893. getViewport: Function;
  62894. }
  62895. interface XRRigidTransform {
  62896. position: DOMPointReadOnly;
  62897. orientation: DOMPointReadOnly;
  62898. matrix: Float32Array;
  62899. inverse: XRRigidTransform;
  62900. }
  62901. interface XRView {
  62902. eye: XREye;
  62903. projectionMatrix: Float32Array;
  62904. transform: XRRigidTransform;
  62905. }
  62906. interface XRInputSourceChangeEvent {
  62907. session: XRSession;
  62908. removed: Array<XRInputSource>;
  62909. added: Array<XRInputSource>;
  62910. }
  62911. /**
  62912. * @ignore
  62913. */
  62914. declare module BABYLON.GLTF2.Exporter {
  62915. }
  62916. /**
  62917. * @ignore
  62918. */
  62919. declare module BABYLON.GLTF1 {
  62920. }
  62921. declare module BABYLON.GUI {
  62922. /**
  62923. * Class used to specific a value and its associated unit
  62924. */
  62925. export class ValueAndUnit {
  62926. /** defines the unit to store */
  62927. unit: number;
  62928. /** defines a boolean indicating if the value can be negative */
  62929. negativeValueAllowed: boolean;
  62930. private _value;
  62931. private _originalUnit;
  62932. /**
  62933. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  62934. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62935. */
  62936. ignoreAdaptiveScaling: boolean;
  62937. /**
  62938. * Creates a new ValueAndUnit
  62939. * @param value defines the value to store
  62940. * @param unit defines the unit to store
  62941. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  62942. */
  62943. constructor(value: number,
  62944. /** defines the unit to store */
  62945. unit?: number,
  62946. /** defines a boolean indicating if the value can be negative */
  62947. negativeValueAllowed?: boolean);
  62948. /** Gets a boolean indicating if the value is a percentage */
  62949. readonly isPercentage: boolean;
  62950. /** Gets a boolean indicating if the value is store as pixel */
  62951. readonly isPixel: boolean;
  62952. /** Gets direct internal value */
  62953. readonly internalValue: number;
  62954. /**
  62955. * Gets value as pixel
  62956. * @param host defines the root host
  62957. * @param refValue defines the reference value for percentages
  62958. * @returns the value as pixel
  62959. */
  62960. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  62961. /**
  62962. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  62963. * @param value defines the value to store
  62964. * @param unit defines the unit to store
  62965. * @returns the current ValueAndUnit
  62966. */
  62967. updateInPlace(value: number, unit?: number): ValueAndUnit;
  62968. /**
  62969. * Gets the value accordingly to its unit
  62970. * @param host defines the root host
  62971. * @returns the value
  62972. */
  62973. getValue(host: AdvancedDynamicTexture): number;
  62974. /**
  62975. * Gets a string representation of the value
  62976. * @param host defines the root host
  62977. * @param decimals defines an optional number of decimals to display
  62978. * @returns a string
  62979. */
  62980. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  62981. /**
  62982. * Store a value parsed from a string
  62983. * @param source defines the source string
  62984. * @returns true if the value was successfully parsed
  62985. */
  62986. fromString(source: string | number): boolean;
  62987. private static _Regex;
  62988. private static _UNITMODE_PERCENTAGE;
  62989. private static _UNITMODE_PIXEL;
  62990. /** UNITMODE_PERCENTAGE */
  62991. static readonly UNITMODE_PERCENTAGE: number;
  62992. /** UNITMODE_PIXEL */
  62993. static readonly UNITMODE_PIXEL: number;
  62994. }
  62995. }
  62996. declare module BABYLON.GUI {
  62997. /**
  62998. * Define a style used by control to automatically setup properties based on a template.
  62999. * Only support font related properties so far
  63000. */
  63001. export class Style implements BABYLON.IDisposable {
  63002. private _fontFamily;
  63003. private _fontStyle;
  63004. private _fontWeight;
  63005. /** @hidden */
  63006. _host: AdvancedDynamicTexture;
  63007. /** @hidden */
  63008. _fontSize: ValueAndUnit;
  63009. /**
  63010. * BABYLON.Observable raised when the style values are changed
  63011. */
  63012. onChangedObservable: BABYLON.Observable<Style>;
  63013. /**
  63014. * Creates a new style object
  63015. * @param host defines the AdvancedDynamicTexture which hosts this style
  63016. */
  63017. constructor(host: AdvancedDynamicTexture);
  63018. /**
  63019. * Gets or sets the font size
  63020. */
  63021. fontSize: string | number;
  63022. /**
  63023. * Gets or sets the font family
  63024. */
  63025. fontFamily: string;
  63026. /**
  63027. * Gets or sets the font style
  63028. */
  63029. fontStyle: string;
  63030. /** Gets or sets font weight */
  63031. fontWeight: string;
  63032. /** Dispose all associated resources */
  63033. dispose(): void;
  63034. }
  63035. }
  63036. declare module BABYLON.GUI {
  63037. /**
  63038. * Class used to transport BABYLON.Vector2 information for pointer events
  63039. */
  63040. export class Vector2WithInfo extends BABYLON.Vector2 {
  63041. /** defines the current mouse button index */
  63042. buttonIndex: number;
  63043. /**
  63044. * Creates a new Vector2WithInfo
  63045. * @param source defines the vector2 data to transport
  63046. * @param buttonIndex defines the current mouse button index
  63047. */
  63048. constructor(source: BABYLON.Vector2,
  63049. /** defines the current mouse button index */
  63050. buttonIndex?: number);
  63051. }
  63052. /** Class used to provide 2D matrix features */
  63053. export class Matrix2D {
  63054. /** Gets the internal array of 6 floats used to store matrix data */
  63055. m: Float32Array;
  63056. /**
  63057. * Creates a new matrix
  63058. * @param m00 defines value for (0, 0)
  63059. * @param m01 defines value for (0, 1)
  63060. * @param m10 defines value for (1, 0)
  63061. * @param m11 defines value for (1, 1)
  63062. * @param m20 defines value for (2, 0)
  63063. * @param m21 defines value for (2, 1)
  63064. */
  63065. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  63066. /**
  63067. * Fills the matrix from direct values
  63068. * @param m00 defines value for (0, 0)
  63069. * @param m01 defines value for (0, 1)
  63070. * @param m10 defines value for (1, 0)
  63071. * @param m11 defines value for (1, 1)
  63072. * @param m20 defines value for (2, 0)
  63073. * @param m21 defines value for (2, 1)
  63074. * @returns the current modified matrix
  63075. */
  63076. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  63077. /**
  63078. * Gets matrix determinant
  63079. * @returns the determinant
  63080. */
  63081. determinant(): number;
  63082. /**
  63083. * Inverses the matrix and stores it in a target matrix
  63084. * @param result defines the target matrix
  63085. * @returns the current matrix
  63086. */
  63087. invertToRef(result: Matrix2D): Matrix2D;
  63088. /**
  63089. * Multiplies the current matrix with another one
  63090. * @param other defines the second operand
  63091. * @param result defines the target matrix
  63092. * @returns the current matrix
  63093. */
  63094. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  63095. /**
  63096. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  63097. * @param x defines the x coordinate to transform
  63098. * @param y defines the x coordinate to transform
  63099. * @param result defines the target vector2
  63100. * @returns the current matrix
  63101. */
  63102. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  63103. /**
  63104. * Creates an identity matrix
  63105. * @returns a new matrix
  63106. */
  63107. static Identity(): Matrix2D;
  63108. /**
  63109. * Creates a translation matrix and stores it in a target matrix
  63110. * @param x defines the x coordinate of the translation
  63111. * @param y defines the y coordinate of the translation
  63112. * @param result defines the target matrix
  63113. */
  63114. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  63115. /**
  63116. * Creates a scaling matrix and stores it in a target matrix
  63117. * @param x defines the x coordinate of the scaling
  63118. * @param y defines the y coordinate of the scaling
  63119. * @param result defines the target matrix
  63120. */
  63121. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  63122. /**
  63123. * Creates a rotation matrix and stores it in a target matrix
  63124. * @param angle defines the rotation angle
  63125. * @param result defines the target matrix
  63126. */
  63127. static RotationToRef(angle: number, result: Matrix2D): void;
  63128. private static _TempPreTranslationMatrix;
  63129. private static _TempPostTranslationMatrix;
  63130. private static _TempRotationMatrix;
  63131. private static _TempScalingMatrix;
  63132. private static _TempCompose0;
  63133. private static _TempCompose1;
  63134. private static _TempCompose2;
  63135. /**
  63136. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  63137. * @param tx defines the x coordinate of the translation
  63138. * @param ty defines the y coordinate of the translation
  63139. * @param angle defines the rotation angle
  63140. * @param scaleX defines the x coordinate of the scaling
  63141. * @param scaleY defines the y coordinate of the scaling
  63142. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  63143. * @param result defines the target matrix
  63144. */
  63145. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  63146. }
  63147. }
  63148. declare module BABYLON.GUI {
  63149. /**
  63150. * Class used to store 2D control sizes
  63151. */
  63152. export class Measure {
  63153. /** defines left coordinate */
  63154. left: number;
  63155. /** defines top coordinate */
  63156. top: number;
  63157. /** defines width dimension */
  63158. width: number;
  63159. /** defines height dimension */
  63160. height: number;
  63161. /**
  63162. * Creates a new measure
  63163. * @param left defines left coordinate
  63164. * @param top defines top coordinate
  63165. * @param width defines width dimension
  63166. * @param height defines height dimension
  63167. */
  63168. constructor(
  63169. /** defines left coordinate */
  63170. left: number,
  63171. /** defines top coordinate */
  63172. top: number,
  63173. /** defines width dimension */
  63174. width: number,
  63175. /** defines height dimension */
  63176. height: number);
  63177. /**
  63178. * Copy from another measure
  63179. * @param other defines the other measure to copy from
  63180. */
  63181. copyFrom(other: Measure): void;
  63182. /**
  63183. * Copy from a group of 4 floats
  63184. * @param left defines left coordinate
  63185. * @param top defines top coordinate
  63186. * @param width defines width dimension
  63187. * @param height defines height dimension
  63188. */
  63189. copyFromFloats(left: number, top: number, width: number, height: number): void;
  63190. /**
  63191. * Computes the axis aligned bounding box measure for two given measures
  63192. * @param a Input measure
  63193. * @param b Input measure
  63194. * @param result the resulting bounding measure
  63195. */
  63196. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  63197. /**
  63198. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  63199. * @param transform the matrix to transform the measure before computing the AABB
  63200. * @param result the resulting AABB
  63201. */
  63202. transformToRef(transform: Matrix2D, result: Measure): void;
  63203. /**
  63204. * Check equality between this measure and another one
  63205. * @param other defines the other measures
  63206. * @returns true if both measures are equals
  63207. */
  63208. isEqualsTo(other: Measure): boolean;
  63209. /**
  63210. * Creates an empty measure
  63211. * @returns a new measure
  63212. */
  63213. static Empty(): Measure;
  63214. }
  63215. }
  63216. declare module BABYLON.GUI {
  63217. /**
  63218. * Interface used to define a control that can receive focus
  63219. */
  63220. export interface IFocusableControl {
  63221. /**
  63222. * Function called when the control receives the focus
  63223. */
  63224. onFocus(): void;
  63225. /**
  63226. * Function called when the control loses the focus
  63227. */
  63228. onBlur(): void;
  63229. /**
  63230. * Function called to let the control handle keyboard events
  63231. * @param evt defines the current keyboard event
  63232. */
  63233. processKeyboard(evt: KeyboardEvent): void;
  63234. /**
  63235. * Function called to get the list of controls that should not steal the focus from this control
  63236. * @returns an array of controls
  63237. */
  63238. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63239. }
  63240. /**
  63241. * Class used to create texture to support 2D GUI elements
  63242. * @see http://doc.babylonjs.com/how_to/gui
  63243. */
  63244. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  63245. private _isDirty;
  63246. private _renderObserver;
  63247. private _resizeObserver;
  63248. private _preKeyboardObserver;
  63249. private _pointerMoveObserver;
  63250. private _pointerObserver;
  63251. private _canvasPointerOutObserver;
  63252. private _background;
  63253. /** @hidden */
  63254. _rootContainer: Container;
  63255. /** @hidden */
  63256. _lastPickedControl: Control;
  63257. /** @hidden */
  63258. _lastControlOver: {
  63259. [pointerId: number]: Control;
  63260. };
  63261. /** @hidden */
  63262. _lastControlDown: {
  63263. [pointerId: number]: Control;
  63264. };
  63265. /** @hidden */
  63266. _capturingControl: {
  63267. [pointerId: number]: Control;
  63268. };
  63269. /** @hidden */
  63270. _shouldBlockPointer: boolean;
  63271. /** @hidden */
  63272. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  63273. /** @hidden */
  63274. _linkedControls: Control[];
  63275. private _isFullscreen;
  63276. private _fullscreenViewport;
  63277. private _idealWidth;
  63278. private _idealHeight;
  63279. private _useSmallestIdeal;
  63280. private _renderAtIdealSize;
  63281. private _focusedControl;
  63282. private _blockNextFocusCheck;
  63283. private _renderScale;
  63284. private _rootCanvas;
  63285. private _cursorChanged;
  63286. /**
  63287. * Define type to string to ensure compatibility across browsers
  63288. * Safari doesn't support DataTransfer constructor
  63289. */
  63290. private _clipboardData;
  63291. /**
  63292. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  63293. */
  63294. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  63295. /**
  63296. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  63297. */
  63298. onControlPickedObservable: BABYLON.Observable<Control>;
  63299. /**
  63300. * BABYLON.Observable event triggered before layout is evaluated
  63301. */
  63302. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63303. /**
  63304. * BABYLON.Observable event triggered after the layout was evaluated
  63305. */
  63306. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63307. /**
  63308. * BABYLON.Observable event triggered before the texture is rendered
  63309. */
  63310. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63311. /**
  63312. * BABYLON.Observable event triggered after the texture was rendered
  63313. */
  63314. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63315. /**
  63316. * Gets or sets a boolean defining if alpha is stored as premultiplied
  63317. */
  63318. premulAlpha: boolean;
  63319. /**
  63320. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  63321. * Useful when you want more antialiasing
  63322. */
  63323. renderScale: number;
  63324. /** Gets or sets the background color */
  63325. background: string;
  63326. /**
  63327. * Gets or sets the ideal width used to design controls.
  63328. * The GUI will then rescale everything accordingly
  63329. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63330. */
  63331. idealWidth: number;
  63332. /**
  63333. * Gets or sets the ideal height used to design controls.
  63334. * The GUI will then rescale everything accordingly
  63335. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63336. */
  63337. idealHeight: number;
  63338. /**
  63339. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  63340. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63341. */
  63342. useSmallestIdeal: boolean;
  63343. /**
  63344. * Gets or sets a boolean indicating if adaptive scaling must be used
  63345. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63346. */
  63347. renderAtIdealSize: boolean;
  63348. /**
  63349. * Gets the underlying layer used to render the texture when in fullscreen mode
  63350. */
  63351. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  63352. /**
  63353. * Gets the root container control
  63354. */
  63355. readonly rootContainer: Container;
  63356. /**
  63357. * Returns an array containing the root container.
  63358. * This is mostly used to let the Inspector introspects the ADT
  63359. * @returns an array containing the rootContainer
  63360. */
  63361. getChildren(): Array<Container>;
  63362. /**
  63363. * Will return all controls that are inside this texture
  63364. * @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
  63365. * @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
  63366. * @return all child controls
  63367. */
  63368. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63369. /**
  63370. * Gets or sets the current focused control
  63371. */
  63372. focusedControl: BABYLON.Nullable<IFocusableControl>;
  63373. /**
  63374. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  63375. */
  63376. isForeground: boolean;
  63377. /**
  63378. * Gets or set information about clipboardData
  63379. */
  63380. clipboardData: string;
  63381. /**
  63382. * Creates a new AdvancedDynamicTexture
  63383. * @param name defines the name of the texture
  63384. * @param width defines the width of the texture
  63385. * @param height defines the height of the texture
  63386. * @param scene defines the hosting scene
  63387. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  63388. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  63389. */
  63390. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  63391. /**
  63392. * Get the current class name of the texture useful for serialization or dynamic coding.
  63393. * @returns "AdvancedDynamicTexture"
  63394. */
  63395. getClassName(): string;
  63396. /**
  63397. * Function used to execute a function on all controls
  63398. * @param func defines the function to execute
  63399. * @param container defines the container where controls belong. If null the root container will be used
  63400. */
  63401. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  63402. private _useInvalidateRectOptimization;
  63403. /**
  63404. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  63405. */
  63406. useInvalidateRectOptimization: boolean;
  63407. private _invalidatedRectangle;
  63408. /**
  63409. * Invalidates a rectangle area on the gui texture
  63410. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  63411. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  63412. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  63413. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  63414. */
  63415. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  63416. /**
  63417. * Marks the texture as dirty forcing a complete update
  63418. */
  63419. markAsDirty(): void;
  63420. /**
  63421. * Helper function used to create a new style
  63422. * @returns a new style
  63423. * @see http://doc.babylonjs.com/how_to/gui#styles
  63424. */
  63425. createStyle(): Style;
  63426. /**
  63427. * Adds a new control to the root container
  63428. * @param control defines the control to add
  63429. * @returns the current texture
  63430. */
  63431. addControl(control: Control): AdvancedDynamicTexture;
  63432. /**
  63433. * Removes a control from the root container
  63434. * @param control defines the control to remove
  63435. * @returns the current texture
  63436. */
  63437. removeControl(control: Control): AdvancedDynamicTexture;
  63438. /**
  63439. * Release all resources
  63440. */
  63441. dispose(): void;
  63442. private _onResize;
  63443. /** @hidden */
  63444. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  63445. /**
  63446. * Get screen coordinates for a vector3
  63447. * @param position defines the position to project
  63448. * @param worldMatrix defines the world matrix to use
  63449. * @returns the projected position
  63450. */
  63451. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  63452. private _checkUpdate;
  63453. private _clearMeasure;
  63454. private _render;
  63455. /** @hidden */
  63456. _changeCursor(cursor: string): void;
  63457. /** @hidden */
  63458. _registerLastControlDown(control: Control, pointerId: number): void;
  63459. private _doPicking;
  63460. /** @hidden */
  63461. _cleanControlAfterRemovalFromList(list: {
  63462. [pointerId: number]: Control;
  63463. }, control: Control): void;
  63464. /** @hidden */
  63465. _cleanControlAfterRemoval(control: Control): void;
  63466. /** Attach to all scene events required to support pointer events */
  63467. attach(): void;
  63468. /** @hidden */
  63469. private onClipboardCopy;
  63470. /** @hidden */
  63471. private onClipboardCut;
  63472. /** @hidden */
  63473. private onClipboardPaste;
  63474. /**
  63475. * Register the clipboard Events onto the canvas
  63476. */
  63477. registerClipboardEvents(): void;
  63478. /**
  63479. * Unregister the clipboard Events from the canvas
  63480. */
  63481. unRegisterClipboardEvents(): void;
  63482. /**
  63483. * Connect the texture to a hosting mesh to enable interactions
  63484. * @param mesh defines the mesh to attach to
  63485. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  63486. */
  63487. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  63488. /**
  63489. * Move the focus to a specific control
  63490. * @param control defines the control which will receive the focus
  63491. */
  63492. moveFocusToControl(control: IFocusableControl): void;
  63493. private _manageFocus;
  63494. private _attachToOnPointerOut;
  63495. /**
  63496. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  63497. * @param mesh defines the mesh which will receive the texture
  63498. * @param width defines the texture width (1024 by default)
  63499. * @param height defines the texture height (1024 by default)
  63500. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  63501. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  63502. * @returns a new AdvancedDynamicTexture
  63503. */
  63504. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  63505. /**
  63506. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  63507. * In this mode the texture will rely on a layer for its rendering.
  63508. * This allows it to be treated like any other layer.
  63509. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  63510. * LayerMask is set through advancedTexture.layer.layerMask
  63511. * @param name defines name for the texture
  63512. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  63513. * @param scene defines the hsoting scene
  63514. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  63515. * @returns a new AdvancedDynamicTexture
  63516. */
  63517. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  63518. }
  63519. }
  63520. declare module BABYLON.GUI {
  63521. /**
  63522. * Root class used for all 2D controls
  63523. * @see http://doc.babylonjs.com/how_to/gui#controls
  63524. */
  63525. export class Control {
  63526. /** defines the name of the control */
  63527. name?: string | undefined;
  63528. /**
  63529. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  63530. */
  63531. static AllowAlphaInheritance: boolean;
  63532. private _alpha;
  63533. private _alphaSet;
  63534. private _zIndex;
  63535. /** @hidden */
  63536. _host: AdvancedDynamicTexture;
  63537. /** Gets or sets the control parent */
  63538. parent: BABYLON.Nullable<Container>;
  63539. /** @hidden */
  63540. _currentMeasure: Measure;
  63541. private _fontFamily;
  63542. private _fontStyle;
  63543. private _fontWeight;
  63544. private _fontSize;
  63545. private _font;
  63546. /** @hidden */
  63547. _width: ValueAndUnit;
  63548. /** @hidden */
  63549. _height: ValueAndUnit;
  63550. /** @hidden */
  63551. protected _fontOffset: {
  63552. ascent: number;
  63553. height: number;
  63554. descent: number;
  63555. };
  63556. private _color;
  63557. private _style;
  63558. private _styleObserver;
  63559. /** @hidden */
  63560. protected _horizontalAlignment: number;
  63561. /** @hidden */
  63562. protected _verticalAlignment: number;
  63563. /** @hidden */
  63564. protected _isDirty: boolean;
  63565. /** @hidden */
  63566. protected _wasDirty: boolean;
  63567. /** @hidden */
  63568. _tempParentMeasure: Measure;
  63569. /** @hidden */
  63570. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  63571. /** @hidden */
  63572. protected _cachedParentMeasure: Measure;
  63573. private _paddingLeft;
  63574. private _paddingRight;
  63575. private _paddingTop;
  63576. private _paddingBottom;
  63577. /** @hidden */
  63578. _left: ValueAndUnit;
  63579. /** @hidden */
  63580. _top: ValueAndUnit;
  63581. private _scaleX;
  63582. private _scaleY;
  63583. private _rotation;
  63584. private _transformCenterX;
  63585. private _transformCenterY;
  63586. /** @hidden */
  63587. _transformMatrix: Matrix2D;
  63588. /** @hidden */
  63589. protected _invertTransformMatrix: Matrix2D;
  63590. /** @hidden */
  63591. protected _transformedPosition: BABYLON.Vector2;
  63592. private _isMatrixDirty;
  63593. private _cachedOffsetX;
  63594. private _cachedOffsetY;
  63595. private _isVisible;
  63596. private _isHighlighted;
  63597. /** @hidden */
  63598. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63599. private _fontSet;
  63600. private _dummyVector2;
  63601. private _downCount;
  63602. private _enterCount;
  63603. private _doNotRender;
  63604. private _downPointerIds;
  63605. protected _isEnabled: boolean;
  63606. protected _disabledColor: string;
  63607. /** @hidden */
  63608. protected _rebuildLayout: boolean;
  63609. /** @hidden */
  63610. _isClipped: boolean;
  63611. /** @hidden */
  63612. _tag: any;
  63613. /**
  63614. * 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
  63615. */
  63616. uniqueId: number;
  63617. /**
  63618. * Gets or sets an object used to store user defined information for the node
  63619. */
  63620. metadata: any;
  63621. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  63622. isHitTestVisible: boolean;
  63623. /** Gets or sets a boolean indicating if the control can block pointer events */
  63624. isPointerBlocker: boolean;
  63625. /** Gets or sets a boolean indicating if the control can be focusable */
  63626. isFocusInvisible: boolean;
  63627. /**
  63628. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  63629. * 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
  63630. */
  63631. clipChildren: boolean;
  63632. /**
  63633. * Gets or sets a boolean indicating that control content must be clipped
  63634. * 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
  63635. */
  63636. clipContent: boolean;
  63637. /**
  63638. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  63639. */
  63640. useBitmapCache: boolean;
  63641. private _cacheData;
  63642. private _shadowOffsetX;
  63643. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  63644. shadowOffsetX: number;
  63645. private _shadowOffsetY;
  63646. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  63647. shadowOffsetY: number;
  63648. private _shadowBlur;
  63649. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  63650. shadowBlur: number;
  63651. private _shadowColor;
  63652. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  63653. shadowColor: string;
  63654. /** Gets or sets the cursor to use when the control is hovered */
  63655. hoverCursor: string;
  63656. /** @hidden */
  63657. protected _linkOffsetX: ValueAndUnit;
  63658. /** @hidden */
  63659. protected _linkOffsetY: ValueAndUnit;
  63660. /** Gets the control type name */
  63661. readonly typeName: string;
  63662. /**
  63663. * Get the current class name of the control.
  63664. * @returns current class name
  63665. */
  63666. getClassName(): string;
  63667. /**
  63668. * An event triggered when the pointer move over the control.
  63669. */
  63670. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  63671. /**
  63672. * An event triggered when the pointer move out of the control.
  63673. */
  63674. onPointerOutObservable: BABYLON.Observable<Control>;
  63675. /**
  63676. * An event triggered when the pointer taps the control
  63677. */
  63678. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  63679. /**
  63680. * An event triggered when pointer up
  63681. */
  63682. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  63683. /**
  63684. * An event triggered when a control is clicked on
  63685. */
  63686. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  63687. /**
  63688. * An event triggered when pointer enters the control
  63689. */
  63690. onPointerEnterObservable: BABYLON.Observable<Control>;
  63691. /**
  63692. * An event triggered when the control is marked as dirty
  63693. */
  63694. onDirtyObservable: BABYLON.Observable<Control>;
  63695. /**
  63696. * An event triggered before drawing the control
  63697. */
  63698. onBeforeDrawObservable: BABYLON.Observable<Control>;
  63699. /**
  63700. * An event triggered after the control was drawn
  63701. */
  63702. onAfterDrawObservable: BABYLON.Observable<Control>;
  63703. /**
  63704. * Get the hosting AdvancedDynamicTexture
  63705. */
  63706. readonly host: AdvancedDynamicTexture;
  63707. /** Gets or set information about font offsets (used to render and align text) */
  63708. fontOffset: {
  63709. ascent: number;
  63710. height: number;
  63711. descent: number;
  63712. };
  63713. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  63714. alpha: number;
  63715. /**
  63716. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  63717. */
  63718. isHighlighted: boolean;
  63719. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  63720. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63721. */
  63722. scaleX: number;
  63723. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  63724. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63725. */
  63726. scaleY: number;
  63727. /** Gets or sets the rotation angle (0 by default)
  63728. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63729. */
  63730. rotation: number;
  63731. /** Gets or sets the transformation center on Y axis (0 by default)
  63732. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63733. */
  63734. transformCenterY: number;
  63735. /** Gets or sets the transformation center on X axis (0 by default)
  63736. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63737. */
  63738. transformCenterX: number;
  63739. /**
  63740. * Gets or sets the horizontal alignment
  63741. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63742. */
  63743. horizontalAlignment: number;
  63744. /**
  63745. * Gets or sets the vertical alignment
  63746. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63747. */
  63748. verticalAlignment: number;
  63749. /**
  63750. * Gets or sets control width
  63751. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63752. */
  63753. width: string | number;
  63754. /**
  63755. * Gets or sets the control width in pixel
  63756. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63757. */
  63758. widthInPixels: number;
  63759. /**
  63760. * Gets or sets control height
  63761. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63762. */
  63763. height: string | number;
  63764. /**
  63765. * Gets or sets control height in pixel
  63766. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63767. */
  63768. heightInPixels: number;
  63769. /** Gets or set font family */
  63770. fontFamily: string;
  63771. /** Gets or sets font style */
  63772. fontStyle: string;
  63773. /** Gets or sets font weight */
  63774. fontWeight: string;
  63775. /**
  63776. * Gets or sets style
  63777. * @see http://doc.babylonjs.com/how_to/gui#styles
  63778. */
  63779. style: BABYLON.Nullable<Style>;
  63780. /** @hidden */
  63781. readonly _isFontSizeInPercentage: boolean;
  63782. /** Gets or sets font size in pixels */
  63783. fontSizeInPixels: number;
  63784. /** Gets or sets font size */
  63785. fontSize: string | number;
  63786. /** Gets or sets foreground color */
  63787. color: string;
  63788. /** Gets or sets z index which is used to reorder controls on the z axis */
  63789. zIndex: number;
  63790. /** Gets or sets a boolean indicating if the control can be rendered */
  63791. notRenderable: boolean;
  63792. /** Gets or sets a boolean indicating if the control is visible */
  63793. isVisible: boolean;
  63794. /** Gets a boolean indicating that the control needs to update its rendering */
  63795. readonly isDirty: boolean;
  63796. /**
  63797. * Gets the current linked mesh (or null if none)
  63798. */
  63799. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63800. /**
  63801. * Gets or sets a value indicating the padding to use on the left of the control
  63802. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63803. */
  63804. paddingLeft: string | number;
  63805. /**
  63806. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  63807. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63808. */
  63809. paddingLeftInPixels: number;
  63810. /**
  63811. * Gets or sets a value indicating the padding to use on the right of the control
  63812. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63813. */
  63814. paddingRight: string | number;
  63815. /**
  63816. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  63817. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63818. */
  63819. paddingRightInPixels: number;
  63820. /**
  63821. * Gets or sets a value indicating the padding to use on the top of the control
  63822. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63823. */
  63824. paddingTop: string | number;
  63825. /**
  63826. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  63827. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63828. */
  63829. paddingTopInPixels: number;
  63830. /**
  63831. * Gets or sets a value indicating the padding to use on the bottom of the control
  63832. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63833. */
  63834. paddingBottom: string | number;
  63835. /**
  63836. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  63837. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63838. */
  63839. paddingBottomInPixels: number;
  63840. /**
  63841. * Gets or sets a value indicating the left coordinate of the control
  63842. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63843. */
  63844. left: string | number;
  63845. /**
  63846. * Gets or sets a value indicating the left coordinate in pixels of the control
  63847. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63848. */
  63849. leftInPixels: number;
  63850. /**
  63851. * Gets or sets a value indicating the top coordinate of the control
  63852. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63853. */
  63854. top: string | number;
  63855. /**
  63856. * Gets or sets a value indicating the top coordinate in pixels of the control
  63857. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63858. */
  63859. topInPixels: number;
  63860. /**
  63861. * Gets or sets a value indicating the offset on X axis to the linked mesh
  63862. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63863. */
  63864. linkOffsetX: string | number;
  63865. /**
  63866. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  63867. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63868. */
  63869. linkOffsetXInPixels: number;
  63870. /**
  63871. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  63872. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63873. */
  63874. linkOffsetY: string | number;
  63875. /**
  63876. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  63877. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63878. */
  63879. linkOffsetYInPixels: number;
  63880. /** Gets the center coordinate on X axis */
  63881. readonly centerX: number;
  63882. /** Gets the center coordinate on Y axis */
  63883. readonly centerY: number;
  63884. /** Gets or sets if control is Enabled*/
  63885. isEnabled: boolean;
  63886. /** Gets or sets background color of control if it's disabled*/
  63887. disabledColor: string;
  63888. /**
  63889. * Creates a new control
  63890. * @param name defines the name of the control
  63891. */
  63892. constructor(
  63893. /** defines the name of the control */
  63894. name?: string | undefined);
  63895. /** @hidden */
  63896. protected _getTypeName(): string;
  63897. /**
  63898. * Gets the first ascendant in the hierarchy of the given type
  63899. * @param className defines the required type
  63900. * @returns the ascendant or null if not found
  63901. */
  63902. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  63903. /** @hidden */
  63904. _resetFontCache(): void;
  63905. /**
  63906. * Determines if a container is an ascendant of the current control
  63907. * @param container defines the container to look for
  63908. * @returns true if the container is one of the ascendant of the control
  63909. */
  63910. isAscendant(container: Control): boolean;
  63911. /**
  63912. * Gets coordinates in local control space
  63913. * @param globalCoordinates defines the coordinates to transform
  63914. * @returns the new coordinates in local space
  63915. */
  63916. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63917. /**
  63918. * Gets coordinates in local control space
  63919. * @param globalCoordinates defines the coordinates to transform
  63920. * @param result defines the target vector2 where to store the result
  63921. * @returns the current control
  63922. */
  63923. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  63924. /**
  63925. * Gets coordinates in parent local control space
  63926. * @param globalCoordinates defines the coordinates to transform
  63927. * @returns the new coordinates in parent local space
  63928. */
  63929. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63930. /**
  63931. * Move the current control to a vector3 position projected onto the screen.
  63932. * @param position defines the target position
  63933. * @param scene defines the hosting scene
  63934. */
  63935. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  63936. /** @hidden */
  63937. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63938. /**
  63939. * Will return all controls that have this control as ascendant
  63940. * @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
  63941. * @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
  63942. * @return all child controls
  63943. */
  63944. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63945. /**
  63946. * Link current control with a target mesh
  63947. * @param mesh defines the mesh to link with
  63948. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63949. */
  63950. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  63951. /** @hidden */
  63952. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  63953. /** @hidden */
  63954. _offsetLeft(offset: number): void;
  63955. /** @hidden */
  63956. _offsetTop(offset: number): void;
  63957. /** @hidden */
  63958. _markMatrixAsDirty(): void;
  63959. /** @hidden */
  63960. _flagDescendantsAsMatrixDirty(): void;
  63961. /** @hidden */
  63962. _intersectsRect(rect: Measure): boolean;
  63963. /** @hidden */
  63964. protected invalidateRect(): void;
  63965. /** @hidden */
  63966. _markAsDirty(force?: boolean): void;
  63967. /** @hidden */
  63968. _markAllAsDirty(): void;
  63969. /** @hidden */
  63970. _link(host: AdvancedDynamicTexture): void;
  63971. /** @hidden */
  63972. protected _transform(context?: CanvasRenderingContext2D): void;
  63973. /** @hidden */
  63974. _renderHighlight(context: CanvasRenderingContext2D): void;
  63975. /** @hidden */
  63976. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63977. /** @hidden */
  63978. protected _applyStates(context: CanvasRenderingContext2D): void;
  63979. /** @hidden */
  63980. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63981. /** @hidden */
  63982. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63983. protected _evaluateClippingState(parentMeasure: Measure): void;
  63984. /** @hidden */
  63985. _measure(): void;
  63986. /** @hidden */
  63987. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63988. /** @hidden */
  63989. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63990. /** @hidden */
  63991. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63992. /** @hidden */
  63993. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63994. private static _ClipMeasure;
  63995. private _tmpMeasureA;
  63996. private _clip;
  63997. /** @hidden */
  63998. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  63999. /** @hidden */
  64000. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  64001. /**
  64002. * Tests if a given coordinates belong to the current control
  64003. * @param x defines x coordinate to test
  64004. * @param y defines y coordinate to test
  64005. * @returns true if the coordinates are inside the control
  64006. */
  64007. contains(x: number, y: number): boolean;
  64008. /** @hidden */
  64009. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64010. /** @hidden */
  64011. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64012. /** @hidden */
  64013. _onPointerEnter(target: Control): boolean;
  64014. /** @hidden */
  64015. _onPointerOut(target: Control, force?: boolean): void;
  64016. /** @hidden */
  64017. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64018. /** @hidden */
  64019. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64020. /** @hidden */
  64021. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  64022. /** @hidden */
  64023. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  64024. private _prepareFont;
  64025. /** Releases associated resources */
  64026. dispose(): void;
  64027. private static _HORIZONTAL_ALIGNMENT_LEFT;
  64028. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  64029. private static _HORIZONTAL_ALIGNMENT_CENTER;
  64030. private static _VERTICAL_ALIGNMENT_TOP;
  64031. private static _VERTICAL_ALIGNMENT_BOTTOM;
  64032. private static _VERTICAL_ALIGNMENT_CENTER;
  64033. /** HORIZONTAL_ALIGNMENT_LEFT */
  64034. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  64035. /** HORIZONTAL_ALIGNMENT_RIGHT */
  64036. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  64037. /** HORIZONTAL_ALIGNMENT_CENTER */
  64038. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  64039. /** VERTICAL_ALIGNMENT_TOP */
  64040. static readonly VERTICAL_ALIGNMENT_TOP: number;
  64041. /** VERTICAL_ALIGNMENT_BOTTOM */
  64042. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  64043. /** VERTICAL_ALIGNMENT_CENTER */
  64044. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  64045. private static _FontHeightSizes;
  64046. /** @hidden */
  64047. static _GetFontOffset(font: string): {
  64048. ascent: number;
  64049. height: number;
  64050. descent: number;
  64051. };
  64052. /**
  64053. * Creates a stack panel that can be used to render headers
  64054. * @param control defines the control to associate with the header
  64055. * @param text defines the text of the header
  64056. * @param size defines the size of the header
  64057. * @param options defines options used to configure the header
  64058. * @returns a new StackPanel
  64059. * @ignore
  64060. * @hidden
  64061. */
  64062. static AddHeader: (control: Control, text: string, size: string | number, options: {
  64063. isHorizontal: boolean;
  64064. controlFirst: boolean;
  64065. }) => any;
  64066. /** @hidden */
  64067. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  64068. }
  64069. }
  64070. declare module BABYLON.GUI {
  64071. /**
  64072. * Root class for 2D containers
  64073. * @see http://doc.babylonjs.com/how_to/gui#containers
  64074. */
  64075. export class Container extends Control {
  64076. name?: string | undefined;
  64077. /** @hidden */
  64078. protected _children: Control[];
  64079. /** @hidden */
  64080. protected _measureForChildren: Measure;
  64081. /** @hidden */
  64082. protected _background: string;
  64083. /** @hidden */
  64084. protected _adaptWidthToChildren: boolean;
  64085. /** @hidden */
  64086. protected _adaptHeightToChildren: boolean;
  64087. /**
  64088. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  64089. */
  64090. logLayoutCycleErrors: boolean;
  64091. /**
  64092. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  64093. */
  64094. maxLayoutCycle: number;
  64095. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  64096. adaptHeightToChildren: boolean;
  64097. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  64098. adaptWidthToChildren: boolean;
  64099. /** Gets or sets background color */
  64100. background: string;
  64101. /** Gets the list of children */
  64102. readonly children: Control[];
  64103. /**
  64104. * Creates a new Container
  64105. * @param name defines the name of the container
  64106. */
  64107. constructor(name?: string | undefined);
  64108. protected _getTypeName(): string;
  64109. _flagDescendantsAsMatrixDirty(): void;
  64110. /**
  64111. * Gets a child using its name
  64112. * @param name defines the child name to look for
  64113. * @returns the child control if found
  64114. */
  64115. getChildByName(name: string): BABYLON.Nullable<Control>;
  64116. /**
  64117. * Gets a child using its type and its name
  64118. * @param name defines the child name to look for
  64119. * @param type defines the child type to look for
  64120. * @returns the child control if found
  64121. */
  64122. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  64123. /**
  64124. * Search for a specific control in children
  64125. * @param control defines the control to look for
  64126. * @returns true if the control is in child list
  64127. */
  64128. containsControl(control: Control): boolean;
  64129. /**
  64130. * Adds a new control to the current container
  64131. * @param control defines the control to add
  64132. * @returns the current container
  64133. */
  64134. addControl(control: BABYLON.Nullable<Control>): Container;
  64135. /**
  64136. * Removes all controls from the current container
  64137. * @returns the current container
  64138. */
  64139. clearControls(): Container;
  64140. /**
  64141. * Removes a control from the current container
  64142. * @param control defines the control to remove
  64143. * @returns the current container
  64144. */
  64145. removeControl(control: Control): Container;
  64146. /** @hidden */
  64147. _reOrderControl(control: Control): void;
  64148. /** @hidden */
  64149. _offsetLeft(offset: number): void;
  64150. /** @hidden */
  64151. _offsetTop(offset: number): void;
  64152. /** @hidden */
  64153. _markAllAsDirty(): void;
  64154. /** @hidden */
  64155. protected _localDraw(context: CanvasRenderingContext2D): void;
  64156. /** @hidden */
  64157. _link(host: AdvancedDynamicTexture): void;
  64158. /** @hidden */
  64159. protected _beforeLayout(): void;
  64160. /** @hidden */
  64161. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64162. /** @hidden */
  64163. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64164. protected _postMeasure(): void;
  64165. /** @hidden */
  64166. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  64167. /** @hidden */
  64168. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64169. /** @hidden */
  64170. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64171. /** @hidden */
  64172. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64173. /** Releases associated resources */
  64174. dispose(): void;
  64175. }
  64176. }
  64177. declare module BABYLON.GUI {
  64178. /** Class used to create rectangle container */
  64179. export class Rectangle extends Container {
  64180. name?: string | undefined;
  64181. private _thickness;
  64182. private _cornerRadius;
  64183. /** Gets or sets border thickness */
  64184. thickness: number;
  64185. /** Gets or sets the corner radius angle */
  64186. cornerRadius: number;
  64187. /**
  64188. * Creates a new Rectangle
  64189. * @param name defines the control name
  64190. */
  64191. constructor(name?: string | undefined);
  64192. protected _getTypeName(): string;
  64193. protected _localDraw(context: CanvasRenderingContext2D): void;
  64194. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64195. private _drawRoundedRect;
  64196. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64197. }
  64198. }
  64199. declare module BABYLON.GUI {
  64200. /**
  64201. * Enum that determines the text-wrapping mode to use.
  64202. */
  64203. export enum TextWrapping {
  64204. /**
  64205. * Clip the text when it's larger than Control.width; this is the default mode.
  64206. */
  64207. Clip = 0,
  64208. /**
  64209. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  64210. */
  64211. WordWrap = 1,
  64212. /**
  64213. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  64214. */
  64215. Ellipsis = 2
  64216. }
  64217. /**
  64218. * Class used to create text block control
  64219. */
  64220. export class TextBlock extends Control {
  64221. /**
  64222. * Defines the name of the control
  64223. */
  64224. name?: string | undefined;
  64225. private _text;
  64226. private _textWrapping;
  64227. private _textHorizontalAlignment;
  64228. private _textVerticalAlignment;
  64229. private _lines;
  64230. private _resizeToFit;
  64231. private _lineSpacing;
  64232. private _outlineWidth;
  64233. private _outlineColor;
  64234. /**
  64235. * An event triggered after the text is changed
  64236. */
  64237. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  64238. /**
  64239. * An event triggered after the text was broken up into lines
  64240. */
  64241. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  64242. /**
  64243. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  64244. */
  64245. readonly lines: any[];
  64246. /**
  64247. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64248. */
  64249. /**
  64250. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64251. */
  64252. resizeToFit: boolean;
  64253. /**
  64254. * Gets or sets a boolean indicating if text must be wrapped
  64255. */
  64256. /**
  64257. * Gets or sets a boolean indicating if text must be wrapped
  64258. */
  64259. textWrapping: TextWrapping | boolean;
  64260. /**
  64261. * Gets or sets text to display
  64262. */
  64263. /**
  64264. * Gets or sets text to display
  64265. */
  64266. text: string;
  64267. /**
  64268. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64269. */
  64270. /**
  64271. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64272. */
  64273. textHorizontalAlignment: number;
  64274. /**
  64275. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64276. */
  64277. /**
  64278. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64279. */
  64280. textVerticalAlignment: number;
  64281. /**
  64282. * Gets or sets line spacing value
  64283. */
  64284. /**
  64285. * Gets or sets line spacing value
  64286. */
  64287. lineSpacing: string | number;
  64288. /**
  64289. * Gets or sets outlineWidth of the text to display
  64290. */
  64291. /**
  64292. * Gets or sets outlineWidth of the text to display
  64293. */
  64294. outlineWidth: number;
  64295. /**
  64296. * Gets or sets outlineColor of the text to display
  64297. */
  64298. /**
  64299. * Gets or sets outlineColor of the text to display
  64300. */
  64301. outlineColor: string;
  64302. /**
  64303. * Creates a new TextBlock object
  64304. * @param name defines the name of the control
  64305. * @param text defines the text to display (emptry string by default)
  64306. */
  64307. constructor(
  64308. /**
  64309. * Defines the name of the control
  64310. */
  64311. name?: string | undefined, text?: string);
  64312. protected _getTypeName(): string;
  64313. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64314. private _drawText;
  64315. /** @hidden */
  64316. _draw(context: CanvasRenderingContext2D): void;
  64317. protected _applyStates(context: CanvasRenderingContext2D): void;
  64318. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  64319. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  64320. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  64321. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  64322. protected _renderLines(context: CanvasRenderingContext2D): void;
  64323. /**
  64324. * Given a width constraint applied on the text block, find the expected height
  64325. * @returns expected height
  64326. */
  64327. computeExpectedHeight(): number;
  64328. dispose(): void;
  64329. }
  64330. }
  64331. declare module BABYLON.GUI {
  64332. /**
  64333. * Class used to create 2D images
  64334. */
  64335. export class Image extends Control {
  64336. name?: string | undefined;
  64337. private static _WorkingCanvas;
  64338. private _domImage;
  64339. private _imageWidth;
  64340. private _imageHeight;
  64341. private _loaded;
  64342. private _stretch;
  64343. private _source;
  64344. private _autoScale;
  64345. private _sourceLeft;
  64346. private _sourceTop;
  64347. private _sourceWidth;
  64348. private _sourceHeight;
  64349. private _cellWidth;
  64350. private _cellHeight;
  64351. private _cellId;
  64352. private _populateNinePatchSlicesFromImage;
  64353. private _sliceLeft;
  64354. private _sliceRight;
  64355. private _sliceTop;
  64356. private _sliceBottom;
  64357. private _detectPointerOnOpaqueOnly;
  64358. /**
  64359. * BABYLON.Observable notified when the content is loaded
  64360. */
  64361. onImageLoadedObservable: BABYLON.Observable<Image>;
  64362. /**
  64363. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  64364. */
  64365. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  64366. /**
  64367. * Gets a boolean indicating that the content is loaded
  64368. */
  64369. readonly isLoaded: boolean;
  64370. /**
  64371. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  64372. */
  64373. populateNinePatchSlicesFromImage: boolean;
  64374. /**
  64375. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  64376. * Beware using this as this will comsume more memory as the image has to be stored twice
  64377. */
  64378. detectPointerOnOpaqueOnly: boolean;
  64379. /**
  64380. * Gets or sets the left value for slicing (9-patch)
  64381. */
  64382. sliceLeft: number;
  64383. /**
  64384. * Gets or sets the right value for slicing (9-patch)
  64385. */
  64386. sliceRight: number;
  64387. /**
  64388. * Gets or sets the top value for slicing (9-patch)
  64389. */
  64390. sliceTop: number;
  64391. /**
  64392. * Gets or sets the bottom value for slicing (9-patch)
  64393. */
  64394. sliceBottom: number;
  64395. /**
  64396. * Gets or sets the left coordinate in the source image
  64397. */
  64398. sourceLeft: number;
  64399. /**
  64400. * Gets or sets the top coordinate in the source image
  64401. */
  64402. sourceTop: number;
  64403. /**
  64404. * Gets or sets the width to capture in the source image
  64405. */
  64406. sourceWidth: number;
  64407. /**
  64408. * Gets or sets the height to capture in the source image
  64409. */
  64410. sourceHeight: number;
  64411. /**
  64412. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  64413. * @see http://doc.babylonjs.com/how_to/gui#image
  64414. */
  64415. autoScale: boolean;
  64416. /** Gets or sets the streching mode used by the image */
  64417. stretch: number;
  64418. /**
  64419. * Gets or sets the internal DOM image used to render the control
  64420. */
  64421. domImage: HTMLImageElement;
  64422. private _onImageLoaded;
  64423. private _extractNinePatchSliceDataFromImage;
  64424. /**
  64425. * Gets or sets image source url
  64426. */
  64427. source: BABYLON.Nullable<string>;
  64428. /**
  64429. * Checks for svg document with icon id present
  64430. */
  64431. private _svgCheck;
  64432. /**
  64433. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  64434. * given external svg file and icon id
  64435. */
  64436. private _getSVGAttribs;
  64437. /**
  64438. * Gets or sets the cell width to use when animation sheet is enabled
  64439. * @see http://doc.babylonjs.com/how_to/gui#image
  64440. */
  64441. cellWidth: number;
  64442. /**
  64443. * Gets or sets the cell height to use when animation sheet is enabled
  64444. * @see http://doc.babylonjs.com/how_to/gui#image
  64445. */
  64446. cellHeight: number;
  64447. /**
  64448. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  64449. * @see http://doc.babylonjs.com/how_to/gui#image
  64450. */
  64451. cellId: number;
  64452. /**
  64453. * Creates a new Image
  64454. * @param name defines the control name
  64455. * @param url defines the image url
  64456. */
  64457. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  64458. /**
  64459. * Tests if a given coordinates belong to the current control
  64460. * @param x defines x coordinate to test
  64461. * @param y defines y coordinate to test
  64462. * @returns true if the coordinates are inside the control
  64463. */
  64464. contains(x: number, y: number): boolean;
  64465. protected _getTypeName(): string;
  64466. /** Force the control to synchronize with its content */
  64467. synchronizeSizeWithContent(): void;
  64468. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64469. private _prepareWorkingCanvasForOpaqueDetection;
  64470. private _drawImage;
  64471. _draw(context: CanvasRenderingContext2D): void;
  64472. private _renderCornerPatch;
  64473. private _renderNinePatch;
  64474. dispose(): void;
  64475. /** STRETCH_NONE */
  64476. static readonly STRETCH_NONE: number;
  64477. /** STRETCH_FILL */
  64478. static readonly STRETCH_FILL: number;
  64479. /** STRETCH_UNIFORM */
  64480. static readonly STRETCH_UNIFORM: number;
  64481. /** STRETCH_EXTEND */
  64482. static readonly STRETCH_EXTEND: number;
  64483. /** NINE_PATCH */
  64484. static readonly STRETCH_NINE_PATCH: number;
  64485. }
  64486. }
  64487. declare module BABYLON.GUI {
  64488. /**
  64489. * Class used to create 2D buttons
  64490. */
  64491. export class Button extends Rectangle {
  64492. name?: string | undefined;
  64493. /**
  64494. * Function called to generate a pointer enter animation
  64495. */
  64496. pointerEnterAnimation: () => void;
  64497. /**
  64498. * Function called to generate a pointer out animation
  64499. */
  64500. pointerOutAnimation: () => void;
  64501. /**
  64502. * Function called to generate a pointer down animation
  64503. */
  64504. pointerDownAnimation: () => void;
  64505. /**
  64506. * Function called to generate a pointer up animation
  64507. */
  64508. pointerUpAnimation: () => void;
  64509. /**
  64510. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  64511. */
  64512. delegatePickingToChildren: boolean;
  64513. private _image;
  64514. /**
  64515. * Returns the image part of the button (if any)
  64516. */
  64517. readonly image: BABYLON.Nullable<Image>;
  64518. private _textBlock;
  64519. /**
  64520. * Returns the image part of the button (if any)
  64521. */
  64522. readonly textBlock: BABYLON.Nullable<TextBlock>;
  64523. /**
  64524. * Creates a new Button
  64525. * @param name defines the name of the button
  64526. */
  64527. constructor(name?: string | undefined);
  64528. protected _getTypeName(): string;
  64529. /** @hidden */
  64530. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64531. /** @hidden */
  64532. _onPointerEnter(target: Control): boolean;
  64533. /** @hidden */
  64534. _onPointerOut(target: Control, force?: boolean): void;
  64535. /** @hidden */
  64536. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64537. /** @hidden */
  64538. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64539. /**
  64540. * Creates a new button made with an image and a text
  64541. * @param name defines the name of the button
  64542. * @param text defines the text of the button
  64543. * @param imageUrl defines the url of the image
  64544. * @returns a new Button
  64545. */
  64546. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  64547. /**
  64548. * Creates a new button made with an image
  64549. * @param name defines the name of the button
  64550. * @param imageUrl defines the url of the image
  64551. * @returns a new Button
  64552. */
  64553. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  64554. /**
  64555. * Creates a new button made with a text
  64556. * @param name defines the name of the button
  64557. * @param text defines the text of the button
  64558. * @returns a new Button
  64559. */
  64560. static CreateSimpleButton(name: string, text: string): Button;
  64561. /**
  64562. * Creates a new button made with an image and a centered text
  64563. * @param name defines the name of the button
  64564. * @param text defines the text of the button
  64565. * @param imageUrl defines the url of the image
  64566. * @returns a new Button
  64567. */
  64568. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  64569. }
  64570. }
  64571. declare module BABYLON.GUI {
  64572. /**
  64573. * Class used to create a 2D stack panel container
  64574. */
  64575. export class StackPanel extends Container {
  64576. name?: string | undefined;
  64577. private _isVertical;
  64578. private _manualWidth;
  64579. private _manualHeight;
  64580. private _doNotTrackManualChanges;
  64581. /**
  64582. * Gets or sets a boolean indicating that layou warnings should be ignored
  64583. */
  64584. ignoreLayoutWarnings: boolean;
  64585. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  64586. isVertical: boolean;
  64587. /**
  64588. * Gets or sets panel width.
  64589. * This value should not be set when in horizontal mode as it will be computed automatically
  64590. */
  64591. width: string | number;
  64592. /**
  64593. * Gets or sets panel height.
  64594. * This value should not be set when in vertical mode as it will be computed automatically
  64595. */
  64596. height: string | number;
  64597. /**
  64598. * Creates a new StackPanel
  64599. * @param name defines control name
  64600. */
  64601. constructor(name?: string | undefined);
  64602. protected _getTypeName(): string;
  64603. /** @hidden */
  64604. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64605. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64606. protected _postMeasure(): void;
  64607. }
  64608. }
  64609. declare module BABYLON.GUI {
  64610. /**
  64611. * Class used to represent a 2D checkbox
  64612. */
  64613. export class Checkbox extends Control {
  64614. name?: string | undefined;
  64615. private _isChecked;
  64616. private _background;
  64617. private _checkSizeRatio;
  64618. private _thickness;
  64619. /** Gets or sets border thickness */
  64620. thickness: number;
  64621. /**
  64622. * BABYLON.Observable raised when isChecked property changes
  64623. */
  64624. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64625. /** Gets or sets a value indicating the ratio between overall size and check size */
  64626. checkSizeRatio: number;
  64627. /** Gets or sets background color */
  64628. background: string;
  64629. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64630. isChecked: boolean;
  64631. /**
  64632. * Creates a new CheckBox
  64633. * @param name defines the control name
  64634. */
  64635. constructor(name?: string | undefined);
  64636. protected _getTypeName(): string;
  64637. /** @hidden */
  64638. _draw(context: CanvasRenderingContext2D): void;
  64639. /** @hidden */
  64640. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64641. /**
  64642. * Utility function to easily create a checkbox with a header
  64643. * @param title defines the label to use for the header
  64644. * @param onValueChanged defines the callback to call when value changes
  64645. * @returns a StackPanel containing the checkbox and a textBlock
  64646. */
  64647. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  64648. }
  64649. }
  64650. declare module BABYLON.GUI {
  64651. /**
  64652. * Class used to store key control properties
  64653. */
  64654. export class KeyPropertySet {
  64655. /** Width */
  64656. width?: string;
  64657. /** Height */
  64658. height?: string;
  64659. /** Left padding */
  64660. paddingLeft?: string;
  64661. /** Right padding */
  64662. paddingRight?: string;
  64663. /** Top padding */
  64664. paddingTop?: string;
  64665. /** Bottom padding */
  64666. paddingBottom?: string;
  64667. /** Foreground color */
  64668. color?: string;
  64669. /** Background color */
  64670. background?: string;
  64671. }
  64672. /**
  64673. * Class used to create virtual keyboard
  64674. */
  64675. export class VirtualKeyboard extends StackPanel {
  64676. /** BABYLON.Observable raised when a key is pressed */
  64677. onKeyPressObservable: BABYLON.Observable<string>;
  64678. /** Gets or sets default key button width */
  64679. defaultButtonWidth: string;
  64680. /** Gets or sets default key button height */
  64681. defaultButtonHeight: string;
  64682. /** Gets or sets default key button left padding */
  64683. defaultButtonPaddingLeft: string;
  64684. /** Gets or sets default key button right padding */
  64685. defaultButtonPaddingRight: string;
  64686. /** Gets or sets default key button top padding */
  64687. defaultButtonPaddingTop: string;
  64688. /** Gets or sets default key button bottom padding */
  64689. defaultButtonPaddingBottom: string;
  64690. /** Gets or sets default key button foreground color */
  64691. defaultButtonColor: string;
  64692. /** Gets or sets default key button background color */
  64693. defaultButtonBackground: string;
  64694. /** Gets or sets shift button foreground color */
  64695. shiftButtonColor: string;
  64696. /** Gets or sets shift button thickness*/
  64697. selectedShiftThickness: number;
  64698. /** Gets shift key state */
  64699. shiftState: number;
  64700. protected _getTypeName(): string;
  64701. private _createKey;
  64702. /**
  64703. * Adds a new row of keys
  64704. * @param keys defines the list of keys to add
  64705. * @param propertySets defines the associated property sets
  64706. */
  64707. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  64708. /**
  64709. * Set the shift key to a specific state
  64710. * @param shiftState defines the new shift state
  64711. */
  64712. applyShiftState(shiftState: number): void;
  64713. private _currentlyConnectedInputText;
  64714. private _connectedInputTexts;
  64715. private _onKeyPressObserver;
  64716. /** Gets the input text control currently attached to the keyboard */
  64717. readonly connectedInputText: BABYLON.Nullable<InputText>;
  64718. /**
  64719. * Connects the keyboard with an input text control
  64720. *
  64721. * @param input defines the target control
  64722. */
  64723. connect(input: InputText): void;
  64724. /**
  64725. * Disconnects the keyboard from connected InputText controls
  64726. *
  64727. * @param input optionally defines a target control, otherwise all are disconnected
  64728. */
  64729. disconnect(input?: InputText): void;
  64730. private _removeConnectedInputObservables;
  64731. /**
  64732. * Release all resources
  64733. */
  64734. dispose(): void;
  64735. /**
  64736. * Creates a new keyboard using a default layout
  64737. *
  64738. * @param name defines control name
  64739. * @returns a new VirtualKeyboard
  64740. */
  64741. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  64742. }
  64743. }
  64744. declare module BABYLON.GUI {
  64745. /**
  64746. * Class used to create input text control
  64747. */
  64748. export class InputText extends Control implements IFocusableControl {
  64749. name?: string | undefined;
  64750. private _text;
  64751. private _placeholderText;
  64752. private _background;
  64753. private _focusedBackground;
  64754. private _focusedColor;
  64755. private _placeholderColor;
  64756. private _thickness;
  64757. private _margin;
  64758. private _autoStretchWidth;
  64759. private _maxWidth;
  64760. private _isFocused;
  64761. private _blinkTimeout;
  64762. private _blinkIsEven;
  64763. private _cursorOffset;
  64764. private _scrollLeft;
  64765. private _textWidth;
  64766. private _clickedCoordinate;
  64767. private _deadKey;
  64768. private _addKey;
  64769. private _currentKey;
  64770. private _isTextHighlightOn;
  64771. private _textHighlightColor;
  64772. private _highligherOpacity;
  64773. private _highlightedText;
  64774. private _startHighlightIndex;
  64775. private _endHighlightIndex;
  64776. private _cursorIndex;
  64777. private _onFocusSelectAll;
  64778. private _isPointerDown;
  64779. private _onClipboardObserver;
  64780. private _onPointerDblTapObserver;
  64781. /** @hidden */
  64782. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  64783. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  64784. promptMessage: string;
  64785. /** Force disable prompt on mobile device */
  64786. disableMobilePrompt: boolean;
  64787. /** BABYLON.Observable raised when the text changes */
  64788. onTextChangedObservable: BABYLON.Observable<InputText>;
  64789. /** BABYLON.Observable raised just before an entered character is to be added */
  64790. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  64791. /** BABYLON.Observable raised when the control gets the focus */
  64792. onFocusObservable: BABYLON.Observable<InputText>;
  64793. /** BABYLON.Observable raised when the control loses the focus */
  64794. onBlurObservable: BABYLON.Observable<InputText>;
  64795. /**Observable raised when the text is highlighted */
  64796. onTextHighlightObservable: BABYLON.Observable<InputText>;
  64797. /**Observable raised when copy event is triggered */
  64798. onTextCopyObservable: BABYLON.Observable<InputText>;
  64799. /** BABYLON.Observable raised when cut event is triggered */
  64800. onTextCutObservable: BABYLON.Observable<InputText>;
  64801. /** BABYLON.Observable raised when paste event is triggered */
  64802. onTextPasteObservable: BABYLON.Observable<InputText>;
  64803. /** BABYLON.Observable raised when a key event was processed */
  64804. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  64805. /** Gets or sets the maximum width allowed by the control */
  64806. maxWidth: string | number;
  64807. /** Gets the maximum width allowed by the control in pixels */
  64808. readonly maxWidthInPixels: number;
  64809. /** Gets or sets the text highlighter transparency; default: 0.4 */
  64810. highligherOpacity: number;
  64811. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  64812. onFocusSelectAll: boolean;
  64813. /** Gets or sets the text hightlight color */
  64814. textHighlightColor: string;
  64815. /** Gets or sets control margin */
  64816. margin: string;
  64817. /** Gets control margin in pixels */
  64818. readonly marginInPixels: number;
  64819. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  64820. autoStretchWidth: boolean;
  64821. /** Gets or sets border thickness */
  64822. thickness: number;
  64823. /** Gets or sets the background color when focused */
  64824. focusedBackground: string;
  64825. /** Gets or sets the background color when focused */
  64826. focusedColor: string;
  64827. /** Gets or sets the background color */
  64828. background: string;
  64829. /** Gets or sets the placeholder color */
  64830. placeholderColor: string;
  64831. /** Gets or sets the text displayed when the control is empty */
  64832. placeholderText: string;
  64833. /** Gets or sets the dead key flag */
  64834. deadKey: boolean;
  64835. /** Gets or sets the highlight text */
  64836. highlightedText: string;
  64837. /** Gets or sets if the current key should be added */
  64838. addKey: boolean;
  64839. /** Gets or sets the value of the current key being entered */
  64840. currentKey: string;
  64841. /** Gets or sets the text displayed in the control */
  64842. text: string;
  64843. /** Gets or sets control width */
  64844. width: string | number;
  64845. /**
  64846. * Creates a new InputText
  64847. * @param name defines the control name
  64848. * @param text defines the text of the control
  64849. */
  64850. constructor(name?: string | undefined, text?: string);
  64851. /** @hidden */
  64852. onBlur(): void;
  64853. /** @hidden */
  64854. onFocus(): void;
  64855. protected _getTypeName(): string;
  64856. /**
  64857. * Function called to get the list of controls that should not steal the focus from this control
  64858. * @returns an array of controls
  64859. */
  64860. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64861. /** @hidden */
  64862. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  64863. /** @hidden */
  64864. private _updateValueFromCursorIndex;
  64865. /** @hidden */
  64866. private _processDblClick;
  64867. /** @hidden */
  64868. private _selectAllText;
  64869. /**
  64870. * Handles the keyboard event
  64871. * @param evt Defines the KeyboardEvent
  64872. */
  64873. processKeyboard(evt: KeyboardEvent): void;
  64874. /** @hidden */
  64875. private _onCopyText;
  64876. /** @hidden */
  64877. private _onCutText;
  64878. /** @hidden */
  64879. private _onPasteText;
  64880. _draw(context: CanvasRenderingContext2D): void;
  64881. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64882. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64883. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64884. protected _beforeRenderText(text: string): string;
  64885. dispose(): void;
  64886. }
  64887. }
  64888. declare module BABYLON.GUI {
  64889. /**
  64890. * Class used to create a 2D grid container
  64891. */
  64892. export class Grid extends Container {
  64893. name?: string | undefined;
  64894. private _rowDefinitions;
  64895. private _columnDefinitions;
  64896. private _cells;
  64897. private _childControls;
  64898. /**
  64899. * Gets the number of columns
  64900. */
  64901. readonly columnCount: number;
  64902. /**
  64903. * Gets the number of rows
  64904. */
  64905. readonly rowCount: number;
  64906. /** Gets the list of children */
  64907. readonly children: Control[];
  64908. /** Gets the list of cells (e.g. the containers) */
  64909. readonly cells: {
  64910. [key: string]: Container;
  64911. };
  64912. /**
  64913. * Gets the definition of a specific row
  64914. * @param index defines the index of the row
  64915. * @returns the row definition
  64916. */
  64917. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64918. /**
  64919. * Gets the definition of a specific column
  64920. * @param index defines the index of the column
  64921. * @returns the column definition
  64922. */
  64923. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64924. /**
  64925. * Adds a new row to the grid
  64926. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64927. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  64928. * @returns the current grid
  64929. */
  64930. addRowDefinition(height: number, isPixel?: boolean): Grid;
  64931. /**
  64932. * Adds a new column to the grid
  64933. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64934. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64935. * @returns the current grid
  64936. */
  64937. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  64938. /**
  64939. * Update a row definition
  64940. * @param index defines the index of the row to update
  64941. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64942. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  64943. * @returns the current grid
  64944. */
  64945. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  64946. /**
  64947. * Update a column definition
  64948. * @param index defines the index of the column to update
  64949. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64950. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64951. * @returns the current grid
  64952. */
  64953. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  64954. /**
  64955. * Gets the list of children stored in a specific cell
  64956. * @param row defines the row to check
  64957. * @param column defines the column to check
  64958. * @returns the list of controls
  64959. */
  64960. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  64961. /**
  64962. * Gets a string representing the child cell info (row x column)
  64963. * @param child defines the control to get info from
  64964. * @returns a string containing the child cell info (row x column)
  64965. */
  64966. getChildCellInfo(child: Control): string;
  64967. private _removeCell;
  64968. private _offsetCell;
  64969. /**
  64970. * Remove a column definition at specified index
  64971. * @param index defines the index of the column to remove
  64972. * @returns the current grid
  64973. */
  64974. removeColumnDefinition(index: number): Grid;
  64975. /**
  64976. * Remove a row definition at specified index
  64977. * @param index defines the index of the row to remove
  64978. * @returns the current grid
  64979. */
  64980. removeRowDefinition(index: number): Grid;
  64981. /**
  64982. * Adds a new control to the current grid
  64983. * @param control defines the control to add
  64984. * @param row defines the row where to add the control (0 by default)
  64985. * @param column defines the column where to add the control (0 by default)
  64986. * @returns the current grid
  64987. */
  64988. addControl(control: Control, row?: number, column?: number): Grid;
  64989. /**
  64990. * Removes a control from the current container
  64991. * @param control defines the control to remove
  64992. * @returns the current container
  64993. */
  64994. removeControl(control: Control): Container;
  64995. /**
  64996. * Creates a new Grid
  64997. * @param name defines control name
  64998. */
  64999. constructor(name?: string | undefined);
  65000. protected _getTypeName(): string;
  65001. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  65002. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65003. _flagDescendantsAsMatrixDirty(): void;
  65004. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65005. /** Releases associated resources */
  65006. dispose(): void;
  65007. }
  65008. }
  65009. declare module BABYLON.GUI {
  65010. /** Class used to create color pickers */
  65011. export class ColorPicker extends Control {
  65012. name?: string | undefined;
  65013. private static _Epsilon;
  65014. private _colorWheelCanvas;
  65015. private _value;
  65016. private _tmpColor;
  65017. private _pointerStartedOnSquare;
  65018. private _pointerStartedOnWheel;
  65019. private _squareLeft;
  65020. private _squareTop;
  65021. private _squareSize;
  65022. private _h;
  65023. private _s;
  65024. private _v;
  65025. private _lastPointerDownID;
  65026. /**
  65027. * BABYLON.Observable raised when the value changes
  65028. */
  65029. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  65030. /** Gets or sets the color of the color picker */
  65031. value: BABYLON.Color3;
  65032. /**
  65033. * Gets or sets control width
  65034. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65035. */
  65036. width: string | number;
  65037. /**
  65038. * Gets or sets control height
  65039. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65040. */
  65041. /** Gets or sets control height */
  65042. height: string | number;
  65043. /** Gets or sets control size */
  65044. size: string | number;
  65045. /**
  65046. * Creates a new ColorPicker
  65047. * @param name defines the control name
  65048. */
  65049. constructor(name?: string | undefined);
  65050. protected _getTypeName(): string;
  65051. /** @hidden */
  65052. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65053. private _updateSquareProps;
  65054. private _drawGradientSquare;
  65055. private _drawCircle;
  65056. private _createColorWheelCanvas;
  65057. /** @hidden */
  65058. _draw(context: CanvasRenderingContext2D): void;
  65059. private _pointerIsDown;
  65060. private _updateValueFromPointer;
  65061. private _isPointOnSquare;
  65062. private _isPointOnWheel;
  65063. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65064. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65065. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65066. /**
  65067. * This function expands the color picker by creating a color picker dialog with manual
  65068. * color value input and the ability to save colors into an array to be used later in
  65069. * subsequent launches of the dialogue.
  65070. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  65071. * @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.
  65072. * @returns picked color as a hex string and the saved colors array as hex strings.
  65073. */
  65074. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  65075. pickerWidth?: string;
  65076. pickerHeight?: string;
  65077. headerHeight?: string;
  65078. lastColor?: string;
  65079. swatchLimit?: number;
  65080. numSwatchesPerLine?: number;
  65081. savedColors?: Array<string>;
  65082. }): Promise<{
  65083. savedColors?: string[];
  65084. pickedColor: string;
  65085. }>;
  65086. }
  65087. }
  65088. declare module BABYLON.GUI {
  65089. /** Class used to create 2D ellipse containers */
  65090. export class Ellipse extends Container {
  65091. name?: string | undefined;
  65092. private _thickness;
  65093. /** Gets or sets border thickness */
  65094. thickness: number;
  65095. /**
  65096. * Creates a new Ellipse
  65097. * @param name defines the control name
  65098. */
  65099. constructor(name?: string | undefined);
  65100. protected _getTypeName(): string;
  65101. protected _localDraw(context: CanvasRenderingContext2D): void;
  65102. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65103. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65104. }
  65105. }
  65106. declare module BABYLON.GUI {
  65107. /**
  65108. * Class used to create a password control
  65109. */
  65110. export class InputPassword extends InputText {
  65111. protected _beforeRenderText(text: string): string;
  65112. }
  65113. }
  65114. declare module BABYLON.GUI {
  65115. /** Class used to render 2D lines */
  65116. export class Line extends Control {
  65117. name?: string | undefined;
  65118. private _lineWidth;
  65119. private _x1;
  65120. private _y1;
  65121. private _x2;
  65122. private _y2;
  65123. private _dash;
  65124. private _connectedControl;
  65125. private _connectedControlDirtyObserver;
  65126. /** Gets or sets the dash pattern */
  65127. dash: Array<number>;
  65128. /** Gets or sets the control connected with the line end */
  65129. connectedControl: Control;
  65130. /** Gets or sets start coordinates on X axis */
  65131. x1: string | number;
  65132. /** Gets or sets start coordinates on Y axis */
  65133. y1: string | number;
  65134. /** Gets or sets end coordinates on X axis */
  65135. x2: string | number;
  65136. /** Gets or sets end coordinates on Y axis */
  65137. y2: string | number;
  65138. /** Gets or sets line width */
  65139. lineWidth: number;
  65140. /** Gets or sets horizontal alignment */
  65141. horizontalAlignment: number;
  65142. /** Gets or sets vertical alignment */
  65143. verticalAlignment: number;
  65144. private readonly _effectiveX2;
  65145. private readonly _effectiveY2;
  65146. /**
  65147. * Creates a new Line
  65148. * @param name defines the control name
  65149. */
  65150. constructor(name?: string | undefined);
  65151. protected _getTypeName(): string;
  65152. _draw(context: CanvasRenderingContext2D): void;
  65153. _measure(): void;
  65154. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65155. /**
  65156. * Move one end of the line given 3D cartesian coordinates.
  65157. * @param position Targeted world position
  65158. * @param scene BABYLON.Scene
  65159. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65160. */
  65161. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  65162. /**
  65163. * Move one end of the line to a position in screen absolute space.
  65164. * @param projectedPosition Position in screen absolute space (X, Y)
  65165. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65166. */
  65167. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  65168. }
  65169. }
  65170. declare module BABYLON.GUI {
  65171. /**
  65172. * Class used to store a point for a MultiLine object.
  65173. * The point can be pure 2D coordinates, a mesh or a control
  65174. */
  65175. export class MultiLinePoint {
  65176. private _multiLine;
  65177. private _x;
  65178. private _y;
  65179. private _control;
  65180. private _mesh;
  65181. private _controlObserver;
  65182. private _meshObserver;
  65183. /** @hidden */
  65184. _point: BABYLON.Vector2;
  65185. /**
  65186. * Creates a new MultiLinePoint
  65187. * @param multiLine defines the source MultiLine object
  65188. */
  65189. constructor(multiLine: MultiLine);
  65190. /** Gets or sets x coordinate */
  65191. x: string | number;
  65192. /** Gets or sets y coordinate */
  65193. y: string | number;
  65194. /** Gets or sets the control associated with this point */
  65195. control: BABYLON.Nullable<Control>;
  65196. /** Gets or sets the mesh associated with this point */
  65197. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65198. /** Resets links */
  65199. resetLinks(): void;
  65200. /**
  65201. * Gets a translation vector
  65202. * @returns the translation vector
  65203. */
  65204. translate(): BABYLON.Vector2;
  65205. private _translatePoint;
  65206. /** Release associated resources */
  65207. dispose(): void;
  65208. }
  65209. }
  65210. declare module BABYLON.GUI {
  65211. /**
  65212. * Class used to create multi line control
  65213. */
  65214. export class MultiLine extends Control {
  65215. name?: string | undefined;
  65216. private _lineWidth;
  65217. private _dash;
  65218. private _points;
  65219. private _minX;
  65220. private _minY;
  65221. private _maxX;
  65222. private _maxY;
  65223. /**
  65224. * Creates a new MultiLine
  65225. * @param name defines the control name
  65226. */
  65227. constructor(name?: string | undefined);
  65228. /** Gets or sets dash pattern */
  65229. dash: Array<number>;
  65230. /**
  65231. * Gets point stored at specified index
  65232. * @param index defines the index to look for
  65233. * @returns the requested point if found
  65234. */
  65235. getAt(index: number): MultiLinePoint;
  65236. /** Function called when a point is updated */
  65237. onPointUpdate: () => void;
  65238. /**
  65239. * Adds new points to the point collection
  65240. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  65241. * @returns the list of created MultiLinePoint
  65242. */
  65243. add(...items: (AbstractMesh | Control | {
  65244. x: string | number;
  65245. y: string | number;
  65246. })[]): MultiLinePoint[];
  65247. /**
  65248. * Adds a new point to the point collection
  65249. * @param item defines the item (mesh, control or 2d coordiantes) to add
  65250. * @returns the created MultiLinePoint
  65251. */
  65252. push(item?: (AbstractMesh | Control | {
  65253. x: string | number;
  65254. y: string | number;
  65255. })): MultiLinePoint;
  65256. /**
  65257. * Remove a specific value or point from the active point collection
  65258. * @param value defines the value or point to remove
  65259. */
  65260. remove(value: number | MultiLinePoint): void;
  65261. /**
  65262. * Resets this object to initial state (no point)
  65263. */
  65264. reset(): void;
  65265. /**
  65266. * Resets all links
  65267. */
  65268. resetLinks(): void;
  65269. /** Gets or sets line width */
  65270. lineWidth: number;
  65271. horizontalAlignment: number;
  65272. verticalAlignment: number;
  65273. protected _getTypeName(): string;
  65274. _draw(context: CanvasRenderingContext2D): void;
  65275. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65276. _measure(): void;
  65277. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65278. dispose(): void;
  65279. }
  65280. }
  65281. declare module BABYLON.GUI {
  65282. /**
  65283. * Class used to create radio button controls
  65284. */
  65285. export class RadioButton extends Control {
  65286. name?: string | undefined;
  65287. private _isChecked;
  65288. private _background;
  65289. private _checkSizeRatio;
  65290. private _thickness;
  65291. /** Gets or sets border thickness */
  65292. thickness: number;
  65293. /** Gets or sets group name */
  65294. group: string;
  65295. /** BABYLON.Observable raised when isChecked is changed */
  65296. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65297. /** Gets or sets a value indicating the ratio between overall size and check size */
  65298. checkSizeRatio: number;
  65299. /** Gets or sets background color */
  65300. background: string;
  65301. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65302. isChecked: boolean;
  65303. /**
  65304. * Creates a new RadioButton
  65305. * @param name defines the control name
  65306. */
  65307. constructor(name?: string | undefined);
  65308. protected _getTypeName(): string;
  65309. _draw(context: CanvasRenderingContext2D): void;
  65310. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65311. /**
  65312. * Utility function to easily create a radio button with a header
  65313. * @param title defines the label to use for the header
  65314. * @param group defines the group to use for the radio button
  65315. * @param isChecked defines the initial state of the radio button
  65316. * @param onValueChanged defines the callback to call when value changes
  65317. * @returns a StackPanel containing the radio button and a textBlock
  65318. */
  65319. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  65320. }
  65321. }
  65322. declare module BABYLON.GUI {
  65323. /**
  65324. * Class used to create slider controls
  65325. */
  65326. export class BaseSlider extends Control {
  65327. name?: string | undefined;
  65328. protected _thumbWidth: ValueAndUnit;
  65329. private _minimum;
  65330. private _maximum;
  65331. private _value;
  65332. private _isVertical;
  65333. protected _barOffset: ValueAndUnit;
  65334. private _isThumbClamped;
  65335. protected _displayThumb: boolean;
  65336. private _step;
  65337. private _lastPointerDownID;
  65338. protected _effectiveBarOffset: number;
  65339. protected _renderLeft: number;
  65340. protected _renderTop: number;
  65341. protected _renderWidth: number;
  65342. protected _renderHeight: number;
  65343. protected _backgroundBoxLength: number;
  65344. protected _backgroundBoxThickness: number;
  65345. protected _effectiveThumbThickness: number;
  65346. /** BABYLON.Observable raised when the sldier value changes */
  65347. onValueChangedObservable: BABYLON.Observable<number>;
  65348. /** Gets or sets a boolean indicating if the thumb must be rendered */
  65349. displayThumb: boolean;
  65350. /** Gets or sets a step to apply to values (0 by default) */
  65351. step: number;
  65352. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  65353. barOffset: string | number;
  65354. /** Gets main bar offset in pixels*/
  65355. readonly barOffsetInPixels: number;
  65356. /** Gets or sets thumb width */
  65357. thumbWidth: string | number;
  65358. /** Gets thumb width in pixels */
  65359. readonly thumbWidthInPixels: number;
  65360. /** Gets or sets minimum value */
  65361. minimum: number;
  65362. /** Gets or sets maximum value */
  65363. maximum: number;
  65364. /** Gets or sets current value */
  65365. value: number;
  65366. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  65367. isVertical: boolean;
  65368. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  65369. isThumbClamped: boolean;
  65370. /**
  65371. * Creates a new BaseSlider
  65372. * @param name defines the control name
  65373. */
  65374. constructor(name?: string | undefined);
  65375. protected _getTypeName(): string;
  65376. protected _getThumbPosition(): number;
  65377. protected _getThumbThickness(type: string): number;
  65378. protected _prepareRenderingData(type: string): void;
  65379. private _pointerIsDown;
  65380. /** @hidden */
  65381. protected _updateValueFromPointer(x: number, y: number): void;
  65382. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65383. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65384. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65385. }
  65386. }
  65387. declare module BABYLON.GUI {
  65388. /**
  65389. * Class used to create slider controls
  65390. */
  65391. export class Slider extends BaseSlider {
  65392. name?: string | undefined;
  65393. private _background;
  65394. private _borderColor;
  65395. private _isThumbCircle;
  65396. protected _displayValueBar: boolean;
  65397. /** Gets or sets a boolean indicating if the value bar must be rendered */
  65398. displayValueBar: boolean;
  65399. /** Gets or sets border color */
  65400. borderColor: string;
  65401. /** Gets or sets background color */
  65402. background: string;
  65403. /** Gets or sets a boolean indicating if the thumb should be round or square */
  65404. isThumbCircle: boolean;
  65405. /**
  65406. * Creates a new Slider
  65407. * @param name defines the control name
  65408. */
  65409. constructor(name?: string | undefined);
  65410. protected _getTypeName(): string;
  65411. _draw(context: CanvasRenderingContext2D): void;
  65412. }
  65413. }
  65414. declare module BABYLON.GUI {
  65415. /** Class used to create a RadioGroup
  65416. * which contains groups of radio buttons
  65417. */
  65418. export class SelectorGroup {
  65419. /** name of SelectorGroup */
  65420. name: string;
  65421. private _groupPanel;
  65422. private _selectors;
  65423. private _groupHeader;
  65424. /**
  65425. * Creates a new SelectorGroup
  65426. * @param name of group, used as a group heading
  65427. */
  65428. constructor(
  65429. /** name of SelectorGroup */
  65430. name: string);
  65431. /** Gets the groupPanel of the SelectorGroup */
  65432. readonly groupPanel: StackPanel;
  65433. /** Gets the selectors array */
  65434. readonly selectors: StackPanel[];
  65435. /** Gets and sets the group header */
  65436. header: string;
  65437. /** @hidden */
  65438. private _addGroupHeader;
  65439. /** @hidden*/
  65440. _getSelector(selectorNb: number): StackPanel | undefined;
  65441. /** Removes the selector at the given position
  65442. * @param selectorNb the position of the selector within the group
  65443. */
  65444. removeSelector(selectorNb: number): void;
  65445. }
  65446. /** Class used to create a CheckboxGroup
  65447. * which contains groups of checkbox buttons
  65448. */
  65449. export class CheckboxGroup extends SelectorGroup {
  65450. /** Adds a checkbox as a control
  65451. * @param text is the label for the selector
  65452. * @param func is the function called when the Selector is checked
  65453. * @param checked is true when Selector is checked
  65454. */
  65455. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  65456. /** @hidden */
  65457. _setSelectorLabel(selectorNb: number, label: string): void;
  65458. /** @hidden */
  65459. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65460. /** @hidden */
  65461. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65462. /** @hidden */
  65463. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65464. }
  65465. /** Class used to create a RadioGroup
  65466. * which contains groups of radio buttons
  65467. */
  65468. export class RadioGroup extends SelectorGroup {
  65469. private _selectNb;
  65470. /** Adds a radio button as a control
  65471. * @param label is the label for the selector
  65472. * @param func is the function called when the Selector is checked
  65473. * @param checked is true when Selector is checked
  65474. */
  65475. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  65476. /** @hidden */
  65477. _setSelectorLabel(selectorNb: number, label: string): void;
  65478. /** @hidden */
  65479. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65480. /** @hidden */
  65481. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65482. /** @hidden */
  65483. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65484. }
  65485. /** Class used to create a SliderGroup
  65486. * which contains groups of slider buttons
  65487. */
  65488. export class SliderGroup extends SelectorGroup {
  65489. /**
  65490. * Adds a slider to the SelectorGroup
  65491. * @param label is the label for the SliderBar
  65492. * @param func is the function called when the Slider moves
  65493. * @param unit is a string describing the units used, eg degrees or metres
  65494. * @param min is the minimum value for the Slider
  65495. * @param max is the maximum value for the Slider
  65496. * @param value is the start value for the Slider between min and max
  65497. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  65498. */
  65499. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  65500. /** @hidden */
  65501. _setSelectorLabel(selectorNb: number, label: string): void;
  65502. /** @hidden */
  65503. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65504. /** @hidden */
  65505. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65506. /** @hidden */
  65507. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65508. }
  65509. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  65510. * @see http://doc.babylonjs.com/how_to/selector
  65511. */
  65512. export class SelectionPanel extends Rectangle {
  65513. /** name of SelectionPanel */
  65514. name: string;
  65515. /** an array of SelectionGroups */
  65516. groups: SelectorGroup[];
  65517. private _panel;
  65518. private _buttonColor;
  65519. private _buttonBackground;
  65520. private _headerColor;
  65521. private _barColor;
  65522. private _barHeight;
  65523. private _spacerHeight;
  65524. private _labelColor;
  65525. private _groups;
  65526. private _bars;
  65527. /**
  65528. * Creates a new SelectionPanel
  65529. * @param name of SelectionPanel
  65530. * @param groups is an array of SelectionGroups
  65531. */
  65532. constructor(
  65533. /** name of SelectionPanel */
  65534. name: string,
  65535. /** an array of SelectionGroups */
  65536. groups?: SelectorGroup[]);
  65537. protected _getTypeName(): string;
  65538. /** Gets or sets the headerColor */
  65539. headerColor: string;
  65540. private _setHeaderColor;
  65541. /** Gets or sets the button color */
  65542. buttonColor: string;
  65543. private _setbuttonColor;
  65544. /** Gets or sets the label color */
  65545. labelColor: string;
  65546. private _setLabelColor;
  65547. /** Gets or sets the button background */
  65548. buttonBackground: string;
  65549. private _setButtonBackground;
  65550. /** Gets or sets the color of separator bar */
  65551. barColor: string;
  65552. private _setBarColor;
  65553. /** Gets or sets the height of separator bar */
  65554. barHeight: string;
  65555. private _setBarHeight;
  65556. /** Gets or sets the height of spacers*/
  65557. spacerHeight: string;
  65558. private _setSpacerHeight;
  65559. /** Adds a bar between groups */
  65560. private _addSpacer;
  65561. /** Add a group to the selection panel
  65562. * @param group is the selector group to add
  65563. */
  65564. addGroup(group: SelectorGroup): void;
  65565. /** Remove the group from the given position
  65566. * @param groupNb is the position of the group in the list
  65567. */
  65568. removeGroup(groupNb: number): void;
  65569. /** Change a group header label
  65570. * @param label is the new group header label
  65571. * @param groupNb is the number of the group to relabel
  65572. * */
  65573. setHeaderName(label: string, groupNb: number): void;
  65574. /** Change selector label to the one given
  65575. * @param label is the new selector label
  65576. * @param groupNb is the number of the groupcontaining the selector
  65577. * @param selectorNb is the number of the selector within a group to relabel
  65578. * */
  65579. relabel(label: string, groupNb: number, selectorNb: number): void;
  65580. /** For a given group position remove the selector at the given position
  65581. * @param groupNb is the number of the group to remove the selector from
  65582. * @param selectorNb is the number of the selector within the group
  65583. */
  65584. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  65585. /** For a given group position of correct type add a checkbox button
  65586. * @param groupNb is the number of the group to remove the selector from
  65587. * @param label is the label for the selector
  65588. * @param func is the function called when the Selector is checked
  65589. * @param checked is true when Selector is checked
  65590. */
  65591. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65592. /** For a given group position of correct type add a radio button
  65593. * @param groupNb is the number of the group to remove the selector from
  65594. * @param label is the label for the selector
  65595. * @param func is the function called when the Selector is checked
  65596. * @param checked is true when Selector is checked
  65597. */
  65598. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65599. /**
  65600. * For a given slider group add a slider
  65601. * @param groupNb is the number of the group to add the slider to
  65602. * @param label is the label for the Slider
  65603. * @param func is the function called when the Slider moves
  65604. * @param unit is a string describing the units used, eg degrees or metres
  65605. * @param min is the minimum value for the Slider
  65606. * @param max is the maximum value for the Slider
  65607. * @param value is the start value for the Slider between min and max
  65608. * @param onVal is the function used to format the value displayed, eg radians to degrees
  65609. */
  65610. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  65611. }
  65612. }
  65613. declare module BABYLON.GUI {
  65614. /**
  65615. * Class used to hold a the container for ScrollViewer
  65616. * @hidden
  65617. */
  65618. export class _ScrollViewerWindow extends Container {
  65619. parentClientWidth: number;
  65620. parentClientHeight: number;
  65621. /**
  65622. * Creates a new ScrollViewerWindow
  65623. * @param name of ScrollViewerWindow
  65624. */
  65625. constructor(name?: string);
  65626. protected _getTypeName(): string;
  65627. /** @hidden */
  65628. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65629. protected _postMeasure(): void;
  65630. }
  65631. }
  65632. declare module BABYLON.GUI {
  65633. /**
  65634. * Class used to create slider controls
  65635. */
  65636. export class ScrollBar extends BaseSlider {
  65637. name?: string | undefined;
  65638. private _background;
  65639. private _borderColor;
  65640. private _thumbMeasure;
  65641. /** Gets or sets border color */
  65642. borderColor: string;
  65643. /** Gets or sets background color */
  65644. background: string;
  65645. /**
  65646. * Creates a new Slider
  65647. * @param name defines the control name
  65648. */
  65649. constructor(name?: string | undefined);
  65650. protected _getTypeName(): string;
  65651. protected _getThumbThickness(): number;
  65652. _draw(context: CanvasRenderingContext2D): void;
  65653. private _first;
  65654. private _originX;
  65655. private _originY;
  65656. /** @hidden */
  65657. protected _updateValueFromPointer(x: number, y: number): void;
  65658. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65659. }
  65660. }
  65661. declare module BABYLON.GUI {
  65662. /**
  65663. * Class used to hold a viewer window and sliders in a grid
  65664. */
  65665. export class ScrollViewer extends Rectangle {
  65666. private _grid;
  65667. private _horizontalBarSpace;
  65668. private _verticalBarSpace;
  65669. private _dragSpace;
  65670. private _horizontalBar;
  65671. private _verticalBar;
  65672. private _barColor;
  65673. private _barBackground;
  65674. private _barSize;
  65675. private _endLeft;
  65676. private _endTop;
  65677. private _window;
  65678. private _pointerIsOver;
  65679. private _wheelPrecision;
  65680. private _onPointerObserver;
  65681. private _clientWidth;
  65682. private _clientHeight;
  65683. /**
  65684. * Gets the horizontal scrollbar
  65685. */
  65686. readonly horizontalBar: ScrollBar;
  65687. /**
  65688. * Gets the vertical scrollbar
  65689. */
  65690. readonly verticalBar: ScrollBar;
  65691. /**
  65692. * Adds a new control to the current container
  65693. * @param control defines the control to add
  65694. * @returns the current container
  65695. */
  65696. addControl(control: BABYLON.Nullable<Control>): Container;
  65697. /**
  65698. * Removes a control from the current container
  65699. * @param control defines the control to remove
  65700. * @returns the current container
  65701. */
  65702. removeControl(control: Control): Container;
  65703. /** Gets the list of children */
  65704. readonly children: Control[];
  65705. _flagDescendantsAsMatrixDirty(): void;
  65706. /**
  65707. * Creates a new ScrollViewer
  65708. * @param name of ScrollViewer
  65709. */
  65710. constructor(name?: string);
  65711. /** Reset the scroll viewer window to initial size */
  65712. resetWindow(): void;
  65713. protected _getTypeName(): string;
  65714. private _buildClientSizes;
  65715. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65716. protected _postMeasure(): void;
  65717. /**
  65718. * Gets or sets the mouse wheel precision
  65719. * from 0 to 1 with a default value of 0.05
  65720. * */
  65721. wheelPrecision: number;
  65722. /** Gets or sets the bar color */
  65723. barColor: string;
  65724. /** Gets or sets the size of the bar */
  65725. barSize: number;
  65726. /** Gets or sets the bar background */
  65727. barBackground: string;
  65728. /** @hidden */
  65729. private _updateScroller;
  65730. _link(host: AdvancedDynamicTexture): void;
  65731. /** @hidden */
  65732. private _attachWheel;
  65733. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65734. /** Releases associated resources */
  65735. dispose(): void;
  65736. }
  65737. }
  65738. declare module BABYLON.GUI {
  65739. /** Class used to render a grid */
  65740. export class DisplayGrid extends Control {
  65741. name?: string | undefined;
  65742. private _cellWidth;
  65743. private _cellHeight;
  65744. private _minorLineTickness;
  65745. private _minorLineColor;
  65746. private _majorLineTickness;
  65747. private _majorLineColor;
  65748. private _majorLineFrequency;
  65749. private _background;
  65750. private _displayMajorLines;
  65751. private _displayMinorLines;
  65752. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  65753. displayMinorLines: boolean;
  65754. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  65755. displayMajorLines: boolean;
  65756. /** Gets or sets background color (Black by default) */
  65757. background: string;
  65758. /** Gets or sets the width of each cell (20 by default) */
  65759. cellWidth: number;
  65760. /** Gets or sets the height of each cell (20 by default) */
  65761. cellHeight: number;
  65762. /** Gets or sets the tickness of minor lines (1 by default) */
  65763. minorLineTickness: number;
  65764. /** Gets or sets the color of minor lines (DarkGray by default) */
  65765. minorLineColor: string;
  65766. /** Gets or sets the tickness of major lines (2 by default) */
  65767. majorLineTickness: number;
  65768. /** Gets or sets the color of major lines (White by default) */
  65769. majorLineColor: string;
  65770. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  65771. majorLineFrequency: number;
  65772. /**
  65773. * Creates a new GridDisplayRectangle
  65774. * @param name defines the control name
  65775. */
  65776. constructor(name?: string | undefined);
  65777. _draw(context: CanvasRenderingContext2D): void;
  65778. protected _getTypeName(): string;
  65779. }
  65780. }
  65781. declare module BABYLON.GUI {
  65782. /**
  65783. * Class used to create slider controls based on images
  65784. */
  65785. export class ImageBasedSlider extends BaseSlider {
  65786. name?: string | undefined;
  65787. private _backgroundImage;
  65788. private _thumbImage;
  65789. private _valueBarImage;
  65790. private _tempMeasure;
  65791. displayThumb: boolean;
  65792. /**
  65793. * Gets or sets the image used to render the background
  65794. */
  65795. backgroundImage: Image;
  65796. /**
  65797. * Gets or sets the image used to render the value bar
  65798. */
  65799. valueBarImage: Image;
  65800. /**
  65801. * Gets or sets the image used to render the thumb
  65802. */
  65803. thumbImage: Image;
  65804. /**
  65805. * Creates a new ImageBasedSlider
  65806. * @param name defines the control name
  65807. */
  65808. constructor(name?: string | undefined);
  65809. protected _getTypeName(): string;
  65810. _draw(context: CanvasRenderingContext2D): void;
  65811. }
  65812. }
  65813. declare module BABYLON.GUI {
  65814. /**
  65815. * Forcing an export so that this code will execute
  65816. * @hidden
  65817. */
  65818. const name = "Statics";
  65819. }
  65820. declare module BABYLON.GUI {
  65821. /**
  65822. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  65823. */
  65824. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  65825. /**
  65826. * Define the instrumented AdvancedDynamicTexture.
  65827. */
  65828. texture: AdvancedDynamicTexture;
  65829. private _captureRenderTime;
  65830. private _renderTime;
  65831. private _captureLayoutTime;
  65832. private _layoutTime;
  65833. private _onBeginRenderObserver;
  65834. private _onEndRenderObserver;
  65835. private _onBeginLayoutObserver;
  65836. private _onEndLayoutObserver;
  65837. /**
  65838. * Gets the perf counter used to capture render time
  65839. */
  65840. readonly renderTimeCounter: BABYLON.PerfCounter;
  65841. /**
  65842. * Gets the perf counter used to capture layout time
  65843. */
  65844. readonly layoutTimeCounter: BABYLON.PerfCounter;
  65845. /**
  65846. * Enable or disable the render time capture
  65847. */
  65848. captureRenderTime: boolean;
  65849. /**
  65850. * Enable or disable the layout time capture
  65851. */
  65852. captureLayoutTime: boolean;
  65853. /**
  65854. * Instantiates a new advanced dynamic texture instrumentation.
  65855. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  65856. * @param texture Defines the AdvancedDynamicTexture to instrument
  65857. */
  65858. constructor(
  65859. /**
  65860. * Define the instrumented AdvancedDynamicTexture.
  65861. */
  65862. texture: AdvancedDynamicTexture);
  65863. /**
  65864. * Dispose and release associated resources.
  65865. */
  65866. dispose(): void;
  65867. }
  65868. }
  65869. declare module BABYLON.GUI {
  65870. /**
  65871. * Class used to load GUI via XML.
  65872. */
  65873. export class XmlLoader {
  65874. private _nodes;
  65875. private _nodeTypes;
  65876. private _isLoaded;
  65877. private _objectAttributes;
  65878. private _parentClass;
  65879. /**
  65880. * Create a new xml loader
  65881. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  65882. */
  65883. constructor(parentClass?: null);
  65884. private _getChainElement;
  65885. private _getClassAttribute;
  65886. private _createGuiElement;
  65887. private _parseGrid;
  65888. private _parseElement;
  65889. private _prepareSourceElement;
  65890. private _parseElementsFromSource;
  65891. private _parseXml;
  65892. /**
  65893. * Gets if the loading has finished.
  65894. * @returns whether the loading has finished or not
  65895. */
  65896. isLoaded(): boolean;
  65897. /**
  65898. * Gets a loaded node / control by id.
  65899. * @param id the Controls id set in the xml
  65900. * @returns element of type Control
  65901. */
  65902. getNodeById(id: string): any;
  65903. /**
  65904. * Gets all loaded nodes / controls
  65905. * @returns Array of controls
  65906. */
  65907. getNodes(): any;
  65908. /**
  65909. * Initiates the xml layout loading
  65910. * @param xmlFile defines the xml layout to load
  65911. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  65912. * @param callback defines the callback called on layout load.
  65913. */
  65914. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  65915. }
  65916. }
  65917. declare module BABYLON.GUI {
  65918. /**
  65919. * Class used to create containers for controls
  65920. */
  65921. export class Container3D extends Control3D {
  65922. private _blockLayout;
  65923. /**
  65924. * Gets the list of child controls
  65925. */
  65926. protected _children: Control3D[];
  65927. /**
  65928. * Gets the list of child controls
  65929. */
  65930. readonly children: Array<Control3D>;
  65931. /**
  65932. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  65933. * This is helpful to optimize layout operation when adding multiple children in a row
  65934. */
  65935. blockLayout: boolean;
  65936. /**
  65937. * Creates a new container
  65938. * @param name defines the container name
  65939. */
  65940. constructor(name?: string);
  65941. /**
  65942. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  65943. * @returns the current container
  65944. */
  65945. updateLayout(): Container3D;
  65946. /**
  65947. * Gets a boolean indicating if the given control is in the children of this control
  65948. * @param control defines the control to check
  65949. * @returns true if the control is in the child list
  65950. */
  65951. containsControl(control: Control3D): boolean;
  65952. /**
  65953. * Adds a control to the children of this control
  65954. * @param control defines the control to add
  65955. * @returns the current container
  65956. */
  65957. addControl(control: Control3D): Container3D;
  65958. /**
  65959. * This function will be called everytime a new control is added
  65960. */
  65961. protected _arrangeChildren(): void;
  65962. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65963. /**
  65964. * Removes a control from the children of this control
  65965. * @param control defines the control to remove
  65966. * @returns the current container
  65967. */
  65968. removeControl(control: Control3D): Container3D;
  65969. protected _getTypeName(): string;
  65970. /**
  65971. * Releases all associated resources
  65972. */
  65973. dispose(): void;
  65974. /** Control rotation will remain unchanged */
  65975. static readonly UNSET_ORIENTATION: number;
  65976. /** Control will rotate to make it look at sphere central axis */
  65977. static readonly FACEORIGIN_ORIENTATION: number;
  65978. /** Control will rotate to make it look back at sphere central axis */
  65979. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  65980. /** Control will rotate to look at z axis (0, 0, 1) */
  65981. static readonly FACEFORWARD_ORIENTATION: number;
  65982. /** Control will rotate to look at negative z axis (0, 0, -1) */
  65983. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  65984. }
  65985. }
  65986. declare module BABYLON.GUI {
  65987. /**
  65988. * Class used to manage 3D user interface
  65989. * @see http://doc.babylonjs.com/how_to/gui3d
  65990. */
  65991. export class GUI3DManager implements BABYLON.IDisposable {
  65992. private _scene;
  65993. private _sceneDisposeObserver;
  65994. private _utilityLayer;
  65995. private _rootContainer;
  65996. private _pointerObserver;
  65997. private _pointerOutObserver;
  65998. /** @hidden */
  65999. _lastPickedControl: Control3D;
  66000. /** @hidden */
  66001. _lastControlOver: {
  66002. [pointerId: number]: Control3D;
  66003. };
  66004. /** @hidden */
  66005. _lastControlDown: {
  66006. [pointerId: number]: Control3D;
  66007. };
  66008. /**
  66009. * BABYLON.Observable raised when the point picked by the pointer events changed
  66010. */
  66011. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  66012. /** @hidden */
  66013. _sharedMaterials: {
  66014. [key: string]: BABYLON.Material;
  66015. };
  66016. /** Gets the hosting scene */
  66017. readonly scene: BABYLON.Scene;
  66018. /** Gets associated utility layer */
  66019. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  66020. /**
  66021. * Creates a new GUI3DManager
  66022. * @param scene
  66023. */
  66024. constructor(scene?: BABYLON.Scene);
  66025. private _handlePointerOut;
  66026. private _doPicking;
  66027. /**
  66028. * Gets the root container
  66029. */
  66030. readonly rootContainer: Container3D;
  66031. /**
  66032. * Gets a boolean indicating if the given control is in the root child list
  66033. * @param control defines the control to check
  66034. * @returns true if the control is in the root child list
  66035. */
  66036. containsControl(control: Control3D): boolean;
  66037. /**
  66038. * Adds a control to the root child list
  66039. * @param control defines the control to add
  66040. * @returns the current manager
  66041. */
  66042. addControl(control: Control3D): GUI3DManager;
  66043. /**
  66044. * Removes a control from the root child list
  66045. * @param control defines the control to remove
  66046. * @returns the current container
  66047. */
  66048. removeControl(control: Control3D): GUI3DManager;
  66049. /**
  66050. * Releases all associated resources
  66051. */
  66052. dispose(): void;
  66053. }
  66054. }
  66055. declare module BABYLON.GUI {
  66056. /**
  66057. * Class used to transport BABYLON.Vector3 information for pointer events
  66058. */
  66059. export class Vector3WithInfo extends BABYLON.Vector3 {
  66060. /** defines the current mouse button index */
  66061. buttonIndex: number;
  66062. /**
  66063. * Creates a new Vector3WithInfo
  66064. * @param source defines the vector3 data to transport
  66065. * @param buttonIndex defines the current mouse button index
  66066. */
  66067. constructor(source: BABYLON.Vector3,
  66068. /** defines the current mouse button index */
  66069. buttonIndex?: number);
  66070. }
  66071. }
  66072. declare module BABYLON.GUI {
  66073. /**
  66074. * Class used as base class for controls
  66075. */
  66076. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  66077. /** Defines the control name */
  66078. name?: string | undefined;
  66079. /** @hidden */
  66080. _host: GUI3DManager;
  66081. private _node;
  66082. private _downCount;
  66083. private _enterCount;
  66084. private _downPointerIds;
  66085. private _isVisible;
  66086. /** Gets or sets the control position in world space */
  66087. position: BABYLON.Vector3;
  66088. /** Gets or sets the control scaling in world space */
  66089. scaling: BABYLON.Vector3;
  66090. /** Callback used to start pointer enter animation */
  66091. pointerEnterAnimation: () => void;
  66092. /** Callback used to start pointer out animation */
  66093. pointerOutAnimation: () => void;
  66094. /** Callback used to start pointer down animation */
  66095. pointerDownAnimation: () => void;
  66096. /** Callback used to start pointer up animation */
  66097. pointerUpAnimation: () => void;
  66098. /**
  66099. * An event triggered when the pointer move over the control
  66100. */
  66101. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  66102. /**
  66103. * An event triggered when the pointer move out of the control
  66104. */
  66105. onPointerOutObservable: BABYLON.Observable<Control3D>;
  66106. /**
  66107. * An event triggered when the pointer taps the control
  66108. */
  66109. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  66110. /**
  66111. * An event triggered when pointer is up
  66112. */
  66113. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  66114. /**
  66115. * An event triggered when a control is clicked on (with a mouse)
  66116. */
  66117. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  66118. /**
  66119. * An event triggered when pointer enters the control
  66120. */
  66121. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  66122. /**
  66123. * Gets or sets the parent container
  66124. */
  66125. parent: BABYLON.Nullable<Container3D>;
  66126. private _behaviors;
  66127. /**
  66128. * Gets the list of attached behaviors
  66129. * @see http://doc.babylonjs.com/features/behaviour
  66130. */
  66131. readonly behaviors: BABYLON.Behavior<Control3D>[];
  66132. /**
  66133. * Attach a behavior to the control
  66134. * @see http://doc.babylonjs.com/features/behaviour
  66135. * @param behavior defines the behavior to attach
  66136. * @returns the current control
  66137. */
  66138. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66139. /**
  66140. * Remove an attached behavior
  66141. * @see http://doc.babylonjs.com/features/behaviour
  66142. * @param behavior defines the behavior to attach
  66143. * @returns the current control
  66144. */
  66145. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66146. /**
  66147. * Gets an attached behavior by name
  66148. * @param name defines the name of the behavior to look for
  66149. * @see http://doc.babylonjs.com/features/behaviour
  66150. * @returns null if behavior was not found else the requested behavior
  66151. */
  66152. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  66153. /** Gets or sets a boolean indicating if the control is visible */
  66154. isVisible: boolean;
  66155. /**
  66156. * Creates a new control
  66157. * @param name defines the control name
  66158. */
  66159. constructor(
  66160. /** Defines the control name */
  66161. name?: string | undefined);
  66162. /**
  66163. * Gets a string representing the class name
  66164. */
  66165. readonly typeName: string;
  66166. /**
  66167. * Get the current class name of the control.
  66168. * @returns current class name
  66169. */
  66170. getClassName(): string;
  66171. protected _getTypeName(): string;
  66172. /**
  66173. * Gets the transform node used by this control
  66174. */
  66175. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  66176. /**
  66177. * Gets the mesh used to render this control
  66178. */
  66179. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66180. /**
  66181. * Link the control as child of the given node
  66182. * @param node defines the node to link to. Use null to unlink the control
  66183. * @returns the current control
  66184. */
  66185. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  66186. /** @hidden **/
  66187. _prepareNode(scene: BABYLON.Scene): void;
  66188. /**
  66189. * Node creation.
  66190. * Can be overriden by children
  66191. * @param scene defines the scene where the node must be attached
  66192. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  66193. */
  66194. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66195. /**
  66196. * Affect a material to the given mesh
  66197. * @param mesh defines the mesh which will represent the control
  66198. */
  66199. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66200. /** @hidden */
  66201. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  66202. /** @hidden */
  66203. _onPointerEnter(target: Control3D): boolean;
  66204. /** @hidden */
  66205. _onPointerOut(target: Control3D): void;
  66206. /** @hidden */
  66207. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66208. /** @hidden */
  66209. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66210. /** @hidden */
  66211. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  66212. /** @hidden */
  66213. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66214. /** @hidden */
  66215. _disposeNode(): void;
  66216. /**
  66217. * Releases all associated resources
  66218. */
  66219. dispose(): void;
  66220. }
  66221. }
  66222. declare module BABYLON.GUI {
  66223. /**
  66224. * Class used as a root to all buttons
  66225. */
  66226. export class AbstractButton3D extends Control3D {
  66227. /**
  66228. * Creates a new button
  66229. * @param name defines the control name
  66230. */
  66231. constructor(name?: string);
  66232. protected _getTypeName(): string;
  66233. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66234. }
  66235. }
  66236. declare module BABYLON.GUI {
  66237. /**
  66238. * Class used to create a button in 3D
  66239. */
  66240. export class Button3D extends AbstractButton3D {
  66241. /** @hidden */
  66242. protected _currentMaterial: BABYLON.Material;
  66243. private _facadeTexture;
  66244. private _content;
  66245. private _contentResolution;
  66246. private _contentScaleRatio;
  66247. /**
  66248. * Gets or sets the texture resolution used to render content (512 by default)
  66249. */
  66250. contentResolution: BABYLON.int;
  66251. /**
  66252. * Gets or sets the texture scale ratio used to render content (2 by default)
  66253. */
  66254. contentScaleRatio: number;
  66255. protected _disposeFacadeTexture(): void;
  66256. protected _resetContent(): void;
  66257. /**
  66258. * Creates a new button
  66259. * @param name defines the control name
  66260. */
  66261. constructor(name?: string);
  66262. /**
  66263. * Gets or sets the GUI 2D content used to display the button's facade
  66264. */
  66265. content: Control;
  66266. /**
  66267. * Apply the facade texture (created from the content property).
  66268. * This function can be overloaded by child classes
  66269. * @param facadeTexture defines the AdvancedDynamicTexture to use
  66270. */
  66271. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66272. protected _getTypeName(): string;
  66273. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66274. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66275. /**
  66276. * Releases all associated resources
  66277. */
  66278. dispose(): void;
  66279. }
  66280. }
  66281. declare module BABYLON.GUI {
  66282. /**
  66283. * Abstract class used to create a container panel deployed on the surface of a volume
  66284. */
  66285. export abstract class VolumeBasedPanel extends Container3D {
  66286. private _columns;
  66287. private _rows;
  66288. private _rowThenColum;
  66289. private _orientation;
  66290. protected _cellWidth: number;
  66291. protected _cellHeight: number;
  66292. /**
  66293. * Gets or sets the distance between elements
  66294. */
  66295. margin: number;
  66296. /**
  66297. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  66298. * | Value | Type | Description |
  66299. * | ----- | ----------------------------------- | ----------- |
  66300. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  66301. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  66302. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  66303. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  66304. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  66305. */
  66306. orientation: number;
  66307. /**
  66308. * Gets or sets the number of columns requested (10 by default).
  66309. * The panel will automatically compute the number of rows based on number of child controls.
  66310. */
  66311. columns: BABYLON.int;
  66312. /**
  66313. * Gets or sets a the number of rows requested.
  66314. * The panel will automatically compute the number of columns based on number of child controls.
  66315. */
  66316. rows: BABYLON.int;
  66317. /**
  66318. * Creates new VolumeBasedPanel
  66319. */
  66320. constructor();
  66321. protected _arrangeChildren(): void;
  66322. /** Child classes must implement this function to provide correct control positioning */
  66323. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66324. /** Child classes can implement this function to provide additional processing */
  66325. protected _finalProcessing(): void;
  66326. }
  66327. }
  66328. declare module BABYLON.GUI {
  66329. /**
  66330. * Class used to create a container panel deployed on the surface of a cylinder
  66331. */
  66332. export class CylinderPanel extends VolumeBasedPanel {
  66333. private _radius;
  66334. /**
  66335. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  66336. */
  66337. radius: BABYLON.float;
  66338. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66339. private _cylindricalMapping;
  66340. }
  66341. }
  66342. declare module BABYLON.GUI {
  66343. /** @hidden */
  66344. export var fluentVertexShader: {
  66345. name: string;
  66346. shader: string;
  66347. };
  66348. }
  66349. declare module BABYLON.GUI {
  66350. /** @hidden */
  66351. export var fluentPixelShader: {
  66352. name: string;
  66353. shader: string;
  66354. };
  66355. }
  66356. declare module BABYLON.GUI {
  66357. /** @hidden */
  66358. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  66359. INNERGLOW: boolean;
  66360. BORDER: boolean;
  66361. HOVERLIGHT: boolean;
  66362. TEXTURE: boolean;
  66363. constructor();
  66364. }
  66365. /**
  66366. * Class used to render controls with fluent desgin
  66367. */
  66368. export class FluentMaterial extends BABYLON.PushMaterial {
  66369. /**
  66370. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  66371. */
  66372. innerGlowColorIntensity: number;
  66373. /**
  66374. * Gets or sets the inner glow color (white by default)
  66375. */
  66376. innerGlowColor: BABYLON.Color3;
  66377. /**
  66378. * Gets or sets alpha value (default is 1.0)
  66379. */
  66380. alpha: number;
  66381. /**
  66382. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  66383. */
  66384. albedoColor: BABYLON.Color3;
  66385. /**
  66386. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  66387. */
  66388. renderBorders: boolean;
  66389. /**
  66390. * Gets or sets border width (default is 0.5)
  66391. */
  66392. borderWidth: number;
  66393. /**
  66394. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  66395. */
  66396. edgeSmoothingValue: number;
  66397. /**
  66398. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  66399. */
  66400. borderMinValue: number;
  66401. /**
  66402. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  66403. */
  66404. renderHoverLight: boolean;
  66405. /**
  66406. * Gets or sets the radius used to render the hover light (default is 1.0)
  66407. */
  66408. hoverRadius: number;
  66409. /**
  66410. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  66411. */
  66412. hoverColor: BABYLON.Color4;
  66413. /**
  66414. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  66415. */
  66416. hoverPosition: BABYLON.Vector3;
  66417. private _albedoTexture;
  66418. /** Gets or sets the texture to use for albedo color */
  66419. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66420. /**
  66421. * Creates a new Fluent material
  66422. * @param name defines the name of the material
  66423. * @param scene defines the hosting scene
  66424. */
  66425. constructor(name: string, scene: BABYLON.Scene);
  66426. needAlphaBlending(): boolean;
  66427. needAlphaTesting(): boolean;
  66428. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66429. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66430. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66431. getActiveTextures(): BABYLON.BaseTexture[];
  66432. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66433. dispose(forceDisposeEffect?: boolean): void;
  66434. clone(name: string): FluentMaterial;
  66435. serialize(): any;
  66436. getClassName(): string;
  66437. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  66438. }
  66439. }
  66440. declare module BABYLON.GUI {
  66441. /**
  66442. * Class used to create a holographic button in 3D
  66443. */
  66444. export class HolographicButton extends Button3D {
  66445. private _backPlate;
  66446. private _textPlate;
  66447. private _frontPlate;
  66448. private _text;
  66449. private _imageUrl;
  66450. private _shareMaterials;
  66451. private _frontMaterial;
  66452. private _backMaterial;
  66453. private _plateMaterial;
  66454. private _pickedPointObserver;
  66455. private _tooltipFade;
  66456. private _tooltipTextBlock;
  66457. private _tooltipTexture;
  66458. private _tooltipMesh;
  66459. private _tooltipHoverObserver;
  66460. private _tooltipOutObserver;
  66461. private _disposeTooltip;
  66462. /**
  66463. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  66464. */
  66465. tooltipText: BABYLON.Nullable<string>;
  66466. /**
  66467. * Gets or sets text for the button
  66468. */
  66469. text: string;
  66470. /**
  66471. * Gets or sets the image url for the button
  66472. */
  66473. imageUrl: string;
  66474. /**
  66475. * Gets the back material used by this button
  66476. */
  66477. readonly backMaterial: FluentMaterial;
  66478. /**
  66479. * Gets the front material used by this button
  66480. */
  66481. readonly frontMaterial: FluentMaterial;
  66482. /**
  66483. * Gets the plate material used by this button
  66484. */
  66485. readonly plateMaterial: BABYLON.StandardMaterial;
  66486. /**
  66487. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  66488. */
  66489. readonly shareMaterials: boolean;
  66490. /**
  66491. * Creates a new button
  66492. * @param name defines the control name
  66493. */
  66494. constructor(name?: string, shareMaterials?: boolean);
  66495. protected _getTypeName(): string;
  66496. private _rebuildContent;
  66497. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66498. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66499. private _createBackMaterial;
  66500. private _createFrontMaterial;
  66501. private _createPlateMaterial;
  66502. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  66503. /**
  66504. * Releases all associated resources
  66505. */
  66506. dispose(): void;
  66507. }
  66508. }
  66509. declare module BABYLON.GUI {
  66510. /**
  66511. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  66512. */
  66513. export class MeshButton3D extends Button3D {
  66514. /** @hidden */
  66515. protected _currentMesh: BABYLON.Mesh;
  66516. /**
  66517. * Creates a new 3D button based on a mesh
  66518. * @param mesh mesh to become a 3D button
  66519. * @param name defines the control name
  66520. */
  66521. constructor(mesh: BABYLON.Mesh, name?: string);
  66522. protected _getTypeName(): string;
  66523. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66524. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66525. }
  66526. }
  66527. declare module BABYLON.GUI {
  66528. /**
  66529. * Class used to create a container panel deployed on the surface of a plane
  66530. */
  66531. export class PlanePanel extends VolumeBasedPanel {
  66532. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66533. }
  66534. }
  66535. declare module BABYLON.GUI {
  66536. /**
  66537. * Class used to create a container panel where items get randomized planar mapping
  66538. */
  66539. export class ScatterPanel extends VolumeBasedPanel {
  66540. private _iteration;
  66541. /**
  66542. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  66543. */
  66544. iteration: BABYLON.float;
  66545. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66546. private _scatterMapping;
  66547. protected _finalProcessing(): void;
  66548. }
  66549. }
  66550. declare module BABYLON.GUI {
  66551. /**
  66552. * Class used to create a container panel deployed on the surface of a sphere
  66553. */
  66554. export class SpherePanel extends VolumeBasedPanel {
  66555. private _radius;
  66556. /**
  66557. * Gets or sets the radius of the sphere where to project controls (5 by default)
  66558. */
  66559. radius: BABYLON.float;
  66560. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66561. private _sphericalMapping;
  66562. }
  66563. }
  66564. declare module BABYLON.GUI {
  66565. /**
  66566. * Class used to create a stack panel in 3D on XY plane
  66567. */
  66568. export class StackPanel3D extends Container3D {
  66569. private _isVertical;
  66570. /**
  66571. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  66572. */
  66573. isVertical: boolean;
  66574. /**
  66575. * Gets or sets the distance between elements
  66576. */
  66577. margin: number;
  66578. /**
  66579. * Creates new StackPanel
  66580. * @param isVertical
  66581. */
  66582. constructor(isVertical?: boolean);
  66583. protected _arrangeChildren(): void;
  66584. }
  66585. }
  66586. declare module BABYLON {
  66587. /**
  66588. * Mode that determines the coordinate system to use.
  66589. */
  66590. export enum GLTFLoaderCoordinateSystemMode {
  66591. /**
  66592. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  66593. */
  66594. AUTO = 0,
  66595. /**
  66596. * Sets the useRightHandedSystem flag on the scene.
  66597. */
  66598. FORCE_RIGHT_HANDED = 1
  66599. }
  66600. /**
  66601. * Mode that determines what animations will start.
  66602. */
  66603. export enum GLTFLoaderAnimationStartMode {
  66604. /**
  66605. * No animation will start.
  66606. */
  66607. NONE = 0,
  66608. /**
  66609. * The first animation will start.
  66610. */
  66611. FIRST = 1,
  66612. /**
  66613. * All animations will start.
  66614. */
  66615. ALL = 2
  66616. }
  66617. /**
  66618. * Interface that contains the data for the glTF asset.
  66619. */
  66620. export interface IGLTFLoaderData {
  66621. /**
  66622. * Object that represents the glTF JSON.
  66623. */
  66624. json: Object;
  66625. /**
  66626. * The BIN chunk of a binary glTF.
  66627. */
  66628. bin: Nullable<ArrayBufferView>;
  66629. }
  66630. /**
  66631. * Interface for extending the loader.
  66632. */
  66633. export interface IGLTFLoaderExtension {
  66634. /**
  66635. * The name of this extension.
  66636. */
  66637. readonly name: string;
  66638. /**
  66639. * Defines whether this extension is enabled.
  66640. */
  66641. enabled: boolean;
  66642. }
  66643. /**
  66644. * Loader state.
  66645. */
  66646. export enum GLTFLoaderState {
  66647. /**
  66648. * The asset is loading.
  66649. */
  66650. LOADING = 0,
  66651. /**
  66652. * The asset is ready for rendering.
  66653. */
  66654. READY = 1,
  66655. /**
  66656. * The asset is completely loaded.
  66657. */
  66658. COMPLETE = 2
  66659. }
  66660. /** @hidden */
  66661. export interface IGLTFLoader extends IDisposable {
  66662. readonly state: Nullable<GLTFLoaderState>;
  66663. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  66664. meshes: AbstractMesh[];
  66665. particleSystems: IParticleSystem[];
  66666. skeletons: Skeleton[];
  66667. animationGroups: AnimationGroup[];
  66668. }>;
  66669. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  66670. }
  66671. /**
  66672. * File loader for loading glTF files into a scene.
  66673. */
  66674. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  66675. /** @hidden */
  66676. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66677. /** @hidden */
  66678. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66679. /**
  66680. * Raised when the asset has been parsed
  66681. */
  66682. onParsedObservable: Observable<IGLTFLoaderData>;
  66683. private _onParsedObserver;
  66684. /**
  66685. * Raised when the asset has been parsed
  66686. */
  66687. onParsed: (loaderData: IGLTFLoaderData) => void;
  66688. /**
  66689. * 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.
  66690. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  66691. * Defaults to true.
  66692. * @hidden
  66693. */
  66694. static IncrementalLoading: boolean;
  66695. /**
  66696. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  66697. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  66698. * @hidden
  66699. */
  66700. static HomogeneousCoordinates: boolean;
  66701. /**
  66702. * The coordinate system mode. Defaults to AUTO.
  66703. */
  66704. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  66705. /**
  66706. * The animation start mode. Defaults to FIRST.
  66707. */
  66708. animationStartMode: GLTFLoaderAnimationStartMode;
  66709. /**
  66710. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  66711. */
  66712. compileMaterials: boolean;
  66713. /**
  66714. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  66715. */
  66716. useClipPlane: boolean;
  66717. /**
  66718. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  66719. */
  66720. compileShadowGenerators: boolean;
  66721. /**
  66722. * Defines if the Alpha blended materials are only applied as coverage.
  66723. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  66724. * If true, no extra effects are applied to transparent pixels.
  66725. */
  66726. transparencyAsCoverage: boolean;
  66727. /**
  66728. * Function called before loading a url referenced by the asset.
  66729. */
  66730. preprocessUrlAsync: (url: string) => Promise<string>;
  66731. /**
  66732. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66733. */
  66734. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  66735. private _onMeshLoadedObserver;
  66736. /**
  66737. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66738. */
  66739. onMeshLoaded: (mesh: AbstractMesh) => void;
  66740. /**
  66741. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  66742. */
  66743. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  66744. private _onTextureLoadedObserver;
  66745. /**
  66746. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  66747. */
  66748. onTextureLoaded: (texture: BaseTexture) => void;
  66749. /**
  66750. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  66751. */
  66752. readonly onMaterialLoadedObservable: Observable<Material>;
  66753. private _onMaterialLoadedObserver;
  66754. /**
  66755. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  66756. */
  66757. onMaterialLoaded: (material: Material) => void;
  66758. /**
  66759. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  66760. */
  66761. readonly onCameraLoadedObservable: Observable<Camera>;
  66762. private _onCameraLoadedObserver;
  66763. /**
  66764. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  66765. */
  66766. onCameraLoaded: (camera: Camera) => void;
  66767. /**
  66768. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  66769. * For assets with LODs, raised when all of the LODs are complete.
  66770. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66771. */
  66772. readonly onCompleteObservable: Observable<void>;
  66773. private _onCompleteObserver;
  66774. /**
  66775. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  66776. * For assets with LODs, raised when all of the LODs are complete.
  66777. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66778. */
  66779. onComplete: () => void;
  66780. /**
  66781. * Observable raised when an error occurs.
  66782. */
  66783. readonly onErrorObservable: Observable<any>;
  66784. private _onErrorObserver;
  66785. /**
  66786. * Callback raised when an error occurs.
  66787. */
  66788. onError: (reason: any) => void;
  66789. /**
  66790. * Observable raised after the loader is disposed.
  66791. */
  66792. readonly onDisposeObservable: Observable<void>;
  66793. private _onDisposeObserver;
  66794. /**
  66795. * Callback raised after the loader is disposed.
  66796. */
  66797. onDispose: () => void;
  66798. /**
  66799. * Observable raised after a loader extension is created.
  66800. * Set additional options for a loader extension in this event.
  66801. */
  66802. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  66803. private _onExtensionLoadedObserver;
  66804. /**
  66805. * Callback raised after a loader extension is created.
  66806. */
  66807. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  66808. /**
  66809. * Defines if the loader logging is enabled.
  66810. */
  66811. loggingEnabled: boolean;
  66812. /**
  66813. * Defines if the loader should capture performance counters.
  66814. */
  66815. capturePerformanceCounters: boolean;
  66816. /**
  66817. * Defines if the loader should validate the asset.
  66818. */
  66819. validate: boolean;
  66820. /**
  66821. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  66822. */
  66823. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  66824. private _onValidatedObserver;
  66825. /**
  66826. * Callback raised after a loader extension is created.
  66827. */
  66828. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  66829. private _loader;
  66830. /**
  66831. * Name of the loader ("gltf")
  66832. */
  66833. name: string;
  66834. /**
  66835. * Supported file extensions of the loader (.gltf, .glb)
  66836. */
  66837. extensions: ISceneLoaderPluginExtensions;
  66838. /**
  66839. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  66840. */
  66841. dispose(): void;
  66842. /** @hidden */
  66843. _clear(): void;
  66844. /**
  66845. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  66846. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66847. * @param scene the scene the meshes should be added to
  66848. * @param data the glTF data to load
  66849. * @param rootUrl root url to load from
  66850. * @param onProgress event that fires when loading progress has occured
  66851. * @param fileName Defines the name of the file to load
  66852. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66853. */
  66854. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66855. meshes: AbstractMesh[];
  66856. particleSystems: IParticleSystem[];
  66857. skeletons: Skeleton[];
  66858. animationGroups: AnimationGroup[];
  66859. }>;
  66860. /**
  66861. * Imports all objects from the loaded glTF data and adds them to the scene
  66862. * @param scene the scene the objects should be added to
  66863. * @param data the glTF data to load
  66864. * @param rootUrl root url to load from
  66865. * @param onProgress event that fires when loading progress has occured
  66866. * @param fileName Defines the name of the file to load
  66867. * @returns a promise which completes when objects have been loaded to the scene
  66868. */
  66869. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66870. /**
  66871. * Load into an asset container.
  66872. * @param scene The scene to load into
  66873. * @param data The data to import
  66874. * @param rootUrl The root url for scene and resources
  66875. * @param onProgress The callback when the load progresses
  66876. * @param fileName Defines the name of the file to load
  66877. * @returns The loaded asset container
  66878. */
  66879. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  66880. /**
  66881. * If the data string can be loaded directly.
  66882. * @param data string contianing the file data
  66883. * @returns if the data can be loaded directly
  66884. */
  66885. canDirectLoad(data: string): boolean;
  66886. /**
  66887. * Rewrites a url by combining a root url and response url.
  66888. */
  66889. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  66890. /**
  66891. * Instantiates a glTF file loader plugin.
  66892. * @returns the created plugin
  66893. */
  66894. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  66895. /**
  66896. * The loader state or null if the loader is not active.
  66897. */
  66898. readonly loaderState: Nullable<GLTFLoaderState>;
  66899. /**
  66900. * Returns a promise that resolves when the asset is completely loaded.
  66901. * @returns a promise that resolves when the asset is completely loaded.
  66902. */
  66903. whenCompleteAsync(): Promise<void>;
  66904. private _parseAsync;
  66905. private _validateAsync;
  66906. private _getLoader;
  66907. private _unpackBinary;
  66908. private _unpackBinaryV1;
  66909. private _unpackBinaryV2;
  66910. private static _parseVersion;
  66911. private static _compareVersion;
  66912. private static _decodeBufferToText;
  66913. private static readonly _logSpaces;
  66914. private _logIndentLevel;
  66915. private _loggingEnabled;
  66916. /** @hidden */
  66917. _log: (message: string) => void;
  66918. /** @hidden */
  66919. _logOpen(message: string): void;
  66920. /** @hidden */
  66921. _logClose(): void;
  66922. private _logEnabled;
  66923. private _logDisabled;
  66924. private _capturePerformanceCounters;
  66925. /** @hidden */
  66926. _startPerformanceCounter: (counterName: string) => void;
  66927. /** @hidden */
  66928. _endPerformanceCounter: (counterName: string) => void;
  66929. private _startPerformanceCounterEnabled;
  66930. private _startPerformanceCounterDisabled;
  66931. private _endPerformanceCounterEnabled;
  66932. private _endPerformanceCounterDisabled;
  66933. }
  66934. }
  66935. declare module BABYLON.GLTF1 {
  66936. /**
  66937. * Enums
  66938. * @hidden
  66939. */
  66940. export enum EComponentType {
  66941. BYTE = 5120,
  66942. UNSIGNED_BYTE = 5121,
  66943. SHORT = 5122,
  66944. UNSIGNED_SHORT = 5123,
  66945. FLOAT = 5126
  66946. }
  66947. /** @hidden */
  66948. export enum EShaderType {
  66949. FRAGMENT = 35632,
  66950. VERTEX = 35633
  66951. }
  66952. /** @hidden */
  66953. export enum EParameterType {
  66954. BYTE = 5120,
  66955. UNSIGNED_BYTE = 5121,
  66956. SHORT = 5122,
  66957. UNSIGNED_SHORT = 5123,
  66958. INT = 5124,
  66959. UNSIGNED_INT = 5125,
  66960. FLOAT = 5126,
  66961. FLOAT_VEC2 = 35664,
  66962. FLOAT_VEC3 = 35665,
  66963. FLOAT_VEC4 = 35666,
  66964. INT_VEC2 = 35667,
  66965. INT_VEC3 = 35668,
  66966. INT_VEC4 = 35669,
  66967. BOOL = 35670,
  66968. BOOL_VEC2 = 35671,
  66969. BOOL_VEC3 = 35672,
  66970. BOOL_VEC4 = 35673,
  66971. FLOAT_MAT2 = 35674,
  66972. FLOAT_MAT3 = 35675,
  66973. FLOAT_MAT4 = 35676,
  66974. SAMPLER_2D = 35678
  66975. }
  66976. /** @hidden */
  66977. export enum ETextureWrapMode {
  66978. CLAMP_TO_EDGE = 33071,
  66979. MIRRORED_REPEAT = 33648,
  66980. REPEAT = 10497
  66981. }
  66982. /** @hidden */
  66983. export enum ETextureFilterType {
  66984. NEAREST = 9728,
  66985. LINEAR = 9728,
  66986. NEAREST_MIPMAP_NEAREST = 9984,
  66987. LINEAR_MIPMAP_NEAREST = 9985,
  66988. NEAREST_MIPMAP_LINEAR = 9986,
  66989. LINEAR_MIPMAP_LINEAR = 9987
  66990. }
  66991. /** @hidden */
  66992. export enum ETextureFormat {
  66993. ALPHA = 6406,
  66994. RGB = 6407,
  66995. RGBA = 6408,
  66996. LUMINANCE = 6409,
  66997. LUMINANCE_ALPHA = 6410
  66998. }
  66999. /** @hidden */
  67000. export enum ECullingType {
  67001. FRONT = 1028,
  67002. BACK = 1029,
  67003. FRONT_AND_BACK = 1032
  67004. }
  67005. /** @hidden */
  67006. export enum EBlendingFunction {
  67007. ZERO = 0,
  67008. ONE = 1,
  67009. SRC_COLOR = 768,
  67010. ONE_MINUS_SRC_COLOR = 769,
  67011. DST_COLOR = 774,
  67012. ONE_MINUS_DST_COLOR = 775,
  67013. SRC_ALPHA = 770,
  67014. ONE_MINUS_SRC_ALPHA = 771,
  67015. DST_ALPHA = 772,
  67016. ONE_MINUS_DST_ALPHA = 773,
  67017. CONSTANT_COLOR = 32769,
  67018. ONE_MINUS_CONSTANT_COLOR = 32770,
  67019. CONSTANT_ALPHA = 32771,
  67020. ONE_MINUS_CONSTANT_ALPHA = 32772,
  67021. SRC_ALPHA_SATURATE = 776
  67022. }
  67023. /** @hidden */
  67024. export interface IGLTFProperty {
  67025. extensions?: {
  67026. [key: string]: any;
  67027. };
  67028. extras?: Object;
  67029. }
  67030. /** @hidden */
  67031. export interface IGLTFChildRootProperty extends IGLTFProperty {
  67032. name?: string;
  67033. }
  67034. /** @hidden */
  67035. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  67036. bufferView: string;
  67037. byteOffset: number;
  67038. byteStride: number;
  67039. count: number;
  67040. type: string;
  67041. componentType: EComponentType;
  67042. max?: number[];
  67043. min?: number[];
  67044. name?: string;
  67045. }
  67046. /** @hidden */
  67047. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  67048. buffer: string;
  67049. byteOffset: number;
  67050. byteLength: number;
  67051. byteStride: number;
  67052. target?: number;
  67053. }
  67054. /** @hidden */
  67055. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  67056. uri: string;
  67057. byteLength?: number;
  67058. type?: string;
  67059. }
  67060. /** @hidden */
  67061. export interface IGLTFShader extends IGLTFChildRootProperty {
  67062. uri: string;
  67063. type: EShaderType;
  67064. }
  67065. /** @hidden */
  67066. export interface IGLTFProgram extends IGLTFChildRootProperty {
  67067. attributes: string[];
  67068. fragmentShader: string;
  67069. vertexShader: string;
  67070. }
  67071. /** @hidden */
  67072. export interface IGLTFTechniqueParameter {
  67073. type: number;
  67074. count?: number;
  67075. semantic?: string;
  67076. node?: string;
  67077. value?: number | boolean | string | Array<any>;
  67078. source?: string;
  67079. babylonValue?: any;
  67080. }
  67081. /** @hidden */
  67082. export interface IGLTFTechniqueCommonProfile {
  67083. lightingModel: string;
  67084. texcoordBindings: Object;
  67085. parameters?: Array<any>;
  67086. }
  67087. /** @hidden */
  67088. export interface IGLTFTechniqueStatesFunctions {
  67089. blendColor?: number[];
  67090. blendEquationSeparate?: number[];
  67091. blendFuncSeparate?: number[];
  67092. colorMask: boolean[];
  67093. cullFace: number[];
  67094. }
  67095. /** @hidden */
  67096. export interface IGLTFTechniqueStates {
  67097. enable: number[];
  67098. functions: IGLTFTechniqueStatesFunctions;
  67099. }
  67100. /** @hidden */
  67101. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  67102. parameters: {
  67103. [key: string]: IGLTFTechniqueParameter;
  67104. };
  67105. program: string;
  67106. attributes: {
  67107. [key: string]: string;
  67108. };
  67109. uniforms: {
  67110. [key: string]: string;
  67111. };
  67112. states: IGLTFTechniqueStates;
  67113. }
  67114. /** @hidden */
  67115. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  67116. technique?: string;
  67117. values: string[];
  67118. }
  67119. /** @hidden */
  67120. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  67121. attributes: {
  67122. [key: string]: string;
  67123. };
  67124. indices: string;
  67125. material: string;
  67126. mode?: number;
  67127. }
  67128. /** @hidden */
  67129. export interface IGLTFMesh extends IGLTFChildRootProperty {
  67130. primitives: IGLTFMeshPrimitive[];
  67131. }
  67132. /** @hidden */
  67133. export interface IGLTFImage extends IGLTFChildRootProperty {
  67134. uri: string;
  67135. }
  67136. /** @hidden */
  67137. export interface IGLTFSampler extends IGLTFChildRootProperty {
  67138. magFilter?: number;
  67139. minFilter?: number;
  67140. wrapS?: number;
  67141. wrapT?: number;
  67142. }
  67143. /** @hidden */
  67144. export interface IGLTFTexture extends IGLTFChildRootProperty {
  67145. sampler: string;
  67146. source: string;
  67147. format?: ETextureFormat;
  67148. internalFormat?: ETextureFormat;
  67149. target?: number;
  67150. type?: number;
  67151. babylonTexture?: Texture;
  67152. }
  67153. /** @hidden */
  67154. export interface IGLTFAmbienLight {
  67155. color?: number[];
  67156. }
  67157. /** @hidden */
  67158. export interface IGLTFDirectionalLight {
  67159. color?: number[];
  67160. }
  67161. /** @hidden */
  67162. export interface IGLTFPointLight {
  67163. color?: number[];
  67164. constantAttenuation?: number;
  67165. linearAttenuation?: number;
  67166. quadraticAttenuation?: number;
  67167. }
  67168. /** @hidden */
  67169. export interface IGLTFSpotLight {
  67170. color?: number[];
  67171. constantAttenuation?: number;
  67172. fallOfAngle?: number;
  67173. fallOffExponent?: number;
  67174. linearAttenuation?: number;
  67175. quadraticAttenuation?: number;
  67176. }
  67177. /** @hidden */
  67178. export interface IGLTFLight extends IGLTFChildRootProperty {
  67179. type: string;
  67180. }
  67181. /** @hidden */
  67182. export interface IGLTFCameraOrthographic {
  67183. xmag: number;
  67184. ymag: number;
  67185. zfar: number;
  67186. znear: number;
  67187. }
  67188. /** @hidden */
  67189. export interface IGLTFCameraPerspective {
  67190. aspectRatio: number;
  67191. yfov: number;
  67192. zfar: number;
  67193. znear: number;
  67194. }
  67195. /** @hidden */
  67196. export interface IGLTFCamera extends IGLTFChildRootProperty {
  67197. type: string;
  67198. }
  67199. /** @hidden */
  67200. export interface IGLTFAnimationChannelTarget {
  67201. id: string;
  67202. path: string;
  67203. }
  67204. /** @hidden */
  67205. export interface IGLTFAnimationChannel {
  67206. sampler: string;
  67207. target: IGLTFAnimationChannelTarget;
  67208. }
  67209. /** @hidden */
  67210. export interface IGLTFAnimationSampler {
  67211. input: string;
  67212. output: string;
  67213. interpolation?: string;
  67214. }
  67215. /** @hidden */
  67216. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  67217. channels?: IGLTFAnimationChannel[];
  67218. parameters?: {
  67219. [key: string]: string;
  67220. };
  67221. samplers?: {
  67222. [key: string]: IGLTFAnimationSampler;
  67223. };
  67224. }
  67225. /** @hidden */
  67226. export interface IGLTFNodeInstanceSkin {
  67227. skeletons: string[];
  67228. skin: string;
  67229. meshes: string[];
  67230. }
  67231. /** @hidden */
  67232. export interface IGLTFSkins extends IGLTFChildRootProperty {
  67233. bindShapeMatrix: number[];
  67234. inverseBindMatrices: string;
  67235. jointNames: string[];
  67236. babylonSkeleton?: Skeleton;
  67237. }
  67238. /** @hidden */
  67239. export interface IGLTFNode extends IGLTFChildRootProperty {
  67240. camera?: string;
  67241. children: string[];
  67242. skin?: string;
  67243. jointName?: string;
  67244. light?: string;
  67245. matrix: number[];
  67246. mesh?: string;
  67247. meshes?: string[];
  67248. rotation?: number[];
  67249. scale?: number[];
  67250. translation?: number[];
  67251. babylonNode?: Node;
  67252. }
  67253. /** @hidden */
  67254. export interface IGLTFScene extends IGLTFChildRootProperty {
  67255. nodes: string[];
  67256. }
  67257. /** @hidden */
  67258. export interface IGLTFRuntime {
  67259. extensions: {
  67260. [key: string]: any;
  67261. };
  67262. accessors: {
  67263. [key: string]: IGLTFAccessor;
  67264. };
  67265. buffers: {
  67266. [key: string]: IGLTFBuffer;
  67267. };
  67268. bufferViews: {
  67269. [key: string]: IGLTFBufferView;
  67270. };
  67271. meshes: {
  67272. [key: string]: IGLTFMesh;
  67273. };
  67274. lights: {
  67275. [key: string]: IGLTFLight;
  67276. };
  67277. cameras: {
  67278. [key: string]: IGLTFCamera;
  67279. };
  67280. nodes: {
  67281. [key: string]: IGLTFNode;
  67282. };
  67283. images: {
  67284. [key: string]: IGLTFImage;
  67285. };
  67286. textures: {
  67287. [key: string]: IGLTFTexture;
  67288. };
  67289. shaders: {
  67290. [key: string]: IGLTFShader;
  67291. };
  67292. programs: {
  67293. [key: string]: IGLTFProgram;
  67294. };
  67295. samplers: {
  67296. [key: string]: IGLTFSampler;
  67297. };
  67298. techniques: {
  67299. [key: string]: IGLTFTechnique;
  67300. };
  67301. materials: {
  67302. [key: string]: IGLTFMaterial;
  67303. };
  67304. animations: {
  67305. [key: string]: IGLTFAnimation;
  67306. };
  67307. skins: {
  67308. [key: string]: IGLTFSkins;
  67309. };
  67310. currentScene?: Object;
  67311. scenes: {
  67312. [key: string]: IGLTFScene;
  67313. };
  67314. extensionsUsed: string[];
  67315. extensionsRequired?: string[];
  67316. buffersCount: number;
  67317. shaderscount: number;
  67318. scene: Scene;
  67319. rootUrl: string;
  67320. loadedBufferCount: number;
  67321. loadedBufferViews: {
  67322. [name: string]: ArrayBufferView;
  67323. };
  67324. loadedShaderCount: number;
  67325. importOnlyMeshes: boolean;
  67326. importMeshesNames?: string[];
  67327. dummyNodes: Node[];
  67328. }
  67329. /** @hidden */
  67330. export interface INodeToRoot {
  67331. bone: Bone;
  67332. node: IGLTFNode;
  67333. id: string;
  67334. }
  67335. /** @hidden */
  67336. export interface IJointNode {
  67337. node: IGLTFNode;
  67338. id: string;
  67339. }
  67340. }
  67341. declare module BABYLON.GLTF1 {
  67342. /**
  67343. * Utils functions for GLTF
  67344. * @hidden
  67345. */
  67346. export class GLTFUtils {
  67347. /**
  67348. * Sets the given "parameter" matrix
  67349. * @param scene: the Scene object
  67350. * @param source: the source node where to pick the matrix
  67351. * @param parameter: the GLTF technique parameter
  67352. * @param uniformName: the name of the shader's uniform
  67353. * @param shaderMaterial: the shader material
  67354. */
  67355. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  67356. /**
  67357. * Sets the given "parameter" matrix
  67358. * @param shaderMaterial: the shader material
  67359. * @param uniform: the name of the shader's uniform
  67360. * @param value: the value of the uniform
  67361. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  67362. */
  67363. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  67364. /**
  67365. * Returns the wrap mode of the texture
  67366. * @param mode: the mode value
  67367. */
  67368. static GetWrapMode(mode: number): number;
  67369. /**
  67370. * Returns the byte stride giving an accessor
  67371. * @param accessor: the GLTF accessor objet
  67372. */
  67373. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  67374. /**
  67375. * Returns the texture filter mode giving a mode value
  67376. * @param mode: the filter mode value
  67377. */
  67378. static GetTextureFilterMode(mode: number): ETextureFilterType;
  67379. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  67380. /**
  67381. * Returns a buffer from its accessor
  67382. * @param gltfRuntime: the GLTF runtime
  67383. * @param accessor: the GLTF accessor
  67384. */
  67385. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  67386. /**
  67387. * Decodes a buffer view into a string
  67388. * @param view: the buffer view
  67389. */
  67390. static DecodeBufferToText(view: ArrayBufferView): string;
  67391. /**
  67392. * Returns the default material of gltf. Related to
  67393. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  67394. * @param scene: the Babylon.js scene
  67395. */
  67396. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  67397. private static _DefaultMaterial;
  67398. }
  67399. }
  67400. declare module BABYLON.GLTF1 {
  67401. /**
  67402. * Implementation of the base glTF spec
  67403. * @hidden
  67404. */
  67405. export class GLTFLoaderBase {
  67406. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  67407. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67408. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  67409. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67410. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  67411. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67412. }
  67413. /**
  67414. * glTF V1 Loader
  67415. * @hidden
  67416. */
  67417. export class GLTFLoader implements IGLTFLoader {
  67418. static Extensions: {
  67419. [name: string]: GLTFLoaderExtension;
  67420. };
  67421. static RegisterExtension(extension: GLTFLoaderExtension): void;
  67422. state: Nullable<GLTFLoaderState>;
  67423. dispose(): void;
  67424. private _importMeshAsync;
  67425. /**
  67426. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  67427. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67428. * @param scene the scene the meshes should be added to
  67429. * @param data gltf data containing information of the meshes in a loaded file
  67430. * @param rootUrl root url to load from
  67431. * @param onProgress event that fires when loading progress has occured
  67432. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67433. */
  67434. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  67435. meshes: AbstractMesh[];
  67436. particleSystems: IParticleSystem[];
  67437. skeletons: Skeleton[];
  67438. animationGroups: AnimationGroup[];
  67439. }>;
  67440. private _loadAsync;
  67441. /**
  67442. * Imports all objects from a loaded gltf file and adds them to the scene
  67443. * @param scene the scene the objects should be added to
  67444. * @param data gltf data containing information of the meshes in a loaded file
  67445. * @param rootUrl root url to load from
  67446. * @param onProgress event that fires when loading progress has occured
  67447. * @returns a promise which completes when objects have been loaded to the scene
  67448. */
  67449. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  67450. private _loadShadersAsync;
  67451. private _loadBuffersAsync;
  67452. private _createNodes;
  67453. }
  67454. /** @hidden */
  67455. export abstract class GLTFLoaderExtension {
  67456. private _name;
  67457. constructor(name: string);
  67458. readonly name: string;
  67459. /**
  67460. * Defines an override for loading the runtime
  67461. * Return true to stop further extensions from loading the runtime
  67462. */
  67463. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  67464. /**
  67465. * Defines an onverride for creating gltf runtime
  67466. * Return true to stop further extensions from creating the runtime
  67467. */
  67468. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  67469. /**
  67470. * Defines an override for loading buffers
  67471. * Return true to stop further extensions from loading this buffer
  67472. */
  67473. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  67474. /**
  67475. * Defines an override for loading texture buffers
  67476. * Return true to stop further extensions from loading this texture data
  67477. */
  67478. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67479. /**
  67480. * Defines an override for creating textures
  67481. * Return true to stop further extensions from loading this texture
  67482. */
  67483. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  67484. /**
  67485. * Defines an override for loading shader strings
  67486. * Return true to stop further extensions from loading this shader data
  67487. */
  67488. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67489. /**
  67490. * Defines an override for loading materials
  67491. * Return true to stop further extensions from loading this material
  67492. */
  67493. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67494. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  67495. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  67496. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67497. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67498. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  67499. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67500. private static LoadTextureBufferAsync;
  67501. private static CreateTextureAsync;
  67502. private static ApplyExtensions;
  67503. }
  67504. }
  67505. declare module BABYLON.GLTF1 {
  67506. /** @hidden */
  67507. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  67508. private _bin;
  67509. constructor();
  67510. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  67511. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67512. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67513. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67514. }
  67515. }
  67516. declare module BABYLON.GLTF1 {
  67517. /** @hidden */
  67518. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  67519. constructor();
  67520. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  67521. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67522. private _loadTexture;
  67523. }
  67524. }
  67525. declare module BABYLON.GLTF2.Loader {
  67526. /**
  67527. * Loader interface with an index field.
  67528. */
  67529. export interface IArrayItem {
  67530. /**
  67531. * The index of this item in the array.
  67532. */
  67533. index: number;
  67534. }
  67535. /**
  67536. * Loader interface with additional members.
  67537. */
  67538. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  67539. /** @hidden */
  67540. _data?: Promise<ArrayBufferView>;
  67541. /** @hidden */
  67542. _babylonVertexBuffer?: Promise<VertexBuffer>;
  67543. }
  67544. /**
  67545. * Loader interface with additional members.
  67546. */
  67547. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  67548. }
  67549. /** @hidden */
  67550. export interface _IAnimationSamplerData {
  67551. input: Float32Array;
  67552. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  67553. output: Float32Array;
  67554. }
  67555. /**
  67556. * Loader interface with additional members.
  67557. */
  67558. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  67559. /** @hidden */
  67560. _data?: Promise<_IAnimationSamplerData>;
  67561. }
  67562. /**
  67563. * Loader interface with additional members.
  67564. */
  67565. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  67566. channels: IAnimationChannel[];
  67567. samplers: IAnimationSampler[];
  67568. /** @hidden */
  67569. _babylonAnimationGroup?: AnimationGroup;
  67570. }
  67571. /**
  67572. * Loader interface with additional members.
  67573. */
  67574. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  67575. /** @hidden */
  67576. _data?: Promise<ArrayBufferView>;
  67577. }
  67578. /**
  67579. * Loader interface with additional members.
  67580. */
  67581. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  67582. /** @hidden */
  67583. _data?: Promise<ArrayBufferView>;
  67584. /** @hidden */
  67585. _babylonBuffer?: Promise<Buffer>;
  67586. }
  67587. /**
  67588. * Loader interface with additional members.
  67589. */
  67590. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  67591. }
  67592. /**
  67593. * Loader interface with additional members.
  67594. */
  67595. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  67596. /** @hidden */
  67597. _data?: Promise<ArrayBufferView>;
  67598. }
  67599. /**
  67600. * Loader interface with additional members.
  67601. */
  67602. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  67603. }
  67604. /**
  67605. * Loader interface with additional members.
  67606. */
  67607. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  67608. }
  67609. /**
  67610. * Loader interface with additional members.
  67611. */
  67612. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  67613. baseColorTexture?: ITextureInfo;
  67614. metallicRoughnessTexture?: ITextureInfo;
  67615. }
  67616. /**
  67617. * Loader interface with additional members.
  67618. */
  67619. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  67620. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  67621. normalTexture?: IMaterialNormalTextureInfo;
  67622. occlusionTexture?: IMaterialOcclusionTextureInfo;
  67623. emissiveTexture?: ITextureInfo;
  67624. /** @hidden */
  67625. _data?: {
  67626. [babylonDrawMode: number]: {
  67627. babylonMaterial: Material;
  67628. babylonMeshes: AbstractMesh[];
  67629. promise: Promise<void>;
  67630. };
  67631. };
  67632. }
  67633. /**
  67634. * Loader interface with additional members.
  67635. */
  67636. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  67637. primitives: IMeshPrimitive[];
  67638. }
  67639. /**
  67640. * Loader interface with additional members.
  67641. */
  67642. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  67643. /** @hidden */
  67644. _instanceData?: {
  67645. babylonSourceMesh: Mesh;
  67646. promise: Promise<any>;
  67647. };
  67648. }
  67649. /**
  67650. * Loader interface with additional members.
  67651. */
  67652. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  67653. /**
  67654. * The parent glTF node.
  67655. */
  67656. parent?: INode;
  67657. /** @hidden */
  67658. _babylonTransformNode?: TransformNode;
  67659. /** @hidden */
  67660. _primitiveBabylonMeshes?: AbstractMesh[];
  67661. /** @hidden */
  67662. _babylonBones?: Bone[];
  67663. /** @hidden */
  67664. _numMorphTargets?: number;
  67665. }
  67666. /** @hidden */
  67667. export interface _ISamplerData {
  67668. noMipMaps: boolean;
  67669. samplingMode: number;
  67670. wrapU: number;
  67671. wrapV: number;
  67672. }
  67673. /**
  67674. * Loader interface with additional members.
  67675. */
  67676. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  67677. /** @hidden */
  67678. _data?: _ISamplerData;
  67679. }
  67680. /**
  67681. * Loader interface with additional members.
  67682. */
  67683. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  67684. }
  67685. /**
  67686. * Loader interface with additional members.
  67687. */
  67688. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  67689. /** @hidden */
  67690. _data?: {
  67691. babylonSkeleton: Skeleton;
  67692. promise: Promise<void>;
  67693. };
  67694. }
  67695. /**
  67696. * Loader interface with additional members.
  67697. */
  67698. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  67699. }
  67700. /**
  67701. * Loader interface with additional members.
  67702. */
  67703. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  67704. }
  67705. /**
  67706. * Loader interface with additional members.
  67707. */
  67708. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  67709. accessors?: IAccessor[];
  67710. animations?: IAnimation[];
  67711. buffers?: IBuffer[];
  67712. bufferViews?: IBufferView[];
  67713. cameras?: ICamera[];
  67714. images?: IImage[];
  67715. materials?: IMaterial[];
  67716. meshes?: IMesh[];
  67717. nodes?: INode[];
  67718. samplers?: ISampler[];
  67719. scenes?: IScene[];
  67720. skins?: ISkin[];
  67721. textures?: ITexture[];
  67722. }
  67723. }
  67724. declare module BABYLON.GLTF2 {
  67725. /**
  67726. * Interface for a glTF loader extension.
  67727. */
  67728. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  67729. /**
  67730. * Called after the loader state changes to LOADING.
  67731. */
  67732. onLoading?(): void;
  67733. /**
  67734. * Called after the loader state changes to READY.
  67735. */
  67736. onReady?(): void;
  67737. /**
  67738. * Define this method to modify the default behavior when loading scenes.
  67739. * @param context The context when loading the asset
  67740. * @param scene The glTF scene property
  67741. * @returns A promise that resolves when the load is complete or null if not handled
  67742. */
  67743. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  67744. /**
  67745. * Define this method to modify the default behavior when loading nodes.
  67746. * @param context The context when loading the asset
  67747. * @param node The glTF node property
  67748. * @param assign A function called synchronously after parsing the glTF properties
  67749. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  67750. */
  67751. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67752. /**
  67753. * Define this method to modify the default behavior when loading cameras.
  67754. * @param context The context when loading the asset
  67755. * @param camera The glTF camera property
  67756. * @param assign A function called synchronously after parsing the glTF properties
  67757. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  67758. */
  67759. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67760. /**
  67761. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  67762. * @param context The context when loading the asset
  67763. * @param primitive The glTF mesh primitive property
  67764. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  67765. */
  67766. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67767. /**
  67768. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67769. * @param context The context when loading the asset
  67770. * @param name The mesh name when loading the asset
  67771. * @param node The glTF node when loading the asset
  67772. * @param mesh The glTF mesh when loading the asset
  67773. * @param primitive The glTF mesh primitive property
  67774. * @param assign A function called synchronously after parsing the glTF properties
  67775. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67776. */
  67777. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67778. /**
  67779. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  67780. * @param context The context when loading the asset
  67781. * @param material The glTF material property
  67782. * @param assign A function called synchronously after parsing the glTF properties
  67783. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  67784. */
  67785. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67786. /**
  67787. * Define this method to modify the default behavior when creating materials.
  67788. * @param context The context when loading the asset
  67789. * @param material The glTF material property
  67790. * @param babylonDrawMode The draw mode for the Babylon material
  67791. * @returns The Babylon material or null if not handled
  67792. */
  67793. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67794. /**
  67795. * Define this method to modify the default behavior when loading material properties.
  67796. * @param context The context when loading the asset
  67797. * @param material The glTF material property
  67798. * @param babylonMaterial The Babylon material
  67799. * @returns A promise that resolves when the load is complete or null if not handled
  67800. */
  67801. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67802. /**
  67803. * Define this method to modify the default behavior when loading texture infos.
  67804. * @param context The context when loading the asset
  67805. * @param textureInfo The glTF texture info property
  67806. * @param assign A function called synchronously after parsing the glTF properties
  67807. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  67808. */
  67809. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67810. /**
  67811. * Define this method to modify the default behavior when loading animations.
  67812. * @param context The context when loading the asset
  67813. * @param animation The glTF animation property
  67814. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  67815. */
  67816. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67817. /**
  67818. * @hidden Define this method to modify the default behavior when loading skins.
  67819. * @param context The context when loading the asset
  67820. * @param node The glTF node property
  67821. * @param skin The glTF skin property
  67822. * @returns A promise that resolves when the load is complete or null if not handled
  67823. */
  67824. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  67825. /**
  67826. * @hidden Define this method to modify the default behavior when loading uris.
  67827. * @param context The context when loading the asset
  67828. * @param property The glTF property associated with the uri
  67829. * @param uri The uri to load
  67830. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  67831. */
  67832. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67833. }
  67834. }
  67835. declare module BABYLON.GLTF2 {
  67836. /**
  67837. * Helper class for working with arrays when loading the glTF asset
  67838. */
  67839. export class ArrayItem {
  67840. /**
  67841. * Gets an item from the given array.
  67842. * @param context The context when loading the asset
  67843. * @param array The array to get the item from
  67844. * @param index The index to the array
  67845. * @returns The array item
  67846. */
  67847. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  67848. /**
  67849. * Assign an `index` field to each item of the given array.
  67850. * @param array The array of items
  67851. */
  67852. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  67853. }
  67854. /**
  67855. * The glTF 2.0 loader
  67856. */
  67857. export class GLTFLoader implements IGLTFLoader {
  67858. /** @hidden */
  67859. _completePromises: Promise<any>[];
  67860. private _disposed;
  67861. private _parent;
  67862. private _state;
  67863. private _extensions;
  67864. private _rootUrl;
  67865. private _fileName;
  67866. private _uniqueRootUrl;
  67867. private _gltf;
  67868. private _babylonScene;
  67869. private _rootBabylonMesh;
  67870. private _defaultBabylonMaterialData;
  67871. private _progressCallback?;
  67872. private _requests;
  67873. private static readonly _DefaultSampler;
  67874. private static _ExtensionNames;
  67875. private static _ExtensionFactories;
  67876. /**
  67877. * Registers a loader extension.
  67878. * @param name The name of the loader extension.
  67879. * @param factory The factory function that creates the loader extension.
  67880. */
  67881. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  67882. /**
  67883. * Unregisters a loader extension.
  67884. * @param name The name of the loader extenion.
  67885. * @returns A boolean indicating whether the extension has been unregistered
  67886. */
  67887. static UnregisterExtension(name: string): boolean;
  67888. /**
  67889. * Gets the loader state.
  67890. */
  67891. readonly state: Nullable<GLTFLoaderState>;
  67892. /**
  67893. * The glTF object parsed from the JSON.
  67894. */
  67895. readonly gltf: IGLTF;
  67896. /**
  67897. * The Babylon scene when loading the asset.
  67898. */
  67899. readonly babylonScene: Scene;
  67900. /**
  67901. * The root Babylon mesh when loading the asset.
  67902. */
  67903. readonly rootBabylonMesh: Mesh;
  67904. /** @hidden */
  67905. constructor(parent: GLTFFileLoader);
  67906. /** @hidden */
  67907. dispose(): void;
  67908. /** @hidden */
  67909. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67910. meshes: AbstractMesh[];
  67911. particleSystems: IParticleSystem[];
  67912. skeletons: Skeleton[];
  67913. animationGroups: AnimationGroup[];
  67914. }>;
  67915. /** @hidden */
  67916. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67917. private _loadAsync;
  67918. private _loadData;
  67919. private _setupData;
  67920. private _loadExtensions;
  67921. private _checkExtensions;
  67922. private _setState;
  67923. private _createRootNode;
  67924. /**
  67925. * Loads a glTF scene.
  67926. * @param context The context when loading the asset
  67927. * @param scene The glTF scene property
  67928. * @returns A promise that resolves when the load is complete
  67929. */
  67930. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  67931. private _forEachPrimitive;
  67932. private _getMeshes;
  67933. private _getSkeletons;
  67934. private _getAnimationGroups;
  67935. private _startAnimations;
  67936. /**
  67937. * Loads a glTF node.
  67938. * @param context The context when loading the asset
  67939. * @param node The glTF node property
  67940. * @param assign A function called synchronously after parsing the glTF properties
  67941. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  67942. */
  67943. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  67944. private _loadMeshAsync;
  67945. /**
  67946. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67947. * @param context The context when loading the asset
  67948. * @param name The mesh name when loading the asset
  67949. * @param node The glTF node when loading the asset
  67950. * @param mesh The glTF mesh when loading the asset
  67951. * @param primitive The glTF mesh primitive property
  67952. * @param assign A function called synchronously after parsing the glTF properties
  67953. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67954. */
  67955. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67956. private _loadVertexDataAsync;
  67957. private _createMorphTargets;
  67958. private _loadMorphTargetsAsync;
  67959. private _loadMorphTargetVertexDataAsync;
  67960. private static _LoadTransform;
  67961. private _loadSkinAsync;
  67962. private _loadBones;
  67963. private _loadBone;
  67964. private _loadSkinInverseBindMatricesDataAsync;
  67965. private _updateBoneMatrices;
  67966. private _getNodeMatrix;
  67967. /**
  67968. * Loads a glTF camera.
  67969. * @param context The context when loading the asset
  67970. * @param camera The glTF camera property
  67971. * @param assign A function called synchronously after parsing the glTF properties
  67972. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  67973. */
  67974. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  67975. private _loadAnimationsAsync;
  67976. /**
  67977. * Loads a glTF animation.
  67978. * @param context The context when loading the asset
  67979. * @param animation The glTF animation property
  67980. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  67981. */
  67982. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  67983. /**
  67984. * @hidden Loads a glTF animation channel.
  67985. * @param context The context when loading the asset
  67986. * @param animationContext The context of the animation when loading the asset
  67987. * @param animation The glTF animation property
  67988. * @param channel The glTF animation channel property
  67989. * @param babylonAnimationGroup The babylon animation group property
  67990. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  67991. * @returns A void promise when the channel load is complete
  67992. */
  67993. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  67994. private _loadAnimationSamplerAsync;
  67995. private _loadBufferAsync;
  67996. /**
  67997. * Loads a glTF buffer view.
  67998. * @param context The context when loading the asset
  67999. * @param bufferView The glTF buffer view property
  68000. * @returns A promise that resolves with the loaded data when the load is complete
  68001. */
  68002. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  68003. private _loadAccessorAsync;
  68004. private _loadFloatAccessorAsync;
  68005. private _loadIndicesAccessorAsync;
  68006. private _loadVertexBufferViewAsync;
  68007. private _loadVertexAccessorAsync;
  68008. private _loadMaterialMetallicRoughnessPropertiesAsync;
  68009. /** @hidden */
  68010. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  68011. private _createDefaultMaterial;
  68012. /**
  68013. * Creates a Babylon material from a glTF material.
  68014. * @param context The context when loading the asset
  68015. * @param material The glTF material property
  68016. * @param babylonDrawMode The draw mode for the Babylon material
  68017. * @returns The Babylon material
  68018. */
  68019. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  68020. /**
  68021. * Loads properties from a glTF material into a Babylon material.
  68022. * @param context The context when loading the asset
  68023. * @param material The glTF material property
  68024. * @param babylonMaterial The Babylon material
  68025. * @returns A promise that resolves when the load is complete
  68026. */
  68027. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68028. /**
  68029. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  68030. * @param context The context when loading the asset
  68031. * @param material The glTF material property
  68032. * @param babylonMaterial The Babylon material
  68033. * @returns A promise that resolves when the load is complete
  68034. */
  68035. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68036. /**
  68037. * Loads the alpha properties from a glTF material into a Babylon material.
  68038. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  68039. * @param context The context when loading the asset
  68040. * @param material The glTF material property
  68041. * @param babylonMaterial The Babylon material
  68042. */
  68043. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  68044. /**
  68045. * Loads a glTF texture info.
  68046. * @param context The context when loading the asset
  68047. * @param textureInfo The glTF texture info property
  68048. * @param assign A function called synchronously after parsing the glTF properties
  68049. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  68050. */
  68051. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  68052. private _loadTextureAsync;
  68053. private _loadSampler;
  68054. /**
  68055. * Loads a glTF image.
  68056. * @param context The context when loading the asset
  68057. * @param image The glTF image property
  68058. * @returns A promise that resolves with the loaded data when the load is complete
  68059. */
  68060. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  68061. /**
  68062. * Loads a glTF uri.
  68063. * @param context The context when loading the asset
  68064. * @param property The glTF property associated with the uri
  68065. * @param uri The base64 or relative uri
  68066. * @returns A promise that resolves with the loaded data when the load is complete
  68067. */
  68068. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  68069. private _onProgress;
  68070. /**
  68071. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  68072. * @param babylonObject the Babylon object with metadata
  68073. * @param pointer the JSON pointer
  68074. */
  68075. static AddPointerMetadata(babylonObject: {
  68076. metadata: any;
  68077. }, pointer: string): void;
  68078. private static _GetTextureWrapMode;
  68079. private static _GetTextureSamplingMode;
  68080. private static _GetTypedArrayConstructor;
  68081. private static _GetTypedArray;
  68082. private static _GetNumComponents;
  68083. private static _ValidateUri;
  68084. private static _GetDrawMode;
  68085. private _compileMaterialsAsync;
  68086. private _compileShadowGeneratorsAsync;
  68087. private _forEachExtensions;
  68088. private _applyExtensions;
  68089. private _extensionsOnLoading;
  68090. private _extensionsOnReady;
  68091. private _extensionsLoadSceneAsync;
  68092. private _extensionsLoadNodeAsync;
  68093. private _extensionsLoadCameraAsync;
  68094. private _extensionsLoadVertexDataAsync;
  68095. private _extensionsLoadMeshPrimitiveAsync;
  68096. private _extensionsLoadMaterialAsync;
  68097. private _extensionsCreateMaterial;
  68098. private _extensionsLoadMaterialPropertiesAsync;
  68099. private _extensionsLoadTextureInfoAsync;
  68100. private _extensionsLoadAnimationAsync;
  68101. private _extensionsLoadSkinAsync;
  68102. private _extensionsLoadUriAsync;
  68103. /**
  68104. * Helper method called by a loader extension to load an glTF extension.
  68105. * @param context The context when loading the asset
  68106. * @param property The glTF property to load the extension from
  68107. * @param extensionName The name of the extension to load
  68108. * @param actionAsync The action to run
  68109. * @returns The promise returned by actionAsync or null if the extension does not exist
  68110. */
  68111. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68112. /**
  68113. * Helper method called by a loader extension to load a glTF extra.
  68114. * @param context The context when loading the asset
  68115. * @param property The glTF property to load the extra from
  68116. * @param extensionName The name of the extension to load
  68117. * @param actionAsync The action to run
  68118. * @returns The promise returned by actionAsync or null if the extra does not exist
  68119. */
  68120. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68121. /**
  68122. * Increments the indentation level and logs a message.
  68123. * @param message The message to log
  68124. */
  68125. logOpen(message: string): void;
  68126. /**
  68127. * Decrements the indentation level.
  68128. */
  68129. logClose(): void;
  68130. /**
  68131. * Logs a message
  68132. * @param message The message to log
  68133. */
  68134. log(message: string): void;
  68135. /**
  68136. * Starts a performance counter.
  68137. * @param counterName The name of the performance counter
  68138. */
  68139. startPerformanceCounter(counterName: string): void;
  68140. /**
  68141. * Ends a performance counter.
  68142. * @param counterName The name of the performance counter
  68143. */
  68144. endPerformanceCounter(counterName: string): void;
  68145. }
  68146. }
  68147. declare module BABYLON.GLTF2.Loader.Extensions {
  68148. /**
  68149. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  68150. */
  68151. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  68152. /** The name of this extension. */
  68153. readonly name: string;
  68154. /** Defines whether this extension is enabled. */
  68155. enabled: boolean;
  68156. private _loader;
  68157. private _lights?;
  68158. /** @hidden */
  68159. constructor(loader: GLTFLoader);
  68160. /** @hidden */
  68161. dispose(): void;
  68162. /** @hidden */
  68163. onLoading(): void;
  68164. /** @hidden */
  68165. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68166. private _loadLightAsync;
  68167. }
  68168. }
  68169. declare module BABYLON.GLTF2.Loader.Extensions {
  68170. /**
  68171. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  68172. */
  68173. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  68174. /** The name of this extension. */
  68175. readonly name: string;
  68176. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  68177. dracoCompression?: DracoCompression;
  68178. /** Defines whether this extension is enabled. */
  68179. enabled: boolean;
  68180. private _loader;
  68181. /** @hidden */
  68182. constructor(loader: GLTFLoader);
  68183. /** @hidden */
  68184. dispose(): void;
  68185. /** @hidden */
  68186. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68187. }
  68188. }
  68189. declare module BABYLON.GLTF2.Loader.Extensions {
  68190. /**
  68191. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  68192. */
  68193. export class KHR_lights implements IGLTFLoaderExtension {
  68194. /** The name of this extension. */
  68195. readonly name: string;
  68196. /** Defines whether this extension is enabled. */
  68197. enabled: boolean;
  68198. private _loader;
  68199. private _lights?;
  68200. /** @hidden */
  68201. constructor(loader: GLTFLoader);
  68202. /** @hidden */
  68203. dispose(): void;
  68204. /** @hidden */
  68205. onLoading(): void;
  68206. /** @hidden */
  68207. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68208. }
  68209. }
  68210. declare module BABYLON.GLTF2.Loader.Extensions {
  68211. /**
  68212. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  68213. */
  68214. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  68215. /** The name of this extension. */
  68216. readonly name: string;
  68217. /** Defines whether this extension is enabled. */
  68218. enabled: boolean;
  68219. private _loader;
  68220. /** @hidden */
  68221. constructor(loader: GLTFLoader);
  68222. /** @hidden */
  68223. dispose(): void;
  68224. /** @hidden */
  68225. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68226. private _loadSpecularGlossinessPropertiesAsync;
  68227. }
  68228. }
  68229. declare module BABYLON.GLTF2.Loader.Extensions {
  68230. /**
  68231. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  68232. */
  68233. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  68234. /** The name of this extension. */
  68235. readonly name: string;
  68236. /** Defines whether this extension is enabled. */
  68237. enabled: boolean;
  68238. private _loader;
  68239. /** @hidden */
  68240. constructor(loader: GLTFLoader);
  68241. /** @hidden */
  68242. dispose(): void;
  68243. /** @hidden */
  68244. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68245. private _loadUnlitPropertiesAsync;
  68246. }
  68247. }
  68248. declare module BABYLON.GLTF2.Loader.Extensions {
  68249. /**
  68250. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  68251. */
  68252. export class KHR_texture_transform implements IGLTFLoaderExtension {
  68253. /** The name of this extension. */
  68254. readonly name: string;
  68255. /** Defines whether this extension is enabled. */
  68256. enabled: boolean;
  68257. private _loader;
  68258. /** @hidden */
  68259. constructor(loader: GLTFLoader);
  68260. /** @hidden */
  68261. dispose(): void;
  68262. /** @hidden */
  68263. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68264. }
  68265. }
  68266. declare module BABYLON.GLTF2.Loader.Extensions {
  68267. /**
  68268. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  68269. */
  68270. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  68271. /** The name of this extension. */
  68272. readonly name: string;
  68273. /** Defines whether this extension is enabled. */
  68274. enabled: boolean;
  68275. private _loader;
  68276. private _clips;
  68277. private _emitters;
  68278. /** @hidden */
  68279. constructor(loader: GLTFLoader);
  68280. /** @hidden */
  68281. dispose(): void;
  68282. /** @hidden */
  68283. onLoading(): void;
  68284. /** @hidden */
  68285. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68286. /** @hidden */
  68287. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68288. /** @hidden */
  68289. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68290. private _loadClipAsync;
  68291. private _loadEmitterAsync;
  68292. private _getEventAction;
  68293. private _loadAnimationEventAsync;
  68294. }
  68295. }
  68296. declare module BABYLON.GLTF2.Loader.Extensions {
  68297. /**
  68298. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  68299. */
  68300. export class MSFT_lod implements IGLTFLoaderExtension {
  68301. /** The name of this extension. */
  68302. readonly name: string;
  68303. /** Defines whether this extension is enabled. */
  68304. enabled: boolean;
  68305. /**
  68306. * Maximum number of LODs to load, starting from the lowest LOD.
  68307. */
  68308. maxLODsToLoad: number;
  68309. /**
  68310. * Observable raised when all node LODs of one level are loaded.
  68311. * The event data is the index of the loaded LOD starting from zero.
  68312. * Dispose the loader to cancel the loading of the next level of LODs.
  68313. */
  68314. onNodeLODsLoadedObservable: Observable<number>;
  68315. /**
  68316. * Observable raised when all material LODs of one level are loaded.
  68317. * The event data is the index of the loaded LOD starting from zero.
  68318. * Dispose the loader to cancel the loading of the next level of LODs.
  68319. */
  68320. onMaterialLODsLoadedObservable: Observable<number>;
  68321. private _loader;
  68322. private _nodeIndexLOD;
  68323. private _nodeSignalLODs;
  68324. private _nodePromiseLODs;
  68325. private _materialIndexLOD;
  68326. private _materialSignalLODs;
  68327. private _materialPromiseLODs;
  68328. /** @hidden */
  68329. constructor(loader: GLTFLoader);
  68330. /** @hidden */
  68331. dispose(): void;
  68332. /** @hidden */
  68333. onReady(): void;
  68334. /** @hidden */
  68335. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68336. /** @hidden */
  68337. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68338. /** @hidden */
  68339. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68340. /**
  68341. * Gets an array of LOD properties from lowest to highest.
  68342. */
  68343. private _getLODs;
  68344. private _disposeUnusedMaterials;
  68345. }
  68346. }
  68347. declare module BABYLON.GLTF2.Loader.Extensions {
  68348. /** @hidden */
  68349. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  68350. readonly name: string;
  68351. enabled: boolean;
  68352. private _loader;
  68353. constructor(loader: GLTFLoader);
  68354. dispose(): void;
  68355. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68356. }
  68357. }
  68358. declare module BABYLON.GLTF2.Loader.Extensions {
  68359. /** @hidden */
  68360. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  68361. readonly name: string;
  68362. enabled: boolean;
  68363. private _loader;
  68364. constructor(loader: GLTFLoader);
  68365. dispose(): void;
  68366. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68367. }
  68368. }
  68369. declare module BABYLON.GLTF2.Loader.Extensions {
  68370. /**
  68371. * Store glTF extras (if present) in BJS objects' metadata
  68372. */
  68373. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  68374. /** The name of this extension. */
  68375. readonly name: string;
  68376. /** Defines whether this extension is enabled. */
  68377. enabled: boolean;
  68378. private _loader;
  68379. private _assignExtras;
  68380. /** @hidden */
  68381. constructor(loader: GLTFLoader);
  68382. /** @hidden */
  68383. dispose(): void;
  68384. /** @hidden */
  68385. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68386. /** @hidden */
  68387. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68388. /** @hidden */
  68389. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68390. }
  68391. }
  68392. declare module BABYLON {
  68393. /**
  68394. * Class reading and parsing the MTL file bundled with the obj file.
  68395. */
  68396. export class MTLFileLoader {
  68397. /**
  68398. * All material loaded from the mtl will be set here
  68399. */
  68400. materials: StandardMaterial[];
  68401. /**
  68402. * This function will read the mtl file and create each material described inside
  68403. * This function could be improve by adding :
  68404. * -some component missing (Ni, Tf...)
  68405. * -including the specific options available
  68406. *
  68407. * @param scene defines the scene the material will be created in
  68408. * @param data defines the mtl data to parse
  68409. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  68410. */
  68411. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  68412. /**
  68413. * Gets the texture for the material.
  68414. *
  68415. * If the material is imported from input file,
  68416. * We sanitize the url to ensure it takes the textre from aside the material.
  68417. *
  68418. * @param rootUrl The root url to load from
  68419. * @param value The value stored in the mtl
  68420. * @return The Texture
  68421. */
  68422. private static _getTexture;
  68423. }
  68424. /**
  68425. * Options for loading OBJ/MTL files
  68426. */
  68427. type MeshLoadOptions = {
  68428. /**
  68429. * Defines if UVs are optimized by default during load.
  68430. */
  68431. OptimizeWithUV: boolean;
  68432. /**
  68433. * Defines custom scaling of UV coordinates of loaded meshes.
  68434. */
  68435. UVScaling: Vector2;
  68436. /**
  68437. * Invert model on y-axis (does a model scaling inversion)
  68438. */
  68439. InvertY: boolean;
  68440. /**
  68441. * Invert Y-Axis of referenced textures on load
  68442. */
  68443. InvertTextureY: boolean;
  68444. /**
  68445. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68446. */
  68447. ImportVertexColors: boolean;
  68448. /**
  68449. * Compute the normals for the model, even if normals are present in the file.
  68450. */
  68451. ComputeNormals: boolean;
  68452. /**
  68453. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68454. */
  68455. SkipMaterials: boolean;
  68456. /**
  68457. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68458. */
  68459. MaterialLoadingFailsSilently: boolean;
  68460. };
  68461. /**
  68462. * OBJ file type loader.
  68463. * This is a babylon scene loader plugin.
  68464. */
  68465. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68466. /**
  68467. * Defines if UVs are optimized by default during load.
  68468. */
  68469. static OPTIMIZE_WITH_UV: boolean;
  68470. /**
  68471. * Invert model on y-axis (does a model scaling inversion)
  68472. */
  68473. static INVERT_Y: boolean;
  68474. /**
  68475. * Invert Y-Axis of referenced textures on load
  68476. */
  68477. static INVERT_TEXTURE_Y: boolean;
  68478. /**
  68479. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68480. */
  68481. static IMPORT_VERTEX_COLORS: boolean;
  68482. /**
  68483. * Compute the normals for the model, even if normals are present in the file.
  68484. */
  68485. static COMPUTE_NORMALS: boolean;
  68486. /**
  68487. * Defines custom scaling of UV coordinates of loaded meshes.
  68488. */
  68489. static UV_SCALING: Vector2;
  68490. /**
  68491. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68492. */
  68493. static SKIP_MATERIALS: boolean;
  68494. /**
  68495. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68496. *
  68497. * Defaults to true for backwards compatibility.
  68498. */
  68499. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  68500. /**
  68501. * Defines the name of the plugin.
  68502. */
  68503. name: string;
  68504. /**
  68505. * Defines the extension the plugin is able to load.
  68506. */
  68507. extensions: string;
  68508. /** @hidden */
  68509. obj: RegExp;
  68510. /** @hidden */
  68511. group: RegExp;
  68512. /** @hidden */
  68513. mtllib: RegExp;
  68514. /** @hidden */
  68515. usemtl: RegExp;
  68516. /** @hidden */
  68517. smooth: RegExp;
  68518. /** @hidden */
  68519. vertexPattern: RegExp;
  68520. /** @hidden */
  68521. normalPattern: RegExp;
  68522. /** @hidden */
  68523. uvPattern: RegExp;
  68524. /** @hidden */
  68525. facePattern1: RegExp;
  68526. /** @hidden */
  68527. facePattern2: RegExp;
  68528. /** @hidden */
  68529. facePattern3: RegExp;
  68530. /** @hidden */
  68531. facePattern4: RegExp;
  68532. /** @hidden */
  68533. facePattern5: RegExp;
  68534. private _meshLoadOptions;
  68535. /**
  68536. * Creates loader for .OBJ files
  68537. *
  68538. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  68539. */
  68540. constructor(meshLoadOptions?: MeshLoadOptions);
  68541. private static readonly currentMeshLoadOptions;
  68542. /**
  68543. * Calls synchronously the MTL file attached to this obj.
  68544. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  68545. * Without this function materials are not displayed in the first frame (but displayed after).
  68546. * In consequence it is impossible to get material information in your HTML file
  68547. *
  68548. * @param url The URL of the MTL file
  68549. * @param rootUrl
  68550. * @param onSuccess Callback function to be called when the MTL file is loaded
  68551. * @private
  68552. */
  68553. private _loadMTL;
  68554. /**
  68555. * Instantiates a OBJ file loader plugin.
  68556. * @returns the created plugin
  68557. */
  68558. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  68559. /**
  68560. * If the data string can be loaded directly.
  68561. *
  68562. * @param data string containing the file data
  68563. * @returns if the data can be loaded directly
  68564. */
  68565. canDirectLoad(data: string): boolean;
  68566. /**
  68567. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  68568. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68569. * @param scene the scene the meshes should be added to
  68570. * @param data the OBJ data to load
  68571. * @param rootUrl root url to load from
  68572. * @param onProgress event that fires when loading progress has occured
  68573. * @param fileName Defines the name of the file to load
  68574. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68575. */
  68576. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68577. meshes: AbstractMesh[];
  68578. particleSystems: IParticleSystem[];
  68579. skeletons: Skeleton[];
  68580. animationGroups: AnimationGroup[];
  68581. }>;
  68582. /**
  68583. * Imports all objects from the loaded OBJ data and adds them to the scene
  68584. * @param scene the scene the objects should be added to
  68585. * @param data the OBJ data to load
  68586. * @param rootUrl root url to load from
  68587. * @param onProgress event that fires when loading progress has occured
  68588. * @param fileName Defines the name of the file to load
  68589. * @returns a promise which completes when objects have been loaded to the scene
  68590. */
  68591. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68592. /**
  68593. * Load into an asset container.
  68594. * @param scene The scene to load into
  68595. * @param data The data to import
  68596. * @param rootUrl The root url for scene and resources
  68597. * @param onProgress The callback when the load progresses
  68598. * @param fileName Defines the name of the file to load
  68599. * @returns The loaded asset container
  68600. */
  68601. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  68602. /**
  68603. * Read the OBJ file and create an Array of meshes.
  68604. * Each mesh contains all information given by the OBJ and the MTL file.
  68605. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  68606. *
  68607. * @param meshesNames
  68608. * @param scene Scene The scene where are displayed the data
  68609. * @param data String The content of the obj file
  68610. * @param rootUrl String The path to the folder
  68611. * @returns Array<AbstractMesh>
  68612. * @private
  68613. */
  68614. private _parseSolid;
  68615. }
  68616. }
  68617. declare module BABYLON {
  68618. /**
  68619. * STL file type loader.
  68620. * This is a babylon scene loader plugin.
  68621. */
  68622. export class STLFileLoader implements ISceneLoaderPlugin {
  68623. /** @hidden */
  68624. solidPattern: RegExp;
  68625. /** @hidden */
  68626. facetsPattern: RegExp;
  68627. /** @hidden */
  68628. normalPattern: RegExp;
  68629. /** @hidden */
  68630. vertexPattern: RegExp;
  68631. /**
  68632. * Defines the name of the plugin.
  68633. */
  68634. name: string;
  68635. /**
  68636. * Defines the extensions the stl loader is able to load.
  68637. * force data to come in as an ArrayBuffer
  68638. * we'll convert to string if it looks like it's an ASCII .stl
  68639. */
  68640. extensions: ISceneLoaderPluginExtensions;
  68641. /**
  68642. * Import meshes into a scene.
  68643. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  68644. * @param scene The scene to import into
  68645. * @param data The data to import
  68646. * @param rootUrl The root url for scene and resources
  68647. * @param meshes The meshes array to import into
  68648. * @param particleSystems The particle systems array to import into
  68649. * @param skeletons The skeletons array to import into
  68650. * @param onError The callback when import fails
  68651. * @returns True if successful or false otherwise
  68652. */
  68653. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  68654. /**
  68655. * Load into a scene.
  68656. * @param scene The scene to load into
  68657. * @param data The data to import
  68658. * @param rootUrl The root url for scene and resources
  68659. * @param onError The callback when import fails
  68660. * @returns true if successful or false otherwise
  68661. */
  68662. load(scene: Scene, data: any, rootUrl: string): boolean;
  68663. /**
  68664. * Load into an asset container.
  68665. * @param scene The scene to load into
  68666. * @param data The data to import
  68667. * @param rootUrl The root url for scene and resources
  68668. * @param onError The callback when import fails
  68669. * @returns The loaded asset container
  68670. */
  68671. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  68672. private _isBinary;
  68673. private _parseBinary;
  68674. private _parseASCII;
  68675. }
  68676. }
  68677. declare module BABYLON {
  68678. /**
  68679. * Class for generating OBJ data from a Babylon scene.
  68680. */
  68681. export class OBJExport {
  68682. /**
  68683. * Exports the geometry of a Mesh array in .OBJ file format (text)
  68684. * @param mesh defines the list of meshes to serialize
  68685. * @param materials defines if materials should be exported
  68686. * @param matlibname defines the name of the associated mtl file
  68687. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  68688. * @returns the OBJ content
  68689. */
  68690. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  68691. /**
  68692. * Exports the material(s) of a mesh in .MTL file format (text)
  68693. * @param mesh defines the mesh to extract the material from
  68694. * @returns the mtl content
  68695. */
  68696. static MTL(mesh: Mesh): string;
  68697. }
  68698. }
  68699. declare module BABYLON {
  68700. /** @hidden */
  68701. export var __IGLTFExporterExtension: number;
  68702. /**
  68703. * Interface for extending the exporter
  68704. * @hidden
  68705. */
  68706. export interface IGLTFExporterExtension {
  68707. /**
  68708. * The name of this extension
  68709. */
  68710. readonly name: string;
  68711. /**
  68712. * Defines whether this extension is enabled
  68713. */
  68714. enabled: boolean;
  68715. /**
  68716. * Defines whether this extension is required
  68717. */
  68718. required: boolean;
  68719. }
  68720. }
  68721. declare module BABYLON.GLTF2.Exporter {
  68722. /** @hidden */
  68723. export var __IGLTFExporterExtensionV2: number;
  68724. /**
  68725. * Interface for a glTF exporter extension
  68726. * @hidden
  68727. */
  68728. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  68729. /**
  68730. * Define this method to modify the default behavior before exporting a texture
  68731. * @param context The context when loading the asset
  68732. * @param babylonTexture The glTF texture info property
  68733. * @param mimeType The mime-type of the generated image
  68734. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  68735. */
  68736. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  68737. /**
  68738. * Define this method to modify the default behavior when exporting texture info
  68739. * @param context The context when loading the asset
  68740. * @param meshPrimitive glTF mesh primitive
  68741. * @param babylonSubMesh Babylon submesh
  68742. * @param binaryWriter glTF serializer binary writer instance
  68743. * @returns nullable IMeshPrimitive promise
  68744. */
  68745. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  68746. /**
  68747. * Define this method to modify the default behavior when exporting a node
  68748. * @param context The context when exporting the node
  68749. * @param node glTF node
  68750. * @param babylonNode BabylonJS node
  68751. * @returns nullable INode promise
  68752. */
  68753. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68754. /**
  68755. * Called after the exporter state changes to EXPORTING
  68756. */
  68757. onExporting?(): void;
  68758. }
  68759. }
  68760. declare module BABYLON.GLTF2.Exporter {
  68761. /**
  68762. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  68763. * @hidden
  68764. */
  68765. export class _GLTFMaterialExporter {
  68766. /**
  68767. * Represents the dielectric specular values for R, G and B
  68768. */
  68769. private static readonly _DielectricSpecular;
  68770. /**
  68771. * Allows the maximum specular power to be defined for material calculations
  68772. */
  68773. private static readonly _MaxSpecularPower;
  68774. /**
  68775. * Mapping to store textures
  68776. */
  68777. private _textureMap;
  68778. /**
  68779. * Numeric tolerance value
  68780. */
  68781. private static readonly _Epsilon;
  68782. /**
  68783. * Reference to the glTF Exporter
  68784. */
  68785. private _exporter;
  68786. constructor(exporter: _Exporter);
  68787. /**
  68788. * Specifies if two colors are approximately equal in value
  68789. * @param color1 first color to compare to
  68790. * @param color2 second color to compare to
  68791. * @param epsilon threshold value
  68792. */
  68793. private static FuzzyEquals;
  68794. /**
  68795. * Gets the materials from a Babylon scene and converts them to glTF materials
  68796. * @param scene babylonjs scene
  68797. * @param mimeType texture mime type
  68798. * @param images array of images
  68799. * @param textures array of textures
  68800. * @param materials array of materials
  68801. * @param imageData mapping of texture names to base64 textures
  68802. * @param hasTextureCoords specifies if texture coordinates are present on the material
  68803. */
  68804. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68805. /**
  68806. * Makes a copy of the glTF material without the texture parameters
  68807. * @param originalMaterial original glTF material
  68808. * @returns glTF material without texture parameters
  68809. */
  68810. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  68811. /**
  68812. * Specifies if the material has any texture parameters present
  68813. * @param material glTF Material
  68814. * @returns boolean specifying if texture parameters are present
  68815. */
  68816. _hasTexturesPresent(material: IMaterial): boolean;
  68817. /**
  68818. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  68819. * @param babylonStandardMaterial
  68820. * @returns glTF Metallic Roughness Material representation
  68821. */
  68822. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  68823. /**
  68824. * Computes the metallic factor
  68825. * @param diffuse diffused value
  68826. * @param specular specular value
  68827. * @param oneMinusSpecularStrength one minus the specular strength
  68828. * @returns metallic value
  68829. */
  68830. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  68831. /**
  68832. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  68833. * @param glTFMaterial glTF material
  68834. * @param babylonMaterial Babylon material
  68835. */
  68836. private static _SetAlphaMode;
  68837. /**
  68838. * Converts a Babylon Standard Material to a glTF Material
  68839. * @param babylonStandardMaterial BJS Standard Material
  68840. * @param mimeType mime type to use for the textures
  68841. * @param images array of glTF image interfaces
  68842. * @param textures array of glTF texture interfaces
  68843. * @param materials array of glTF material interfaces
  68844. * @param imageData map of image file name to data
  68845. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68846. */
  68847. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68848. /**
  68849. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68850. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  68851. * @param mimeType mime type to use for the textures
  68852. * @param images array of glTF image interfaces
  68853. * @param textures array of glTF texture interfaces
  68854. * @param materials array of glTF material interfaces
  68855. * @param imageData map of image file name to data
  68856. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68857. */
  68858. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68859. /**
  68860. * Converts an image typed array buffer to a base64 image
  68861. * @param buffer typed array buffer
  68862. * @param width width of the image
  68863. * @param height height of the image
  68864. * @param mimeType mimetype of the image
  68865. * @returns base64 image string
  68866. */
  68867. private _createBase64FromCanvasAsync;
  68868. /**
  68869. * Generates a white texture based on the specified width and height
  68870. * @param width width of the texture in pixels
  68871. * @param height height of the texture in pixels
  68872. * @param scene babylonjs scene
  68873. * @returns white texture
  68874. */
  68875. private _createWhiteTexture;
  68876. /**
  68877. * 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
  68878. * @param texture1 first texture to resize
  68879. * @param texture2 second texture to resize
  68880. * @param scene babylonjs scene
  68881. * @returns resized textures or null
  68882. */
  68883. private _resizeTexturesToSameDimensions;
  68884. /**
  68885. * Converts an array of pixels to a Float32Array
  68886. * Throws an error if the pixel format is not supported
  68887. * @param pixels - array buffer containing pixel values
  68888. * @returns Float32 of pixels
  68889. */
  68890. private _convertPixelArrayToFloat32;
  68891. /**
  68892. * Convert Specular Glossiness Textures to Metallic Roughness
  68893. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  68894. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  68895. * @param diffuseTexture texture used to store diffuse information
  68896. * @param specularGlossinessTexture texture used to store specular and glossiness information
  68897. * @param factors specular glossiness material factors
  68898. * @param mimeType the mime type to use for the texture
  68899. * @returns pbr metallic roughness interface or null
  68900. */
  68901. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  68902. /**
  68903. * Converts specular glossiness material properties to metallic roughness
  68904. * @param specularGlossiness interface with specular glossiness material properties
  68905. * @returns interface with metallic roughness material properties
  68906. */
  68907. private _convertSpecularGlossinessToMetallicRoughness;
  68908. /**
  68909. * Calculates the surface reflectance, independent of lighting conditions
  68910. * @param color Color source to calculate brightness from
  68911. * @returns number representing the perceived brightness, or zero if color is undefined
  68912. */
  68913. private _getPerceivedBrightness;
  68914. /**
  68915. * Returns the maximum color component value
  68916. * @param color
  68917. * @returns maximum color component value, or zero if color is null or undefined
  68918. */
  68919. private _getMaxComponent;
  68920. /**
  68921. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  68922. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68923. * @param mimeType mime type to use for the textures
  68924. * @param images array of glTF image interfaces
  68925. * @param textures array of glTF texture interfaces
  68926. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68927. * @param imageData map of image file name to data
  68928. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68929. * @returns glTF PBR Metallic Roughness factors
  68930. */
  68931. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  68932. private _getGLTFTextureSampler;
  68933. private _getGLTFTextureWrapMode;
  68934. private _getGLTFTextureWrapModesSampler;
  68935. /**
  68936. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  68937. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68938. * @param mimeType mime type to use for the textures
  68939. * @param images array of glTF image interfaces
  68940. * @param textures array of glTF texture interfaces
  68941. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68942. * @param imageData map of image file name to data
  68943. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68944. * @returns glTF PBR Metallic Roughness factors
  68945. */
  68946. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  68947. /**
  68948. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68949. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68950. * @param mimeType mime type to use for the textures
  68951. * @param images array of glTF image interfaces
  68952. * @param textures array of glTF texture interfaces
  68953. * @param materials array of glTF material interfaces
  68954. * @param imageData map of image file name to data
  68955. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68956. */
  68957. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68958. private setMetallicRoughnessPbrMaterial;
  68959. private getPixelsFromTexture;
  68960. /**
  68961. * Extracts a texture from a Babylon texture into file data and glTF data
  68962. * @param babylonTexture Babylon texture to extract
  68963. * @param mimeType Mime Type of the babylonTexture
  68964. * @return glTF texture info, or null if the texture format is not supported
  68965. */
  68966. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68967. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68968. /**
  68969. * Builds a texture from base64 string
  68970. * @param base64Texture base64 texture string
  68971. * @param baseTextureName Name to use for the texture
  68972. * @param mimeType image mime type for the texture
  68973. * @param images array of images
  68974. * @param textures array of textures
  68975. * @param imageData map of image data
  68976. * @returns glTF texture info, or null if the texture format is not supported
  68977. */
  68978. private _getTextureInfoFromBase64;
  68979. }
  68980. }
  68981. declare module BABYLON {
  68982. /**
  68983. * Class for holding and downloading glTF file data
  68984. */
  68985. export class GLTFData {
  68986. /**
  68987. * Object which contains the file name as the key and its data as the value
  68988. */
  68989. glTFFiles: {
  68990. [fileName: string]: string | Blob;
  68991. };
  68992. /**
  68993. * Initializes the glTF file object
  68994. */
  68995. constructor();
  68996. /**
  68997. * Downloads the glTF data as files based on their names and data
  68998. */
  68999. downloadFiles(): void;
  69000. }
  69001. }
  69002. declare module BABYLON {
  69003. /**
  69004. * Holds a collection of exporter options and parameters
  69005. */
  69006. export interface IExportOptions {
  69007. /**
  69008. * Function which indicates whether a babylon node should be exported or not
  69009. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  69010. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  69011. */
  69012. shouldExportNode?(node: Node): boolean;
  69013. /**
  69014. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  69015. * @param metadata source metadata to read from
  69016. * @returns the data to store to glTF node extras
  69017. */
  69018. metadataSelector?(metadata: any): any;
  69019. /**
  69020. * The sample rate to bake animation curves
  69021. */
  69022. animationSampleRate?: number;
  69023. /**
  69024. * Begin serialization without waiting for the scene to be ready
  69025. */
  69026. exportWithoutWaitingForScene?: boolean;
  69027. }
  69028. /**
  69029. * Class for generating glTF data from a Babylon scene.
  69030. */
  69031. export class GLTF2Export {
  69032. /**
  69033. * Exports the geometry of the scene to .gltf file format asynchronously
  69034. * @param scene Babylon scene with scene hierarchy information
  69035. * @param filePrefix File prefix to use when generating the glTF file
  69036. * @param options Exporter options
  69037. * @returns Returns an object with a .gltf file and associates texture names
  69038. * as keys and their data and paths as values
  69039. */
  69040. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69041. private static _PreExportAsync;
  69042. private static _PostExportAsync;
  69043. /**
  69044. * Exports the geometry of the scene to .glb file format asychronously
  69045. * @param scene Babylon scene with scene hierarchy information
  69046. * @param filePrefix File prefix to use when generating glb file
  69047. * @param options Exporter options
  69048. * @returns Returns an object with a .glb filename as key and data as value
  69049. */
  69050. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69051. }
  69052. }
  69053. declare module BABYLON.GLTF2.Exporter {
  69054. /**
  69055. * @hidden
  69056. */
  69057. export class _GLTFUtilities {
  69058. /**
  69059. * Creates a buffer view based on the supplied arguments
  69060. * @param bufferIndex index value of the specified buffer
  69061. * @param byteOffset byte offset value
  69062. * @param byteLength byte length of the bufferView
  69063. * @param byteStride byte distance between conequential elements
  69064. * @param name name of the buffer view
  69065. * @returns bufferView for glTF
  69066. */
  69067. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  69068. /**
  69069. * Creates an accessor based on the supplied arguments
  69070. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  69071. * @param name The name of the accessor
  69072. * @param type The type of the accessor
  69073. * @param componentType The datatype of components in the attribute
  69074. * @param count The number of attributes referenced by this accessor
  69075. * @param byteOffset The offset relative to the start of the bufferView in bytes
  69076. * @param min Minimum value of each component in this attribute
  69077. * @param max Maximum value of each component in this attribute
  69078. * @returns accessor for glTF
  69079. */
  69080. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  69081. /**
  69082. * Calculates the minimum and maximum values of an array of position floats
  69083. * @param positions Positions array of a mesh
  69084. * @param vertexStart Starting vertex offset to calculate min and max values
  69085. * @param vertexCount Number of vertices to check for min and max values
  69086. * @returns min number array and max number array
  69087. */
  69088. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  69089. min: number[];
  69090. max: number[];
  69091. };
  69092. /**
  69093. * Converts a new right-handed Vector3
  69094. * @param vector vector3 array
  69095. * @returns right-handed Vector3
  69096. */
  69097. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  69098. /**
  69099. * Converts a Vector3 to right-handed
  69100. * @param vector Vector3 to convert to right-handed
  69101. */
  69102. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  69103. /**
  69104. * Converts a three element number array to right-handed
  69105. * @param vector number array to convert to right-handed
  69106. */
  69107. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  69108. /**
  69109. * Converts a new right-handed Vector3
  69110. * @param vector vector3 array
  69111. * @returns right-handed Vector3
  69112. */
  69113. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  69114. /**
  69115. * Converts a Vector3 to right-handed
  69116. * @param vector Vector3 to convert to right-handed
  69117. */
  69118. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  69119. /**
  69120. * Converts a three element number array to right-handed
  69121. * @param vector number array to convert to right-handed
  69122. */
  69123. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  69124. /**
  69125. * Converts a Vector4 to right-handed
  69126. * @param vector Vector4 to convert to right-handed
  69127. */
  69128. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  69129. /**
  69130. * Converts a Vector4 to right-handed
  69131. * @param vector Vector4 to convert to right-handed
  69132. */
  69133. static _GetRightHandedArray4FromRef(vector: number[]): void;
  69134. /**
  69135. * Converts a Quaternion to right-handed
  69136. * @param quaternion Source quaternion to convert to right-handed
  69137. */
  69138. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  69139. /**
  69140. * Converts a Quaternion to right-handed
  69141. * @param quaternion Source quaternion to convert to right-handed
  69142. */
  69143. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  69144. static _NormalizeTangentFromRef(tangent: Vector4): void;
  69145. }
  69146. }
  69147. declare module BABYLON.GLTF2.Exporter {
  69148. /**
  69149. * Converts Babylon Scene into glTF 2.0.
  69150. * @hidden
  69151. */
  69152. export class _Exporter {
  69153. /**
  69154. * Stores the glTF to export
  69155. */
  69156. _glTF: IGLTF;
  69157. /**
  69158. * Stores all generated buffer views, which represents views into the main glTF buffer data
  69159. */
  69160. _bufferViews: IBufferView[];
  69161. /**
  69162. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  69163. */
  69164. _accessors: IAccessor[];
  69165. /**
  69166. * Stores all the generated nodes, which contains transform and/or mesh information per node
  69167. */
  69168. private _nodes;
  69169. /**
  69170. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  69171. */
  69172. private _scenes;
  69173. /**
  69174. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  69175. */
  69176. private _meshes;
  69177. /**
  69178. * Stores all the generated material information, which represents the appearance of each primitive
  69179. */
  69180. _materials: IMaterial[];
  69181. _materialMap: {
  69182. [materialID: number]: number;
  69183. };
  69184. /**
  69185. * Stores all the generated texture information, which is referenced by glTF materials
  69186. */
  69187. _textures: ITexture[];
  69188. /**
  69189. * Stores all the generated image information, which is referenced by glTF textures
  69190. */
  69191. _images: IImage[];
  69192. /**
  69193. * Stores all the texture samplers
  69194. */
  69195. _samplers: ISampler[];
  69196. /**
  69197. * Stores all the generated animation samplers, which is referenced by glTF animations
  69198. */
  69199. /**
  69200. * Stores the animations for glTF models
  69201. */
  69202. private _animations;
  69203. /**
  69204. * Stores the total amount of bytes stored in the glTF buffer
  69205. */
  69206. private _totalByteLength;
  69207. /**
  69208. * Stores a reference to the Babylon scene containing the source geometry and material information
  69209. */
  69210. _babylonScene: Scene;
  69211. /**
  69212. * Stores a map of the image data, where the key is the file name and the value
  69213. * is the image data
  69214. */
  69215. _imageData: {
  69216. [fileName: string]: {
  69217. data: Uint8Array;
  69218. mimeType: ImageMimeType;
  69219. };
  69220. };
  69221. /**
  69222. * Stores a map of the unique id of a node to its index in the node array
  69223. */
  69224. private _nodeMap;
  69225. /**
  69226. * Specifies if the Babylon scene should be converted to right-handed on export
  69227. */
  69228. _convertToRightHandedSystem: boolean;
  69229. /**
  69230. * Baked animation sample rate
  69231. */
  69232. private _animationSampleRate;
  69233. private _options;
  69234. private _localEngine;
  69235. _glTFMaterialExporter: _GLTFMaterialExporter;
  69236. private _extensions;
  69237. private static _ExtensionNames;
  69238. private static _ExtensionFactories;
  69239. private _applyExtensions;
  69240. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  69241. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  69242. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69243. private _forEachExtensions;
  69244. private _extensionsOnExporting;
  69245. /**
  69246. * Load glTF serializer extensions
  69247. */
  69248. private _loadExtensions;
  69249. /**
  69250. * Creates a glTF Exporter instance, which can accept optional exporter options
  69251. * @param babylonScene Babylon scene object
  69252. * @param options Options to modify the behavior of the exporter
  69253. */
  69254. constructor(babylonScene: Scene, options?: IExportOptions);
  69255. /**
  69256. * Registers a glTF exporter extension
  69257. * @param name Name of the extension to export
  69258. * @param factory The factory function that creates the exporter extension
  69259. */
  69260. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  69261. /**
  69262. * Un-registers an exporter extension
  69263. * @param name The name fo the exporter extension
  69264. * @returns A boolean indicating whether the extension has been un-registered
  69265. */
  69266. static UnregisterExtension(name: string): boolean;
  69267. /**
  69268. * Lazy load a local engine with premultiplied alpha set to false
  69269. */
  69270. _getLocalEngine(): Engine;
  69271. private reorderIndicesBasedOnPrimitiveMode;
  69272. /**
  69273. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  69274. * clock-wise during export to glTF
  69275. * @param submesh BabylonJS submesh
  69276. * @param primitiveMode Primitive mode of the mesh
  69277. * @param sideOrientation the winding order of the submesh
  69278. * @param vertexBufferKind The type of vertex attribute
  69279. * @param meshAttributeArray The vertex attribute data
  69280. * @param byteOffset The offset to the binary data
  69281. * @param binaryWriter The binary data for the glTF file
  69282. */
  69283. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  69284. /**
  69285. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  69286. * clock-wise during export to glTF
  69287. * @param submesh BabylonJS submesh
  69288. * @param primitiveMode Primitive mode of the mesh
  69289. * @param sideOrientation the winding order of the submesh
  69290. * @param vertexBufferKind The type of vertex attribute
  69291. * @param meshAttributeArray The vertex attribute data
  69292. * @param byteOffset The offset to the binary data
  69293. * @param binaryWriter The binary data for the glTF file
  69294. */
  69295. private reorderTriangleFillMode;
  69296. /**
  69297. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  69298. * clock-wise during export to glTF
  69299. * @param submesh BabylonJS submesh
  69300. * @param primitiveMode Primitive mode of the mesh
  69301. * @param sideOrientation the winding order of the submesh
  69302. * @param vertexBufferKind The type of vertex attribute
  69303. * @param meshAttributeArray The vertex attribute data
  69304. * @param byteOffset The offset to the binary data
  69305. * @param binaryWriter The binary data for the glTF file
  69306. */
  69307. private reorderTriangleStripDrawMode;
  69308. /**
  69309. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  69310. * clock-wise during export to glTF
  69311. * @param submesh BabylonJS submesh
  69312. * @param primitiveMode Primitive mode of the mesh
  69313. * @param sideOrientation the winding order of the submesh
  69314. * @param vertexBufferKind The type of vertex attribute
  69315. * @param meshAttributeArray The vertex attribute data
  69316. * @param byteOffset The offset to the binary data
  69317. * @param binaryWriter The binary data for the glTF file
  69318. */
  69319. private reorderTriangleFanMode;
  69320. /**
  69321. * Writes the vertex attribute data to binary
  69322. * @param vertices The vertices to write to the binary writer
  69323. * @param byteOffset The offset into the binary writer to overwrite binary data
  69324. * @param vertexAttributeKind The vertex attribute type
  69325. * @param meshAttributeArray The vertex attribute data
  69326. * @param binaryWriter The writer containing the binary data
  69327. */
  69328. private writeVertexAttributeData;
  69329. /**
  69330. * Writes mesh attribute data to a data buffer
  69331. * Returns the bytelength of the data
  69332. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  69333. * @param meshAttributeArray Array containing the attribute data
  69334. * @param binaryWriter The buffer to write the binary data to
  69335. * @param indices Used to specify the order of the vertex data
  69336. */
  69337. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  69338. /**
  69339. * Generates glTF json data
  69340. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  69341. * @param glTFPrefix Text to use when prefixing a glTF file
  69342. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  69343. * @returns json data as string
  69344. */
  69345. private generateJSON;
  69346. /**
  69347. * Generates data for .gltf and .bin files based on the glTF prefix string
  69348. * @param glTFPrefix Text to use when prefixing a glTF file
  69349. * @returns GLTFData with glTF file data
  69350. */
  69351. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  69352. /**
  69353. * Creates a binary buffer for glTF
  69354. * @returns array buffer for binary data
  69355. */
  69356. private _generateBinaryAsync;
  69357. /**
  69358. * Pads the number to a multiple of 4
  69359. * @param num number to pad
  69360. * @returns padded number
  69361. */
  69362. private _getPadding;
  69363. /**
  69364. * Generates a glb file from the json and binary data
  69365. * Returns an object with the glb file name as the key and data as the value
  69366. * @param glTFPrefix
  69367. * @returns object with glb filename as key and data as value
  69368. */
  69369. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  69370. /**
  69371. * Sets the TRS for each node
  69372. * @param node glTF Node for storing the transformation data
  69373. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  69374. */
  69375. private setNodeTransformation;
  69376. private getVertexBufferFromMesh;
  69377. /**
  69378. * Creates a bufferview based on the vertices type for the Babylon mesh
  69379. * @param kind Indicates the type of vertices data
  69380. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  69381. * @param binaryWriter The buffer to write the bufferview data to
  69382. */
  69383. private createBufferViewKind;
  69384. /**
  69385. * The primitive mode of the Babylon mesh
  69386. * @param babylonMesh The BabylonJS mesh
  69387. */
  69388. private getMeshPrimitiveMode;
  69389. /**
  69390. * Sets the primitive mode of the glTF mesh primitive
  69391. * @param meshPrimitive glTF mesh primitive
  69392. * @param primitiveMode The primitive mode
  69393. */
  69394. private setPrimitiveMode;
  69395. /**
  69396. * Sets the vertex attribute accessor based of the glTF mesh primitive
  69397. * @param meshPrimitive glTF mesh primitive
  69398. * @param attributeKind vertex attribute
  69399. * @returns boolean specifying if uv coordinates are present
  69400. */
  69401. private setAttributeKind;
  69402. /**
  69403. * Sets data for the primitive attributes of each submesh
  69404. * @param mesh glTF Mesh object to store the primitive attribute information
  69405. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  69406. * @param binaryWriter Buffer to write the attribute data to
  69407. */
  69408. private setPrimitiveAttributesAsync;
  69409. /**
  69410. * Creates a glTF scene based on the array of meshes
  69411. * Returns the the total byte offset
  69412. * @param babylonScene Babylon scene to get the mesh data from
  69413. * @param binaryWriter Buffer to write binary data to
  69414. */
  69415. private createSceneAsync;
  69416. /**
  69417. * Creates a mapping of Node unique id to node index and handles animations
  69418. * @param babylonScene Babylon Scene
  69419. * @param nodes Babylon transform nodes
  69420. * @param binaryWriter Buffer to write binary data to
  69421. * @returns Node mapping of unique id to index
  69422. */
  69423. private createNodeMapAndAnimationsAsync;
  69424. /**
  69425. * Creates a glTF node from a Babylon mesh
  69426. * @param babylonMesh Source Babylon mesh
  69427. * @param binaryWriter Buffer for storing geometry data
  69428. * @returns glTF node
  69429. */
  69430. private createNodeAsync;
  69431. }
  69432. /**
  69433. * @hidden
  69434. *
  69435. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  69436. */
  69437. export class _BinaryWriter {
  69438. /**
  69439. * Array buffer which stores all binary data
  69440. */
  69441. private _arrayBuffer;
  69442. /**
  69443. * View of the array buffer
  69444. */
  69445. private _dataView;
  69446. /**
  69447. * byte offset of data in array buffer
  69448. */
  69449. private _byteOffset;
  69450. /**
  69451. * Initialize binary writer with an initial byte length
  69452. * @param byteLength Initial byte length of the array buffer
  69453. */
  69454. constructor(byteLength: number);
  69455. /**
  69456. * Resize the array buffer to the specified byte length
  69457. * @param byteLength
  69458. */
  69459. private resizeBuffer;
  69460. /**
  69461. * Get an array buffer with the length of the byte offset
  69462. * @returns ArrayBuffer resized to the byte offset
  69463. */
  69464. getArrayBuffer(): ArrayBuffer;
  69465. /**
  69466. * Get the byte offset of the array buffer
  69467. * @returns byte offset
  69468. */
  69469. getByteOffset(): number;
  69470. /**
  69471. * Stores an UInt8 in the array buffer
  69472. * @param entry
  69473. * @param byteOffset If defined, specifies where to set the value as an offset.
  69474. */
  69475. setUInt8(entry: number, byteOffset?: number): void;
  69476. /**
  69477. * Gets an UInt32 in the array buffer
  69478. * @param entry
  69479. * @param byteOffset If defined, specifies where to set the value as an offset.
  69480. */
  69481. getUInt32(byteOffset: number): number;
  69482. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69483. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69484. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69485. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69486. /**
  69487. * Stores a Float32 in the array buffer
  69488. * @param entry
  69489. */
  69490. setFloat32(entry: number, byteOffset?: number): void;
  69491. /**
  69492. * Stores an UInt32 in the array buffer
  69493. * @param entry
  69494. * @param byteOffset If defined, specifies where to set the value as an offset.
  69495. */
  69496. setUInt32(entry: number, byteOffset?: number): void;
  69497. }
  69498. }
  69499. declare module BABYLON.GLTF2.Exporter {
  69500. /**
  69501. * @hidden
  69502. * Interface to store animation data.
  69503. */
  69504. export interface _IAnimationData {
  69505. /**
  69506. * Keyframe data.
  69507. */
  69508. inputs: number[];
  69509. /**
  69510. * Value data.
  69511. */
  69512. outputs: number[][];
  69513. /**
  69514. * Animation interpolation data.
  69515. */
  69516. samplerInterpolation: AnimationSamplerInterpolation;
  69517. /**
  69518. * Minimum keyframe value.
  69519. */
  69520. inputsMin: number;
  69521. /**
  69522. * Maximum keyframe value.
  69523. */
  69524. inputsMax: number;
  69525. }
  69526. /**
  69527. * @hidden
  69528. */
  69529. export interface _IAnimationInfo {
  69530. /**
  69531. * The target channel for the animation
  69532. */
  69533. animationChannelTargetPath: AnimationChannelTargetPath;
  69534. /**
  69535. * The glTF accessor type for the data.
  69536. */
  69537. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  69538. /**
  69539. * Specifies if quaternions should be used.
  69540. */
  69541. useQuaternion: boolean;
  69542. }
  69543. /**
  69544. * @hidden
  69545. * Utility class for generating glTF animation data from BabylonJS.
  69546. */
  69547. export class _GLTFAnimation {
  69548. /**
  69549. * @ignore
  69550. *
  69551. * Creates glTF channel animation from BabylonJS animation.
  69552. * @param babylonTransformNode - BabylonJS mesh.
  69553. * @param animation - animation.
  69554. * @param animationChannelTargetPath - The target animation channel.
  69555. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  69556. * @param useQuaternion - Specifies if quaternions are used.
  69557. * @returns nullable IAnimationData
  69558. */
  69559. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  69560. private static _DeduceAnimationInfo;
  69561. /**
  69562. * @ignore
  69563. * Create node animations from the transform node animations
  69564. * @param babylonNode
  69565. * @param runtimeGLTFAnimation
  69566. * @param idleGLTFAnimations
  69567. * @param nodeMap
  69568. * @param nodes
  69569. * @param binaryWriter
  69570. * @param bufferViews
  69571. * @param accessors
  69572. * @param convertToRightHandedSystem
  69573. */
  69574. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  69575. [key: number]: number;
  69576. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  69577. /**
  69578. * @ignore
  69579. * Create node animations from the animation groups
  69580. * @param babylonScene
  69581. * @param glTFAnimations
  69582. * @param nodeMap
  69583. * @param nodes
  69584. * @param binaryWriter
  69585. * @param bufferViews
  69586. * @param accessors
  69587. * @param convertToRightHandedSystem
  69588. */
  69589. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  69590. [key: number]: number;
  69591. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  69592. private static AddAnimation;
  69593. /**
  69594. * Create a baked animation
  69595. * @param babylonTransformNode BabylonJS mesh
  69596. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  69597. * @param animationChannelTargetPath animation target channel
  69598. * @param minFrame minimum animation frame
  69599. * @param maxFrame maximum animation frame
  69600. * @param fps frames per second of the animation
  69601. * @param inputs input key frames of the animation
  69602. * @param outputs output key frame data of the animation
  69603. * @param convertToRightHandedSystem converts the values to right-handed
  69604. * @param useQuaternion specifies if quaternions should be used
  69605. */
  69606. private static _CreateBakedAnimation;
  69607. private static _ConvertFactorToVector3OrQuaternion;
  69608. private static _SetInterpolatedValue;
  69609. /**
  69610. * Creates linear animation from the animation key frames
  69611. * @param babylonTransformNode BabylonJS mesh
  69612. * @param animation BabylonJS animation
  69613. * @param animationChannelTargetPath The target animation channel
  69614. * @param frameDelta The difference between the last and first frame of the animation
  69615. * @param inputs Array to store the key frame times
  69616. * @param outputs Array to store the key frame data
  69617. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  69618. * @param useQuaternion Specifies if quaternions are used in the animation
  69619. */
  69620. private static _CreateLinearOrStepAnimation;
  69621. /**
  69622. * Creates cubic spline animation from the animation key frames
  69623. * @param babylonTransformNode BabylonJS mesh
  69624. * @param animation BabylonJS animation
  69625. * @param animationChannelTargetPath The target animation channel
  69626. * @param frameDelta The difference between the last and first frame of the animation
  69627. * @param inputs Array to store the key frame times
  69628. * @param outputs Array to store the key frame data
  69629. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  69630. * @param useQuaternion Specifies if quaternions are used in the animation
  69631. */
  69632. private static _CreateCubicSplineAnimation;
  69633. private static _GetBasePositionRotationOrScale;
  69634. /**
  69635. * Adds a key frame value
  69636. * @param keyFrame
  69637. * @param animation
  69638. * @param outputs
  69639. * @param animationChannelTargetPath
  69640. * @param basePositionRotationOrScale
  69641. * @param convertToRightHandedSystem
  69642. * @param useQuaternion
  69643. */
  69644. private static _AddKeyframeValue;
  69645. /**
  69646. * Determine the interpolation based on the key frames
  69647. * @param keyFrames
  69648. * @param animationChannelTargetPath
  69649. * @param useQuaternion
  69650. */
  69651. private static _DeduceInterpolation;
  69652. /**
  69653. * Adds an input tangent or output tangent to the output data
  69654. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  69655. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  69656. * @param outputs The animation data by keyframe
  69657. * @param animationChannelTargetPath The target animation channel
  69658. * @param interpolation The interpolation type
  69659. * @param keyFrame The key frame with the animation data
  69660. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  69661. * @param useQuaternion Specifies if quaternions are used
  69662. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  69663. */
  69664. private static AddSplineTangent;
  69665. /**
  69666. * Get the minimum and maximum key frames' frame values
  69667. * @param keyFrames animation key frames
  69668. * @returns the minimum and maximum key frame value
  69669. */
  69670. private static calculateMinMaxKeyFrames;
  69671. }
  69672. }
  69673. declare module BABYLON.GLTF2.Exporter {
  69674. /** @hidden */
  69675. export var textureTransformPixelShader: {
  69676. name: string;
  69677. shader: string;
  69678. };
  69679. }
  69680. declare module BABYLON.GLTF2.Exporter.Extensions {
  69681. /**
  69682. * @hidden
  69683. */
  69684. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  69685. /** Name of this extension */
  69686. readonly name: string;
  69687. /** Defines whether this extension is enabled */
  69688. enabled: boolean;
  69689. /** Defines whether this extension is required */
  69690. required: boolean;
  69691. /** Reference to the glTF exporter */
  69692. private _exporter;
  69693. constructor(exporter: _Exporter);
  69694. dispose(): void;
  69695. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69696. /**
  69697. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  69698. * @param babylonTexture
  69699. * @param offset
  69700. * @param rotation
  69701. * @param scale
  69702. * @param scene
  69703. */
  69704. private _textureTransformTextureAsync;
  69705. }
  69706. }
  69707. declare module BABYLON.GLTF2.Exporter.Extensions {
  69708. /**
  69709. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  69710. */
  69711. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  69712. /** The name of this extension. */
  69713. readonly name: string;
  69714. /** Defines whether this extension is enabled. */
  69715. enabled: boolean;
  69716. /** Defines whether this extension is required */
  69717. required: boolean;
  69718. /** Reference to the glTF exporter */
  69719. private _exporter;
  69720. private _lights;
  69721. /** @hidden */
  69722. constructor(exporter: _Exporter);
  69723. /** @hidden */
  69724. dispose(): void;
  69725. /** @hidden */
  69726. onExporting(): void;
  69727. /**
  69728. * Define this method to modify the default behavior when exporting a node
  69729. * @param context The context when exporting the node
  69730. * @param node glTF node
  69731. * @param babylonNode BabylonJS node
  69732. * @returns nullable INode promise
  69733. */
  69734. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69735. }
  69736. }
  69737. declare module BABYLON {
  69738. /**
  69739. * Class for generating STL data from a Babylon scene.
  69740. */
  69741. export class STLExport {
  69742. /**
  69743. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  69744. * @param meshes list defines the mesh to serialize
  69745. * @param download triggers the automatic download of the file.
  69746. * @param fileName changes the downloads fileName.
  69747. * @param binary changes the STL to a binary type.
  69748. * @param isLittleEndian toggle for binary type exporter.
  69749. * @returns the STL as UTF8 string
  69750. */
  69751. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  69752. }
  69753. }
  69754. declare module "babylonjs-gltf2interface" {
  69755. export = BABYLON.GLTF2;
  69756. }
  69757. /**
  69758. * Module for glTF 2.0 Interface
  69759. */
  69760. declare module BABYLON.GLTF2 {
  69761. /**
  69762. * The datatype of the components in the attribute
  69763. */
  69764. const enum AccessorComponentType {
  69765. /**
  69766. * Byte
  69767. */
  69768. BYTE = 5120,
  69769. /**
  69770. * Unsigned Byte
  69771. */
  69772. UNSIGNED_BYTE = 5121,
  69773. /**
  69774. * Short
  69775. */
  69776. SHORT = 5122,
  69777. /**
  69778. * Unsigned Short
  69779. */
  69780. UNSIGNED_SHORT = 5123,
  69781. /**
  69782. * Unsigned Int
  69783. */
  69784. UNSIGNED_INT = 5125,
  69785. /**
  69786. * Float
  69787. */
  69788. FLOAT = 5126,
  69789. }
  69790. /**
  69791. * Specifies if the attirbute is a scalar, vector, or matrix
  69792. */
  69793. const enum AccessorType {
  69794. /**
  69795. * Scalar
  69796. */
  69797. SCALAR = "SCALAR",
  69798. /**
  69799. * Vector2
  69800. */
  69801. VEC2 = "VEC2",
  69802. /**
  69803. * Vector3
  69804. */
  69805. VEC3 = "VEC3",
  69806. /**
  69807. * Vector4
  69808. */
  69809. VEC4 = "VEC4",
  69810. /**
  69811. * Matrix2x2
  69812. */
  69813. MAT2 = "MAT2",
  69814. /**
  69815. * Matrix3x3
  69816. */
  69817. MAT3 = "MAT3",
  69818. /**
  69819. * Matrix4x4
  69820. */
  69821. MAT4 = "MAT4",
  69822. }
  69823. /**
  69824. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69825. */
  69826. const enum AnimationChannelTargetPath {
  69827. /**
  69828. * Translation
  69829. */
  69830. TRANSLATION = "translation",
  69831. /**
  69832. * Rotation
  69833. */
  69834. ROTATION = "rotation",
  69835. /**
  69836. * Scale
  69837. */
  69838. SCALE = "scale",
  69839. /**
  69840. * Weights
  69841. */
  69842. WEIGHTS = "weights",
  69843. }
  69844. /**
  69845. * Interpolation algorithm
  69846. */
  69847. const enum AnimationSamplerInterpolation {
  69848. /**
  69849. * The animated values are linearly interpolated between keyframes
  69850. */
  69851. LINEAR = "LINEAR",
  69852. /**
  69853. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  69854. */
  69855. STEP = "STEP",
  69856. /**
  69857. * The animation's interpolation is computed using a cubic spline with specified tangents
  69858. */
  69859. CUBICSPLINE = "CUBICSPLINE",
  69860. }
  69861. /**
  69862. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69863. */
  69864. const enum CameraType {
  69865. /**
  69866. * A perspective camera containing properties to create a perspective projection matrix
  69867. */
  69868. PERSPECTIVE = "perspective",
  69869. /**
  69870. * An orthographic camera containing properties to create an orthographic projection matrix
  69871. */
  69872. ORTHOGRAPHIC = "orthographic",
  69873. }
  69874. /**
  69875. * The mime-type of the image
  69876. */
  69877. const enum ImageMimeType {
  69878. /**
  69879. * JPEG Mime-type
  69880. */
  69881. JPEG = "image/jpeg",
  69882. /**
  69883. * PNG Mime-type
  69884. */
  69885. PNG = "image/png",
  69886. }
  69887. /**
  69888. * The alpha rendering mode of the material
  69889. */
  69890. const enum MaterialAlphaMode {
  69891. /**
  69892. * The alpha value is ignored and the rendered output is fully opaque
  69893. */
  69894. OPAQUE = "OPAQUE",
  69895. /**
  69896. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  69897. */
  69898. MASK = "MASK",
  69899. /**
  69900. * 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)
  69901. */
  69902. BLEND = "BLEND",
  69903. }
  69904. /**
  69905. * The type of the primitives to render
  69906. */
  69907. const enum MeshPrimitiveMode {
  69908. /**
  69909. * Points
  69910. */
  69911. POINTS = 0,
  69912. /**
  69913. * Lines
  69914. */
  69915. LINES = 1,
  69916. /**
  69917. * Line Loop
  69918. */
  69919. LINE_LOOP = 2,
  69920. /**
  69921. * Line Strip
  69922. */
  69923. LINE_STRIP = 3,
  69924. /**
  69925. * Triangles
  69926. */
  69927. TRIANGLES = 4,
  69928. /**
  69929. * Triangle Strip
  69930. */
  69931. TRIANGLE_STRIP = 5,
  69932. /**
  69933. * Triangle Fan
  69934. */
  69935. TRIANGLE_FAN = 6,
  69936. }
  69937. /**
  69938. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69939. */
  69940. const enum TextureMagFilter {
  69941. /**
  69942. * Nearest
  69943. */
  69944. NEAREST = 9728,
  69945. /**
  69946. * Linear
  69947. */
  69948. LINEAR = 9729,
  69949. }
  69950. /**
  69951. * Minification filter. All valid values correspond to WebGL enums
  69952. */
  69953. const enum TextureMinFilter {
  69954. /**
  69955. * Nearest
  69956. */
  69957. NEAREST = 9728,
  69958. /**
  69959. * Linear
  69960. */
  69961. LINEAR = 9729,
  69962. /**
  69963. * Nearest Mip-Map Nearest
  69964. */
  69965. NEAREST_MIPMAP_NEAREST = 9984,
  69966. /**
  69967. * Linear Mipmap Nearest
  69968. */
  69969. LINEAR_MIPMAP_NEAREST = 9985,
  69970. /**
  69971. * Nearest Mipmap Linear
  69972. */
  69973. NEAREST_MIPMAP_LINEAR = 9986,
  69974. /**
  69975. * Linear Mipmap Linear
  69976. */
  69977. LINEAR_MIPMAP_LINEAR = 9987,
  69978. }
  69979. /**
  69980. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69981. */
  69982. const enum TextureWrapMode {
  69983. /**
  69984. * Clamp to Edge
  69985. */
  69986. CLAMP_TO_EDGE = 33071,
  69987. /**
  69988. * Mirrored Repeat
  69989. */
  69990. MIRRORED_REPEAT = 33648,
  69991. /**
  69992. * Repeat
  69993. */
  69994. REPEAT = 10497,
  69995. }
  69996. /**
  69997. * glTF Property
  69998. */
  69999. interface IProperty {
  70000. /**
  70001. * Dictionary object with extension-specific objects
  70002. */
  70003. extensions?: {
  70004. [key: string]: any;
  70005. };
  70006. /**
  70007. * Application-Specific data
  70008. */
  70009. extras?: any;
  70010. }
  70011. /**
  70012. * glTF Child of Root Property
  70013. */
  70014. interface IChildRootProperty extends IProperty {
  70015. /**
  70016. * The user-defined name of this object
  70017. */
  70018. name?: string;
  70019. }
  70020. /**
  70021. * Indices of those attributes that deviate from their initialization value
  70022. */
  70023. interface IAccessorSparseIndices extends IProperty {
  70024. /**
  70025. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70026. */
  70027. bufferView: number;
  70028. /**
  70029. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70030. */
  70031. byteOffset?: number;
  70032. /**
  70033. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  70034. */
  70035. componentType: AccessorComponentType;
  70036. }
  70037. /**
  70038. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  70039. */
  70040. interface IAccessorSparseValues extends IProperty {
  70041. /**
  70042. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70043. */
  70044. bufferView: number;
  70045. /**
  70046. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70047. */
  70048. byteOffset?: number;
  70049. }
  70050. /**
  70051. * Sparse storage of attributes that deviate from their initialization value
  70052. */
  70053. interface IAccessorSparse extends IProperty {
  70054. /**
  70055. * The number of attributes encoded in this sparse accessor
  70056. */
  70057. count: number;
  70058. /**
  70059. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  70060. */
  70061. indices: IAccessorSparseIndices;
  70062. /**
  70063. * 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
  70064. */
  70065. values: IAccessorSparseValues;
  70066. }
  70067. /**
  70068. * 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
  70069. */
  70070. interface IAccessor extends IChildRootProperty {
  70071. /**
  70072. * The index of the bufferview
  70073. */
  70074. bufferView?: number;
  70075. /**
  70076. * The offset relative to the start of the bufferView in bytes
  70077. */
  70078. byteOffset?: number;
  70079. /**
  70080. * The datatype of components in the attribute
  70081. */
  70082. componentType: AccessorComponentType;
  70083. /**
  70084. * Specifies whether integer data values should be normalized
  70085. */
  70086. normalized?: boolean;
  70087. /**
  70088. * The number of attributes referenced by this accessor
  70089. */
  70090. count: number;
  70091. /**
  70092. * Specifies if the attribute is a scalar, vector, or matrix
  70093. */
  70094. type: AccessorType;
  70095. /**
  70096. * Maximum value of each component in this attribute
  70097. */
  70098. max?: number[];
  70099. /**
  70100. * Minimum value of each component in this attribute
  70101. */
  70102. min?: number[];
  70103. /**
  70104. * Sparse storage of attributes that deviate from their initialization value
  70105. */
  70106. sparse?: IAccessorSparse;
  70107. }
  70108. /**
  70109. * Targets an animation's sampler at a node's property
  70110. */
  70111. interface IAnimationChannel extends IProperty {
  70112. /**
  70113. * The index of a sampler in this animation used to compute the value for the target
  70114. */
  70115. sampler: number;
  70116. /**
  70117. * The index of the node and TRS property to target
  70118. */
  70119. target: IAnimationChannelTarget;
  70120. }
  70121. /**
  70122. * The index of the node and TRS property that an animation channel targets
  70123. */
  70124. interface IAnimationChannelTarget extends IProperty {
  70125. /**
  70126. * The index of the node to target
  70127. */
  70128. node: number;
  70129. /**
  70130. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70131. */
  70132. path: AnimationChannelTargetPath;
  70133. }
  70134. /**
  70135. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70136. */
  70137. interface IAnimationSampler extends IProperty {
  70138. /**
  70139. * The index of an accessor containing keyframe input values, e.g., time
  70140. */
  70141. input: number;
  70142. /**
  70143. * Interpolation algorithm
  70144. */
  70145. interpolation?: AnimationSamplerInterpolation;
  70146. /**
  70147. * The index of an accessor, containing keyframe output values
  70148. */
  70149. output: number;
  70150. }
  70151. /**
  70152. * A keyframe animation
  70153. */
  70154. interface IAnimation extends IChildRootProperty {
  70155. /**
  70156. * An array of channels, each of which targets an animation's sampler at a node's property
  70157. */
  70158. channels: IAnimationChannel[];
  70159. /**
  70160. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70161. */
  70162. samplers: IAnimationSampler[];
  70163. }
  70164. /**
  70165. * Metadata about the glTF asset
  70166. */
  70167. interface IAsset extends IChildRootProperty {
  70168. /**
  70169. * A copyright message suitable for display to credit the content creator
  70170. */
  70171. copyright?: string;
  70172. /**
  70173. * Tool that generated this glTF model. Useful for debugging
  70174. */
  70175. generator?: string;
  70176. /**
  70177. * The glTF version that this asset targets
  70178. */
  70179. version: string;
  70180. /**
  70181. * The minimum glTF version that this asset targets
  70182. */
  70183. minVersion?: string;
  70184. }
  70185. /**
  70186. * A buffer points to binary geometry, animation, or skins
  70187. */
  70188. interface IBuffer extends IChildRootProperty {
  70189. /**
  70190. * 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
  70191. */
  70192. uri?: string;
  70193. /**
  70194. * The length of the buffer in bytes
  70195. */
  70196. byteLength: number;
  70197. }
  70198. /**
  70199. * A view into a buffer generally representing a subset of the buffer
  70200. */
  70201. interface IBufferView extends IChildRootProperty {
  70202. /**
  70203. * The index of the buffer
  70204. */
  70205. buffer: number;
  70206. /**
  70207. * The offset into the buffer in bytes
  70208. */
  70209. byteOffset?: number;
  70210. /**
  70211. * The lenth of the bufferView in bytes
  70212. */
  70213. byteLength: number;
  70214. /**
  70215. * The stride, in bytes
  70216. */
  70217. byteStride?: number;
  70218. }
  70219. /**
  70220. * An orthographic camera containing properties to create an orthographic projection matrix
  70221. */
  70222. interface ICameraOrthographic extends IProperty {
  70223. /**
  70224. * The floating-point horizontal magnification of the view. Must not be zero
  70225. */
  70226. xmag: number;
  70227. /**
  70228. * The floating-point vertical magnification of the view. Must not be zero
  70229. */
  70230. ymag: number;
  70231. /**
  70232. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  70233. */
  70234. zfar: number;
  70235. /**
  70236. * The floating-point distance to the near clipping plane
  70237. */
  70238. znear: number;
  70239. }
  70240. /**
  70241. * A perspective camera containing properties to create a perspective projection matrix
  70242. */
  70243. interface ICameraPerspective extends IProperty {
  70244. /**
  70245. * The floating-point aspect ratio of the field of view
  70246. */
  70247. aspectRatio?: number;
  70248. /**
  70249. * The floating-point vertical field of view in radians
  70250. */
  70251. yfov: number;
  70252. /**
  70253. * The floating-point distance to the far clipping plane
  70254. */
  70255. zfar?: number;
  70256. /**
  70257. * The floating-point distance to the near clipping plane
  70258. */
  70259. znear: number;
  70260. }
  70261. /**
  70262. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70263. */
  70264. interface ICamera extends IChildRootProperty {
  70265. /**
  70266. * An orthographic camera containing properties to create an orthographic projection matrix
  70267. */
  70268. orthographic?: ICameraOrthographic;
  70269. /**
  70270. * A perspective camera containing properties to create a perspective projection matrix
  70271. */
  70272. perspective?: ICameraPerspective;
  70273. /**
  70274. * Specifies if the camera uses a perspective or orthographic projection
  70275. */
  70276. type: CameraType;
  70277. }
  70278. /**
  70279. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  70280. */
  70281. interface IImage extends IChildRootProperty {
  70282. /**
  70283. * 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
  70284. */
  70285. uri?: string;
  70286. /**
  70287. * The image's MIME type
  70288. */
  70289. mimeType?: ImageMimeType;
  70290. /**
  70291. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  70292. */
  70293. bufferView?: number;
  70294. }
  70295. /**
  70296. * Material Normal Texture Info
  70297. */
  70298. interface IMaterialNormalTextureInfo extends ITextureInfo {
  70299. /**
  70300. * The scalar multiplier applied to each normal vector of the normal texture
  70301. */
  70302. scale?: number;
  70303. }
  70304. /**
  70305. * Material Occlusion Texture Info
  70306. */
  70307. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  70308. /**
  70309. * A scalar multiplier controlling the amount of occlusion applied
  70310. */
  70311. strength?: number;
  70312. }
  70313. /**
  70314. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  70315. */
  70316. interface IMaterialPbrMetallicRoughness {
  70317. /**
  70318. * The material's base color factor
  70319. */
  70320. baseColorFactor?: number[];
  70321. /**
  70322. * The base color texture
  70323. */
  70324. baseColorTexture?: ITextureInfo;
  70325. /**
  70326. * The metalness of the material
  70327. */
  70328. metallicFactor?: number;
  70329. /**
  70330. * The roughness of the material
  70331. */
  70332. roughnessFactor?: number;
  70333. /**
  70334. * The metallic-roughness texture
  70335. */
  70336. metallicRoughnessTexture?: ITextureInfo;
  70337. }
  70338. /**
  70339. * The material appearance of a primitive
  70340. */
  70341. interface IMaterial extends IChildRootProperty {
  70342. /**
  70343. * 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
  70344. */
  70345. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  70346. /**
  70347. * The normal map texture
  70348. */
  70349. normalTexture?: IMaterialNormalTextureInfo;
  70350. /**
  70351. * The occlusion map texture
  70352. */
  70353. occlusionTexture?: IMaterialOcclusionTextureInfo;
  70354. /**
  70355. * The emissive map texture
  70356. */
  70357. emissiveTexture?: ITextureInfo;
  70358. /**
  70359. * 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
  70360. */
  70361. emissiveFactor?: number[];
  70362. /**
  70363. * The alpha rendering mode of the material
  70364. */
  70365. alphaMode?: MaterialAlphaMode;
  70366. /**
  70367. * The alpha cutoff value of the material
  70368. */
  70369. alphaCutoff?: number;
  70370. /**
  70371. * Specifies whether the material is double sided
  70372. */
  70373. doubleSided?: boolean;
  70374. }
  70375. /**
  70376. * Geometry to be rendered with the given material
  70377. */
  70378. interface IMeshPrimitive extends IProperty {
  70379. /**
  70380. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  70381. */
  70382. attributes: {
  70383. [name: string]: number;
  70384. };
  70385. /**
  70386. * The index of the accessor that contains the indices
  70387. */
  70388. indices?: number;
  70389. /**
  70390. * The index of the material to apply to this primitive when rendering
  70391. */
  70392. material?: number;
  70393. /**
  70394. * The type of primitives to render. All valid values correspond to WebGL enums
  70395. */
  70396. mode?: MeshPrimitiveMode;
  70397. /**
  70398. * 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
  70399. */
  70400. targets?: {
  70401. [name: string]: number;
  70402. }[];
  70403. }
  70404. /**
  70405. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  70406. */
  70407. interface IMesh extends IChildRootProperty {
  70408. /**
  70409. * An array of primitives, each defining geometry to be rendered with a material
  70410. */
  70411. primitives: IMeshPrimitive[];
  70412. /**
  70413. * Array of weights to be applied to the Morph Targets
  70414. */
  70415. weights?: number[];
  70416. }
  70417. /**
  70418. * A node in the node hierarchy
  70419. */
  70420. interface INode extends IChildRootProperty {
  70421. /**
  70422. * The index of the camera referenced by this node
  70423. */
  70424. camera?: number;
  70425. /**
  70426. * The indices of this node's children
  70427. */
  70428. children?: number[];
  70429. /**
  70430. * The index of the skin referenced by this node
  70431. */
  70432. skin?: number;
  70433. /**
  70434. * A floating-point 4x4 transformation matrix stored in column-major order
  70435. */
  70436. matrix?: number[];
  70437. /**
  70438. * The index of the mesh in this node
  70439. */
  70440. mesh?: number;
  70441. /**
  70442. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  70443. */
  70444. rotation?: number[];
  70445. /**
  70446. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  70447. */
  70448. scale?: number[];
  70449. /**
  70450. * The node's translation along the x, y, and z axes
  70451. */
  70452. translation?: number[];
  70453. /**
  70454. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  70455. */
  70456. weights?: number[];
  70457. }
  70458. /**
  70459. * Texture sampler properties for filtering and wrapping modes
  70460. */
  70461. interface ISampler extends IChildRootProperty {
  70462. /**
  70463. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70464. */
  70465. magFilter?: TextureMagFilter;
  70466. /**
  70467. * Minification filter. All valid values correspond to WebGL enums
  70468. */
  70469. minFilter?: TextureMinFilter;
  70470. /**
  70471. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70472. */
  70473. wrapS?: TextureWrapMode;
  70474. /**
  70475. * T (V) wrapping mode. All valid values correspond to WebGL enums
  70476. */
  70477. wrapT?: TextureWrapMode;
  70478. }
  70479. /**
  70480. * The root nodes of a scene
  70481. */
  70482. interface IScene extends IChildRootProperty {
  70483. /**
  70484. * The indices of each root node
  70485. */
  70486. nodes: number[];
  70487. }
  70488. /**
  70489. * Joints and matrices defining a skin
  70490. */
  70491. interface ISkin extends IChildRootProperty {
  70492. /**
  70493. * 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
  70494. */
  70495. inverseBindMatrices?: number;
  70496. /**
  70497. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  70498. */
  70499. skeleton?: number;
  70500. /**
  70501. * 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)
  70502. */
  70503. joints: number[];
  70504. }
  70505. /**
  70506. * A texture and its sampler
  70507. */
  70508. interface ITexture extends IChildRootProperty {
  70509. /**
  70510. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  70511. */
  70512. sampler?: number;
  70513. /**
  70514. * The index of the image used by this texture
  70515. */
  70516. source: number;
  70517. }
  70518. /**
  70519. * Reference to a texture
  70520. */
  70521. interface ITextureInfo extends IProperty {
  70522. /**
  70523. * The index of the texture
  70524. */
  70525. index: number;
  70526. /**
  70527. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  70528. */
  70529. texCoord?: number;
  70530. }
  70531. /**
  70532. * The root object for a glTF asset
  70533. */
  70534. interface IGLTF extends IProperty {
  70535. /**
  70536. * An array of accessors. An accessor is a typed view into a bufferView
  70537. */
  70538. accessors?: IAccessor[];
  70539. /**
  70540. * An array of keyframe animations
  70541. */
  70542. animations?: IAnimation[];
  70543. /**
  70544. * Metadata about the glTF asset
  70545. */
  70546. asset: IAsset;
  70547. /**
  70548. * An array of buffers. A buffer points to binary geometry, animation, or skins
  70549. */
  70550. buffers?: IBuffer[];
  70551. /**
  70552. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  70553. */
  70554. bufferViews?: IBufferView[];
  70555. /**
  70556. * An array of cameras
  70557. */
  70558. cameras?: ICamera[];
  70559. /**
  70560. * Names of glTF extensions used somewhere in this asset
  70561. */
  70562. extensionsUsed?: string[];
  70563. /**
  70564. * Names of glTF extensions required to properly load this asset
  70565. */
  70566. extensionsRequired?: string[];
  70567. /**
  70568. * An array of images. An image defines data used to create a texture
  70569. */
  70570. images?: IImage[];
  70571. /**
  70572. * An array of materials. A material defines the appearance of a primitive
  70573. */
  70574. materials?: IMaterial[];
  70575. /**
  70576. * An array of meshes. A mesh is a set of primitives to be rendered
  70577. */
  70578. meshes?: IMesh[];
  70579. /**
  70580. * An array of nodes
  70581. */
  70582. nodes?: INode[];
  70583. /**
  70584. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  70585. */
  70586. samplers?: ISampler[];
  70587. /**
  70588. * The index of the default scene
  70589. */
  70590. scene?: number;
  70591. /**
  70592. * An array of scenes
  70593. */
  70594. scenes?: IScene[];
  70595. /**
  70596. * An array of skins. A skin is defined by joints and matrices
  70597. */
  70598. skins?: ISkin[];
  70599. /**
  70600. * An array of textures
  70601. */
  70602. textures?: ITexture[];
  70603. }
  70604. /**
  70605. * The glTF validation results
  70606. * @ignore
  70607. */
  70608. interface IGLTFValidationResults {
  70609. info: {
  70610. generator: string;
  70611. hasAnimations: boolean;
  70612. hasDefaultScene: boolean;
  70613. hasMaterials: boolean;
  70614. hasMorphTargets: boolean;
  70615. hasSkins: boolean;
  70616. hasTextures: boolean;
  70617. maxAttributesUsed: number;
  70618. primitivesCount: number
  70619. };
  70620. issues: {
  70621. messages: Array<string>;
  70622. numErrors: number;
  70623. numHints: number;
  70624. numInfos: number;
  70625. numWarnings: number;
  70626. truncated: boolean
  70627. };
  70628. mimeType: string;
  70629. uri: string;
  70630. validatedAt: string;
  70631. validatorVersion: string;
  70632. }
  70633. /**
  70634. * The glTF validation options
  70635. */
  70636. interface IGLTFValidationOptions {
  70637. /** Uri to use */
  70638. uri?: string;
  70639. /** Function used to load external resources */
  70640. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  70641. /** Boolean indicating that we need to validate accessor data */
  70642. validateAccessorData?: boolean;
  70643. /** max number of issues allowed */
  70644. maxIssues?: number;
  70645. /** Ignored issues */
  70646. ignoredIssues?: Array<string>;
  70647. /** Value to override severy settings */
  70648. severityOverrides?: Object;
  70649. }
  70650. /**
  70651. * The glTF validator object
  70652. * @ignore
  70653. */
  70654. interface IGLTFValidator {
  70655. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70656. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70657. }
  70658. }
  70659. declare module BABYLON {
  70660. /** @hidden */
  70661. export var cellPixelShader: {
  70662. name: string;
  70663. shader: string;
  70664. };
  70665. }
  70666. declare module BABYLON {
  70667. /** @hidden */
  70668. export var cellVertexShader: {
  70669. name: string;
  70670. shader: string;
  70671. };
  70672. }
  70673. declare module BABYLON {
  70674. export class CellMaterial extends BABYLON.PushMaterial {
  70675. private _diffuseTexture;
  70676. diffuseTexture: BABYLON.BaseTexture;
  70677. diffuseColor: BABYLON.Color3;
  70678. _computeHighLevel: boolean;
  70679. computeHighLevel: boolean;
  70680. private _disableLighting;
  70681. disableLighting: boolean;
  70682. private _maxSimultaneousLights;
  70683. maxSimultaneousLights: number;
  70684. private _renderId;
  70685. constructor(name: string, scene: BABYLON.Scene);
  70686. needAlphaBlending(): boolean;
  70687. needAlphaTesting(): boolean;
  70688. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70689. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70690. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70691. getAnimatables(): BABYLON.IAnimatable[];
  70692. getActiveTextures(): BABYLON.BaseTexture[];
  70693. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70694. dispose(forceDisposeEffect?: boolean): void;
  70695. getClassName(): string;
  70696. clone(name: string): CellMaterial;
  70697. serialize(): any;
  70698. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  70699. }
  70700. }
  70701. declare module BABYLON {
  70702. export class CustomShaderStructure {
  70703. FragmentStore: string;
  70704. VertexStore: string;
  70705. constructor();
  70706. }
  70707. export class ShaderSpecialParts {
  70708. constructor();
  70709. Fragment_Begin: string;
  70710. Fragment_Definitions: string;
  70711. Fragment_MainBegin: string;
  70712. Fragment_Custom_Diffuse: string;
  70713. Fragment_Before_Lights: string;
  70714. Fragment_Before_Fog: string;
  70715. Fragment_Custom_Alpha: string;
  70716. Fragment_Before_FragColor: string;
  70717. Vertex_Begin: string;
  70718. Vertex_Definitions: string;
  70719. Vertex_MainBegin: string;
  70720. Vertex_Before_PositionUpdated: string;
  70721. Vertex_Before_NormalUpdated: string;
  70722. Vertex_MainEnd: string;
  70723. }
  70724. export class CustomMaterial extends BABYLON.StandardMaterial {
  70725. static ShaderIndexer: number;
  70726. CustomParts: ShaderSpecialParts;
  70727. _isCreatedShader: boolean;
  70728. _createdShaderName: string;
  70729. _customUniform: string[];
  70730. _newUniforms: string[];
  70731. _newUniformInstances: any[];
  70732. _newSamplerInstances: BABYLON.Texture[];
  70733. FragmentShader: string;
  70734. VertexShader: string;
  70735. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70736. ReviewUniform(name: string, arr: string[]): string[];
  70737. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  70738. constructor(name: string, scene: BABYLON.Scene);
  70739. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  70740. Fragment_Begin(shaderPart: string): CustomMaterial;
  70741. Fragment_Definitions(shaderPart: string): CustomMaterial;
  70742. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  70743. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  70744. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  70745. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  70746. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  70747. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  70748. Vertex_Begin(shaderPart: string): CustomMaterial;
  70749. Vertex_Definitions(shaderPart: string): CustomMaterial;
  70750. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  70751. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  70752. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  70753. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  70754. }
  70755. }
  70756. declare module BABYLON {
  70757. export class ShaderAlebdoParts {
  70758. constructor();
  70759. Fragment_Begin: string;
  70760. Fragment_Definitions: string;
  70761. Fragment_MainBegin: string;
  70762. Fragment_Custom_Albedo: string;
  70763. Fragment_Before_Lights: string;
  70764. Fragment_Custom_MetallicRoughness: string;
  70765. Fragment_Custom_MicroSurface: string;
  70766. Fragment_Before_Fog: string;
  70767. Fragment_Custom_Alpha: string;
  70768. Fragment_Before_FragColor: string;
  70769. Vertex_Begin: string;
  70770. Vertex_Definitions: string;
  70771. Vertex_MainBegin: string;
  70772. Vertex_Before_PositionUpdated: string;
  70773. Vertex_Before_NormalUpdated: string;
  70774. Vertex_MainEnd: string;
  70775. }
  70776. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  70777. static ShaderIndexer: number;
  70778. CustomParts: ShaderAlebdoParts;
  70779. _isCreatedShader: boolean;
  70780. _createdShaderName: string;
  70781. _customUniform: string[];
  70782. _newUniforms: string[];
  70783. _newUniformInstances: any[];
  70784. _newSamplerInstances: BABYLON.Texture[];
  70785. FragmentShader: string;
  70786. VertexShader: string;
  70787. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70788. ReviewUniform(name: string, arr: string[]): string[];
  70789. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  70790. constructor(name: string, scene: BABYLON.Scene);
  70791. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  70792. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  70793. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  70794. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  70795. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  70796. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  70797. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  70798. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  70799. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  70800. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  70801. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  70802. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  70803. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  70804. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  70805. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  70806. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  70807. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  70808. }
  70809. }
  70810. declare module BABYLON {
  70811. /** @hidden */
  70812. export var firePixelShader: {
  70813. name: string;
  70814. shader: string;
  70815. };
  70816. }
  70817. declare module BABYLON {
  70818. /** @hidden */
  70819. export var fireVertexShader: {
  70820. name: string;
  70821. shader: string;
  70822. };
  70823. }
  70824. declare module BABYLON {
  70825. export class FireMaterial extends BABYLON.PushMaterial {
  70826. private _diffuseTexture;
  70827. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70828. private _distortionTexture;
  70829. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70830. private _opacityTexture;
  70831. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70832. diffuseColor: BABYLON.Color3;
  70833. speed: number;
  70834. private _scaledDiffuse;
  70835. private _renderId;
  70836. private _lastTime;
  70837. constructor(name: string, scene: BABYLON.Scene);
  70838. needAlphaBlending(): boolean;
  70839. needAlphaTesting(): boolean;
  70840. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70841. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70842. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70843. getAnimatables(): BABYLON.IAnimatable[];
  70844. getActiveTextures(): BABYLON.BaseTexture[];
  70845. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70846. getClassName(): string;
  70847. dispose(forceDisposeEffect?: boolean): void;
  70848. clone(name: string): FireMaterial;
  70849. serialize(): any;
  70850. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  70851. }
  70852. }
  70853. declare module BABYLON {
  70854. /** @hidden */
  70855. export var furPixelShader: {
  70856. name: string;
  70857. shader: string;
  70858. };
  70859. }
  70860. declare module BABYLON {
  70861. /** @hidden */
  70862. export var furVertexShader: {
  70863. name: string;
  70864. shader: string;
  70865. };
  70866. }
  70867. declare module BABYLON {
  70868. export class FurMaterial extends BABYLON.PushMaterial {
  70869. private _diffuseTexture;
  70870. diffuseTexture: BABYLON.BaseTexture;
  70871. private _heightTexture;
  70872. heightTexture: BABYLON.BaseTexture;
  70873. diffuseColor: BABYLON.Color3;
  70874. furLength: number;
  70875. furAngle: number;
  70876. furColor: BABYLON.Color3;
  70877. furOffset: number;
  70878. furSpacing: number;
  70879. furGravity: BABYLON.Vector3;
  70880. furSpeed: number;
  70881. furDensity: number;
  70882. furOcclusion: number;
  70883. furTexture: BABYLON.DynamicTexture;
  70884. private _disableLighting;
  70885. disableLighting: boolean;
  70886. private _maxSimultaneousLights;
  70887. maxSimultaneousLights: number;
  70888. highLevelFur: boolean;
  70889. _meshes: BABYLON.AbstractMesh[];
  70890. private _renderId;
  70891. private _furTime;
  70892. constructor(name: string, scene: BABYLON.Scene);
  70893. furTime: number;
  70894. needAlphaBlending(): boolean;
  70895. needAlphaTesting(): boolean;
  70896. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70897. updateFur(): void;
  70898. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70899. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70900. getAnimatables(): BABYLON.IAnimatable[];
  70901. getActiveTextures(): BABYLON.BaseTexture[];
  70902. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70903. dispose(forceDisposeEffect?: boolean): void;
  70904. clone(name: string): FurMaterial;
  70905. serialize(): any;
  70906. getClassName(): string;
  70907. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  70908. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  70909. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  70910. }
  70911. }
  70912. declare module BABYLON {
  70913. /** @hidden */
  70914. export var gradientPixelShader: {
  70915. name: string;
  70916. shader: string;
  70917. };
  70918. }
  70919. declare module BABYLON {
  70920. /** @hidden */
  70921. export var gradientVertexShader: {
  70922. name: string;
  70923. shader: string;
  70924. };
  70925. }
  70926. declare module BABYLON {
  70927. export class GradientMaterial extends BABYLON.PushMaterial {
  70928. private _maxSimultaneousLights;
  70929. maxSimultaneousLights: number;
  70930. topColor: BABYLON.Color3;
  70931. topColorAlpha: number;
  70932. bottomColor: BABYLON.Color3;
  70933. bottomColorAlpha: number;
  70934. offset: number;
  70935. scale: number;
  70936. smoothness: number;
  70937. private _disableLighting;
  70938. disableLighting: boolean;
  70939. private _renderId;
  70940. constructor(name: string, scene: BABYLON.Scene);
  70941. needAlphaBlending(): boolean;
  70942. needAlphaTesting(): boolean;
  70943. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70944. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70945. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70946. getAnimatables(): BABYLON.IAnimatable[];
  70947. dispose(forceDisposeEffect?: boolean): void;
  70948. clone(name: string): GradientMaterial;
  70949. serialize(): any;
  70950. getClassName(): string;
  70951. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  70952. }
  70953. }
  70954. declare module BABYLON {
  70955. /** @hidden */
  70956. export var gridPixelShader: {
  70957. name: string;
  70958. shader: string;
  70959. };
  70960. }
  70961. declare module BABYLON {
  70962. /** @hidden */
  70963. export var gridVertexShader: {
  70964. name: string;
  70965. shader: string;
  70966. };
  70967. }
  70968. declare module BABYLON {
  70969. /**
  70970. * The grid materials allows you to wrap any shape with a grid.
  70971. * Colors are customizable.
  70972. */
  70973. export class GridMaterial extends BABYLON.PushMaterial {
  70974. /**
  70975. * Main color of the grid (e.g. between lines)
  70976. */
  70977. mainColor: BABYLON.Color3;
  70978. /**
  70979. * Color of the grid lines.
  70980. */
  70981. lineColor: BABYLON.Color3;
  70982. /**
  70983. * The scale of the grid compared to unit.
  70984. */
  70985. gridRatio: number;
  70986. /**
  70987. * Allows setting an offset for the grid lines.
  70988. */
  70989. gridOffset: BABYLON.Vector3;
  70990. /**
  70991. * The frequency of thicker lines.
  70992. */
  70993. majorUnitFrequency: number;
  70994. /**
  70995. * The visibility of minor units in the grid.
  70996. */
  70997. minorUnitVisibility: number;
  70998. /**
  70999. * The grid opacity outside of the lines.
  71000. */
  71001. opacity: number;
  71002. /**
  71003. * Determine RBG output is premultiplied by alpha value.
  71004. */
  71005. preMultiplyAlpha: boolean;
  71006. private _opacityTexture;
  71007. opacityTexture: BABYLON.BaseTexture;
  71008. private _gridControl;
  71009. private _renderId;
  71010. /**
  71011. * constructor
  71012. * @param name The name given to the material in order to identify it afterwards.
  71013. * @param scene The scene the material is used in.
  71014. */
  71015. constructor(name: string, scene: BABYLON.Scene);
  71016. /**
  71017. * Returns wehter or not the grid requires alpha blending.
  71018. */
  71019. needAlphaBlending(): boolean;
  71020. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71021. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71022. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71023. /**
  71024. * Dispose the material and its associated resources.
  71025. * @param forceDisposeEffect will also dispose the used effect when true
  71026. */
  71027. dispose(forceDisposeEffect?: boolean): void;
  71028. clone(name: string): GridMaterial;
  71029. serialize(): any;
  71030. getClassName(): string;
  71031. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  71032. }
  71033. }
  71034. declare module BABYLON {
  71035. /** @hidden */
  71036. export var lavaPixelShader: {
  71037. name: string;
  71038. shader: string;
  71039. };
  71040. }
  71041. declare module BABYLON {
  71042. /** @hidden */
  71043. export var lavaVertexShader: {
  71044. name: string;
  71045. shader: string;
  71046. };
  71047. }
  71048. declare module BABYLON {
  71049. export class LavaMaterial extends BABYLON.PushMaterial {
  71050. private _diffuseTexture;
  71051. diffuseTexture: BABYLON.BaseTexture;
  71052. noiseTexture: BABYLON.BaseTexture;
  71053. fogColor: BABYLON.Color3;
  71054. speed: number;
  71055. movingSpeed: number;
  71056. lowFrequencySpeed: number;
  71057. fogDensity: number;
  71058. private _lastTime;
  71059. diffuseColor: BABYLON.Color3;
  71060. private _disableLighting;
  71061. disableLighting: boolean;
  71062. private _unlit;
  71063. unlit: boolean;
  71064. private _maxSimultaneousLights;
  71065. maxSimultaneousLights: number;
  71066. private _scaledDiffuse;
  71067. private _renderId;
  71068. constructor(name: string, scene: BABYLON.Scene);
  71069. needAlphaBlending(): boolean;
  71070. needAlphaTesting(): boolean;
  71071. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71072. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71073. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71074. getAnimatables(): BABYLON.IAnimatable[];
  71075. getActiveTextures(): BABYLON.BaseTexture[];
  71076. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71077. dispose(forceDisposeEffect?: boolean): void;
  71078. clone(name: string): LavaMaterial;
  71079. serialize(): any;
  71080. getClassName(): string;
  71081. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  71082. }
  71083. }
  71084. declare module BABYLON {
  71085. /** @hidden */
  71086. export var mixPixelShader: {
  71087. name: string;
  71088. shader: string;
  71089. };
  71090. }
  71091. declare module BABYLON {
  71092. /** @hidden */
  71093. export var mixVertexShader: {
  71094. name: string;
  71095. shader: string;
  71096. };
  71097. }
  71098. declare module BABYLON {
  71099. export class MixMaterial extends BABYLON.PushMaterial {
  71100. /**
  71101. * Mix textures
  71102. */
  71103. private _mixTexture1;
  71104. mixTexture1: BABYLON.BaseTexture;
  71105. private _mixTexture2;
  71106. mixTexture2: BABYLON.BaseTexture;
  71107. /**
  71108. * Diffuse textures
  71109. */
  71110. private _diffuseTexture1;
  71111. diffuseTexture1: BABYLON.Texture;
  71112. private _diffuseTexture2;
  71113. diffuseTexture2: BABYLON.Texture;
  71114. private _diffuseTexture3;
  71115. diffuseTexture3: BABYLON.Texture;
  71116. private _diffuseTexture4;
  71117. diffuseTexture4: BABYLON.Texture;
  71118. private _diffuseTexture5;
  71119. diffuseTexture5: BABYLON.Texture;
  71120. private _diffuseTexture6;
  71121. diffuseTexture6: BABYLON.Texture;
  71122. private _diffuseTexture7;
  71123. diffuseTexture7: BABYLON.Texture;
  71124. private _diffuseTexture8;
  71125. diffuseTexture8: BABYLON.Texture;
  71126. /**
  71127. * Uniforms
  71128. */
  71129. diffuseColor: BABYLON.Color3;
  71130. specularColor: BABYLON.Color3;
  71131. specularPower: number;
  71132. private _disableLighting;
  71133. disableLighting: boolean;
  71134. private _maxSimultaneousLights;
  71135. maxSimultaneousLights: number;
  71136. private _renderId;
  71137. constructor(name: string, scene: BABYLON.Scene);
  71138. needAlphaBlending(): boolean;
  71139. needAlphaTesting(): boolean;
  71140. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71141. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71142. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71143. getAnimatables(): BABYLON.IAnimatable[];
  71144. getActiveTextures(): BABYLON.BaseTexture[];
  71145. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71146. dispose(forceDisposeEffect?: boolean): void;
  71147. clone(name: string): MixMaterial;
  71148. serialize(): any;
  71149. getClassName(): string;
  71150. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  71151. }
  71152. }
  71153. declare module BABYLON {
  71154. /** @hidden */
  71155. export var normalPixelShader: {
  71156. name: string;
  71157. shader: string;
  71158. };
  71159. }
  71160. declare module BABYLON {
  71161. /** @hidden */
  71162. export var normalVertexShader: {
  71163. name: string;
  71164. shader: string;
  71165. };
  71166. }
  71167. declare module BABYLON {
  71168. export class NormalMaterial extends BABYLON.PushMaterial {
  71169. private _diffuseTexture;
  71170. diffuseTexture: BABYLON.BaseTexture;
  71171. diffuseColor: BABYLON.Color3;
  71172. private _disableLighting;
  71173. disableLighting: boolean;
  71174. private _maxSimultaneousLights;
  71175. maxSimultaneousLights: number;
  71176. private _renderId;
  71177. constructor(name: string, scene: BABYLON.Scene);
  71178. needAlphaBlending(): boolean;
  71179. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71180. needAlphaTesting(): boolean;
  71181. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71182. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71183. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71184. getAnimatables(): BABYLON.IAnimatable[];
  71185. getActiveTextures(): BABYLON.BaseTexture[];
  71186. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71187. dispose(forceDisposeEffect?: boolean): void;
  71188. clone(name: string): NormalMaterial;
  71189. serialize(): any;
  71190. getClassName(): string;
  71191. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  71192. }
  71193. }
  71194. declare module BABYLON {
  71195. /** @hidden */
  71196. export var shadowOnlyPixelShader: {
  71197. name: string;
  71198. shader: string;
  71199. };
  71200. }
  71201. declare module BABYLON {
  71202. /** @hidden */
  71203. export var shadowOnlyVertexShader: {
  71204. name: string;
  71205. shader: string;
  71206. };
  71207. }
  71208. declare module BABYLON {
  71209. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  71210. private _renderId;
  71211. private _activeLight;
  71212. constructor(name: string, scene: BABYLON.Scene);
  71213. shadowColor: BABYLON.Color3;
  71214. needAlphaBlending(): boolean;
  71215. needAlphaTesting(): boolean;
  71216. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71217. activeLight: BABYLON.IShadowLight;
  71218. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71219. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71220. clone(name: string): ShadowOnlyMaterial;
  71221. serialize(): any;
  71222. getClassName(): string;
  71223. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  71224. }
  71225. }
  71226. declare module BABYLON {
  71227. /** @hidden */
  71228. export var simplePixelShader: {
  71229. name: string;
  71230. shader: string;
  71231. };
  71232. }
  71233. declare module BABYLON {
  71234. /** @hidden */
  71235. export var simpleVertexShader: {
  71236. name: string;
  71237. shader: string;
  71238. };
  71239. }
  71240. declare module BABYLON {
  71241. export class SimpleMaterial extends BABYLON.PushMaterial {
  71242. private _diffuseTexture;
  71243. diffuseTexture: BABYLON.BaseTexture;
  71244. diffuseColor: BABYLON.Color3;
  71245. private _disableLighting;
  71246. disableLighting: boolean;
  71247. private _maxSimultaneousLights;
  71248. maxSimultaneousLights: number;
  71249. private _renderId;
  71250. constructor(name: string, scene: BABYLON.Scene);
  71251. needAlphaBlending(): boolean;
  71252. needAlphaTesting(): boolean;
  71253. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71254. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71255. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71256. getAnimatables(): BABYLON.IAnimatable[];
  71257. getActiveTextures(): BABYLON.BaseTexture[];
  71258. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71259. dispose(forceDisposeEffect?: boolean): void;
  71260. clone(name: string): SimpleMaterial;
  71261. serialize(): any;
  71262. getClassName(): string;
  71263. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  71264. }
  71265. }
  71266. declare module BABYLON {
  71267. /** @hidden */
  71268. export var skyPixelShader: {
  71269. name: string;
  71270. shader: string;
  71271. };
  71272. }
  71273. declare module BABYLON {
  71274. /** @hidden */
  71275. export var skyVertexShader: {
  71276. name: string;
  71277. shader: string;
  71278. };
  71279. }
  71280. declare module BABYLON {
  71281. /**
  71282. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  71283. * @see https://doc.babylonjs.com/extensions/sky
  71284. */
  71285. export class SkyMaterial extends BABYLON.PushMaterial {
  71286. /**
  71287. * Defines the overall luminance of sky in interval ]0, 1[.
  71288. */
  71289. luminance: number;
  71290. /**
  71291. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  71292. */
  71293. turbidity: number;
  71294. /**
  71295. * Defines the sky appearance (light intensity).
  71296. */
  71297. rayleigh: number;
  71298. /**
  71299. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  71300. */
  71301. mieCoefficient: number;
  71302. /**
  71303. * Defines the amount of haze particles following the Mie scattering theory.
  71304. */
  71305. mieDirectionalG: number;
  71306. /**
  71307. * Defines the distance of the sun according to the active scene camera.
  71308. */
  71309. distance: number;
  71310. /**
  71311. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  71312. * "inclined".
  71313. */
  71314. inclination: number;
  71315. /**
  71316. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  71317. * an object direction and a reference direction.
  71318. */
  71319. azimuth: number;
  71320. /**
  71321. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  71322. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  71323. */
  71324. sunPosition: BABYLON.Vector3;
  71325. /**
  71326. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  71327. * .sunPosition property.
  71328. */
  71329. useSunPosition: boolean;
  71330. /**
  71331. * Defines an offset vector used to get a horizon offset.
  71332. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  71333. */
  71334. cameraOffset: BABYLON.Vector3;
  71335. private _cameraPosition;
  71336. private _renderId;
  71337. /**
  71338. * Instantiates a new sky material.
  71339. * This material allows to create dynamic and texture free
  71340. * effects for skyboxes by taking care of the atmosphere state.
  71341. * @see https://doc.babylonjs.com/extensions/sky
  71342. * @param name Define the name of the material in the scene
  71343. * @param scene Define the scene the material belong to
  71344. */
  71345. constructor(name: string, scene: BABYLON.Scene);
  71346. /**
  71347. * Specifies if the material will require alpha blending
  71348. * @returns a boolean specifying if alpha blending is needed
  71349. */
  71350. needAlphaBlending(): boolean;
  71351. /**
  71352. * Specifies if this material should be rendered in alpha test mode
  71353. * @returns false as the sky material doesn't need alpha testing.
  71354. */
  71355. needAlphaTesting(): boolean;
  71356. /**
  71357. * Get the texture used for alpha test purpose.
  71358. * @returns null as the sky material has no texture.
  71359. */
  71360. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71361. /**
  71362. * Get if the submesh is ready to be used and all its information available.
  71363. * Child classes can use it to update shaders
  71364. * @param mesh defines the mesh to check
  71365. * @param subMesh defines which submesh to check
  71366. * @param useInstances specifies that instances should be used
  71367. * @returns a boolean indicating that the submesh is ready or not
  71368. */
  71369. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71370. /**
  71371. * Binds the submesh to this material by preparing the effect and shader to draw
  71372. * @param world defines the world transformation matrix
  71373. * @param mesh defines the mesh containing the submesh
  71374. * @param subMesh defines the submesh to bind the material to
  71375. */
  71376. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71377. /**
  71378. * Get the list of animatables in the material.
  71379. * @returns the list of animatables object used in the material
  71380. */
  71381. getAnimatables(): BABYLON.IAnimatable[];
  71382. /**
  71383. * Disposes the material
  71384. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  71385. */
  71386. dispose(forceDisposeEffect?: boolean): void;
  71387. /**
  71388. * Makes a duplicate of the material, and gives it a new name
  71389. * @param name defines the new name for the duplicated material
  71390. * @returns the cloned material
  71391. */
  71392. clone(name: string): SkyMaterial;
  71393. /**
  71394. * Serializes this material in a JSON representation
  71395. * @returns the serialized material object
  71396. */
  71397. serialize(): any;
  71398. /**
  71399. * Gets the current class name of the material e.g. "SkyMaterial"
  71400. * Mainly use in serialization.
  71401. * @returns the class name
  71402. */
  71403. getClassName(): string;
  71404. /**
  71405. * Creates a sky material from parsed material data
  71406. * @param source defines the JSON representation of the material
  71407. * @param scene defines the hosting scene
  71408. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71409. * @returns a new sky material
  71410. */
  71411. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  71412. }
  71413. }
  71414. declare module BABYLON {
  71415. /** @hidden */
  71416. export var terrainPixelShader: {
  71417. name: string;
  71418. shader: string;
  71419. };
  71420. }
  71421. declare module BABYLON {
  71422. /** @hidden */
  71423. export var terrainVertexShader: {
  71424. name: string;
  71425. shader: string;
  71426. };
  71427. }
  71428. declare module BABYLON {
  71429. export class TerrainMaterial extends BABYLON.PushMaterial {
  71430. private _mixTexture;
  71431. mixTexture: BABYLON.BaseTexture;
  71432. private _diffuseTexture1;
  71433. diffuseTexture1: BABYLON.Texture;
  71434. private _diffuseTexture2;
  71435. diffuseTexture2: BABYLON.Texture;
  71436. private _diffuseTexture3;
  71437. diffuseTexture3: BABYLON.Texture;
  71438. private _bumpTexture1;
  71439. bumpTexture1: BABYLON.Texture;
  71440. private _bumpTexture2;
  71441. bumpTexture2: BABYLON.Texture;
  71442. private _bumpTexture3;
  71443. bumpTexture3: BABYLON.Texture;
  71444. diffuseColor: BABYLON.Color3;
  71445. specularColor: BABYLON.Color3;
  71446. specularPower: number;
  71447. private _disableLighting;
  71448. disableLighting: boolean;
  71449. private _maxSimultaneousLights;
  71450. maxSimultaneousLights: number;
  71451. private _renderId;
  71452. constructor(name: string, scene: BABYLON.Scene);
  71453. needAlphaBlending(): boolean;
  71454. needAlphaTesting(): boolean;
  71455. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71456. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71457. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71458. getAnimatables(): BABYLON.IAnimatable[];
  71459. getActiveTextures(): BABYLON.BaseTexture[];
  71460. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71461. dispose(forceDisposeEffect?: boolean): void;
  71462. clone(name: string): TerrainMaterial;
  71463. serialize(): any;
  71464. getClassName(): string;
  71465. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  71466. }
  71467. }
  71468. declare module BABYLON {
  71469. /** @hidden */
  71470. export var triplanarPixelShader: {
  71471. name: string;
  71472. shader: string;
  71473. };
  71474. }
  71475. declare module BABYLON {
  71476. /** @hidden */
  71477. export var triplanarVertexShader: {
  71478. name: string;
  71479. shader: string;
  71480. };
  71481. }
  71482. declare module BABYLON {
  71483. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  71484. mixTexture: BABYLON.BaseTexture;
  71485. private _diffuseTextureX;
  71486. diffuseTextureX: BABYLON.BaseTexture;
  71487. private _diffuseTextureY;
  71488. diffuseTextureY: BABYLON.BaseTexture;
  71489. private _diffuseTextureZ;
  71490. diffuseTextureZ: BABYLON.BaseTexture;
  71491. private _normalTextureX;
  71492. normalTextureX: BABYLON.BaseTexture;
  71493. private _normalTextureY;
  71494. normalTextureY: BABYLON.BaseTexture;
  71495. private _normalTextureZ;
  71496. normalTextureZ: BABYLON.BaseTexture;
  71497. tileSize: number;
  71498. diffuseColor: BABYLON.Color3;
  71499. specularColor: BABYLON.Color3;
  71500. specularPower: number;
  71501. private _disableLighting;
  71502. disableLighting: boolean;
  71503. private _maxSimultaneousLights;
  71504. maxSimultaneousLights: number;
  71505. private _renderId;
  71506. constructor(name: string, scene: BABYLON.Scene);
  71507. needAlphaBlending(): boolean;
  71508. needAlphaTesting(): boolean;
  71509. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71510. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71511. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71512. getAnimatables(): BABYLON.IAnimatable[];
  71513. getActiveTextures(): BABYLON.BaseTexture[];
  71514. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71515. dispose(forceDisposeEffect?: boolean): void;
  71516. clone(name: string): TriPlanarMaterial;
  71517. serialize(): any;
  71518. getClassName(): string;
  71519. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  71520. }
  71521. }
  71522. declare module BABYLON {
  71523. /** @hidden */
  71524. export var waterPixelShader: {
  71525. name: string;
  71526. shader: string;
  71527. };
  71528. }
  71529. declare module BABYLON {
  71530. /** @hidden */
  71531. export var waterVertexShader: {
  71532. name: string;
  71533. shader: string;
  71534. };
  71535. }
  71536. declare module BABYLON {
  71537. export class WaterMaterial extends BABYLON.PushMaterial {
  71538. renderTargetSize: BABYLON.Vector2;
  71539. private _bumpTexture;
  71540. bumpTexture: BABYLON.BaseTexture;
  71541. diffuseColor: BABYLON.Color3;
  71542. specularColor: BABYLON.Color3;
  71543. specularPower: number;
  71544. private _disableLighting;
  71545. disableLighting: boolean;
  71546. private _maxSimultaneousLights;
  71547. maxSimultaneousLights: number;
  71548. /**
  71549. * @param {number}: Represents the wind force
  71550. */
  71551. windForce: number;
  71552. /**
  71553. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  71554. */
  71555. windDirection: BABYLON.Vector2;
  71556. /**
  71557. * @param {number}: Wave height, represents the height of the waves
  71558. */
  71559. waveHeight: number;
  71560. /**
  71561. * @param {number}: Bump height, represents the bump height related to the bump map
  71562. */
  71563. bumpHeight: number;
  71564. /**
  71565. * @param {boolean}: Add a smaller moving bump to less steady waves.
  71566. */
  71567. private _bumpSuperimpose;
  71568. bumpSuperimpose: boolean;
  71569. /**
  71570. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  71571. */
  71572. private _fresnelSeparate;
  71573. fresnelSeparate: boolean;
  71574. /**
  71575. * @param {boolean}: bump Waves modify the reflection.
  71576. */
  71577. private _bumpAffectsReflection;
  71578. bumpAffectsReflection: boolean;
  71579. /**
  71580. * @param {number}: The water color blended with the refraction (near)
  71581. */
  71582. waterColor: BABYLON.Color3;
  71583. /**
  71584. * @param {number}: The blend factor related to the water color
  71585. */
  71586. colorBlendFactor: number;
  71587. /**
  71588. * @param {number}: The water color blended with the reflection (far)
  71589. */
  71590. waterColor2: BABYLON.Color3;
  71591. /**
  71592. * @param {number}: The blend factor related to the water color (reflection, far)
  71593. */
  71594. colorBlendFactor2: number;
  71595. /**
  71596. * @param {number}: Represents the maximum length of a wave
  71597. */
  71598. waveLength: number;
  71599. /**
  71600. * @param {number}: Defines the waves speed
  71601. */
  71602. waveSpeed: number;
  71603. /**
  71604. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  71605. * will avoid calculating useless pixels in the pixel shader of the water material.
  71606. */
  71607. disableClipPlane: boolean;
  71608. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  71609. private _mesh;
  71610. private _refractionRTT;
  71611. private _reflectionRTT;
  71612. private _reflectionTransform;
  71613. private _lastTime;
  71614. private _lastDeltaTime;
  71615. private _renderId;
  71616. private _useLogarithmicDepth;
  71617. private _waitingRenderList;
  71618. private _imageProcessingConfiguration;
  71619. private _imageProcessingObserver;
  71620. /**
  71621. * Gets a boolean indicating that current material needs to register RTT
  71622. */
  71623. readonly hasRenderTargetTextures: boolean;
  71624. /**
  71625. * Constructor
  71626. */
  71627. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  71628. useLogarithmicDepth: boolean;
  71629. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  71630. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  71631. addToRenderList(node: any): void;
  71632. enableRenderTargets(enable: boolean): void;
  71633. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  71634. readonly renderTargetsEnabled: boolean;
  71635. needAlphaBlending(): boolean;
  71636. needAlphaTesting(): boolean;
  71637. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71638. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71639. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71640. private _createRenderTargets;
  71641. getAnimatables(): BABYLON.IAnimatable[];
  71642. getActiveTextures(): BABYLON.BaseTexture[];
  71643. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71644. dispose(forceDisposeEffect?: boolean): void;
  71645. clone(name: string): WaterMaterial;
  71646. serialize(): any;
  71647. getClassName(): string;
  71648. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  71649. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  71650. }
  71651. }
  71652. declare module BABYLON {
  71653. /** @hidden */
  71654. export var asciiartPixelShader: {
  71655. name: string;
  71656. shader: string;
  71657. };
  71658. }
  71659. declare module BABYLON {
  71660. /**
  71661. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  71662. *
  71663. * It basically takes care rendering the font front the given font size to a texture.
  71664. * This is used later on in the postprocess.
  71665. */
  71666. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  71667. private _font;
  71668. private _text;
  71669. private _charSize;
  71670. /**
  71671. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71672. */
  71673. readonly charSize: number;
  71674. /**
  71675. * Create a new instance of the Ascii Art FontTexture class
  71676. * @param name the name of the texture
  71677. * @param font the font to use, use the W3C CSS notation
  71678. * @param text the caracter set to use in the rendering.
  71679. * @param scene the scene that owns the texture
  71680. */
  71681. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71682. /**
  71683. * Gets the max char width of a font.
  71684. * @param font the font to use, use the W3C CSS notation
  71685. * @return the max char width
  71686. */
  71687. private getFontWidth;
  71688. /**
  71689. * Gets the max char height of a font.
  71690. * @param font the font to use, use the W3C CSS notation
  71691. * @return the max char height
  71692. */
  71693. private getFontHeight;
  71694. /**
  71695. * Clones the current AsciiArtTexture.
  71696. * @return the clone of the texture.
  71697. */
  71698. clone(): AsciiArtFontTexture;
  71699. /**
  71700. * Parses a json object representing the texture and returns an instance of it.
  71701. * @param source the source JSON representation
  71702. * @param scene the scene to create the texture for
  71703. * @return the parsed texture
  71704. */
  71705. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  71706. }
  71707. /**
  71708. * Option available in the Ascii Art Post Process.
  71709. */
  71710. export interface IAsciiArtPostProcessOptions {
  71711. /**
  71712. * The font to use following the w3c font definition.
  71713. */
  71714. font?: string;
  71715. /**
  71716. * The character set to use in the postprocess.
  71717. */
  71718. characterSet?: string;
  71719. /**
  71720. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71721. * This number is defined between 0 and 1;
  71722. */
  71723. mixToTile?: number;
  71724. /**
  71725. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71726. * This number is defined between 0 and 1;
  71727. */
  71728. mixToNormal?: number;
  71729. }
  71730. /**
  71731. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  71732. *
  71733. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71734. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  71735. */
  71736. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  71737. /**
  71738. * The font texture used to render the char in the post process.
  71739. */
  71740. private _asciiArtFontTexture;
  71741. /**
  71742. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71743. * This number is defined between 0 and 1;
  71744. */
  71745. mixToTile: number;
  71746. /**
  71747. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71748. * This number is defined between 0 and 1;
  71749. */
  71750. mixToNormal: number;
  71751. /**
  71752. * Instantiates a new Ascii Art Post Process.
  71753. * @param name the name to give to the postprocess
  71754. * @camera the camera to apply the post process to.
  71755. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  71756. */
  71757. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  71758. }
  71759. }
  71760. declare module BABYLON {
  71761. /** @hidden */
  71762. export var digitalrainPixelShader: {
  71763. name: string;
  71764. shader: string;
  71765. };
  71766. }
  71767. declare module BABYLON {
  71768. /**
  71769. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  71770. *
  71771. * It basically takes care rendering the font front the given font size to a texture.
  71772. * This is used later on in the postprocess.
  71773. */
  71774. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  71775. private _font;
  71776. private _text;
  71777. private _charSize;
  71778. /**
  71779. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71780. */
  71781. readonly charSize: number;
  71782. /**
  71783. * Create a new instance of the Digital Rain FontTexture class
  71784. * @param name the name of the texture
  71785. * @param font the font to use, use the W3C CSS notation
  71786. * @param text the caracter set to use in the rendering.
  71787. * @param scene the scene that owns the texture
  71788. */
  71789. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71790. /**
  71791. * Gets the max char width of a font.
  71792. * @param font the font to use, use the W3C CSS notation
  71793. * @return the max char width
  71794. */
  71795. private getFontWidth;
  71796. /**
  71797. * Gets the max char height of a font.
  71798. * @param font the font to use, use the W3C CSS notation
  71799. * @return the max char height
  71800. */
  71801. private getFontHeight;
  71802. /**
  71803. * Clones the current DigitalRainFontTexture.
  71804. * @return the clone of the texture.
  71805. */
  71806. clone(): DigitalRainFontTexture;
  71807. /**
  71808. * Parses a json object representing the texture and returns an instance of it.
  71809. * @param source the source JSON representation
  71810. * @param scene the scene to create the texture for
  71811. * @return the parsed texture
  71812. */
  71813. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  71814. }
  71815. /**
  71816. * Option available in the Digital Rain Post Process.
  71817. */
  71818. export interface IDigitalRainPostProcessOptions {
  71819. /**
  71820. * The font to use following the w3c font definition.
  71821. */
  71822. font?: string;
  71823. /**
  71824. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71825. * This number is defined between 0 and 1;
  71826. */
  71827. mixToTile?: number;
  71828. /**
  71829. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71830. * This number is defined between 0 and 1;
  71831. */
  71832. mixToNormal?: number;
  71833. }
  71834. /**
  71835. * DigitalRainPostProcess helps rendering everithing in digital rain.
  71836. *
  71837. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71838. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  71839. */
  71840. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  71841. /**
  71842. * The font texture used to render the char in the post process.
  71843. */
  71844. private _digitalRainFontTexture;
  71845. /**
  71846. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71847. * This number is defined between 0 and 1;
  71848. */
  71849. mixToTile: number;
  71850. /**
  71851. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71852. * This number is defined between 0 and 1;
  71853. */
  71854. mixToNormal: number;
  71855. /**
  71856. * Instantiates a new Digital Rain Post Process.
  71857. * @param name the name to give to the postprocess
  71858. * @camera the camera to apply the post process to.
  71859. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  71860. */
  71861. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  71862. }
  71863. }
  71864. declare module BABYLON {
  71865. /** @hidden */
  71866. export var oceanPostProcessPixelShader: {
  71867. name: string;
  71868. shader: string;
  71869. };
  71870. }
  71871. declare module BABYLON {
  71872. /**
  71873. * Option available in the Ocean Post Process.
  71874. */
  71875. export interface IOceanPostProcessOptions {
  71876. /**
  71877. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71878. */
  71879. reflectionSize?: number | {
  71880. width: number;
  71881. height: number;
  71882. } | {
  71883. ratio: number;
  71884. };
  71885. /**
  71886. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71887. */
  71888. refractionSize?: number | {
  71889. width: number;
  71890. height: number;
  71891. } | {
  71892. ratio: number;
  71893. };
  71894. }
  71895. /**
  71896. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  71897. *
  71898. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71899. * Example usage:
  71900. * var pp = new OceanPostProcess("myOcean", camera);
  71901. * pp.reflectionEnabled = true;
  71902. * pp.refractionEnabled = true;
  71903. */
  71904. export class OceanPostProcess extends BABYLON.PostProcess {
  71905. /**
  71906. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  71907. */
  71908. /**
  71909. * Sets weither or not the real-time reflection is enabled on the ocean.
  71910. * Is set to true, the reflection mirror texture will be used as reflection texture.
  71911. */
  71912. reflectionEnabled: boolean;
  71913. /**
  71914. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  71915. */
  71916. /**
  71917. * Sets weither or not the real-time refraction is enabled on the ocean.
  71918. * Is set to true, the refraction render target texture will be used as refraction texture.
  71919. */
  71920. refractionEnabled: boolean;
  71921. /**
  71922. * Gets wether or not the post-processes is supported by the running hardware.
  71923. * This requires draw buffer supports.
  71924. */
  71925. readonly isSupported: boolean;
  71926. /**
  71927. * This is the reflection mirror texture used to display reflections on the ocean.
  71928. * By default, render list is empty.
  71929. */
  71930. reflectionTexture: BABYLON.MirrorTexture;
  71931. /**
  71932. * This is the refraction render target texture used to display refraction on the ocean.
  71933. * By default, render list is empty.
  71934. */
  71935. refractionTexture: BABYLON.RenderTargetTexture;
  71936. private _time;
  71937. private _cameraRotation;
  71938. private _cameraViewMatrix;
  71939. private _reflectionEnabled;
  71940. private _refractionEnabled;
  71941. private _geometryRenderer;
  71942. /**
  71943. * Instantiates a new Ocean Post Process.
  71944. * @param name the name to give to the postprocess.
  71945. * @camera the camera to apply the post process to.
  71946. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  71947. */
  71948. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  71949. /**
  71950. * Returns the appropriate defines according to the current configuration.
  71951. */
  71952. private _getDefines;
  71953. /**
  71954. * Computes the current camera rotation as the shader requires a camera rotation.
  71955. */
  71956. private _computeCameraRotation;
  71957. }
  71958. }
  71959. declare module BABYLON {
  71960. /** @hidden */
  71961. export var brickProceduralTexturePixelShader: {
  71962. name: string;
  71963. shader: string;
  71964. };
  71965. }
  71966. declare module BABYLON {
  71967. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  71968. private _numberOfBricksHeight;
  71969. private _numberOfBricksWidth;
  71970. private _jointColor;
  71971. private _brickColor;
  71972. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71973. updateShaderUniforms(): void;
  71974. numberOfBricksHeight: number;
  71975. numberOfBricksWidth: number;
  71976. jointColor: BABYLON.Color3;
  71977. brickColor: BABYLON.Color3;
  71978. /**
  71979. * Serializes this brick procedural texture
  71980. * @returns a serialized brick procedural texture object
  71981. */
  71982. serialize(): any;
  71983. /**
  71984. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  71985. * @param parsedTexture defines parsed texture data
  71986. * @param scene defines the current scene
  71987. * @param rootUrl defines the root URL containing brick procedural texture information
  71988. * @returns a parsed Brick Procedural BABYLON.Texture
  71989. */
  71990. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  71991. }
  71992. }
  71993. declare module BABYLON {
  71994. /** @hidden */
  71995. export var cloudProceduralTexturePixelShader: {
  71996. name: string;
  71997. shader: string;
  71998. };
  71999. }
  72000. declare module BABYLON {
  72001. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  72002. private _skyColor;
  72003. private _cloudColor;
  72004. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72005. updateShaderUniforms(): void;
  72006. skyColor: BABYLON.Color4;
  72007. cloudColor: BABYLON.Color4;
  72008. /**
  72009. * Serializes this cloud procedural texture
  72010. * @returns a serialized cloud procedural texture object
  72011. */
  72012. serialize(): any;
  72013. /**
  72014. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  72015. * @param parsedTexture defines parsed texture data
  72016. * @param scene defines the current scene
  72017. * @param rootUrl defines the root URL containing cloud procedural texture information
  72018. * @returns a parsed Cloud Procedural BABYLON.Texture
  72019. */
  72020. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  72021. }
  72022. }
  72023. declare module BABYLON {
  72024. /** @hidden */
  72025. export var fireProceduralTexturePixelShader: {
  72026. name: string;
  72027. shader: string;
  72028. };
  72029. }
  72030. declare module BABYLON {
  72031. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  72032. private _time;
  72033. private _speed;
  72034. private _autoGenerateTime;
  72035. private _fireColors;
  72036. private _alphaThreshold;
  72037. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72038. updateShaderUniforms(): void;
  72039. render(useCameraPostProcess?: boolean): void;
  72040. static readonly PurpleFireColors: BABYLON.Color3[];
  72041. static readonly GreenFireColors: BABYLON.Color3[];
  72042. static readonly RedFireColors: BABYLON.Color3[];
  72043. static readonly BlueFireColors: BABYLON.Color3[];
  72044. autoGenerateTime: boolean;
  72045. fireColors: BABYLON.Color3[];
  72046. time: number;
  72047. speed: BABYLON.Vector2;
  72048. alphaThreshold: number;
  72049. /**
  72050. * Serializes this fire procedural texture
  72051. * @returns a serialized fire procedural texture object
  72052. */
  72053. serialize(): any;
  72054. /**
  72055. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  72056. * @param parsedTexture defines parsed texture data
  72057. * @param scene defines the current scene
  72058. * @param rootUrl defines the root URL containing fire procedural texture information
  72059. * @returns a parsed Fire Procedural BABYLON.Texture
  72060. */
  72061. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  72062. }
  72063. }
  72064. declare module BABYLON {
  72065. /** @hidden */
  72066. export var grassProceduralTexturePixelShader: {
  72067. name: string;
  72068. shader: string;
  72069. };
  72070. }
  72071. declare module BABYLON {
  72072. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  72073. private _grassColors;
  72074. private _groundColor;
  72075. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72076. updateShaderUniforms(): void;
  72077. grassColors: BABYLON.Color3[];
  72078. groundColor: BABYLON.Color3;
  72079. /**
  72080. * Serializes this grass procedural texture
  72081. * @returns a serialized grass procedural texture object
  72082. */
  72083. serialize(): any;
  72084. /**
  72085. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  72086. * @param parsedTexture defines parsed texture data
  72087. * @param scene defines the current scene
  72088. * @param rootUrl defines the root URL containing grass procedural texture information
  72089. * @returns a parsed Grass Procedural BABYLON.Texture
  72090. */
  72091. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  72092. }
  72093. }
  72094. declare module BABYLON {
  72095. /** @hidden */
  72096. export var marbleProceduralTexturePixelShader: {
  72097. name: string;
  72098. shader: string;
  72099. };
  72100. }
  72101. declare module BABYLON {
  72102. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  72103. private _numberOfTilesHeight;
  72104. private _numberOfTilesWidth;
  72105. private _amplitude;
  72106. private _jointColor;
  72107. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72108. updateShaderUniforms(): void;
  72109. numberOfTilesHeight: number;
  72110. amplitude: number;
  72111. numberOfTilesWidth: number;
  72112. jointColor: BABYLON.Color3;
  72113. /**
  72114. * Serializes this marble procedural texture
  72115. * @returns a serialized marble procedural texture object
  72116. */
  72117. serialize(): any;
  72118. /**
  72119. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  72120. * @param parsedTexture defines parsed texture data
  72121. * @param scene defines the current scene
  72122. * @param rootUrl defines the root URL containing marble procedural texture information
  72123. * @returns a parsed Marble Procedural BABYLON.Texture
  72124. */
  72125. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  72126. }
  72127. }
  72128. declare module BABYLON {
  72129. /** @hidden */
  72130. export var normalMapProceduralTexturePixelShader: {
  72131. name: string;
  72132. shader: string;
  72133. };
  72134. }
  72135. declare module BABYLON {
  72136. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  72137. private _baseTexture;
  72138. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72139. updateShaderUniforms(): void;
  72140. render(useCameraPostProcess?: boolean): void;
  72141. resize(size: any, generateMipMaps: any): void;
  72142. baseTexture: BABYLON.Texture;
  72143. /**
  72144. * Serializes this normal map procedural texture
  72145. * @returns a serialized normal map procedural texture object
  72146. */
  72147. serialize(): any;
  72148. /**
  72149. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  72150. * @param parsedTexture defines parsed texture data
  72151. * @param scene defines the current scene
  72152. * @param rootUrl defines the root URL containing normal map procedural texture information
  72153. * @returns a parsed Normal Map Procedural BABYLON.Texture
  72154. */
  72155. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  72156. }
  72157. }
  72158. declare module BABYLON {
  72159. /** @hidden */
  72160. export var perlinNoiseProceduralTexturePixelShader: {
  72161. name: string;
  72162. shader: string;
  72163. };
  72164. }
  72165. declare module BABYLON {
  72166. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  72167. time: number;
  72168. timeScale: number;
  72169. translationSpeed: number;
  72170. private _currentTranslation;
  72171. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72172. updateShaderUniforms(): void;
  72173. render(useCameraPostProcess?: boolean): void;
  72174. resize(size: any, generateMipMaps: any): void;
  72175. /**
  72176. * Serializes this perlin noise procedural texture
  72177. * @returns a serialized perlin noise procedural texture object
  72178. */
  72179. serialize(): any;
  72180. /**
  72181. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  72182. * @param parsedTexture defines parsed texture data
  72183. * @param scene defines the current scene
  72184. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  72185. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  72186. */
  72187. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  72188. }
  72189. }
  72190. declare module BABYLON {
  72191. /** @hidden */
  72192. export var roadProceduralTexturePixelShader: {
  72193. name: string;
  72194. shader: string;
  72195. };
  72196. }
  72197. declare module BABYLON {
  72198. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  72199. private _roadColor;
  72200. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72201. updateShaderUniforms(): void;
  72202. roadColor: BABYLON.Color3;
  72203. /**
  72204. * Serializes this road procedural texture
  72205. * @returns a serialized road procedural texture object
  72206. */
  72207. serialize(): any;
  72208. /**
  72209. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  72210. * @param parsedTexture defines parsed texture data
  72211. * @param scene defines the current scene
  72212. * @param rootUrl defines the root URL containing road procedural texture information
  72213. * @returns a parsed Road Procedural BABYLON.Texture
  72214. */
  72215. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  72216. }
  72217. }
  72218. declare module BABYLON {
  72219. /** @hidden */
  72220. export var starfieldProceduralTexturePixelShader: {
  72221. name: string;
  72222. shader: string;
  72223. };
  72224. }
  72225. declare module BABYLON {
  72226. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  72227. private _time;
  72228. private _alpha;
  72229. private _beta;
  72230. private _zoom;
  72231. private _formuparam;
  72232. private _stepsize;
  72233. private _tile;
  72234. private _brightness;
  72235. private _darkmatter;
  72236. private _distfading;
  72237. private _saturation;
  72238. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72239. updateShaderUniforms(): void;
  72240. time: number;
  72241. alpha: number;
  72242. beta: number;
  72243. formuparam: number;
  72244. stepsize: number;
  72245. zoom: number;
  72246. tile: number;
  72247. brightness: number;
  72248. darkmatter: number;
  72249. distfading: number;
  72250. saturation: number;
  72251. /**
  72252. * Serializes this starfield procedural texture
  72253. * @returns a serialized starfield procedural texture object
  72254. */
  72255. serialize(): any;
  72256. /**
  72257. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  72258. * @param parsedTexture defines parsed texture data
  72259. * @param scene defines the current scene
  72260. * @param rootUrl defines the root URL containing startfield procedural texture information
  72261. * @returns a parsed Starfield Procedural BABYLON.Texture
  72262. */
  72263. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  72264. }
  72265. }
  72266. declare module BABYLON {
  72267. /** @hidden */
  72268. export var woodProceduralTexturePixelShader: {
  72269. name: string;
  72270. shader: string;
  72271. };
  72272. }
  72273. declare module BABYLON {
  72274. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  72275. private _ampScale;
  72276. private _woodColor;
  72277. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72278. updateShaderUniforms(): void;
  72279. ampScale: number;
  72280. woodColor: BABYLON.Color3;
  72281. /**
  72282. * Serializes this wood procedural texture
  72283. * @returns a serialized wood procedural texture object
  72284. */
  72285. serialize(): any;
  72286. /**
  72287. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  72288. * @param parsedTexture defines parsed texture data
  72289. * @param scene defines the current scene
  72290. * @param rootUrl defines the root URL containing wood procedural texture information
  72291. * @returns a parsed Wood Procedural BABYLON.Texture
  72292. */
  72293. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  72294. }
  72295. }