babylon.d.ts 2.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /**
  62. * Gets the list of root nodes (ie. nodes with no parent)
  63. */
  64. rootNodes: Node[];
  65. /** All of the cameras added to this scene
  66. * @see http://doc.babylonjs.com/babylon101/cameras
  67. */
  68. cameras: Camera[];
  69. /**
  70. * All of the lights added to this scene
  71. * @see http://doc.babylonjs.com/babylon101/lights
  72. */
  73. lights: Light[];
  74. /**
  75. * All of the (abstract) meshes added to this scene
  76. */
  77. meshes: AbstractMesh[];
  78. /**
  79. * The list of skeletons added to the scene
  80. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81. */
  82. skeletons: Skeleton[];
  83. /**
  84. * All of the particle systems added to this scene
  85. * @see http://doc.babylonjs.com/babylon101/particles
  86. */
  87. particleSystems: IParticleSystem[];
  88. /**
  89. * Gets a list of Animations associated with the scene
  90. */
  91. animations: Animation[];
  92. /**
  93. * All of the animation groups added to this scene
  94. * @see http://doc.babylonjs.com/how_to/group
  95. */
  96. animationGroups: AnimationGroup[];
  97. /**
  98. * All of the multi-materials added to this scene
  99. * @see http://doc.babylonjs.com/how_to/multi_materials
  100. */
  101. multiMaterials: MultiMaterial[];
  102. /**
  103. * All of the materials added to this scene
  104. * In the context of a Scene, it is not supposed to be modified manually.
  105. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  106. * Note also that the order of the Material wihin the array is not significant and might change.
  107. * @see http://doc.babylonjs.com/babylon101/materials
  108. */
  109. materials: Material[];
  110. /**
  111. * The list of morph target managers added to the scene
  112. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  113. */
  114. morphTargetManagers: MorphTargetManager[];
  115. /**
  116. * The list of geometries used in the scene.
  117. */
  118. geometries: Geometry[];
  119. /**
  120. * All of the tranform nodes added to this scene
  121. * In the context of a Scene, it is not supposed to be modified manually.
  122. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  123. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  124. * @see http://doc.babylonjs.com/how_to/transformnode
  125. */
  126. transformNodes: TransformNode[];
  127. /**
  128. * ActionManagers available on the scene.
  129. */
  130. actionManagers: ActionManager[];
  131. /**
  132. * Textures to keep.
  133. */
  134. textures: BaseTexture[];
  135. }
  136. }
  137. declare module BABYLON {
  138. /**
  139. * Set of assets to keep when moving a scene into an asset container.
  140. */
  141. class KeepAssets extends AbstractScene {
  142. }
  143. /**
  144. * Container with a set of assets that can be added or removed from a scene.
  145. */
  146. class AssetContainer extends AbstractScene {
  147. /**
  148. * The scene the AssetContainer belongs to.
  149. */
  150. scene: Scene;
  151. /**
  152. * Instantiates an AssetContainer.
  153. * @param scene The scene the AssetContainer belongs to.
  154. */
  155. constructor(scene: Scene);
  156. /**
  157. * Adds all the assets from the container to the scene.
  158. */
  159. addAllToScene(): void;
  160. /**
  161. * Removes all the assets in the container from the scene
  162. */
  163. removeAllFromScene(): void;
  164. private _moveAssets;
  165. /**
  166. * Removes all the assets contained in the scene and adds them to the container.
  167. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  168. */
  169. moveAllFromScene(keepAssets?: KeepAssets): void;
  170. /**
  171. * 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.
  172. * @returns the root mesh
  173. */
  174. createRootMesh(): Mesh;
  175. }
  176. }
  177. interface Window {
  178. mozIndexedDB: IDBFactory;
  179. webkitIndexedDB: IDBFactory;
  180. msIndexedDB: IDBFactory;
  181. webkitURL: typeof URL;
  182. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  183. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  184. WebGLRenderingContext: WebGLRenderingContext;
  185. MSGesture: MSGesture;
  186. CANNON: any;
  187. AudioContext: AudioContext;
  188. webkitAudioContext: AudioContext;
  189. PointerEvent: any;
  190. Math: Math;
  191. Uint8Array: Uint8ArrayConstructor;
  192. Float32Array: Float32ArrayConstructor;
  193. mozURL: typeof URL;
  194. msURL: typeof URL;
  195. VRFrameData: any;
  196. DracoDecoderModule: any;
  197. setImmediate(handler: (...args: any[]) => void): number;
  198. }
  199. interface WebGLProgram {
  200. context?: WebGLRenderingContext;
  201. vertexShader?: WebGLShader;
  202. fragmentShader?: WebGLShader;
  203. isParallelCompiled: boolean;
  204. onCompiled?: () => void;
  205. }
  206. interface WebGLRenderingContext {
  207. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  208. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  209. vertexAttribDivisor(index: number, divisor: number): void;
  210. createVertexArray(): any;
  211. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  212. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  213. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  214. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  215. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  216. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  217. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  218. createQuery(): WebGLQuery;
  219. deleteQuery(query: WebGLQuery): void;
  220. beginQuery(target: number, query: WebGLQuery): void;
  221. endQuery(target: number): void;
  222. getQueryParameter(query: WebGLQuery, pname: number): any;
  223. getQuery(target: number, pname: number): any;
  224. MAX_SAMPLES: number;
  225. RGBA8: number;
  226. READ_FRAMEBUFFER: number;
  227. DRAW_FRAMEBUFFER: number;
  228. UNIFORM_BUFFER: number;
  229. HALF_FLOAT_OES: number;
  230. RGBA16F: number;
  231. RGBA32F: number;
  232. R32F: number;
  233. RG32F: number;
  234. RGB32F: number;
  235. R16F: number;
  236. RG16F: number;
  237. RGB16F: number;
  238. RED: number;
  239. RG: number;
  240. R8: number;
  241. RG8: number;
  242. UNSIGNED_INT_24_8: number;
  243. DEPTH24_STENCIL8: number;
  244. drawBuffers(buffers: number[]): void;
  245. readBuffer(src: number): void;
  246. readonly COLOR_ATTACHMENT0: number;
  247. readonly COLOR_ATTACHMENT1: number;
  248. readonly COLOR_ATTACHMENT2: number;
  249. readonly COLOR_ATTACHMENT3: number;
  250. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  251. ANY_SAMPLES_PASSED: number;
  252. QUERY_RESULT_AVAILABLE: number;
  253. QUERY_RESULT: number;
  254. }
  255. interface Document {
  256. mozCancelFullScreen(): void;
  257. msCancelFullScreen(): void;
  258. webkitCancelFullScreen(): void;
  259. requestPointerLock(): void;
  260. exitPointerLock(): void;
  261. mozFullScreen: boolean;
  262. msIsFullScreen: boolean;
  263. readonly webkitIsFullScreen: boolean;
  264. readonly pointerLockElement: Element;
  265. mozPointerLockElement: HTMLElement;
  266. msPointerLockElement: HTMLElement;
  267. webkitPointerLockElement: HTMLElement;
  268. }
  269. interface HTMLCanvasElement {
  270. requestPointerLock(): void;
  271. msRequestPointerLock?(): void;
  272. mozRequestPointerLock?(): void;
  273. webkitRequestPointerLock?(): void;
  274. }
  275. interface CanvasRenderingContext2D {
  276. msImageSmoothingEnabled: boolean;
  277. }
  278. interface WebGLBuffer {
  279. references: number;
  280. capacity: number;
  281. is32Bits: boolean;
  282. }
  283. interface WebGLProgram {
  284. transformFeedback?: WebGLTransformFeedback | null;
  285. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  286. }
  287. interface MouseEvent {
  288. mozMovementX: number;
  289. mozMovementY: number;
  290. webkitMovementX: number;
  291. webkitMovementY: number;
  292. msMovementX: number;
  293. msMovementY: number;
  294. }
  295. interface Navigator {
  296. mozGetVRDevices: (any: any) => any;
  297. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  298. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  299. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  300. webkitGetGamepads(): Gamepad[];
  301. msGetGamepads(): Gamepad[];
  302. webkitGamepads(): Gamepad[];
  303. }
  304. interface HTMLVideoElement {
  305. mozSrcObject: any;
  306. }
  307. interface Math {
  308. fround(x: number): number;
  309. imul(a: number, b: number): number;
  310. }
  311. interface EXT_disjoint_timer_query {
  312. QUERY_COUNTER_BITS_EXT: number;
  313. TIME_ELAPSED_EXT: number;
  314. TIMESTAMP_EXT: number;
  315. GPU_DISJOINT_EXT: number;
  316. QUERY_RESULT_EXT: number;
  317. QUERY_RESULT_AVAILABLE_EXT: number;
  318. queryCounterEXT(query: WebGLQuery, target: number): void;
  319. createQueryEXT(): WebGLQuery;
  320. beginQueryEXT(target: number, query: WebGLQuery): void;
  321. endQueryEXT(target: number): void;
  322. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  323. deleteQueryEXT(query: WebGLQuery): void;
  324. }
  325. interface WebGLUniformLocation {
  326. _currentState: any;
  327. }
  328. interface XRDevice {
  329. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  330. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  331. }
  332. interface XRSession {
  333. baseLayer: XRWebGLLayer;
  334. requestFrameOfReference(type: string): Promise<void>;
  335. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  336. end(): Promise<void>;
  337. requestAnimationFrame: Function;
  338. addEventListener: Function;
  339. }
  340. interface XRSessionCreationOptions {
  341. outputContext?: WebGLRenderingContext | null;
  342. immersive?: boolean;
  343. environmentIntegration?: boolean;
  344. }
  345. interface XRLayer {
  346. getViewport: Function;
  347. framebufferWidth: number;
  348. framebufferHeight: number;
  349. }
  350. interface XRView {
  351. projectionMatrix: Float32Array;
  352. }
  353. interface XRFrame {
  354. getDevicePose: Function;
  355. views: Array<XRView>;
  356. baseLayer: XRLayer;
  357. }
  358. interface XRFrameOfReference {
  359. }
  360. interface XRWebGLLayer extends XRLayer {
  361. framebuffer: WebGLFramebuffer;
  362. }
  363. declare var XRWebGLLayer: {
  364. prototype: XRWebGLLayer;
  365. new (session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  366. };
  367. declare module BABYLON {
  368. /**
  369. * Defines how a node can be built from a string name.
  370. */
  371. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  372. /**
  373. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  374. */
  375. class Node implements IBehaviorAware<Node> {
  376. private static _NodeConstructors;
  377. /**
  378. * Add a new node constructor
  379. * @param type defines the type name of the node to construct
  380. * @param constructorFunc defines the constructor function
  381. */
  382. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  383. /**
  384. * Returns a node constructor based on type name
  385. * @param type defines the type name
  386. * @param name defines the new node name
  387. * @param scene defines the hosting scene
  388. * @param options defines optional options to transmit to constructors
  389. * @returns the new constructor or null
  390. */
  391. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  392. /**
  393. * Gets or sets the name of the node
  394. */
  395. name: string;
  396. /**
  397. * Gets or sets the id of the node
  398. */
  399. id: string;
  400. /**
  401. * Gets or sets the unique id of the node
  402. */
  403. uniqueId: number;
  404. /**
  405. * Gets or sets a string used to store user defined state for the node
  406. */
  407. state: string;
  408. /**
  409. * Gets or sets an object used to store user defined information for the node
  410. */
  411. metadata: any;
  412. /**
  413. * Gets or sets a boolean used to define if the node must be serialized
  414. */
  415. doNotSerialize: boolean;
  416. /** @hidden */
  417. _isDisposed: boolean;
  418. /**
  419. * Gets a list of Animations associated with the node
  420. */
  421. animations: Animation[];
  422. protected _ranges: {
  423. [name: string]: Nullable<AnimationRange>;
  424. };
  425. /**
  426. * Callback raised when the node is ready to be used
  427. */
  428. onReady: (node: Node) => void;
  429. private _isEnabled;
  430. private _isParentEnabled;
  431. private _isReady;
  432. /** @hidden */
  433. _currentRenderId: number;
  434. private _parentRenderId;
  435. protected _childRenderId: number;
  436. /** @hidden */
  437. _waitingParentId: Nullable<string>;
  438. /** @hidden */
  439. _scene: Scene;
  440. /** @hidden */
  441. _cache: any;
  442. private _parentNode;
  443. private _children;
  444. /** @hidden */
  445. _worldMatrix: Matrix;
  446. /** @hidden */
  447. _worldMatrixDeterminant: number;
  448. /** @hidden */
  449. private _sceneRootNodesIndex;
  450. /**
  451. * Gets a boolean indicating if the node has been disposed
  452. * @returns true if the node was disposed
  453. */
  454. isDisposed(): boolean;
  455. /**
  456. * Gets or sets the parent of the node
  457. */
  458. parent: Nullable<Node>;
  459. private addToSceneRootNodes;
  460. private removeFromSceneRootNodes;
  461. private _animationPropertiesOverride;
  462. /**
  463. * Gets or sets the animation properties override
  464. */
  465. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  466. /**
  467. * Gets a string idenfifying the name of the class
  468. * @returns "Node" string
  469. */
  470. getClassName(): string;
  471. /**
  472. * An event triggered when the mesh is disposed
  473. */
  474. onDisposeObservable: Observable<Node>;
  475. private _onDisposeObserver;
  476. /**
  477. * Sets a callback that will be raised when the node will be disposed
  478. */
  479. onDispose: () => void;
  480. /**
  481. * Creates a new Node
  482. * @param name the name and id to be given to this node
  483. * @param scene the scene this node will be added to
  484. */
  485. constructor(name: string, scene?: Nullable<Scene>);
  486. /**
  487. * Gets the scene of the node
  488. * @returns a scene
  489. */
  490. getScene(): Scene;
  491. /**
  492. * Gets the engine of the node
  493. * @returns a Engine
  494. */
  495. getEngine(): Engine;
  496. private _behaviors;
  497. /**
  498. * Attach a behavior to the node
  499. * @see http://doc.babylonjs.com/features/behaviour
  500. * @param behavior defines the behavior to attach
  501. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  502. * @returns the current Node
  503. */
  504. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  505. /**
  506. * Remove an attached behavior
  507. * @see http://doc.babylonjs.com/features/behaviour
  508. * @param behavior defines the behavior to attach
  509. * @returns the current Node
  510. */
  511. removeBehavior(behavior: Behavior<Node>): Node;
  512. /**
  513. * Gets the list of attached behaviors
  514. * @see http://doc.babylonjs.com/features/behaviour
  515. */
  516. readonly behaviors: Behavior<Node>[];
  517. /**
  518. * Gets an attached behavior by name
  519. * @param name defines the name of the behavior to look for
  520. * @see http://doc.babylonjs.com/features/behaviour
  521. * @returns null if behavior was not found else the requested behavior
  522. */
  523. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  524. /**
  525. * Returns the latest update of the World matrix
  526. * @returns a Matrix
  527. */
  528. getWorldMatrix(): Matrix;
  529. /** @hidden */
  530. _getWorldMatrixDeterminant(): number;
  531. /**
  532. * Returns directly the latest state of the mesh World matrix.
  533. * A Matrix is returned.
  534. */
  535. readonly worldMatrixFromCache: Matrix;
  536. /** @hidden */
  537. _initCache(): void;
  538. /** @hidden */
  539. updateCache(force?: boolean): void;
  540. /** @hidden */
  541. _updateCache(ignoreParentClass?: boolean): void;
  542. /** @hidden */
  543. _isSynchronized(): boolean;
  544. /** @hidden */
  545. _markSyncedWithParent(): void;
  546. /** @hidden */
  547. isSynchronizedWithParent(): boolean;
  548. /** @hidden */
  549. isSynchronized(): boolean;
  550. /**
  551. * Is this node ready to be used/rendered
  552. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  553. * @return true if the node is ready
  554. */
  555. isReady(completeCheck?: boolean): boolean;
  556. /**
  557. * Is this node enabled?
  558. * 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
  559. * @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
  560. * @return whether this node (and its parent) is enabled
  561. */
  562. isEnabled(checkAncestors?: boolean): boolean;
  563. /** @hidden */
  564. protected _syncParentEnabledState(): void;
  565. /**
  566. * Set the enabled state of this node
  567. * @param value defines the new enabled state
  568. */
  569. setEnabled(value: boolean): void;
  570. /**
  571. * Is this node a descendant of the given node?
  572. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  573. * @param ancestor defines the parent node to inspect
  574. * @returns a boolean indicating if this node is a descendant of the given node
  575. */
  576. isDescendantOf(ancestor: Node): boolean;
  577. /** @hidden */
  578. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  579. /**
  580. * Will return all nodes that have this node as ascendant
  581. * @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
  582. * @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
  583. * @return all children nodes of all types
  584. */
  585. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  586. /**
  587. * Get all child-meshes of this node
  588. * @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
  589. * @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
  590. * @returns an array of AbstractMesh
  591. */
  592. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  593. /**
  594. * Get all child-transformNodes of this node
  595. * @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
  596. * @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
  597. * @returns an array of TransformNode
  598. */
  599. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  600. /**
  601. * Get all direct children of this node
  602. * @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
  603. * @returns an array of Node
  604. */
  605. getChildren(predicate?: (node: Node) => boolean): Node[];
  606. /** @hidden */
  607. _setReady(state: boolean): void;
  608. /**
  609. * Get an animation by name
  610. * @param name defines the name of the animation to look for
  611. * @returns null if not found else the requested animation
  612. */
  613. getAnimationByName(name: string): Nullable<Animation>;
  614. /**
  615. * Creates an animation range for this node
  616. * @param name defines the name of the range
  617. * @param from defines the starting key
  618. * @param to defines the end key
  619. */
  620. createAnimationRange(name: string, from: number, to: number): void;
  621. /**
  622. * Delete a specific animation range
  623. * @param name defines the name of the range to delete
  624. * @param deleteFrames defines if animation frames from the range must be deleted as well
  625. */
  626. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  627. /**
  628. * Get an animation range by name
  629. * @param name defines the name of the animation range to look for
  630. * @returns null if not found else the requested animation range
  631. */
  632. getAnimationRange(name: string): Nullable<AnimationRange>;
  633. /**
  634. * Will start the animation sequence
  635. * @param name defines the range frames for animation sequence
  636. * @param loop defines if the animation should loop (false by default)
  637. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  638. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  639. * @returns the object created for this animation. If range does not exist, it will return null
  640. */
  641. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  642. /**
  643. * Serialize animation ranges into a JSON compatible object
  644. * @returns serialization object
  645. */
  646. serializeAnimationRanges(): any;
  647. /**
  648. * Computes the world matrix of the node
  649. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  650. * @returns the world matrix
  651. */
  652. computeWorldMatrix(force?: boolean): Matrix;
  653. /**
  654. * Releases resources associated with this node.
  655. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  656. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  657. */
  658. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  659. /**
  660. * Parse animation range data from a serialization object and store them into a given node
  661. * @param node defines where to store the animation ranges
  662. * @param parsedNode defines the serialization object to read data from
  663. * @param scene defines the hosting scene
  664. */
  665. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  666. }
  667. }
  668. declare module BABYLON {
  669. /**
  670. * Define an interface for all classes that will hold resources
  671. */
  672. interface IDisposable {
  673. /**
  674. * Releases all held resources
  675. */
  676. dispose(): void;
  677. }
  678. /**
  679. * This class is used by the onRenderingGroupObservable
  680. */
  681. class RenderingGroupInfo {
  682. /**
  683. * The Scene that being rendered
  684. */
  685. scene: Scene;
  686. /**
  687. * The camera currently used for the rendering pass
  688. */
  689. camera: Nullable<Camera>;
  690. /**
  691. * The ID of the renderingGroup being processed
  692. */
  693. renderingGroupId: number;
  694. }
  695. /** Interface defining initialization parameters for Scene class */
  696. interface SceneOptions {
  697. /**
  698. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by Id
  699. * It will improve performance when the number of geometries becomes important.
  700. */
  701. useGeometryIdsMap?: boolean;
  702. /**
  703. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  704. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  705. */
  706. useMaterialMeshMap?: boolean;
  707. /**
  708. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  709. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  710. */
  711. useClonedMeshhMap?: boolean;
  712. }
  713. /**
  714. * Represents a scene to be rendered by the engine.
  715. * @see http://doc.babylonjs.com/features/scene
  716. */
  717. class Scene extends AbstractScene implements IAnimatable {
  718. private static _uniqueIdCounter;
  719. /** The fog is deactivated */
  720. static readonly FOGMODE_NONE: number;
  721. /** The fog density is following an exponential function */
  722. static readonly FOGMODE_EXP: number;
  723. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  724. static readonly FOGMODE_EXP2: number;
  725. /** The fog density is following a linear function. */
  726. static readonly FOGMODE_LINEAR: number;
  727. /**
  728. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  729. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  730. */
  731. static MinDeltaTime: number;
  732. /**
  733. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  734. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  735. */
  736. static MaxDeltaTime: number;
  737. /**
  738. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  739. */
  740. autoClear: boolean;
  741. /**
  742. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  743. */
  744. autoClearDepthAndStencil: boolean;
  745. /**
  746. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  747. */
  748. clearColor: Color4;
  749. /**
  750. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  751. */
  752. ambientColor: Color3;
  753. /** @hidden */
  754. _environmentBRDFTexture: BaseTexture;
  755. /** @hidden */
  756. protected _environmentTexture: BaseTexture;
  757. /**
  758. * Texture used in all pbr material as the reflection texture.
  759. * As in the majority of the scene they are the same (exception for multi room and so on),
  760. * this is easier to reference from here than from all the materials.
  761. */
  762. /**
  763. * Texture used in all pbr material as the reflection texture.
  764. * As in the majority of the scene they are the same (exception for multi room and so on),
  765. * this is easier to set here than in all the materials.
  766. */
  767. environmentTexture: BaseTexture;
  768. /** @hidden */
  769. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  770. /**
  771. * Default image processing configuration used either in the rendering
  772. * Forward main pass or through the imageProcessingPostProcess if present.
  773. * As in the majority of the scene they are the same (exception for multi camera),
  774. * this is easier to reference from here than from all the materials and post process.
  775. *
  776. * No setter as we it is a shared configuration, you can set the values instead.
  777. */
  778. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  779. private _forceWireframe;
  780. /**
  781. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  782. */
  783. forceWireframe: boolean;
  784. private _forcePointsCloud;
  785. /**
  786. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  787. */
  788. forcePointsCloud: boolean;
  789. /**
  790. * Gets or sets the active clipplane 1
  791. */
  792. clipPlane: Nullable<Plane>;
  793. /**
  794. * Gets or sets the active clipplane 2
  795. */
  796. clipPlane2: Nullable<Plane>;
  797. /**
  798. * Gets or sets the active clipplane 3
  799. */
  800. clipPlane3: Nullable<Plane>;
  801. /**
  802. * Gets or sets the active clipplane 4
  803. */
  804. clipPlane4: Nullable<Plane>;
  805. /**
  806. * Gets or sets a boolean indicating if animations are enabled
  807. */
  808. animationsEnabled: boolean;
  809. private _animationPropertiesOverride;
  810. /**
  811. * Gets or sets the animation properties override
  812. */
  813. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  814. /**
  815. * Gets or sets a boolean indicating if a constant deltatime has to be used
  816. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  817. */
  818. useConstantAnimationDeltaTime: boolean;
  819. /**
  820. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  821. * Please note that it requires to run a ray cast through the scene on every frame
  822. */
  823. constantlyUpdateMeshUnderPointer: boolean;
  824. /**
  825. * Defines the HTML cursor to use when hovering over interactive elements
  826. */
  827. hoverCursor: string;
  828. /**
  829. * Defines the HTML default cursor to use (empty by default)
  830. */
  831. defaultCursor: string;
  832. /**
  833. * This is used to call preventDefault() on pointer down
  834. * in order to block unwanted artifacts like system double clicks
  835. */
  836. preventDefaultOnPointerDown: boolean;
  837. /**
  838. * This is used to call preventDefault() on pointer up
  839. * in order to block unwanted artifacts like system double clicks
  840. */
  841. preventDefaultOnPointerUp: boolean;
  842. /**
  843. * Gets or sets user defined metadata
  844. */
  845. metadata: any;
  846. /**
  847. * Gets the name of the plugin used to load this scene (null by default)
  848. */
  849. loadingPluginName: string;
  850. /**
  851. * Use this array to add regular expressions used to disable offline support for specific urls
  852. */
  853. disableOfflineSupportExceptionRules: RegExp[];
  854. /**
  855. * An event triggered when the scene is disposed.
  856. */
  857. onDisposeObservable: Observable<Scene>;
  858. private _onDisposeObserver;
  859. /** Sets a function to be executed when this scene is disposed. */
  860. onDispose: () => void;
  861. /**
  862. * An event triggered before rendering the scene (right after animations and physics)
  863. */
  864. onBeforeRenderObservable: Observable<Scene>;
  865. private _onBeforeRenderObserver;
  866. /** Sets a function to be executed before rendering this scene */
  867. beforeRender: Nullable<() => void>;
  868. /**
  869. * An event triggered after rendering the scene
  870. */
  871. onAfterRenderObservable: Observable<Scene>;
  872. private _onAfterRenderObserver;
  873. /** Sets a function to be executed after rendering this scene */
  874. afterRender: Nullable<() => void>;
  875. /**
  876. * An event triggered before animating the scene
  877. */
  878. onBeforeAnimationsObservable: Observable<Scene>;
  879. /**
  880. * An event triggered after animations processing
  881. */
  882. onAfterAnimationsObservable: Observable<Scene>;
  883. /**
  884. * An event triggered before draw calls are ready to be sent
  885. */
  886. onBeforeDrawPhaseObservable: Observable<Scene>;
  887. /**
  888. * An event triggered after draw calls have been sent
  889. */
  890. onAfterDrawPhaseObservable: Observable<Scene>;
  891. /**
  892. * An event triggered when the scene is ready
  893. */
  894. onReadyObservable: Observable<Scene>;
  895. /**
  896. * An event triggered before rendering a camera
  897. */
  898. onBeforeCameraRenderObservable: Observable<Camera>;
  899. private _onBeforeCameraRenderObserver;
  900. /** Sets a function to be executed before rendering a camera*/
  901. beforeCameraRender: () => void;
  902. /**
  903. * An event triggered after rendering a camera
  904. */
  905. onAfterCameraRenderObservable: Observable<Camera>;
  906. private _onAfterCameraRenderObserver;
  907. /** Sets a function to be executed after rendering a camera*/
  908. afterCameraRender: () => void;
  909. /**
  910. * An event triggered when active meshes evaluation is about to start
  911. */
  912. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  913. /**
  914. * An event triggered when active meshes evaluation is done
  915. */
  916. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  917. /**
  918. * An event triggered when particles rendering is about to start
  919. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  920. */
  921. onBeforeParticlesRenderingObservable: Observable<Scene>;
  922. /**
  923. * An event triggered when particles rendering is done
  924. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  925. */
  926. onAfterParticlesRenderingObservable: Observable<Scene>;
  927. /**
  928. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  929. */
  930. onDataLoadedObservable: Observable<Scene>;
  931. /**
  932. * An event triggered when a camera is created
  933. */
  934. onNewCameraAddedObservable: Observable<Camera>;
  935. /**
  936. * An event triggered when a camera is removed
  937. */
  938. onCameraRemovedObservable: Observable<Camera>;
  939. /**
  940. * An event triggered when a light is created
  941. */
  942. onNewLightAddedObservable: Observable<Light>;
  943. /**
  944. * An event triggered when a light is removed
  945. */
  946. onLightRemovedObservable: Observable<Light>;
  947. /**
  948. * An event triggered when a geometry is created
  949. */
  950. onNewGeometryAddedObservable: Observable<Geometry>;
  951. /**
  952. * An event triggered when a geometry is removed
  953. */
  954. onGeometryRemovedObservable: Observable<Geometry>;
  955. /**
  956. * An event triggered when a transform node is created
  957. */
  958. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  959. /**
  960. * An event triggered when a transform node is removed
  961. */
  962. onTransformNodeRemovedObservable: Observable<TransformNode>;
  963. /**
  964. * An event triggered when a mesh is created
  965. */
  966. onNewMeshAddedObservable: Observable<AbstractMesh>;
  967. /**
  968. * An event triggered when a mesh is removed
  969. */
  970. onMeshRemovedObservable: Observable<AbstractMesh>;
  971. /**
  972. * An event triggered when a material is created
  973. */
  974. onNewMaterialAddedObservable: Observable<Material>;
  975. /**
  976. * An event triggered when a material is removed
  977. */
  978. onMaterialRemovedObservable: Observable<Material>;
  979. /**
  980. * An event triggered when a texture is created
  981. */
  982. onNewTextureAddedObservable: Observable<BaseTexture>;
  983. /**
  984. * An event triggered when a texture is removed
  985. */
  986. onTextureRemovedObservable: Observable<BaseTexture>;
  987. /**
  988. * An event triggered when render targets are about to be rendered
  989. * Can happen multiple times per frame.
  990. */
  991. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  992. /**
  993. * An event triggered when render targets were rendered.
  994. * Can happen multiple times per frame.
  995. */
  996. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  997. /**
  998. * An event triggered before calculating deterministic simulation step
  999. */
  1000. onBeforeStepObservable: Observable<Scene>;
  1001. /**
  1002. * An event triggered after calculating deterministic simulation step
  1003. */
  1004. onAfterStepObservable: Observable<Scene>;
  1005. /**
  1006. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  1007. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1008. * 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)
  1009. */
  1010. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1011. /**
  1012. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  1013. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1014. * 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)
  1015. */
  1016. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1017. /**
  1018. * This Observable will when a mesh has been imported into the scene.
  1019. */
  1020. onMeshImportedObservable: Observable<AbstractMesh>;
  1021. private _registeredForLateAnimationBindings;
  1022. /**
  1023. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  1024. */
  1025. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  1026. /**
  1027. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  1028. */
  1029. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  1030. /**
  1031. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  1032. */
  1033. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  1034. private _onPointerMove;
  1035. private _onPointerDown;
  1036. private _onPointerUp;
  1037. /** Deprecated. Use onPointerObservable instead */
  1038. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1039. /** Deprecated. Use onPointerObservable instead */
  1040. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1041. /** Deprecated. Use onPointerObservable instead */
  1042. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  1043. /** Deprecated. Use onPointerObservable instead */
  1044. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  1045. /**
  1046. * 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).
  1047. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  1048. */
  1049. onPrePointerObservable: Observable<PointerInfoPre>;
  1050. /**
  1051. * Observable event triggered each time an input event is received from the rendering canvas
  1052. */
  1053. onPointerObservable: Observable<PointerInfo>;
  1054. /**
  1055. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  1056. */
  1057. readonly unTranslatedPointer: Vector2;
  1058. /** The distance in pixel that you have to move to prevent some events */
  1059. static DragMovementThreshold: number;
  1060. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1061. static LongPressDelay: number;
  1062. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1063. static DoubleClickDelay: number;
  1064. /** If you need to check double click without raising a single click at first click, enable this flag */
  1065. static ExclusiveDoubleClickMode: boolean;
  1066. private _initClickEvent;
  1067. private _initActionManager;
  1068. private _delayedSimpleClick;
  1069. private _delayedSimpleClickTimeout;
  1070. private _previousDelayedSimpleClickTimeout;
  1071. private _meshPickProceed;
  1072. private _previousButtonPressed;
  1073. private _currentPickResult;
  1074. private _previousPickResult;
  1075. private _totalPointersPressed;
  1076. private _doubleClickOccured;
  1077. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1078. cameraToUseForPointers: Nullable<Camera>;
  1079. private _pointerX;
  1080. private _pointerY;
  1081. private _unTranslatedPointerX;
  1082. private _unTranslatedPointerY;
  1083. private _startingPointerPosition;
  1084. private _previousStartingPointerPosition;
  1085. private _startingPointerTime;
  1086. private _previousStartingPointerTime;
  1087. private _pointerCaptures;
  1088. private _timeAccumulator;
  1089. private _currentStepId;
  1090. private _currentInternalStep;
  1091. /** @hidden */
  1092. _mirroredCameraPosition: Nullable<Vector3>;
  1093. /**
  1094. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1095. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1096. */
  1097. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1098. /**
  1099. * Observable event triggered each time an keyboard event is received from the hosting window
  1100. */
  1101. onKeyboardObservable: Observable<KeyboardInfo>;
  1102. private _onKeyDown;
  1103. private _onKeyUp;
  1104. private _onCanvasFocusObserver;
  1105. private _onCanvasBlurObserver;
  1106. private _useRightHandedSystem;
  1107. /**
  1108. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1109. */
  1110. useRightHandedSystem: boolean;
  1111. /**
  1112. * Sets the step Id used by deterministic lock step
  1113. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1114. * @param newStepId defines the step Id
  1115. */
  1116. setStepId(newStepId: number): void;
  1117. /**
  1118. * Gets the step Id used by deterministic lock step
  1119. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1120. * @returns the step Id
  1121. */
  1122. getStepId(): number;
  1123. /**
  1124. * Gets the internal step used by deterministic lock step
  1125. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1126. * @returns the internal step
  1127. */
  1128. getInternalStep(): number;
  1129. private _fogEnabled;
  1130. /**
  1131. * Gets or sets a boolean indicating if fog is enabled on this scene
  1132. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1133. * (Default is true)
  1134. */
  1135. fogEnabled: boolean;
  1136. private _fogMode;
  1137. /**
  1138. * Gets or sets the fog mode to use
  1139. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1140. * | mode | value |
  1141. * | --- | --- |
  1142. * | FOGMODE_NONE | 0 |
  1143. * | FOGMODE_EXP | 1 |
  1144. * | FOGMODE_EXP2 | 2 |
  1145. * | FOGMODE_LINEAR | 3 |
  1146. */
  1147. fogMode: number;
  1148. /**
  1149. * Gets or sets the fog color to use
  1150. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1151. * (Default is Color3(0.2, 0.2, 0.3))
  1152. */
  1153. fogColor: Color3;
  1154. /**
  1155. * Gets or sets the fog density to use
  1156. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1157. * (Default is 0.1)
  1158. */
  1159. fogDensity: number;
  1160. /**
  1161. * Gets or sets the fog start distance to use
  1162. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1163. * (Default is 0)
  1164. */
  1165. fogStart: number;
  1166. /**
  1167. * Gets or sets the fog end distance to use
  1168. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1169. * (Default is 1000)
  1170. */
  1171. fogEnd: number;
  1172. private _shadowsEnabled;
  1173. /**
  1174. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1175. */
  1176. shadowsEnabled: boolean;
  1177. private _lightsEnabled;
  1178. /**
  1179. * Gets or sets a boolean indicating if lights are enabled on this scene
  1180. */
  1181. lightsEnabled: boolean;
  1182. /** All of the active cameras added to this scene. */
  1183. activeCameras: Camera[];
  1184. /** The current active camera */
  1185. activeCamera: Nullable<Camera>;
  1186. private _defaultMaterial;
  1187. /** The default material used on meshes when no material is affected */
  1188. /** The default material used on meshes when no material is affected */
  1189. defaultMaterial: Material;
  1190. private _texturesEnabled;
  1191. /**
  1192. * Gets or sets a boolean indicating if textures are enabled on this scene
  1193. */
  1194. texturesEnabled: boolean;
  1195. /**
  1196. * Gets or sets a boolean indicating if particles are enabled on this scene
  1197. */
  1198. particlesEnabled: boolean;
  1199. /**
  1200. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1201. */
  1202. spritesEnabled: boolean;
  1203. private _skeletonsEnabled;
  1204. /**
  1205. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1206. */
  1207. skeletonsEnabled: boolean;
  1208. /**
  1209. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1210. */
  1211. lensFlaresEnabled: boolean;
  1212. /**
  1213. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1214. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1215. */
  1216. collisionsEnabled: boolean;
  1217. private _workerCollisions;
  1218. /** @hidden */
  1219. collisionCoordinator: ICollisionCoordinator;
  1220. /**
  1221. * Defines the gravity applied to this scene (used only for collisions)
  1222. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1223. */
  1224. gravity: Vector3;
  1225. /**
  1226. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1227. */
  1228. postProcessesEnabled: boolean;
  1229. /**
  1230. * The list of postprocesses added to the scene
  1231. */
  1232. postProcesses: PostProcess[];
  1233. /**
  1234. * Gets the current postprocess manager
  1235. */
  1236. postProcessManager: PostProcessManager;
  1237. /**
  1238. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1239. */
  1240. renderTargetsEnabled: boolean;
  1241. /**
  1242. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1243. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1244. */
  1245. dumpNextRenderTargets: boolean;
  1246. /**
  1247. * The list of user defined render targets added to the scene
  1248. */
  1249. customRenderTargets: RenderTargetTexture[];
  1250. /**
  1251. * Defines if texture loading must be delayed
  1252. * If true, textures will only be loaded when they need to be rendered
  1253. */
  1254. useDelayedTextureLoading: boolean;
  1255. /**
  1256. * Gets the list of meshes imported to the scene through SceneLoader
  1257. */
  1258. importedMeshesFiles: String[];
  1259. /**
  1260. * Gets or sets a boolean indicating if probes are enabled on this scene
  1261. */
  1262. probesEnabled: boolean;
  1263. /**
  1264. * Gets or sets the current offline provider to use to store scene data
  1265. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1266. */
  1267. offlineProvider: IOfflineProvider;
  1268. /**
  1269. * Gets or sets the action manager associated with the scene
  1270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1271. */
  1272. actionManager: ActionManager;
  1273. private _meshesForIntersections;
  1274. /**
  1275. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1276. */
  1277. proceduralTexturesEnabled: boolean;
  1278. private _engine;
  1279. private _totalVertices;
  1280. /** @hidden */
  1281. _activeIndices: PerfCounter;
  1282. /** @hidden */
  1283. _activeParticles: PerfCounter;
  1284. /** @hidden */
  1285. _activeBones: PerfCounter;
  1286. private _animationRatio;
  1287. private _animationTimeLast;
  1288. private _animationTime;
  1289. /**
  1290. * Gets or sets a general scale for animation speed
  1291. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1292. */
  1293. animationTimeScale: number;
  1294. /** @hidden */
  1295. _cachedMaterial: Nullable<Material>;
  1296. /** @hidden */
  1297. _cachedEffect: Nullable<Effect>;
  1298. /** @hidden */
  1299. _cachedVisibility: Nullable<number>;
  1300. private _renderId;
  1301. private _frameId;
  1302. private _executeWhenReadyTimeoutId;
  1303. private _intermediateRendering;
  1304. private _viewUpdateFlag;
  1305. private _projectionUpdateFlag;
  1306. private _alternateViewUpdateFlag;
  1307. private _alternateProjectionUpdateFlag;
  1308. /** @hidden */
  1309. _toBeDisposed: Nullable<IDisposable>[];
  1310. private _activeRequests;
  1311. private _pendingData;
  1312. private _isDisposed;
  1313. /**
  1314. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1315. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1316. */
  1317. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1318. private _activeMeshes;
  1319. private _processedMaterials;
  1320. private _renderTargets;
  1321. /** @hidden */
  1322. _activeParticleSystems: SmartArray<IParticleSystem>;
  1323. private _activeSkeletons;
  1324. private _softwareSkinnedMeshes;
  1325. private _renderingManager;
  1326. /** @hidden */
  1327. _activeAnimatables: Animatable[];
  1328. private _transformMatrix;
  1329. private _sceneUbo;
  1330. private _alternateSceneUbo;
  1331. private _pickWithRayInverseMatrix;
  1332. private _viewMatrix;
  1333. private _projectionMatrix;
  1334. private _alternateViewMatrix;
  1335. private _alternateProjectionMatrix;
  1336. private _alternateTransformMatrix;
  1337. private _useAlternateCameraConfiguration;
  1338. private _alternateRendering;
  1339. private _wheelEventName;
  1340. /** @hidden */
  1341. _forcedViewPosition: Nullable<Vector3>;
  1342. /** @hidden */
  1343. readonly _isAlternateRenderingEnabled: boolean;
  1344. private _frustumPlanes;
  1345. /**
  1346. * Gets the list of frustum planes (built from the active camera)
  1347. */
  1348. readonly frustumPlanes: Plane[];
  1349. /**
  1350. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1351. * This is useful if there are more lights that the maximum simulteanous authorized
  1352. */
  1353. requireLightSorting: boolean;
  1354. /** @hidden */
  1355. readonly useMaterialMeshMap: boolean;
  1356. /** @hidden */
  1357. readonly useClonedMeshhMap: boolean;
  1358. private _pointerOverMesh;
  1359. private _pickedDownMesh;
  1360. private _pickedUpMesh;
  1361. private _externalData;
  1362. private _uid;
  1363. /**
  1364. * @hidden
  1365. * Backing store of defined scene components.
  1366. */
  1367. _components: ISceneComponent[];
  1368. /**
  1369. * @hidden
  1370. * Backing store of defined scene components.
  1371. */
  1372. _serializableComponents: ISceneSerializableComponent[];
  1373. /**
  1374. * List of components to register on the next registration step.
  1375. */
  1376. private _transientComponents;
  1377. /**
  1378. * Registers the transient components if needed.
  1379. */
  1380. private _registerTransientComponents;
  1381. /**
  1382. * @hidden
  1383. * Add a component to the scene.
  1384. * Note that the ccomponent could be registered on th next frame if this is called after
  1385. * the register component stage.
  1386. * @param component Defines the component to add to the scene
  1387. */
  1388. _addComponent(component: ISceneComponent): void;
  1389. /**
  1390. * @hidden
  1391. * Gets a component from the scene.
  1392. * @param name defines the name of the component to retrieve
  1393. * @returns the component or null if not present
  1394. */
  1395. _getComponent(name: string): Nullable<ISceneComponent>;
  1396. /**
  1397. * @hidden
  1398. * Defines the actions happening before camera updates.
  1399. */
  1400. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1401. /**
  1402. * @hidden
  1403. * Defines the actions happening before clear the canvas.
  1404. */
  1405. _beforeClearStage: Stage<SimpleStageAction>;
  1406. /**
  1407. * @hidden
  1408. * Defines the actions when collecting render targets for the frame.
  1409. */
  1410. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1411. /**
  1412. * @hidden
  1413. * Defines the actions happening for one camera in the frame.
  1414. */
  1415. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1416. /**
  1417. * @hidden
  1418. * Defines the actions happening during the per mesh ready checks.
  1419. */
  1420. _isReadyForMeshStage: Stage<MeshStageAction>;
  1421. /**
  1422. * @hidden
  1423. * Defines the actions happening before evaluate active mesh checks.
  1424. */
  1425. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1426. /**
  1427. * @hidden
  1428. * Defines the actions happening during the evaluate sub mesh checks.
  1429. */
  1430. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1431. /**
  1432. * @hidden
  1433. * Defines the actions happening during the active mesh stage.
  1434. */
  1435. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1436. /**
  1437. * @hidden
  1438. * Defines the actions happening during the per camera render target step.
  1439. */
  1440. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1441. /**
  1442. * @hidden
  1443. * Defines the actions happening just before the active camera is drawing.
  1444. */
  1445. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1446. /**
  1447. * @hidden
  1448. * Defines the actions happening just before a rendering group is drawing.
  1449. */
  1450. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1451. /**
  1452. * @hidden
  1453. * Defines the actions happening just before a mesh is drawing.
  1454. */
  1455. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1456. /**
  1457. * @hidden
  1458. * Defines the actions happening just after a mesh has been drawn.
  1459. */
  1460. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1461. /**
  1462. * @hidden
  1463. * Defines the actions happening just after a rendering group has been drawn.
  1464. */
  1465. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1466. /**
  1467. * @hidden
  1468. * Defines the actions happening just after the active camera has been drawn.
  1469. */
  1470. _afterCameraDrawStage: Stage<CameraStageAction>;
  1471. /**
  1472. * @hidden
  1473. * Defines the actions happening just after rendering all cameras and computing intersections.
  1474. */
  1475. _afterRenderStage: Stage<SimpleStageAction>;
  1476. /**
  1477. * @hidden
  1478. * Defines the actions happening when a pointer move event happens.
  1479. */
  1480. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1481. /**
  1482. * @hidden
  1483. * Defines the actions happening when a pointer down event happens.
  1484. */
  1485. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1486. /**
  1487. * @hidden
  1488. * Defines the actions happening when a pointer up event happens.
  1489. */
  1490. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1491. /**
  1492. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  1493. */
  1494. private geometriesById;
  1495. /**
  1496. * Creates a new Scene
  1497. * @param engine defines the engine to use to render this scene
  1498. */
  1499. constructor(engine: Engine, options?: SceneOptions);
  1500. private _defaultMeshCandidates;
  1501. /**
  1502. * @hidden
  1503. */
  1504. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1505. private _defaultSubMeshCandidates;
  1506. /**
  1507. * @hidden
  1508. */
  1509. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1510. /**
  1511. * Sets the default candidate providers for the scene.
  1512. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1513. * and getCollidingSubMeshCandidates to their default function
  1514. */
  1515. setDefaultCandidateProviders(): void;
  1516. /**
  1517. * Gets a boolean indicating if collisions are processed on a web worker
  1518. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1519. */
  1520. workerCollisions: boolean;
  1521. /**
  1522. * Gets the mesh that is currently under the pointer
  1523. */
  1524. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1525. /**
  1526. * Gets the current on-screen X position of the pointer
  1527. */
  1528. readonly pointerX: number;
  1529. /**
  1530. * Gets the current on-screen Y position of the pointer
  1531. */
  1532. readonly pointerY: number;
  1533. /**
  1534. * Gets the cached material (ie. the latest rendered one)
  1535. * @returns the cached material
  1536. */
  1537. getCachedMaterial(): Nullable<Material>;
  1538. /**
  1539. * Gets the cached effect (ie. the latest rendered one)
  1540. * @returns the cached effect
  1541. */
  1542. getCachedEffect(): Nullable<Effect>;
  1543. /**
  1544. * Gets the cached visibility state (ie. the latest rendered one)
  1545. * @returns the cached visibility state
  1546. */
  1547. getCachedVisibility(): Nullable<number>;
  1548. /**
  1549. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1550. * @param material defines the current material
  1551. * @param effect defines the current effect
  1552. * @param visibility defines the current visibility state
  1553. * @returns true if one parameter is not cached
  1554. */
  1555. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1556. /**
  1557. * Gets the engine associated with the scene
  1558. * @returns an Engine
  1559. */
  1560. getEngine(): Engine;
  1561. /**
  1562. * Gets the total number of vertices rendered per frame
  1563. * @returns the total number of vertices rendered per frame
  1564. */
  1565. getTotalVertices(): number;
  1566. /**
  1567. * Gets the performance counter for total vertices
  1568. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1569. */
  1570. readonly totalVerticesPerfCounter: PerfCounter;
  1571. /**
  1572. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1573. * @returns the total number of active indices rendered per frame
  1574. */
  1575. getActiveIndices(): number;
  1576. /**
  1577. * Gets the performance counter for active indices
  1578. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1579. */
  1580. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1581. /**
  1582. * Gets the total number of active particles rendered per frame
  1583. * @returns the total number of active particles rendered per frame
  1584. */
  1585. getActiveParticles(): number;
  1586. /**
  1587. * Gets the performance counter for active particles
  1588. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1589. */
  1590. readonly activeParticlesPerfCounter: PerfCounter;
  1591. /**
  1592. * Gets the total number of active bones rendered per frame
  1593. * @returns the total number of active bones rendered per frame
  1594. */
  1595. getActiveBones(): number;
  1596. /**
  1597. * Gets the performance counter for active bones
  1598. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1599. */
  1600. readonly activeBonesPerfCounter: PerfCounter;
  1601. /** @hidden */
  1602. getInterFramePerfCounter(): number;
  1603. /** @hidden */
  1604. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1605. /** @hidden */
  1606. getLastFrameDuration(): number;
  1607. /** @hidden */
  1608. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1609. /** @hidden */
  1610. getEvaluateActiveMeshesDuration(): number;
  1611. /** @hidden */
  1612. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1613. /**
  1614. * Gets the array of active meshes
  1615. * @returns an array of AbstractMesh
  1616. */
  1617. getActiveMeshes(): SmartArray<AbstractMesh>;
  1618. /** @hidden */
  1619. getRenderTargetsDuration(): number;
  1620. /** @hidden */
  1621. getRenderDuration(): number;
  1622. /** @hidden */
  1623. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1624. /** @hidden */
  1625. getParticlesDuration(): number;
  1626. /** @hidden */
  1627. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1628. /** @hidden */
  1629. getSpritesDuration(): number;
  1630. /** @hidden */
  1631. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1632. /**
  1633. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1634. * @returns a number
  1635. */
  1636. getAnimationRatio(): number;
  1637. /**
  1638. * Gets an unique Id for the current render phase
  1639. * @returns a number
  1640. */
  1641. getRenderId(): number;
  1642. /**
  1643. * Gets an unique Id for the current frame
  1644. * @returns a number
  1645. */
  1646. getFrameId(): number;
  1647. /** Call this function if you want to manually increment the render Id*/
  1648. incrementRenderId(): void;
  1649. private _updatePointerPosition;
  1650. private _createUbo;
  1651. private _createAlternateUbo;
  1652. private _setRayOnPointerInfo;
  1653. /**
  1654. * Use this method to simulate a pointer move on a mesh
  1655. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1656. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1657. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1658. * @returns the current scene
  1659. */
  1660. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1661. private _processPointerMove;
  1662. private _checkPrePointerObservable;
  1663. /**
  1664. * Use this method to simulate a pointer down on a mesh
  1665. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1666. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1667. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1668. * @returns the current scene
  1669. */
  1670. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1671. private _processPointerDown;
  1672. /**
  1673. * Use this method to simulate a pointer up on a mesh
  1674. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1675. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1676. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1677. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  1678. * @returns the current scene
  1679. */
  1680. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  1681. private _processPointerUp;
  1682. /**
  1683. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1684. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1685. * @returns true if the pointer was captured
  1686. */
  1687. isPointerCaptured(pointerId?: number): boolean;
  1688. /** @hidden */
  1689. _isPointerSwiping(): boolean;
  1690. /**
  1691. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1692. * @param attachUp defines if you want to attach events to pointerup
  1693. * @param attachDown defines if you want to attach events to pointerdown
  1694. * @param attachMove defines if you want to attach events to pointermove
  1695. */
  1696. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1697. /** Detaches all event handlers*/
  1698. detachControl(): void;
  1699. /**
  1700. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1701. * Delay loaded resources are not taking in account
  1702. * @return true if all required resources are ready
  1703. */
  1704. isReady(): boolean;
  1705. /** Resets all cached information relative to material (including effect and visibility) */
  1706. resetCachedMaterial(): void;
  1707. /**
  1708. * Registers a function to be called before every frame render
  1709. * @param func defines the function to register
  1710. */
  1711. registerBeforeRender(func: () => void): void;
  1712. /**
  1713. * Unregisters a function called before every frame render
  1714. * @param func defines the function to unregister
  1715. */
  1716. unregisterBeforeRender(func: () => void): void;
  1717. /**
  1718. * Registers a function to be called after every frame render
  1719. * @param func defines the function to register
  1720. */
  1721. registerAfterRender(func: () => void): void;
  1722. /**
  1723. * Unregisters a function called after every frame render
  1724. * @param func defines the function to unregister
  1725. */
  1726. unregisterAfterRender(func: () => void): void;
  1727. private _executeOnceBeforeRender;
  1728. /**
  1729. * The provided function will run before render once and will be disposed afterwards.
  1730. * A timeout delay can be provided so that the function will be executed in N ms.
  1731. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1732. * @param func The function to be executed.
  1733. * @param timeout optional delay in ms
  1734. */
  1735. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1736. /** @hidden */
  1737. _addPendingData(data: any): void;
  1738. /** @hidden */
  1739. _removePendingData(data: any): void;
  1740. /**
  1741. * Returns the number of items waiting to be loaded
  1742. * @returns the number of items waiting to be loaded
  1743. */
  1744. getWaitingItemsCount(): number;
  1745. /**
  1746. * Returns a boolean indicating if the scene is still loading data
  1747. */
  1748. readonly isLoading: boolean;
  1749. /**
  1750. * Registers a function to be executed when the scene is ready
  1751. * @param {Function} func - the function to be executed
  1752. */
  1753. executeWhenReady(func: () => void): void;
  1754. /**
  1755. * Returns a promise that resolves when the scene is ready
  1756. * @returns A promise that resolves when the scene is ready
  1757. */
  1758. whenReadyAsync(): Promise<void>;
  1759. /** @hidden */
  1760. _checkIsReady(): void;
  1761. /**
  1762. * Will start the animation sequence of a given target
  1763. * @param target defines the target
  1764. * @param from defines from which frame should animation start
  1765. * @param to defines until which frame should animation run.
  1766. * @param weight defines the weight to apply to the animation (1.0 by default)
  1767. * @param loop defines if the animation loops
  1768. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1769. * @param onAnimationEnd defines the function to be executed when the animation ends
  1770. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1771. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1772. * @returns the animatable object created for this animation
  1773. */
  1774. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1775. /**
  1776. * Will start the animation sequence of a given target
  1777. * @param target defines the target
  1778. * @param from defines from which frame should animation start
  1779. * @param to defines until which frame should animation run.
  1780. * @param loop defines if the animation loops
  1781. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1782. * @param onAnimationEnd defines the function to be executed when the animation ends
  1783. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1784. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1785. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1786. * @returns the animatable object created for this animation
  1787. */
  1788. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1789. /**
  1790. * Begin a new animation on a given node
  1791. * @param target defines the target where the animation will take place
  1792. * @param animations defines the list of animations to start
  1793. * @param from defines the initial value
  1794. * @param to defines the final value
  1795. * @param loop defines if you want animation to loop (off by default)
  1796. * @param speedRatio defines the speed ratio to apply to all animations
  1797. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1798. * @returns the list of created animatables
  1799. */
  1800. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1801. /**
  1802. * Begin a new animation on a given node and its hierarchy
  1803. * @param target defines the root node where the animation will take place
  1804. * @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.
  1805. * @param animations defines the list of animations to start
  1806. * @param from defines the initial value
  1807. * @param to defines the final value
  1808. * @param loop defines if you want animation to loop (off by default)
  1809. * @param speedRatio defines the speed ratio to apply to all animations
  1810. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1811. * @returns the list of animatables created for all nodes
  1812. */
  1813. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1814. /**
  1815. * Gets the animatable associated with a specific target
  1816. * @param target defines the target of the animatable
  1817. * @returns the required animatable if found
  1818. */
  1819. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1820. /**
  1821. * Gets all animatables associated with a given target
  1822. * @param target defines the target to look animatables for
  1823. * @returns an array of Animatables
  1824. */
  1825. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1826. /**
  1827. * Gets all animatable attached to the scene
  1828. */
  1829. readonly animatables: Animatable[];
  1830. /**
  1831. * Will stop the animation of the given target
  1832. * @param target - the target
  1833. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1834. * @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)
  1835. */
  1836. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1837. /**
  1838. * Stops and removes all animations that have been applied to the scene
  1839. */
  1840. stopAllAnimations(): void;
  1841. private _animate;
  1842. /** @hidden */
  1843. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1844. private _processLateAnimationBindingsForMatrices;
  1845. private _processLateAnimationBindingsForQuaternions;
  1846. private _processLateAnimationBindings;
  1847. /** @hidden */
  1848. _switchToAlternateCameraConfiguration(active: boolean): void;
  1849. /**
  1850. * Gets the current view matrix
  1851. * @returns a Matrix
  1852. */
  1853. getViewMatrix(): Matrix;
  1854. /**
  1855. * Gets the current projection matrix
  1856. * @returns a Matrix
  1857. */
  1858. getProjectionMatrix(): Matrix;
  1859. /**
  1860. * Gets the current transform matrix
  1861. * @returns a Matrix made of View * Projection
  1862. */
  1863. getTransformMatrix(): Matrix;
  1864. /**
  1865. * Sets the current transform matrix
  1866. * @param view defines the View matrix to use
  1867. * @param projection defines the Projection matrix to use
  1868. */
  1869. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1870. /** @hidden */
  1871. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1872. /**
  1873. * Gets the uniform buffer used to store scene data
  1874. * @returns a UniformBuffer
  1875. */
  1876. getSceneUniformBuffer(): UniformBuffer;
  1877. /**
  1878. * Gets an unique (relatively to the current scene) Id
  1879. * @returns an unique number for the scene
  1880. */
  1881. getUniqueId(): number;
  1882. /**
  1883. * Add a mesh to the list of scene's meshes
  1884. * @param newMesh defines the mesh to add
  1885. * @param recursive if all child meshes should also be added to the scene
  1886. */
  1887. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1888. /**
  1889. * Remove a mesh for the list of scene's meshes
  1890. * @param toRemove defines the mesh to remove
  1891. * @param recursive if all child meshes should also be removed from the scene
  1892. * @returns the index where the mesh was in the mesh list
  1893. */
  1894. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1895. /**
  1896. * Add a transform node to the list of scene's transform nodes
  1897. * @param newTransformNode defines the transform node to add
  1898. */
  1899. addTransformNode(newTransformNode: TransformNode): void;
  1900. /**
  1901. * Remove a transform node for the list of scene's transform nodes
  1902. * @param toRemove defines the transform node to remove
  1903. * @returns the index where the transform node was in the transform node list
  1904. */
  1905. removeTransformNode(toRemove: TransformNode): number;
  1906. /**
  1907. * Remove a skeleton for the list of scene's skeletons
  1908. * @param toRemove defines the skeleton to remove
  1909. * @returns the index where the skeleton was in the skeleton list
  1910. */
  1911. removeSkeleton(toRemove: Skeleton): number;
  1912. /**
  1913. * Remove a morph target for the list of scene's morph targets
  1914. * @param toRemove defines the morph target to remove
  1915. * @returns the index where the morph target was in the morph target list
  1916. */
  1917. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1918. /**
  1919. * Remove a light for the list of scene's lights
  1920. * @param toRemove defines the light to remove
  1921. * @returns the index where the light was in the light list
  1922. */
  1923. removeLight(toRemove: Light): number;
  1924. /**
  1925. * Remove a camera for the list of scene's cameras
  1926. * @param toRemove defines the camera to remove
  1927. * @returns the index where the camera was in the camera list
  1928. */
  1929. removeCamera(toRemove: Camera): number;
  1930. /**
  1931. * Remove a particle system for the list of scene's particle systems
  1932. * @param toRemove defines the particle system to remove
  1933. * @returns the index where the particle system was in the particle system list
  1934. */
  1935. removeParticleSystem(toRemove: IParticleSystem): number;
  1936. /**
  1937. * Remove a animation for the list of scene's animations
  1938. * @param toRemove defines the animation to remove
  1939. * @returns the index where the animation was in the animation list
  1940. */
  1941. removeAnimation(toRemove: Animation): number;
  1942. /**
  1943. * Removes the given animation group from this scene.
  1944. * @param toRemove The animation group to remove
  1945. * @returns The index of the removed animation group
  1946. */
  1947. removeAnimationGroup(toRemove: AnimationGroup): number;
  1948. /**
  1949. * Removes the given multi-material from this scene.
  1950. * @param toRemove The multi-material to remove
  1951. * @returns The index of the removed multi-material
  1952. */
  1953. removeMultiMaterial(toRemove: MultiMaterial): number;
  1954. /**
  1955. * Removes the given material from this scene.
  1956. * @param toRemove The material to remove
  1957. * @returns The index of the removed material
  1958. */
  1959. removeMaterial(toRemove: Material): number;
  1960. /**
  1961. * Removes the given action manager from this scene.
  1962. * @param toRemove The action manager to remove
  1963. * @returns The index of the removed action manager
  1964. */
  1965. removeActionManager(toRemove: ActionManager): number;
  1966. /**
  1967. * Removes the given texture from this scene.
  1968. * @param toRemove The texture to remove
  1969. * @returns The index of the removed texture
  1970. */
  1971. removeTexture(toRemove: BaseTexture): number;
  1972. /**
  1973. * Adds the given light to this scene
  1974. * @param newLight The light to add
  1975. */
  1976. addLight(newLight: Light): void;
  1977. /**
  1978. * Sorts the list list based on light priorities
  1979. */
  1980. sortLightsByPriority(): void;
  1981. /**
  1982. * Adds the given camera to this scene
  1983. * @param newCamera The camera to add
  1984. */
  1985. addCamera(newCamera: Camera): void;
  1986. /**
  1987. * Adds the given skeleton to this scene
  1988. * @param newSkeleton The skeleton to add
  1989. */
  1990. addSkeleton(newSkeleton: Skeleton): void;
  1991. /**
  1992. * Adds the given particle system to this scene
  1993. * @param newParticleSystem The particle system to add
  1994. */
  1995. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1996. /**
  1997. * Adds the given animation to this scene
  1998. * @param newAnimation The animation to add
  1999. */
  2000. addAnimation(newAnimation: Animation): void;
  2001. /**
  2002. * Adds the given animation group to this scene.
  2003. * @param newAnimationGroup The animation group to add
  2004. */
  2005. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  2006. /**
  2007. * Adds the given multi-material to this scene
  2008. * @param newMultiMaterial The multi-material to add
  2009. */
  2010. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  2011. /**
  2012. * Adds the given material to this scene
  2013. * @param newMaterial The material to add
  2014. */
  2015. addMaterial(newMaterial: Material): void;
  2016. /**
  2017. * Adds the given morph target to this scene
  2018. * @param newMorphTargetManager The morph target to add
  2019. */
  2020. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  2021. /**
  2022. * Adds the given geometry to this scene
  2023. * @param newGeometry The geometry to add
  2024. */
  2025. addGeometry(newGeometry: Geometry): void;
  2026. /**
  2027. * Adds the given action manager to this scene
  2028. * @param newActionManager The action manager to add
  2029. */
  2030. addActionManager(newActionManager: ActionManager): void;
  2031. /**
  2032. * Adds the given texture to this scene.
  2033. * @param newTexture The texture to add
  2034. */
  2035. addTexture(newTexture: BaseTexture): void;
  2036. /**
  2037. * Switch active camera
  2038. * @param newCamera defines the new active camera
  2039. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  2040. */
  2041. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  2042. /**
  2043. * sets the active camera of the scene using its ID
  2044. * @param id defines the camera's ID
  2045. * @return the new active camera or null if none found.
  2046. */
  2047. setActiveCameraByID(id: string): Nullable<Camera>;
  2048. /**
  2049. * sets the active camera of the scene using its name
  2050. * @param name defines the camera's name
  2051. * @returns the new active camera or null if none found.
  2052. */
  2053. setActiveCameraByName(name: string): Nullable<Camera>;
  2054. /**
  2055. * get an animation group using its name
  2056. * @param name defines the material's name
  2057. * @return the animation group or null if none found.
  2058. */
  2059. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2060. /**
  2061. * get a material using its id
  2062. * @param id defines the material's ID
  2063. * @return the material or null if none found.
  2064. */
  2065. getMaterialByID(id: string): Nullable<Material>;
  2066. /**
  2067. * Gets a material using its name
  2068. * @param name defines the material's name
  2069. * @return the material or null if none found.
  2070. */
  2071. getMaterialByName(name: string): Nullable<Material>;
  2072. /**
  2073. * Gets a camera using its id
  2074. * @param id defines the id to look for
  2075. * @returns the camera or null if not found
  2076. */
  2077. getCameraByID(id: string): Nullable<Camera>;
  2078. /**
  2079. * Gets a camera using its unique id
  2080. * @param uniqueId defines the unique id to look for
  2081. * @returns the camera or null if not found
  2082. */
  2083. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2084. /**
  2085. * Gets a camera using its name
  2086. * @param name defines the camera's name
  2087. * @return the camera or null if none found.
  2088. */
  2089. getCameraByName(name: string): Nullable<Camera>;
  2090. /**
  2091. * Gets a bone using its id
  2092. * @param id defines the bone's id
  2093. * @return the bone or null if not found
  2094. */
  2095. getBoneByID(id: string): Nullable<Bone>;
  2096. /**
  2097. * Gets a bone using its id
  2098. * @param name defines the bone's name
  2099. * @return the bone or null if not found
  2100. */
  2101. getBoneByName(name: string): Nullable<Bone>;
  2102. /**
  2103. * Gets a light node using its name
  2104. * @param name defines the the light's name
  2105. * @return the light or null if none found.
  2106. */
  2107. getLightByName(name: string): Nullable<Light>;
  2108. /**
  2109. * Gets a light node using its id
  2110. * @param id defines the light's id
  2111. * @return the light or null if none found.
  2112. */
  2113. getLightByID(id: string): Nullable<Light>;
  2114. /**
  2115. * Gets a light node using its scene-generated unique ID
  2116. * @param uniqueId defines the light's unique id
  2117. * @return the light or null if none found.
  2118. */
  2119. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2120. /**
  2121. * Gets a particle system by id
  2122. * @param id defines the particle system id
  2123. * @return the corresponding system or null if none found
  2124. */
  2125. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2126. /**
  2127. * Gets a geometry using its ID
  2128. * @param id defines the geometry's id
  2129. * @return the geometry or null if none found.
  2130. */
  2131. getGeometryByID(id: string): Nullable<Geometry>;
  2132. /**
  2133. * Add a new geometry to this scene
  2134. * @param geometry defines the geometry to be added to the scene.
  2135. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2136. * @return a boolean defining if the geometry was added or not
  2137. */
  2138. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2139. /**
  2140. * Removes an existing geometry
  2141. * @param geometry defines the geometry to be removed from the scene
  2142. * @return a boolean defining if the geometry was removed or not
  2143. */
  2144. removeGeometry(geometry: Geometry): boolean;
  2145. /**
  2146. * Gets the list of geometries attached to the scene
  2147. * @returns an array of Geometry
  2148. */
  2149. getGeometries(): Geometry[];
  2150. /**
  2151. * Gets the first added mesh found of a given ID
  2152. * @param id defines the id to search for
  2153. * @return the mesh found or null if not found at all
  2154. */
  2155. getMeshByID(id: string): Nullable<AbstractMesh>;
  2156. /**
  2157. * Gets a list of meshes using their id
  2158. * @param id defines the id to search for
  2159. * @returns a list of meshes
  2160. */
  2161. getMeshesByID(id: string): Array<AbstractMesh>;
  2162. /**
  2163. * Gets the first added transform node found of a given ID
  2164. * @param id defines the id to search for
  2165. * @return the found transform node or null if not found at all.
  2166. */
  2167. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2168. /**
  2169. * Gets a list of transform nodes using their id
  2170. * @param id defines the id to search for
  2171. * @returns a list of transform nodes
  2172. */
  2173. getTransformNodesByID(id: string): Array<TransformNode>;
  2174. /**
  2175. * Gets a mesh with its auto-generated unique id
  2176. * @param uniqueId defines the unique id to search for
  2177. * @return the found mesh or null if not found at all.
  2178. */
  2179. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2180. /**
  2181. * Gets a the last added mesh using a given id
  2182. * @param id defines the id to search for
  2183. * @return the found mesh or null if not found at all.
  2184. */
  2185. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2186. /**
  2187. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2188. * @param id defines the id to search for
  2189. * @return the found node or null if not found at all
  2190. */
  2191. getLastEntryByID(id: string): Nullable<Node>;
  2192. /**
  2193. * Gets a node (Mesh, Camera, Light) using a given id
  2194. * @param id defines the id to search for
  2195. * @return the found node or null if not found at all
  2196. */
  2197. getNodeByID(id: string): Nullable<Node>;
  2198. /**
  2199. * Gets a node (Mesh, Camera, Light) using a given name
  2200. * @param name defines the name to search for
  2201. * @return the found node or null if not found at all.
  2202. */
  2203. getNodeByName(name: string): Nullable<Node>;
  2204. /**
  2205. * Gets a mesh using a given name
  2206. * @param name defines the name to search for
  2207. * @return the found mesh or null if not found at all.
  2208. */
  2209. getMeshByName(name: string): Nullable<AbstractMesh>;
  2210. /**
  2211. * Gets a transform node using a given name
  2212. * @param name defines the name to search for
  2213. * @return the found transform node or null if not found at all.
  2214. */
  2215. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2216. /**
  2217. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2218. * @param id defines the id to search for
  2219. * @return the found skeleton or null if not found at all.
  2220. */
  2221. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2222. /**
  2223. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2224. * @param id defines the id to search for
  2225. * @return the found skeleton or null if not found at all.
  2226. */
  2227. getSkeletonById(id: string): Nullable<Skeleton>;
  2228. /**
  2229. * Gets a skeleton using a given name
  2230. * @param name defines the name to search for
  2231. * @return the found skeleton or null if not found at all.
  2232. */
  2233. getSkeletonByName(name: string): Nullable<Skeleton>;
  2234. /**
  2235. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2236. * @param id defines the id to search for
  2237. * @return the found morph target manager or null if not found at all.
  2238. */
  2239. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2240. /**
  2241. * Gets a boolean indicating if the given mesh is active
  2242. * @param mesh defines the mesh to look for
  2243. * @returns true if the mesh is in the active list
  2244. */
  2245. isActiveMesh(mesh: AbstractMesh): boolean;
  2246. /**
  2247. * Return a unique id as a string which can serve as an identifier for the scene
  2248. */
  2249. readonly uid: string;
  2250. /**
  2251. * Add an externaly attached data from its key.
  2252. * This method call will fail and return false, if such key already exists.
  2253. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2254. * @param key the unique key that identifies the data
  2255. * @param data the data object to associate to the key for this Engine instance
  2256. * @return true if no such key were already present and the data was added successfully, false otherwise
  2257. */
  2258. addExternalData<T>(key: string, data: T): boolean;
  2259. /**
  2260. * Get an externaly attached data from its key
  2261. * @param key the unique key that identifies the data
  2262. * @return the associated data, if present (can be null), or undefined if not present
  2263. */
  2264. getExternalData<T>(key: string): Nullable<T>;
  2265. /**
  2266. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2267. * @param key the unique key that identifies the data
  2268. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2269. * @return the associated data, can be null if the factory returned null.
  2270. */
  2271. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2272. /**
  2273. * Remove an externaly attached data from the Engine instance
  2274. * @param key the unique key that identifies the data
  2275. * @return true if the data was successfully removed, false if it doesn't exist
  2276. */
  2277. removeExternalData(key: string): boolean;
  2278. private _evaluateSubMesh;
  2279. /**
  2280. * Clear the processed materials smart array preventing retention point in material dispose.
  2281. */
  2282. freeProcessedMaterials(): void;
  2283. private _preventFreeActiveMeshesAndRenderingGroups;
  2284. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  2285. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  2286. * when disposing several meshes in a row or a hierarchy of meshes.
  2287. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  2288. */
  2289. blockfreeActiveMeshesAndRenderingGroups: boolean;
  2290. /**
  2291. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2292. */
  2293. freeActiveMeshes(): void;
  2294. /**
  2295. * Clear the info related to rendering groups preventing retention points during dispose.
  2296. */
  2297. freeRenderingGroups(): void;
  2298. /** @hidden */
  2299. _isInIntermediateRendering(): boolean;
  2300. /**
  2301. * Lambda returning the list of potentially active meshes.
  2302. */
  2303. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2304. /**
  2305. * Lambda returning the list of potentially active sub meshes.
  2306. */
  2307. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2308. /**
  2309. * Lambda returning the list of potentially intersecting sub meshes.
  2310. */
  2311. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2312. /**
  2313. * Lambda returning the list of potentially colliding sub meshes.
  2314. */
  2315. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2316. private _activeMeshesFrozen;
  2317. /**
  2318. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2319. * @returns the current scene
  2320. */
  2321. freezeActiveMeshes(): Scene;
  2322. /**
  2323. * Use this function to restart evaluating active meshes on every frame
  2324. * @returns the current scene
  2325. */
  2326. unfreezeActiveMeshes(): Scene;
  2327. private _evaluateActiveMeshes;
  2328. private _activeMesh;
  2329. /**
  2330. * Update the transform matrix to update from the current active camera
  2331. * @param force defines a boolean used to force the update even if cache is up to date
  2332. */
  2333. updateTransformMatrix(force?: boolean): void;
  2334. /**
  2335. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  2336. * @param alternateCamera defines the camera to use
  2337. */
  2338. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2339. /** @hidden */
  2340. _allowPostProcessClearColor: boolean;
  2341. private _renderForCamera;
  2342. private _processSubCameras;
  2343. private _checkIntersections;
  2344. /** @hidden */
  2345. _advancePhysicsEngineStep(step: number): void;
  2346. /**
  2347. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2348. */
  2349. getDeterministicFrameTime: () => number;
  2350. /**
  2351. * Render the scene
  2352. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2353. */
  2354. render(updateCameras?: boolean): void;
  2355. /**
  2356. * Freeze all materials
  2357. * A frozen material will not be updatable but should be faster to render
  2358. */
  2359. freezeMaterials(): void;
  2360. /**
  2361. * Unfreeze all materials
  2362. * A frozen material will not be updatable but should be faster to render
  2363. */
  2364. unfreezeMaterials(): void;
  2365. /**
  2366. * Releases all held ressources
  2367. */
  2368. dispose(): void;
  2369. /**
  2370. * Gets if the scene is already disposed
  2371. */
  2372. readonly isDisposed: boolean;
  2373. /**
  2374. * Call this function to reduce memory footprint of the scene.
  2375. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2376. */
  2377. clearCachedVertexData(): void;
  2378. /**
  2379. * This function will remove the local cached buffer data from texture.
  2380. * It will save memory but will prevent the texture from being rebuilt
  2381. */
  2382. cleanCachedTextureBuffer(): void;
  2383. /**
  2384. * Get the world extend vectors with an optional filter
  2385. *
  2386. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2387. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2388. */
  2389. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2390. min: Vector3;
  2391. max: Vector3;
  2392. };
  2393. /**
  2394. * Creates a ray that can be used to pick in the scene
  2395. * @param x defines the x coordinate of the origin (on-screen)
  2396. * @param y defines the y coordinate of the origin (on-screen)
  2397. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2398. * @param camera defines the camera to use for the picking
  2399. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2400. * @returns a Ray
  2401. */
  2402. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2403. /**
  2404. * Creates a ray that can be used to pick in the scene
  2405. * @param x defines the x coordinate of the origin (on-screen)
  2406. * @param y defines the y coordinate of the origin (on-screen)
  2407. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2408. * @param result defines the ray where to store the picking ray
  2409. * @param camera defines the camera to use for the picking
  2410. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2411. * @returns the current scene
  2412. */
  2413. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2414. /**
  2415. * Creates a ray that can be used to pick in the scene
  2416. * @param x defines the x coordinate of the origin (on-screen)
  2417. * @param y defines the y coordinate of the origin (on-screen)
  2418. * @param camera defines the camera to use for the picking
  2419. * @returns a Ray
  2420. */
  2421. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2422. /**
  2423. * Creates a ray that can be used to pick in the scene
  2424. * @param x defines the x coordinate of the origin (on-screen)
  2425. * @param y defines the y coordinate of the origin (on-screen)
  2426. * @param result defines the ray where to store the picking ray
  2427. * @param camera defines the camera to use for the picking
  2428. * @returns the current scene
  2429. */
  2430. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2431. private _internalPick;
  2432. private _internalMultiPick;
  2433. private _tempPickingRay;
  2434. /** Launch a ray to try to pick a mesh in the scene
  2435. * @param x position on screen
  2436. * @param y position on screen
  2437. * @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
  2438. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2439. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2440. * @returns a PickingInfo
  2441. */
  2442. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2443. private _cachedRayForTransform;
  2444. /** Use the given ray to pick a mesh in the scene
  2445. * @param ray The ray to use to pick meshes
  2446. * @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
  2447. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2448. * @returns a PickingInfo
  2449. */
  2450. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2451. /**
  2452. * Launch a ray to try to pick a mesh in the scene
  2453. * @param x X position on screen
  2454. * @param y Y position on screen
  2455. * @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
  2456. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2457. * @returns an array of PickingInfo
  2458. */
  2459. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2460. /**
  2461. * Launch a ray to try to pick a mesh in the scene
  2462. * @param ray Ray to use
  2463. * @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
  2464. * @returns an array of PickingInfo
  2465. */
  2466. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2467. /**
  2468. * Force the value of meshUnderPointer
  2469. * @param mesh defines the mesh to use
  2470. */
  2471. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2472. /**
  2473. * Gets the mesh under the pointer
  2474. * @returns a Mesh or null if no mesh is under the pointer
  2475. */
  2476. getPointerOverMesh(): Nullable<AbstractMesh>;
  2477. /** @hidden */
  2478. _rebuildGeometries(): void;
  2479. /** @hidden */
  2480. _rebuildTextures(): void;
  2481. private _getByTags;
  2482. /**
  2483. * Get a list of meshes by tags
  2484. * @param tagsQuery defines the tags query to use
  2485. * @param forEach defines a predicate used to filter results
  2486. * @returns an array of Mesh
  2487. */
  2488. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2489. /**
  2490. * Get a list of cameras by tags
  2491. * @param tagsQuery defines the tags query to use
  2492. * @param forEach defines a predicate used to filter results
  2493. * @returns an array of Camera
  2494. */
  2495. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2496. /**
  2497. * Get a list of lights by tags
  2498. * @param tagsQuery defines the tags query to use
  2499. * @param forEach defines a predicate used to filter results
  2500. * @returns an array of Light
  2501. */
  2502. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2503. /**
  2504. * Get a list of materials by tags
  2505. * @param tagsQuery defines the tags query to use
  2506. * @param forEach defines a predicate used to filter results
  2507. * @returns an array of Material
  2508. */
  2509. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2510. /**
  2511. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2512. * This allowed control for front to back rendering or reversly depending of the special needs.
  2513. *
  2514. * @param renderingGroupId The rendering group id corresponding to its index
  2515. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2516. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2517. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2518. */
  2519. 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;
  2520. /**
  2521. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2522. *
  2523. * @param renderingGroupId The rendering group id corresponding to its index
  2524. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2525. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2526. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2527. */
  2528. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2529. /**
  2530. * Gets the current auto clear configuration for one rendering group of the rendering
  2531. * manager.
  2532. * @param index the rendering group index to get the information for
  2533. * @returns The auto clear setup for the requested rendering group
  2534. */
  2535. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2536. private _blockMaterialDirtyMechanism;
  2537. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2538. blockMaterialDirtyMechanism: boolean;
  2539. /**
  2540. * Will flag all materials as dirty to trigger new shader compilation
  2541. * @param flag defines the flag used to specify which material part must be marked as dirty
  2542. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2543. */
  2544. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2545. /** @hidden */
  2546. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  2547. /** @hidden */
  2548. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2549. }
  2550. }
  2551. declare module BABYLON {
  2552. /**
  2553. * Groups all the scene component constants in one place to ease maintenance.
  2554. * @hidden
  2555. */
  2556. class SceneComponentConstants {
  2557. static readonly NAME_EFFECTLAYER: string;
  2558. static readonly NAME_LAYER: string;
  2559. static readonly NAME_LENSFLARESYSTEM: string;
  2560. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2561. static readonly NAME_PARTICLESYSTEM: string;
  2562. static readonly NAME_GAMEPAD: string;
  2563. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2564. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2565. static readonly NAME_DEPTHRENDERER: string;
  2566. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2567. static readonly NAME_SPRITE: string;
  2568. static readonly NAME_OUTLINERENDERER: string;
  2569. static readonly NAME_PROCEDURALTEXTURE: string;
  2570. static readonly NAME_SHADOWGENERATOR: string;
  2571. static readonly NAME_OCTREE: string;
  2572. static readonly NAME_PHYSICSENGINE: string;
  2573. static readonly NAME_AUDIO: string;
  2574. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2575. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2576. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2577. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2578. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2579. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2580. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2581. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2582. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2583. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2584. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2585. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2586. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2587. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2588. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2589. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2590. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2591. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2592. static readonly STEP_AFTERRENDER_AUDIO: number;
  2593. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2594. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2595. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2596. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2597. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2598. static readonly STEP_POINTERMOVE_SPRITE: number;
  2599. static readonly STEP_POINTERDOWN_SPRITE: number;
  2600. static readonly STEP_POINTERUP_SPRITE: number;
  2601. }
  2602. /**
  2603. * This represents a scene component.
  2604. *
  2605. * This is used to decouple the dependency the scene is having on the different workloads like
  2606. * layers, post processes...
  2607. */
  2608. interface ISceneComponent {
  2609. /**
  2610. * The name of the component. Each component must have a unique name.
  2611. */
  2612. name: string;
  2613. /**
  2614. * The scene the component belongs to.
  2615. */
  2616. scene: Scene;
  2617. /**
  2618. * Register the component to one instance of a scene.
  2619. */
  2620. register(): void;
  2621. /**
  2622. * Rebuilds the elements related to this component in case of
  2623. * context lost for instance.
  2624. */
  2625. rebuild(): void;
  2626. /**
  2627. * Disposes the component and the associated ressources.
  2628. */
  2629. dispose(): void;
  2630. }
  2631. /**
  2632. * This represents a SERIALIZABLE scene component.
  2633. *
  2634. * This extends Scene Component to add Serialization methods on top.
  2635. */
  2636. interface ISceneSerializableComponent extends ISceneComponent {
  2637. /**
  2638. * Adds all the element from the container to the scene
  2639. * @param container the container holding the elements
  2640. */
  2641. addFromContainer(container: AbstractScene): void;
  2642. /**
  2643. * Removes all the elements in the container from the scene
  2644. * @param container contains the elements to remove
  2645. */
  2646. removeFromContainer(container: AbstractScene): void;
  2647. /**
  2648. * Serializes the component data to the specified json object
  2649. * @param serializationObject The object to serialize to
  2650. */
  2651. serialize(serializationObject: any): void;
  2652. }
  2653. /**
  2654. * Strong typing of a Mesh related stage step action
  2655. */
  2656. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2657. /**
  2658. * Strong typing of a Evaluate Sub Mesh related stage step action
  2659. */
  2660. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2661. /**
  2662. * Strong typing of a Active Mesh related stage step action
  2663. */
  2664. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2665. /**
  2666. * Strong typing of a Camera related stage step action
  2667. */
  2668. type CameraStageAction = (camera: Camera) => void;
  2669. /**
  2670. * Strong typing of a RenderingGroup related stage step action
  2671. */
  2672. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2673. /**
  2674. * Strong typing of a Mesh Render related stage step action
  2675. */
  2676. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2677. /**
  2678. * Strong typing of a simple stage step action
  2679. */
  2680. type SimpleStageAction = () => void;
  2681. /**
  2682. * Strong typing of a render target action.
  2683. */
  2684. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2685. /**
  2686. * Strong typing of a pointer move action.
  2687. */
  2688. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2689. /**
  2690. * Strong typing of a pointer up/down action.
  2691. */
  2692. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2693. /**
  2694. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2695. * @hidden
  2696. */
  2697. class Stage<T extends Function> extends Array<{
  2698. index: number;
  2699. component: ISceneComponent;
  2700. action: T;
  2701. }> {
  2702. /**
  2703. * Hide ctor from the rest of the world.
  2704. * @param items The items to add.
  2705. */
  2706. private constructor();
  2707. /**
  2708. * Creates a new Stage.
  2709. * @returns A new instance of a Stage
  2710. */
  2711. static Create<T extends Function>(): Stage<T>;
  2712. /**
  2713. * Registers a step in an ordered way in the targeted stage.
  2714. * @param index Defines the position to register the step in
  2715. * @param component Defines the component attached to the step
  2716. * @param action Defines the action to launch during the step
  2717. */
  2718. registerStep(index: number, component: ISceneComponent, action: T): void;
  2719. /**
  2720. * Clears all the steps from the stage.
  2721. */
  2722. clear(): void;
  2723. }
  2724. }
  2725. declare module BABYLON {
  2726. /** Alias type for value that can be null */
  2727. type Nullable<T> = T | null;
  2728. /**
  2729. * Alias type for number that are floats
  2730. * @ignorenaming
  2731. */
  2732. type float = number;
  2733. /**
  2734. * Alias type for number that are doubles.
  2735. * @ignorenaming
  2736. */
  2737. type double = number;
  2738. /**
  2739. * Alias type for number that are integer
  2740. * @ignorenaming
  2741. */
  2742. type int = number;
  2743. /** Alias type for number array or Float32Array */
  2744. type FloatArray = number[] | Float32Array;
  2745. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2746. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2747. /**
  2748. * Alias for types that can be used by a Buffer or VertexBuffer.
  2749. */
  2750. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2751. }
  2752. declare module BABYLON {
  2753. /**
  2754. * The action to be carried out following a trigger
  2755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2756. */
  2757. class Action {
  2758. /** the trigger, with or without parameters, for the action */
  2759. triggerOptions: any;
  2760. /**
  2761. * Trigger for the action
  2762. */
  2763. trigger: number;
  2764. /**
  2765. * Internal only - manager for action
  2766. * @hidden
  2767. */
  2768. _actionManager: ActionManager;
  2769. private _nextActiveAction;
  2770. private _child;
  2771. private _condition?;
  2772. private _triggerParameter;
  2773. /**
  2774. * An event triggered prior to action being executed.
  2775. */
  2776. onBeforeExecuteObservable: Observable<Action>;
  2777. /**
  2778. * Creates a new Action
  2779. * @param triggerOptions the trigger, with or without parameters, for the action
  2780. * @param condition an optional determinant of action
  2781. */
  2782. constructor(
  2783. /** the trigger, with or without parameters, for the action */
  2784. triggerOptions: any, condition?: Condition);
  2785. /**
  2786. * Internal only
  2787. * @hidden
  2788. */
  2789. _prepare(): void;
  2790. /**
  2791. * Gets the trigger parameters
  2792. * @returns the trigger parameters
  2793. */
  2794. getTriggerParameter(): any;
  2795. /**
  2796. * Internal only - executes current action event
  2797. * @hidden
  2798. */
  2799. _executeCurrent(evt?: ActionEvent): void;
  2800. /**
  2801. * Execute placeholder for child classes
  2802. * @param evt optional action event
  2803. */
  2804. execute(evt?: ActionEvent): void;
  2805. /**
  2806. * Skips to next active action
  2807. */
  2808. skipToNextActiveAction(): void;
  2809. /**
  2810. * Adds action to chain of actions, may be a DoNothingAction
  2811. * @param action defines the next action to execute
  2812. * @returns The action passed in
  2813. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2814. */
  2815. then(action: Action): Action;
  2816. /**
  2817. * Internal only
  2818. * @hidden
  2819. */
  2820. _getProperty(propertyPath: string): string;
  2821. /**
  2822. * Internal only
  2823. * @hidden
  2824. */
  2825. _getEffectiveTarget(target: any, propertyPath: string): any;
  2826. /**
  2827. * Serialize placeholder for child classes
  2828. * @param parent of child
  2829. * @returns the serialized object
  2830. */
  2831. serialize(parent: any): any;
  2832. /**
  2833. * Internal only called by serialize
  2834. * @hidden
  2835. */
  2836. protected _serialize(serializedAction: any, parent?: any): any;
  2837. /**
  2838. * Internal only
  2839. * @hidden
  2840. */
  2841. static _SerializeValueAsString: (value: any) => string;
  2842. /**
  2843. * Internal only
  2844. * @hidden
  2845. */
  2846. static _GetTargetProperty: (target: Scene | Node) => {
  2847. name: string;
  2848. targetType: string;
  2849. value: string;
  2850. };
  2851. }
  2852. }
  2853. declare module BABYLON {
  2854. /**
  2855. * ActionEvent is the event being sent when an action is triggered.
  2856. */
  2857. class ActionEvent {
  2858. /** The mesh or sprite that triggered the action */
  2859. source: any;
  2860. /** The X mouse cursor position at the time of the event */
  2861. pointerX: number;
  2862. /** The Y mouse cursor position at the time of the event */
  2863. pointerY: number;
  2864. /** The mesh that is currently pointed at (can be null) */
  2865. meshUnderPointer: Nullable<AbstractMesh>;
  2866. /** the original (browser) event that triggered the ActionEvent */
  2867. sourceEvent?: any;
  2868. /** additional data for the event */
  2869. additionalData?: any;
  2870. /**
  2871. * Creates a new ActionEvent
  2872. * @param source The mesh or sprite that triggered the action
  2873. * @param pointerX The X mouse cursor position at the time of the event
  2874. * @param pointerY The Y mouse cursor position at the time of the event
  2875. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2876. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2877. * @param additionalData additional data for the event
  2878. */
  2879. constructor(
  2880. /** The mesh or sprite that triggered the action */
  2881. source: any,
  2882. /** The X mouse cursor position at the time of the event */
  2883. pointerX: number,
  2884. /** The Y mouse cursor position at the time of the event */
  2885. pointerY: number,
  2886. /** The mesh that is currently pointed at (can be null) */
  2887. meshUnderPointer: Nullable<AbstractMesh>,
  2888. /** the original (browser) event that triggered the ActionEvent */
  2889. sourceEvent?: any,
  2890. /** additional data for the event */
  2891. additionalData?: any);
  2892. /**
  2893. * Helper function to auto-create an ActionEvent from a source mesh.
  2894. * @param source The source mesh that triggered the event
  2895. * @param evt The original (browser) event
  2896. * @param additionalData additional data for the event
  2897. * @returns the new ActionEvent
  2898. */
  2899. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2900. /**
  2901. * Helper function to auto-create an ActionEvent from a source sprite
  2902. * @param source The source sprite that triggered the event
  2903. * @param scene Scene associated with the sprite
  2904. * @param evt The original (browser) event
  2905. * @param additionalData additional data for the event
  2906. * @returns the new ActionEvent
  2907. */
  2908. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2909. /**
  2910. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2911. * @param scene the scene where the event occurred
  2912. * @param evt The original (browser) event
  2913. * @returns the new ActionEvent
  2914. */
  2915. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2916. /**
  2917. * Helper function to auto-create an ActionEvent from a primitive
  2918. * @param prim defines the target primitive
  2919. * @param pointerPos defines the pointer position
  2920. * @param evt The original (browser) event
  2921. * @param additionalData additional data for the event
  2922. * @returns the new ActionEvent
  2923. */
  2924. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2925. }
  2926. /**
  2927. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2928. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2929. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2930. */
  2931. class ActionManager {
  2932. /**
  2933. * Nothing
  2934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2935. */
  2936. static readonly NothingTrigger: number;
  2937. /**
  2938. * On pick
  2939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2940. */
  2941. static readonly OnPickTrigger: number;
  2942. /**
  2943. * On left pick
  2944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2945. */
  2946. static readonly OnLeftPickTrigger: number;
  2947. /**
  2948. * On right pick
  2949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2950. */
  2951. static readonly OnRightPickTrigger: number;
  2952. /**
  2953. * On center pick
  2954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2955. */
  2956. static readonly OnCenterPickTrigger: number;
  2957. /**
  2958. * On pick down
  2959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2960. */
  2961. static readonly OnPickDownTrigger: number;
  2962. /**
  2963. * On double pick
  2964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2965. */
  2966. static readonly OnDoublePickTrigger: number;
  2967. /**
  2968. * On pick up
  2969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2970. */
  2971. static readonly OnPickUpTrigger: number;
  2972. /**
  2973. * On pick out.
  2974. * This trigger will only be raised if you also declared a OnPickDown
  2975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2976. */
  2977. static readonly OnPickOutTrigger: number;
  2978. /**
  2979. * On long press
  2980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2981. */
  2982. static readonly OnLongPressTrigger: number;
  2983. /**
  2984. * On pointer over
  2985. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2986. */
  2987. static readonly OnPointerOverTrigger: number;
  2988. /**
  2989. * On pointer out
  2990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2991. */
  2992. static readonly OnPointerOutTrigger: number;
  2993. /**
  2994. * On every frame
  2995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2996. */
  2997. static readonly OnEveryFrameTrigger: number;
  2998. /**
  2999. * On intersection enter
  3000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3001. */
  3002. static readonly OnIntersectionEnterTrigger: number;
  3003. /**
  3004. * On intersection exit
  3005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3006. */
  3007. static readonly OnIntersectionExitTrigger: number;
  3008. /**
  3009. * On key down
  3010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3011. */
  3012. static readonly OnKeyDownTrigger: number;
  3013. /**
  3014. * On key up
  3015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3016. */
  3017. static readonly OnKeyUpTrigger: number;
  3018. /** Gets the list of active triggers */
  3019. static Triggers: {
  3020. [key: string]: number;
  3021. };
  3022. /** Gets the list of actions */
  3023. actions: Action[];
  3024. /** Gets the cursor to use when hovering items */
  3025. hoverCursor: string;
  3026. private _scene;
  3027. /**
  3028. * Creates a new action manager
  3029. * @param scene defines the hosting scene
  3030. */
  3031. constructor(scene: Scene);
  3032. /**
  3033. * Releases all associated resources
  3034. */
  3035. dispose(): void;
  3036. /**
  3037. * Gets hosting scene
  3038. * @returns the hosting scene
  3039. */
  3040. getScene(): Scene;
  3041. /**
  3042. * Does this action manager handles actions of any of the given triggers
  3043. * @param triggers defines the triggers to be tested
  3044. * @return a boolean indicating whether one (or more) of the triggers is handled
  3045. */
  3046. hasSpecificTriggers(triggers: number[]): boolean;
  3047. /**
  3048. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3049. * speed.
  3050. * @param triggerA defines the trigger to be tested
  3051. * @param triggerB defines the trigger to be tested
  3052. * @return a boolean indicating whether one (or more) of the triggers is handled
  3053. */
  3054. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3055. /**
  3056. * Does this action manager handles actions of a given trigger
  3057. * @param trigger defines the trigger to be tested
  3058. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3059. * @return whether the trigger is handled
  3060. */
  3061. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3062. /**
  3063. * Does this action manager has pointer triggers
  3064. */
  3065. readonly hasPointerTriggers: boolean;
  3066. /**
  3067. * Does this action manager has pick triggers
  3068. */
  3069. readonly hasPickTriggers: boolean;
  3070. /**
  3071. * Does exist one action manager with at least one trigger
  3072. **/
  3073. static readonly HasTriggers: boolean;
  3074. /**
  3075. * Does exist one action manager with at least one pick trigger
  3076. **/
  3077. static readonly HasPickTriggers: boolean;
  3078. /**
  3079. * Does exist one action manager that handles actions of a given trigger
  3080. * @param trigger defines the trigger to be tested
  3081. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3082. **/
  3083. static HasSpecificTrigger(trigger: number): boolean;
  3084. /**
  3085. * Registers an action to this action manager
  3086. * @param action defines the action to be registered
  3087. * @return the action amended (prepared) after registration
  3088. */
  3089. registerAction(action: Action): Nullable<Action>;
  3090. /**
  3091. * Unregisters an action to this action manager
  3092. * @param action defines the action to be unregistered
  3093. * @return a boolean indicating whether the action has been unregistered
  3094. */
  3095. unregisterAction(action: Action): Boolean;
  3096. /**
  3097. * Process a specific trigger
  3098. * @param trigger defines the trigger to process
  3099. * @param evt defines the event details to be processed
  3100. */
  3101. processTrigger(trigger: number, evt?: ActionEvent): void;
  3102. /** @hidden */
  3103. _getEffectiveTarget(target: any, propertyPath: string): any;
  3104. /** @hidden */
  3105. _getProperty(propertyPath: string): string;
  3106. /**
  3107. * Serialize this manager to a JSON object
  3108. * @param name defines the property name to store this manager
  3109. * @returns a JSON representation of this manager
  3110. */
  3111. serialize(name: string): any;
  3112. /**
  3113. * Creates a new ActionManager from a JSON data
  3114. * @param parsedActions defines the JSON data to read from
  3115. * @param object defines the hosting mesh
  3116. * @param scene defines the hosting scene
  3117. */
  3118. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3119. /**
  3120. * Get a trigger name by index
  3121. * @param trigger defines the trigger index
  3122. * @returns a trigger name
  3123. */
  3124. static GetTriggerName(trigger: number): string;
  3125. }
  3126. }
  3127. declare module BABYLON {
  3128. /**
  3129. * A Condition applied to an Action
  3130. */
  3131. class Condition {
  3132. /**
  3133. * Internal only - manager for action
  3134. * @hidden
  3135. */
  3136. _actionManager: ActionManager;
  3137. /**
  3138. * Internal only
  3139. * @hidden
  3140. */
  3141. _evaluationId: number;
  3142. /**
  3143. * Internal only
  3144. * @hidden
  3145. */
  3146. _currentResult: boolean;
  3147. /**
  3148. * Creates a new Condition
  3149. * @param actionManager the manager of the action the condition is applied to
  3150. */
  3151. constructor(actionManager: ActionManager);
  3152. /**
  3153. * Check if the current condition is valid
  3154. * @returns a boolean
  3155. */
  3156. isValid(): boolean;
  3157. /**
  3158. * Internal only
  3159. * @hidden
  3160. */
  3161. _getProperty(propertyPath: string): string;
  3162. /**
  3163. * Internal only
  3164. * @hidden
  3165. */
  3166. _getEffectiveTarget(target: any, propertyPath: string): any;
  3167. /**
  3168. * Serialize placeholder for child classes
  3169. * @returns the serialized object
  3170. */
  3171. serialize(): any;
  3172. /**
  3173. * Internal only
  3174. * @hidden
  3175. */
  3176. protected _serialize(serializedCondition: any): any;
  3177. }
  3178. /**
  3179. * Defines specific conditional operators as extensions of Condition
  3180. */
  3181. class ValueCondition extends Condition {
  3182. /** path to specify the property of the target the conditional operator uses */
  3183. propertyPath: string;
  3184. /** the value compared by the conditional operator against the current value of the property */
  3185. value: any;
  3186. /** the conditional operator, default ValueCondition.IsEqual */
  3187. operator: number;
  3188. /**
  3189. * Internal only
  3190. * @hidden
  3191. */
  3192. private static _IsEqual;
  3193. /**
  3194. * Internal only
  3195. * @hidden
  3196. */
  3197. private static _IsDifferent;
  3198. /**
  3199. * Internal only
  3200. * @hidden
  3201. */
  3202. private static _IsGreater;
  3203. /**
  3204. * Internal only
  3205. * @hidden
  3206. */
  3207. private static _IsLesser;
  3208. /**
  3209. * returns the number for IsEqual
  3210. */
  3211. static readonly IsEqual: number;
  3212. /**
  3213. * Returns the number for IsDifferent
  3214. */
  3215. static readonly IsDifferent: number;
  3216. /**
  3217. * Returns the number for IsGreater
  3218. */
  3219. static readonly IsGreater: number;
  3220. /**
  3221. * Returns the number for IsLesser
  3222. */
  3223. static readonly IsLesser: number;
  3224. /**
  3225. * Internal only The action manager for the condition
  3226. * @hidden
  3227. */
  3228. _actionManager: ActionManager;
  3229. /**
  3230. * Internal only
  3231. * @hidden
  3232. */
  3233. private _target;
  3234. /**
  3235. * Internal only
  3236. * @hidden
  3237. */
  3238. private _effectiveTarget;
  3239. /**
  3240. * Internal only
  3241. * @hidden
  3242. */
  3243. private _property;
  3244. /**
  3245. * Creates a new ValueCondition
  3246. * @param actionManager manager for the action the condition applies to
  3247. * @param target for the action
  3248. * @param propertyPath path to specify the property of the target the conditional operator uses
  3249. * @param value the value compared by the conditional operator against the current value of the property
  3250. * @param operator the conditional operator, default ValueCondition.IsEqual
  3251. */
  3252. constructor(actionManager: ActionManager, target: any,
  3253. /** path to specify the property of the target the conditional operator uses */
  3254. propertyPath: string,
  3255. /** the value compared by the conditional operator against the current value of the property */
  3256. value: any,
  3257. /** the conditional operator, default ValueCondition.IsEqual */
  3258. operator?: number);
  3259. /**
  3260. * Compares the given value with the property value for the specified conditional operator
  3261. * @returns the result of the comparison
  3262. */
  3263. isValid(): boolean;
  3264. /**
  3265. * Serialize the ValueCondition into a JSON compatible object
  3266. * @returns serialization object
  3267. */
  3268. serialize(): any;
  3269. /**
  3270. * Gets the name of the conditional operator for the ValueCondition
  3271. * @param operator the conditional operator
  3272. * @returns the name
  3273. */
  3274. static GetOperatorName(operator: number): string;
  3275. }
  3276. /**
  3277. * Defines a predicate condition as an extension of Condition
  3278. */
  3279. class PredicateCondition extends Condition {
  3280. /** defines the predicate function used to validate the condition */
  3281. predicate: () => boolean;
  3282. /**
  3283. * Internal only - manager for action
  3284. * @hidden
  3285. */
  3286. _actionManager: ActionManager;
  3287. /**
  3288. * Creates a new PredicateCondition
  3289. * @param actionManager manager for the action the condition applies to
  3290. * @param predicate defines the predicate function used to validate the condition
  3291. */
  3292. constructor(actionManager: ActionManager,
  3293. /** defines the predicate function used to validate the condition */
  3294. predicate: () => boolean);
  3295. /**
  3296. * @returns the validity of the predicate condition
  3297. */
  3298. isValid(): boolean;
  3299. }
  3300. /**
  3301. * Defines a state condition as an extension of Condition
  3302. */
  3303. class StateCondition extends Condition {
  3304. /** Value to compare with target state */
  3305. value: string;
  3306. /**
  3307. * Internal only - manager for action
  3308. * @hidden
  3309. */
  3310. _actionManager: ActionManager;
  3311. /**
  3312. * Internal only
  3313. * @hidden
  3314. */
  3315. private _target;
  3316. /**
  3317. * Creates a new StateCondition
  3318. * @param actionManager manager for the action the condition applies to
  3319. * @param target of the condition
  3320. * @param value to compare with target state
  3321. */
  3322. constructor(actionManager: ActionManager, target: any,
  3323. /** Value to compare with target state */
  3324. value: string);
  3325. /**
  3326. * Gets a boolean indicating if the current condition is met
  3327. * @returns the validity of the state
  3328. */
  3329. isValid(): boolean;
  3330. /**
  3331. * Serialize the StateCondition into a JSON compatible object
  3332. * @returns serialization object
  3333. */
  3334. serialize(): any;
  3335. }
  3336. }
  3337. declare module BABYLON {
  3338. /**
  3339. * This defines an action responsible to toggle a boolean once triggered.
  3340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3341. */
  3342. class SwitchBooleanAction extends Action {
  3343. /**
  3344. * The path to the boolean property in the target object
  3345. */
  3346. propertyPath: string;
  3347. private _target;
  3348. private _effectiveTarget;
  3349. private _property;
  3350. /**
  3351. * Instantiate the action
  3352. * @param triggerOptions defines the trigger options
  3353. * @param target defines the object containing the boolean
  3354. * @param propertyPath defines the path to the boolean property in the target object
  3355. * @param condition defines the trigger related conditions
  3356. */
  3357. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3358. /** @hidden */
  3359. _prepare(): void;
  3360. /**
  3361. * Execute the action toggle the boolean value.
  3362. */
  3363. execute(): void;
  3364. /**
  3365. * Serializes the actions and its related information.
  3366. * @param parent defines the object to serialize in
  3367. * @returns the serialized object
  3368. */
  3369. serialize(parent: any): any;
  3370. }
  3371. /**
  3372. * This defines an action responsible to set a the state field of the target
  3373. * to a desired value once triggered.
  3374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3375. */
  3376. class SetStateAction extends Action {
  3377. /**
  3378. * The value to store in the state field.
  3379. */
  3380. value: string;
  3381. private _target;
  3382. /**
  3383. * Instantiate the action
  3384. * @param triggerOptions defines the trigger options
  3385. * @param target defines the object containing the state property
  3386. * @param value defines the value to store in the state field
  3387. * @param condition defines the trigger related conditions
  3388. */
  3389. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3390. /**
  3391. * Execute the action and store the value on the target state property.
  3392. */
  3393. execute(): void;
  3394. /**
  3395. * Serializes the actions and its related information.
  3396. * @param parent defines the object to serialize in
  3397. * @returns the serialized object
  3398. */
  3399. serialize(parent: any): any;
  3400. }
  3401. /**
  3402. * This defines an action responsible to set a property of the target
  3403. * to a desired value once triggered.
  3404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3405. */
  3406. class SetValueAction extends Action {
  3407. /**
  3408. * The path of the property to set in the target.
  3409. */
  3410. propertyPath: string;
  3411. /**
  3412. * The value to set in the property
  3413. */
  3414. value: any;
  3415. private _target;
  3416. private _effectiveTarget;
  3417. private _property;
  3418. /**
  3419. * Instantiate the action
  3420. * @param triggerOptions defines the trigger options
  3421. * @param target defines the object containing the property
  3422. * @param propertyPath defines the path of the property to set in the target
  3423. * @param value defines the value to set in the property
  3424. * @param condition defines the trigger related conditions
  3425. */
  3426. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3427. /** @hidden */
  3428. _prepare(): void;
  3429. /**
  3430. * Execute the action and set the targetted property to the desired value.
  3431. */
  3432. execute(): void;
  3433. /**
  3434. * Serializes the actions and its related information.
  3435. * @param parent defines the object to serialize in
  3436. * @returns the serialized object
  3437. */
  3438. serialize(parent: any): any;
  3439. }
  3440. /**
  3441. * This defines an action responsible to increment the target value
  3442. * to a desired value once triggered.
  3443. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3444. */
  3445. class IncrementValueAction extends Action {
  3446. /**
  3447. * The path of the property to increment in the target.
  3448. */
  3449. propertyPath: string;
  3450. /**
  3451. * The value we should increment the property by.
  3452. */
  3453. value: any;
  3454. private _target;
  3455. private _effectiveTarget;
  3456. private _property;
  3457. /**
  3458. * Instantiate the action
  3459. * @param triggerOptions defines the trigger options
  3460. * @param target defines the object containing the property
  3461. * @param propertyPath defines the path of the property to increment in the target
  3462. * @param value defines the value value we should increment the property by
  3463. * @param condition defines the trigger related conditions
  3464. */
  3465. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3466. /** @hidden */
  3467. _prepare(): void;
  3468. /**
  3469. * Execute the action and increment the target of the value amount.
  3470. */
  3471. execute(): void;
  3472. /**
  3473. * Serializes the actions and its related information.
  3474. * @param parent defines the object to serialize in
  3475. * @returns the serialized object
  3476. */
  3477. serialize(parent: any): any;
  3478. }
  3479. /**
  3480. * This defines an action responsible to start an animation once triggered.
  3481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3482. */
  3483. class PlayAnimationAction extends Action {
  3484. /**
  3485. * Where the animation should start (animation frame)
  3486. */
  3487. from: number;
  3488. /**
  3489. * Where the animation should stop (animation frame)
  3490. */
  3491. to: number;
  3492. /**
  3493. * Define if the animation should loop or stop after the first play.
  3494. */
  3495. loop?: boolean;
  3496. private _target;
  3497. /**
  3498. * Instantiate the action
  3499. * @param triggerOptions defines the trigger options
  3500. * @param target defines the target animation or animation name
  3501. * @param from defines from where the animation should start (animation frame)
  3502. * @param end defines where the animation should stop (animation frame)
  3503. * @param loop defines if the animation should loop or stop after the first play
  3504. * @param condition defines the trigger related conditions
  3505. */
  3506. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3507. /** @hidden */
  3508. _prepare(): void;
  3509. /**
  3510. * Execute the action and play the animation.
  3511. */
  3512. execute(): void;
  3513. /**
  3514. * Serializes the actions and its related information.
  3515. * @param parent defines the object to serialize in
  3516. * @returns the serialized object
  3517. */
  3518. serialize(parent: any): any;
  3519. }
  3520. /**
  3521. * This defines an action responsible to stop an animation once triggered.
  3522. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3523. */
  3524. class StopAnimationAction extends Action {
  3525. private _target;
  3526. /**
  3527. * Instantiate the action
  3528. * @param triggerOptions defines the trigger options
  3529. * @param target defines the target animation or animation name
  3530. * @param condition defines the trigger related conditions
  3531. */
  3532. constructor(triggerOptions: any, target: any, condition?: Condition);
  3533. /** @hidden */
  3534. _prepare(): void;
  3535. /**
  3536. * Execute the action and stop the animation.
  3537. */
  3538. execute(): void;
  3539. /**
  3540. * Serializes the actions and its related information.
  3541. * @param parent defines the object to serialize in
  3542. * @returns the serialized object
  3543. */
  3544. serialize(parent: any): any;
  3545. }
  3546. /**
  3547. * This defines an action responsible that does nothing once triggered.
  3548. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3549. */
  3550. class DoNothingAction extends Action {
  3551. /**
  3552. * Instantiate the action
  3553. * @param triggerOptions defines the trigger options
  3554. * @param condition defines the trigger related conditions
  3555. */
  3556. constructor(triggerOptions?: any, condition?: Condition);
  3557. /**
  3558. * Execute the action and do nothing.
  3559. */
  3560. execute(): void;
  3561. /**
  3562. * Serializes the actions and its related information.
  3563. * @param parent defines the object to serialize in
  3564. * @returns the serialized object
  3565. */
  3566. serialize(parent: any): any;
  3567. }
  3568. /**
  3569. * This defines an action responsible to trigger several actions once triggered.
  3570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3571. */
  3572. class CombineAction extends Action {
  3573. /**
  3574. * The list of aggregated animations to run.
  3575. */
  3576. children: Action[];
  3577. /**
  3578. * Instantiate the action
  3579. * @param triggerOptions defines the trigger options
  3580. * @param children defines the list of aggregated animations to run
  3581. * @param condition defines the trigger related conditions
  3582. */
  3583. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3584. /** @hidden */
  3585. _prepare(): void;
  3586. /**
  3587. * Execute the action and executes all the aggregated actions.
  3588. */
  3589. execute(evt: ActionEvent): void;
  3590. /**
  3591. * Serializes the actions and its related information.
  3592. * @param parent defines the object to serialize in
  3593. * @returns the serialized object
  3594. */
  3595. serialize(parent: any): any;
  3596. }
  3597. /**
  3598. * This defines an action responsible to run code (external event) once triggered.
  3599. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3600. */
  3601. class ExecuteCodeAction extends Action {
  3602. /**
  3603. * The callback function to run.
  3604. */
  3605. func: (evt: ActionEvent) => void;
  3606. /**
  3607. * Instantiate the action
  3608. * @param triggerOptions defines the trigger options
  3609. * @param func defines the callback function to run
  3610. * @param condition defines the trigger related conditions
  3611. */
  3612. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3613. /**
  3614. * Execute the action and run the attached code.
  3615. */
  3616. execute(evt: ActionEvent): void;
  3617. }
  3618. /**
  3619. * This defines an action responsible to set the parent property of the target once triggered.
  3620. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3621. */
  3622. class SetParentAction extends Action {
  3623. private _parent;
  3624. private _target;
  3625. /**
  3626. * Instantiate the action
  3627. * @param triggerOptions defines the trigger options
  3628. * @param target defines the target containing the parent property
  3629. * @param parent defines from where the animation should start (animation frame)
  3630. * @param condition defines the trigger related conditions
  3631. */
  3632. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3633. /** @hidden */
  3634. _prepare(): void;
  3635. /**
  3636. * Execute the action and set the parent property.
  3637. */
  3638. execute(): void;
  3639. /**
  3640. * Serializes the actions and its related information.
  3641. * @param parent defines the object to serialize in
  3642. * @returns the serialized object
  3643. */
  3644. serialize(parent: any): any;
  3645. }
  3646. }
  3647. declare module BABYLON {
  3648. /**
  3649. * This defines an action helpful to play a defined sound on a triggered action.
  3650. */
  3651. class PlaySoundAction extends Action {
  3652. private _sound;
  3653. /**
  3654. * Instantiate the action
  3655. * @param triggerOptions defines the trigger options
  3656. * @param sound defines the sound to play
  3657. * @param condition defines the trigger related conditions
  3658. */
  3659. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3660. /** @hidden */
  3661. _prepare(): void;
  3662. /**
  3663. * Execute the action and play the sound.
  3664. */
  3665. execute(): void;
  3666. /**
  3667. * Serializes the actions and its related information.
  3668. * @param parent defines the object to serialize in
  3669. * @returns the serialized object
  3670. */
  3671. serialize(parent: any): any;
  3672. }
  3673. /**
  3674. * This defines an action helpful to stop a defined sound on a triggered action.
  3675. */
  3676. class StopSoundAction extends Action {
  3677. private _sound;
  3678. /**
  3679. * Instantiate the action
  3680. * @param triggerOptions defines the trigger options
  3681. * @param sound defines the sound to stop
  3682. * @param condition defines the trigger related conditions
  3683. */
  3684. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3685. /** @hidden */
  3686. _prepare(): void;
  3687. /**
  3688. * Execute the action and stop the sound.
  3689. */
  3690. execute(): void;
  3691. /**
  3692. * Serializes the actions and its related information.
  3693. * @param parent defines the object to serialize in
  3694. * @returns the serialized object
  3695. */
  3696. serialize(parent: any): any;
  3697. }
  3698. }
  3699. declare module BABYLON {
  3700. /**
  3701. * This defines an action responsible to change the value of a property
  3702. * by interpolating between its current value and the newly set one once triggered.
  3703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3704. */
  3705. class InterpolateValueAction extends Action {
  3706. /**
  3707. * Defines the path of the property where the value should be interpolated
  3708. */
  3709. propertyPath: string;
  3710. /**
  3711. * Defines the target value at the end of the interpolation.
  3712. */
  3713. value: any;
  3714. /**
  3715. * Defines the time it will take for the property to interpolate to the value.
  3716. */
  3717. duration: number;
  3718. /**
  3719. * Defines if the other scene animations should be stopped when the action has been triggered
  3720. */
  3721. stopOtherAnimations?: boolean;
  3722. /**
  3723. * Defines a callback raised once the interpolation animation has been done.
  3724. */
  3725. onInterpolationDone?: () => void;
  3726. /**
  3727. * Observable triggered once the interpolation animation has been done.
  3728. */
  3729. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3730. private _target;
  3731. private _effectiveTarget;
  3732. private _property;
  3733. /**
  3734. * Instantiate the action
  3735. * @param triggerOptions defines the trigger options
  3736. * @param target defines the object containing the value to interpolate
  3737. * @param propertyPath defines the path to the property in the target object
  3738. * @param value defines the target value at the end of the interpolation
  3739. * @param duration deines the time it will take for the property to interpolate to the value.
  3740. * @param condition defines the trigger related conditions
  3741. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3742. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3743. */
  3744. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3745. /** @hidden */
  3746. _prepare(): void;
  3747. /**
  3748. * Execute the action starts the value interpolation.
  3749. */
  3750. execute(): void;
  3751. /**
  3752. * Serializes the actions and its related information.
  3753. * @param parent defines the object to serialize in
  3754. * @returns the serialized object
  3755. */
  3756. serialize(parent: any): any;
  3757. }
  3758. }
  3759. declare module BABYLON {
  3760. /**
  3761. * Class used to store an actual running animation
  3762. */
  3763. class Animatable {
  3764. /** defines the target object */
  3765. target: any;
  3766. /** defines the starting frame number (default is 0) */
  3767. fromFrame: number;
  3768. /** defines the ending frame number (default is 100) */
  3769. toFrame: number;
  3770. /** defines if the animation must loop (default is false) */
  3771. loopAnimation: boolean;
  3772. /** defines a callback to call when animation ends if it is not looping */
  3773. onAnimationEnd?: (() => void) | null | undefined;
  3774. private _localDelayOffset;
  3775. private _pausedDelay;
  3776. private _runtimeAnimations;
  3777. private _paused;
  3778. private _scene;
  3779. private _speedRatio;
  3780. private _weight;
  3781. private _syncRoot;
  3782. /**
  3783. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3784. * This will only apply for non looping animation (default is true)
  3785. */
  3786. disposeOnEnd: boolean;
  3787. /**
  3788. * Gets a boolean indicating if the animation has started
  3789. */
  3790. animationStarted: boolean;
  3791. /**
  3792. * Observer raised when the animation ends
  3793. */
  3794. onAnimationEndObservable: Observable<Animatable>;
  3795. /**
  3796. * Gets the root Animatable used to synchronize and normalize animations
  3797. */
  3798. readonly syncRoot: Animatable;
  3799. /**
  3800. * Gets the current frame of the first RuntimeAnimation
  3801. * Used to synchronize Animatables
  3802. */
  3803. readonly masterFrame: number;
  3804. /**
  3805. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3806. */
  3807. weight: number;
  3808. /**
  3809. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3810. */
  3811. speedRatio: number;
  3812. /**
  3813. * Creates a new Animatable
  3814. * @param scene defines the hosting scene
  3815. * @param target defines the target object
  3816. * @param fromFrame defines the starting frame number (default is 0)
  3817. * @param toFrame defines the ending frame number (default is 100)
  3818. * @param loopAnimation defines if the animation must loop (default is false)
  3819. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3820. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3821. * @param animations defines a group of animation to add to the new Animatable
  3822. */
  3823. constructor(scene: Scene,
  3824. /** defines the target object */
  3825. target: any,
  3826. /** defines the starting frame number (default is 0) */
  3827. fromFrame?: number,
  3828. /** defines the ending frame number (default is 100) */
  3829. toFrame?: number,
  3830. /** defines if the animation must loop (default is false) */
  3831. loopAnimation?: boolean, speedRatio?: number,
  3832. /** defines a callback to call when animation ends if it is not looping */
  3833. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3834. /**
  3835. * Synchronize and normalize current Animatable with a source Animatable
  3836. * This is useful when using animation weights and when animations are not of the same length
  3837. * @param root defines the root Animatable to synchronize with
  3838. * @returns the current Animatable
  3839. */
  3840. syncWith(root: Animatable): Animatable;
  3841. /**
  3842. * Gets the list of runtime animations
  3843. * @returns an array of RuntimeAnimation
  3844. */
  3845. getAnimations(): RuntimeAnimation[];
  3846. /**
  3847. * Adds more animations to the current animatable
  3848. * @param target defines the target of the animations
  3849. * @param animations defines the new animations to add
  3850. */
  3851. appendAnimations(target: any, animations: Animation[]): void;
  3852. /**
  3853. * Gets the source animation for a specific property
  3854. * @param property defines the propertyu to look for
  3855. * @returns null or the source animation for the given property
  3856. */
  3857. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3858. /**
  3859. * Gets the runtime animation for a specific property
  3860. * @param property defines the propertyu to look for
  3861. * @returns null or the runtime animation for the given property
  3862. */
  3863. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3864. /**
  3865. * Resets the animatable to its original state
  3866. */
  3867. reset(): void;
  3868. /**
  3869. * Allows the animatable to blend with current running animations
  3870. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3871. * @param blendingSpeed defines the blending speed to use
  3872. */
  3873. enableBlending(blendingSpeed: number): void;
  3874. /**
  3875. * Disable animation blending
  3876. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3877. */
  3878. disableBlending(): void;
  3879. /**
  3880. * Jump directly to a given frame
  3881. * @param frame defines the frame to jump to
  3882. */
  3883. goToFrame(frame: number): void;
  3884. /**
  3885. * Pause the animation
  3886. */
  3887. pause(): void;
  3888. /**
  3889. * Restart the animation
  3890. */
  3891. restart(): void;
  3892. private _raiseOnAnimationEnd;
  3893. /**
  3894. * Stop and delete the current animation
  3895. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3896. * @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)
  3897. */
  3898. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3899. /**
  3900. * Wait asynchronously for the animation to end
  3901. * @returns a promise which will be fullfilled when the animation ends
  3902. */
  3903. waitAsync(): Promise<Animatable>;
  3904. /** @hidden */
  3905. _animate(delay: number): boolean;
  3906. }
  3907. }
  3908. declare module BABYLON {
  3909. /**
  3910. * Represents the range of an animation
  3911. */
  3912. class AnimationRange {
  3913. /**The name of the animation range**/
  3914. name: string;
  3915. /**The starting frame of the animation */
  3916. from: number;
  3917. /**The ending frame of the animation*/
  3918. to: number;
  3919. /**
  3920. * Initializes the range of an animation
  3921. * @param name The name of the animation range
  3922. * @param from The starting frame of the animation
  3923. * @param to The ending frame of the animation
  3924. */
  3925. constructor(
  3926. /**The name of the animation range**/
  3927. name: string,
  3928. /**The starting frame of the animation */
  3929. from: number,
  3930. /**The ending frame of the animation*/
  3931. to: number);
  3932. /**
  3933. * Makes a copy of the animation range
  3934. * @returns A copy of the animation range
  3935. */
  3936. clone(): AnimationRange;
  3937. }
  3938. /**
  3939. * Composed of a frame, and an action function
  3940. */
  3941. class AnimationEvent {
  3942. /** The frame for which the event is triggered **/
  3943. frame: number;
  3944. /** The event to perform when triggered **/
  3945. action: (currentFrame: number) => void;
  3946. /** Specifies if the event should be triggered only once**/
  3947. onlyOnce?: boolean | undefined;
  3948. /**
  3949. * Specifies if the animation event is done
  3950. */
  3951. isDone: boolean;
  3952. /**
  3953. * Initializes the animation event
  3954. * @param frame The frame for which the event is triggered
  3955. * @param action The event to perform when triggered
  3956. * @param onlyOnce Specifies if the event should be triggered only once
  3957. */
  3958. constructor(
  3959. /** The frame for which the event is triggered **/
  3960. frame: number,
  3961. /** The event to perform when triggered **/
  3962. action: (currentFrame: number) => void,
  3963. /** Specifies if the event should be triggered only once**/
  3964. onlyOnce?: boolean | undefined);
  3965. /** @hidden */
  3966. _clone(): AnimationEvent;
  3967. }
  3968. /**
  3969. * A cursor which tracks a point on a path
  3970. */
  3971. class PathCursor {
  3972. private path;
  3973. /**
  3974. * Stores path cursor callbacks for when an onchange event is triggered
  3975. */
  3976. private _onchange;
  3977. /**
  3978. * The value of the path cursor
  3979. */
  3980. value: number;
  3981. /**
  3982. * The animation array of the path cursor
  3983. */
  3984. animations: Animation[];
  3985. /**
  3986. * Initializes the path cursor
  3987. * @param path The path to track
  3988. */
  3989. constructor(path: Path2);
  3990. /**
  3991. * Gets the cursor point on the path
  3992. * @returns A point on the path cursor at the cursor location
  3993. */
  3994. getPoint(): Vector3;
  3995. /**
  3996. * Moves the cursor ahead by the step amount
  3997. * @param step The amount to move the cursor forward
  3998. * @returns This path cursor
  3999. */
  4000. moveAhead(step?: number): PathCursor;
  4001. /**
  4002. * Moves the cursor behind by the step amount
  4003. * @param step The amount to move the cursor back
  4004. * @returns This path cursor
  4005. */
  4006. moveBack(step?: number): PathCursor;
  4007. /**
  4008. * Moves the cursor by the step amount
  4009. * If the step amount is greater than one, an exception is thrown
  4010. * @param step The amount to move the cursor
  4011. * @returns This path cursor
  4012. */
  4013. move(step: number): PathCursor;
  4014. /**
  4015. * Ensures that the value is limited between zero and one
  4016. * @returns This path cursor
  4017. */
  4018. private ensureLimits;
  4019. /**
  4020. * Runs onchange callbacks on change (used by the animation engine)
  4021. * @returns This path cursor
  4022. */
  4023. private raiseOnChange;
  4024. /**
  4025. * Executes a function on change
  4026. * @param f A path cursor onchange callback
  4027. * @returns This path cursor
  4028. */
  4029. onchange(f: (cursor: PathCursor) => void): PathCursor;
  4030. }
  4031. /**
  4032. * Defines an interface which represents an animation key frame
  4033. */
  4034. interface IAnimationKey {
  4035. /**
  4036. * Frame of the key frame
  4037. */
  4038. frame: number;
  4039. /**
  4040. * Value at the specifies key frame
  4041. */
  4042. value: any;
  4043. /**
  4044. * The input tangent for the cubic hermite spline
  4045. */
  4046. inTangent?: any;
  4047. /**
  4048. * The output tangent for the cubic hermite spline
  4049. */
  4050. outTangent?: any;
  4051. /**
  4052. * The animation interpolation type
  4053. */
  4054. interpolation?: AnimationKeyInterpolation;
  4055. }
  4056. /**
  4057. * Enum for the animation key frame interpolation type
  4058. */
  4059. enum AnimationKeyInterpolation {
  4060. /**
  4061. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4062. */
  4063. STEP = 1
  4064. }
  4065. /**
  4066. * Class used to store any kind of animation
  4067. */
  4068. class Animation {
  4069. /**Name of the animation */
  4070. name: string;
  4071. /**Property to animate */
  4072. targetProperty: string;
  4073. /**The frames per second of the animation */
  4074. framePerSecond: number;
  4075. /**The data type of the animation */
  4076. dataType: number;
  4077. /**The loop mode of the animation */
  4078. loopMode?: number | undefined;
  4079. /**Specifies if blending should be enabled */
  4080. enableBlending?: boolean | undefined;
  4081. /**
  4082. * Use matrix interpolation instead of using direct key value when animating matrices
  4083. */
  4084. static AllowMatricesInterpolation: boolean;
  4085. /**
  4086. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4087. */
  4088. static AllowMatrixDecomposeForInterpolation: boolean;
  4089. /**
  4090. * Stores the key frames of the animation
  4091. */
  4092. private _keys;
  4093. /**
  4094. * Stores the easing function of the animation
  4095. */
  4096. private _easingFunction;
  4097. /**
  4098. * @hidden Internal use only
  4099. */
  4100. _runtimeAnimations: RuntimeAnimation[];
  4101. /**
  4102. * The set of event that will be linked to this animation
  4103. */
  4104. private _events;
  4105. /**
  4106. * Stores an array of target property paths
  4107. */
  4108. targetPropertyPath: string[];
  4109. /**
  4110. * Stores the blending speed of the animation
  4111. */
  4112. blendingSpeed: number;
  4113. /**
  4114. * Stores the animation ranges for the animation
  4115. */
  4116. private _ranges;
  4117. /**
  4118. * @hidden Internal use
  4119. */
  4120. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4121. /**
  4122. * Sets up an animation
  4123. * @param property The property to animate
  4124. * @param animationType The animation type to apply
  4125. * @param framePerSecond The frames per second of the animation
  4126. * @param easingFunction The easing function used in the animation
  4127. * @returns The created animation
  4128. */
  4129. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4130. /**
  4131. * Create and start an animation on a node
  4132. * @param name defines the name of the global animation that will be run on all nodes
  4133. * @param node defines the root node where the animation will take place
  4134. * @param targetProperty defines property to animate
  4135. * @param framePerSecond defines the number of frame per second yo use
  4136. * @param totalFrame defines the number of frames in total
  4137. * @param from defines the initial value
  4138. * @param to defines the final value
  4139. * @param loopMode defines which loop mode you want to use (off by default)
  4140. * @param easingFunction defines the easing function to use (linear by default)
  4141. * @param onAnimationEnd defines the callback to call when animation end
  4142. * @returns the animatable created for this animation
  4143. */
  4144. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4145. /**
  4146. * Create and start an animation on a node and its descendants
  4147. * @param name defines the name of the global animation that will be run on all nodes
  4148. * @param node defines the root node where the animation will take place
  4149. * @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
  4150. * @param targetProperty defines property to animate
  4151. * @param framePerSecond defines the number of frame per second to use
  4152. * @param totalFrame defines the number of frames in total
  4153. * @param from defines the initial value
  4154. * @param to defines the final value
  4155. * @param loopMode defines which loop mode you want to use (off by default)
  4156. * @param easingFunction defines the easing function to use (linear by default)
  4157. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4158. * @returns the list of animatables created for all nodes
  4159. * @example https://www.babylonjs-playground.com/#MH0VLI
  4160. */
  4161. 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[]>;
  4162. /**
  4163. * Creates a new animation, merges it with the existing animations and starts it
  4164. * @param name Name of the animation
  4165. * @param node Node which contains the scene that begins the animations
  4166. * @param targetProperty Specifies which property to animate
  4167. * @param framePerSecond The frames per second of the animation
  4168. * @param totalFrame The total number of frames
  4169. * @param from The frame at the beginning of the animation
  4170. * @param to The frame at the end of the animation
  4171. * @param loopMode Specifies the loop mode of the animation
  4172. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4173. * @param onAnimationEnd Callback to run once the animation is complete
  4174. * @returns Nullable animation
  4175. */
  4176. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4177. /**
  4178. * Transition property of an host to the target Value
  4179. * @param property The property to transition
  4180. * @param targetValue The target Value of the property
  4181. * @param host The object where the property to animate belongs
  4182. * @param scene Scene used to run the animation
  4183. * @param frameRate Framerate (in frame/s) to use
  4184. * @param transition The transition type we want to use
  4185. * @param duration The duration of the animation, in milliseconds
  4186. * @param onAnimationEnd Callback trigger at the end of the animation
  4187. * @returns Nullable animation
  4188. */
  4189. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4190. /**
  4191. * Return the array of runtime animations currently using this animation
  4192. */
  4193. readonly runtimeAnimations: RuntimeAnimation[];
  4194. /**
  4195. * Specifies if any of the runtime animations are currently running
  4196. */
  4197. readonly hasRunningRuntimeAnimations: boolean;
  4198. /**
  4199. * Initializes the animation
  4200. * @param name Name of the animation
  4201. * @param targetProperty Property to animate
  4202. * @param framePerSecond The frames per second of the animation
  4203. * @param dataType The data type of the animation
  4204. * @param loopMode The loop mode of the animation
  4205. * @param enableBlendings Specifies if blending should be enabled
  4206. */
  4207. constructor(
  4208. /**Name of the animation */
  4209. name: string,
  4210. /**Property to animate */
  4211. targetProperty: string,
  4212. /**The frames per second of the animation */
  4213. framePerSecond: number,
  4214. /**The data type of the animation */
  4215. dataType: number,
  4216. /**The loop mode of the animation */
  4217. loopMode?: number | undefined,
  4218. /**Specifies if blending should be enabled */
  4219. enableBlending?: boolean | undefined);
  4220. /**
  4221. * Converts the animation to a string
  4222. * @param fullDetails support for multiple levels of logging within scene loading
  4223. * @returns String form of the animation
  4224. */
  4225. toString(fullDetails?: boolean): string;
  4226. /**
  4227. * Add an event to this animation
  4228. * @param event Event to add
  4229. */
  4230. addEvent(event: AnimationEvent): void;
  4231. /**
  4232. * Remove all events found at the given frame
  4233. * @param frame The frame to remove events from
  4234. */
  4235. removeEvents(frame: number): void;
  4236. /**
  4237. * Retrieves all the events from the animation
  4238. * @returns Events from the animation
  4239. */
  4240. getEvents(): AnimationEvent[];
  4241. /**
  4242. * Creates an animation range
  4243. * @param name Name of the animation range
  4244. * @param from Starting frame of the animation range
  4245. * @param to Ending frame of the animation
  4246. */
  4247. createRange(name: string, from: number, to: number): void;
  4248. /**
  4249. * Deletes an animation range by name
  4250. * @param name Name of the animation range to delete
  4251. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4252. */
  4253. deleteRange(name: string, deleteFrames?: boolean): void;
  4254. /**
  4255. * Gets the animation range by name, or null if not defined
  4256. * @param name Name of the animation range
  4257. * @returns Nullable animation range
  4258. */
  4259. getRange(name: string): Nullable<AnimationRange>;
  4260. /**
  4261. * Gets the key frames from the animation
  4262. * @returns The key frames of the animation
  4263. */
  4264. getKeys(): Array<IAnimationKey>;
  4265. /**
  4266. * Gets the highest frame rate of the animation
  4267. * @returns Highest frame rate of the animation
  4268. */
  4269. getHighestFrame(): number;
  4270. /**
  4271. * Gets the easing function of the animation
  4272. * @returns Easing function of the animation
  4273. */
  4274. getEasingFunction(): IEasingFunction;
  4275. /**
  4276. * Sets the easing function of the animation
  4277. * @param easingFunction A custom mathematical formula for animation
  4278. */
  4279. setEasingFunction(easingFunction: EasingFunction): void;
  4280. /**
  4281. * Interpolates a scalar linearly
  4282. * @param startValue Start value of the animation curve
  4283. * @param endValue End value of the animation curve
  4284. * @param gradient Scalar amount to interpolate
  4285. * @returns Interpolated scalar value
  4286. */
  4287. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4288. /**
  4289. * Interpolates a scalar cubically
  4290. * @param startValue Start value of the animation curve
  4291. * @param outTangent End tangent of the animation
  4292. * @param endValue End value of the animation curve
  4293. * @param inTangent Start tangent of the animation curve
  4294. * @param gradient Scalar amount to interpolate
  4295. * @returns Interpolated scalar value
  4296. */
  4297. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4298. /**
  4299. * Interpolates a quaternion using a spherical linear interpolation
  4300. * @param startValue Start value of the animation curve
  4301. * @param endValue End value of the animation curve
  4302. * @param gradient Scalar amount to interpolate
  4303. * @returns Interpolated quaternion value
  4304. */
  4305. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4306. /**
  4307. * Interpolates a quaternion cubically
  4308. * @param startValue Start value of the animation curve
  4309. * @param outTangent End tangent of the animation curve
  4310. * @param endValue End value of the animation curve
  4311. * @param inTangent Start tangent of the animation curve
  4312. * @param gradient Scalar amount to interpolate
  4313. * @returns Interpolated quaternion value
  4314. */
  4315. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4316. /**
  4317. * Interpolates a Vector3 linearl
  4318. * @param startValue Start value of the animation curve
  4319. * @param endValue End value of the animation curve
  4320. * @param gradient Scalar amount to interpolate
  4321. * @returns Interpolated scalar value
  4322. */
  4323. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4324. /**
  4325. * Interpolates a Vector3 cubically
  4326. * @param startValue Start value of the animation curve
  4327. * @param outTangent End tangent of the animation
  4328. * @param endValue End value of the animation curve
  4329. * @param inTangent Start tangent of the animation curve
  4330. * @param gradient Scalar amount to interpolate
  4331. * @returns InterpolatedVector3 value
  4332. */
  4333. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4334. /**
  4335. * Interpolates a Vector2 linearly
  4336. * @param startValue Start value of the animation curve
  4337. * @param endValue End value of the animation curve
  4338. * @param gradient Scalar amount to interpolate
  4339. * @returns Interpolated Vector2 value
  4340. */
  4341. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4342. /**
  4343. * Interpolates a Vector2 cubically
  4344. * @param startValue Start value of the animation curve
  4345. * @param outTangent End tangent of the animation
  4346. * @param endValue End value of the animation curve
  4347. * @param inTangent Start tangent of the animation curve
  4348. * @param gradient Scalar amount to interpolate
  4349. * @returns Interpolated Vector2 value
  4350. */
  4351. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4352. /**
  4353. * Interpolates a size linearly
  4354. * @param startValue Start value of the animation curve
  4355. * @param endValue End value of the animation curve
  4356. * @param gradient Scalar amount to interpolate
  4357. * @returns Interpolated Size value
  4358. */
  4359. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4360. /**
  4361. * Interpolates a Color3 linearly
  4362. * @param startValue Start value of the animation curve
  4363. * @param endValue End value of the animation curve
  4364. * @param gradient Scalar amount to interpolate
  4365. * @returns Interpolated Color3 value
  4366. */
  4367. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4368. /**
  4369. * @hidden Internal use only
  4370. */
  4371. _getKeyValue(value: any): any;
  4372. /**
  4373. * @hidden Internal use only
  4374. */
  4375. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4376. /**
  4377. * Defines the function to use to interpolate matrices
  4378. * @param startValue defines the start matrix
  4379. * @param endValue defines the end matrix
  4380. * @param gradient defines the gradient between both matrices
  4381. * @param result defines an optional target matrix where to store the interpolation
  4382. * @returns the interpolated matrix
  4383. */
  4384. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4385. /**
  4386. * Makes a copy of the animation
  4387. * @returns Cloned animation
  4388. */
  4389. clone(): Animation;
  4390. /**
  4391. * Sets the key frames of the animation
  4392. * @param values The animation key frames to set
  4393. */
  4394. setKeys(values: Array<IAnimationKey>): void;
  4395. /**
  4396. * Serializes the animation to an object
  4397. * @returns Serialized object
  4398. */
  4399. serialize(): any;
  4400. /**
  4401. * Float animation type
  4402. */
  4403. private static _ANIMATIONTYPE_FLOAT;
  4404. /**
  4405. * Vector3 animation type
  4406. */
  4407. private static _ANIMATIONTYPE_VECTOR3;
  4408. /**
  4409. * Quaternion animation type
  4410. */
  4411. private static _ANIMATIONTYPE_QUATERNION;
  4412. /**
  4413. * Matrix animation type
  4414. */
  4415. private static _ANIMATIONTYPE_MATRIX;
  4416. /**
  4417. * Color3 animation type
  4418. */
  4419. private static _ANIMATIONTYPE_COLOR3;
  4420. /**
  4421. * Vector2 animation type
  4422. */
  4423. private static _ANIMATIONTYPE_VECTOR2;
  4424. /**
  4425. * Size animation type
  4426. */
  4427. private static _ANIMATIONTYPE_SIZE;
  4428. /**
  4429. * Relative Loop Mode
  4430. */
  4431. private static _ANIMATIONLOOPMODE_RELATIVE;
  4432. /**
  4433. * Cycle Loop Mode
  4434. */
  4435. private static _ANIMATIONLOOPMODE_CYCLE;
  4436. /**
  4437. * Constant Loop Mode
  4438. */
  4439. private static _ANIMATIONLOOPMODE_CONSTANT;
  4440. /**
  4441. * Get the float animation type
  4442. */
  4443. static readonly ANIMATIONTYPE_FLOAT: number;
  4444. /**
  4445. * Get the Vector3 animation type
  4446. */
  4447. static readonly ANIMATIONTYPE_VECTOR3: number;
  4448. /**
  4449. * Get the Vector2 animation type
  4450. */
  4451. static readonly ANIMATIONTYPE_VECTOR2: number;
  4452. /**
  4453. * Get the Size animation type
  4454. */
  4455. static readonly ANIMATIONTYPE_SIZE: number;
  4456. /**
  4457. * Get the Quaternion animation type
  4458. */
  4459. static readonly ANIMATIONTYPE_QUATERNION: number;
  4460. /**
  4461. * Get the Matrix animation type
  4462. */
  4463. static readonly ANIMATIONTYPE_MATRIX: number;
  4464. /**
  4465. * Get the Color3 animation type
  4466. */
  4467. static readonly ANIMATIONTYPE_COLOR3: number;
  4468. /**
  4469. * Get the Relative Loop Mode
  4470. */
  4471. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4472. /**
  4473. * Get the Cycle Loop Mode
  4474. */
  4475. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4476. /**
  4477. * Get the Constant Loop Mode
  4478. */
  4479. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4480. /** @hidden */
  4481. static _UniversalLerp(left: any, right: any, amount: number): any;
  4482. /**
  4483. * Parses an animation object and creates an animation
  4484. * @param parsedAnimation Parsed animation object
  4485. * @returns Animation object
  4486. */
  4487. static Parse(parsedAnimation: any): Animation;
  4488. /**
  4489. * Appends the serialized animations from the source animations
  4490. * @param source Source containing the animations
  4491. * @param destination Target to store the animations
  4492. */
  4493. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4494. }
  4495. }
  4496. declare module BABYLON {
  4497. /**
  4498. * This class defines the direct association between an animation and a target
  4499. */
  4500. class TargetedAnimation {
  4501. /**
  4502. * Animation to perform
  4503. */
  4504. animation: Animation;
  4505. /**
  4506. * Target to animate
  4507. */
  4508. target: any;
  4509. }
  4510. /**
  4511. * Use this class to create coordinated animations on multiple targets
  4512. */
  4513. class AnimationGroup implements IDisposable {
  4514. /** The name of the animation group */
  4515. name: string;
  4516. private _scene;
  4517. private _targetedAnimations;
  4518. private _animatables;
  4519. private _from;
  4520. private _to;
  4521. private _isStarted;
  4522. private _speedRatio;
  4523. /**
  4524. * This observable will notify when one animation have ended.
  4525. */
  4526. onAnimationEndObservable: Observable<TargetedAnimation>;
  4527. /**
  4528. * This observable will notify when all animations have ended.
  4529. */
  4530. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4531. /**
  4532. * This observable will notify when all animations have paused.
  4533. */
  4534. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4535. /**
  4536. * Gets the first frame
  4537. */
  4538. readonly from: number;
  4539. /**
  4540. * Gets the last frame
  4541. */
  4542. readonly to: number;
  4543. /**
  4544. * Define if the animations are started
  4545. */
  4546. readonly isStarted: boolean;
  4547. /**
  4548. * Gets or sets the speed ratio to use for all animations
  4549. */
  4550. /**
  4551. * Gets or sets the speed ratio to use for all animations
  4552. */
  4553. speedRatio: number;
  4554. /**
  4555. * Gets the targeted animations for this animation group
  4556. */
  4557. readonly targetedAnimations: Array<TargetedAnimation>;
  4558. /**
  4559. * returning the list of animatables controlled by this animation group.
  4560. */
  4561. readonly animatables: Array<Animatable>;
  4562. /**
  4563. * Instantiates a new Animation Group.
  4564. * This helps managing several animations at once.
  4565. * @see http://doc.babylonjs.com/how_to/group
  4566. * @param name Defines the name of the group
  4567. * @param scene Defines the scene the group belongs to
  4568. */
  4569. constructor(
  4570. /** The name of the animation group */
  4571. name: string, scene?: Nullable<Scene>);
  4572. /**
  4573. * Add an animation (with its target) in the group
  4574. * @param animation defines the animation we want to add
  4575. * @param target defines the target of the animation
  4576. * @returns the TargetedAnimation object
  4577. */
  4578. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4579. /**
  4580. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4581. * It can add constant keys at begin or end
  4582. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4583. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4584. * @returns the animation group
  4585. */
  4586. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4587. /**
  4588. * Start all animations on given targets
  4589. * @param loop defines if animations must loop
  4590. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4591. * @param from defines the from key (optional)
  4592. * @param to defines the to key (optional)
  4593. * @returns the current animation group
  4594. */
  4595. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4596. /**
  4597. * Pause all animations
  4598. * @returns the animation group
  4599. */
  4600. pause(): AnimationGroup;
  4601. /**
  4602. * Play all animations to initial state
  4603. * This function will start() the animations if they were not started or will restart() them if they were paused
  4604. * @param loop defines if animations must loop
  4605. * @returns the animation group
  4606. */
  4607. play(loop?: boolean): AnimationGroup;
  4608. /**
  4609. * Reset all animations to initial state
  4610. * @returns the animation group
  4611. */
  4612. reset(): AnimationGroup;
  4613. /**
  4614. * Restart animations from key 0
  4615. * @returns the animation group
  4616. */
  4617. restart(): AnimationGroup;
  4618. /**
  4619. * Stop all animations
  4620. * @returns the animation group
  4621. */
  4622. stop(): AnimationGroup;
  4623. /**
  4624. * Set animation weight for all animatables
  4625. * @param weight defines the weight to use
  4626. * @return the animationGroup
  4627. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4628. */
  4629. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4630. /**
  4631. * Synchronize and normalize all animatables with a source animatable
  4632. * @param root defines the root animatable to synchronize with
  4633. * @return the animationGroup
  4634. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4635. */
  4636. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4637. /**
  4638. * Goes to a specific frame in this animation group
  4639. * @param frame the frame number to go to
  4640. * @return the animationGroup
  4641. */
  4642. goToFrame(frame: number): AnimationGroup;
  4643. /**
  4644. * Dispose all associated resources
  4645. */
  4646. dispose(): void;
  4647. private _checkAnimationGroupEnded;
  4648. /**
  4649. * Returns a new AnimationGroup object parsed from the source provided.
  4650. * @param parsedAnimationGroup defines the source
  4651. * @param scene defines the scene that will receive the animationGroup
  4652. * @returns a new AnimationGroup
  4653. */
  4654. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4655. /**
  4656. * Returns the string "AnimationGroup"
  4657. * @returns "AnimationGroup"
  4658. */
  4659. getClassName(): string;
  4660. /**
  4661. * Creates a detailled string about the object
  4662. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4663. * @returns a string representing the object
  4664. */
  4665. toString(fullDetails?: boolean): string;
  4666. }
  4667. }
  4668. declare module BABYLON {
  4669. /**
  4670. * Class used to override all child animations of a given target
  4671. */
  4672. class AnimationPropertiesOverride {
  4673. /**
  4674. * Gets or sets a value indicating if animation blending must be used
  4675. */
  4676. enableBlending: boolean;
  4677. /**
  4678. * Gets or sets the blending speed to use when enableBlending is true
  4679. */
  4680. blendingSpeed: number;
  4681. /**
  4682. * Gets or sets the default loop mode to use
  4683. */
  4684. loopMode: number;
  4685. }
  4686. }
  4687. declare module BABYLON {
  4688. /**
  4689. * This represents the main contract an easing function should follow.
  4690. * Easing functions are used throughout the animation system.
  4691. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4692. */
  4693. interface IEasingFunction {
  4694. /**
  4695. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4696. * of the easing function.
  4697. * The link below provides some of the most common examples of easing functions.
  4698. * @see https://easings.net/
  4699. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4700. * @returns the corresponding value on the curve defined by the easing function
  4701. */
  4702. ease(gradient: number): number;
  4703. }
  4704. /**
  4705. * Base class used for every default easing function.
  4706. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4707. */
  4708. class EasingFunction implements IEasingFunction {
  4709. /**
  4710. * Interpolation follows the mathematical formula associated with the easing function.
  4711. */
  4712. static readonly EASINGMODE_EASEIN: number;
  4713. /**
  4714. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4715. */
  4716. static readonly EASINGMODE_EASEOUT: number;
  4717. /**
  4718. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4719. */
  4720. static readonly EASINGMODE_EASEINOUT: number;
  4721. private _easingMode;
  4722. /**
  4723. * Sets the easing mode of the current function.
  4724. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4725. */
  4726. setEasingMode(easingMode: number): void;
  4727. /**
  4728. * Gets the current easing mode.
  4729. * @returns the easing mode
  4730. */
  4731. getEasingMode(): number;
  4732. /**
  4733. * @hidden
  4734. */
  4735. easeInCore(gradient: number): number;
  4736. /**
  4737. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4738. * of the easing function.
  4739. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4740. * @returns the corresponding value on the curve defined by the easing function
  4741. */
  4742. ease(gradient: number): number;
  4743. }
  4744. /**
  4745. * Easing function with a circle shape (see link below).
  4746. * @see https://easings.net/#easeInCirc
  4747. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4748. */
  4749. class CircleEase extends EasingFunction implements IEasingFunction {
  4750. /** @hidden */
  4751. easeInCore(gradient: number): number;
  4752. }
  4753. /**
  4754. * Easing function with a ease back shape (see link below).
  4755. * @see https://easings.net/#easeInBack
  4756. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4757. */
  4758. class BackEase extends EasingFunction implements IEasingFunction {
  4759. /** Defines the amplitude of the function */
  4760. amplitude: number;
  4761. /**
  4762. * Instantiates a back ease easing
  4763. * @see https://easings.net/#easeInBack
  4764. * @param amplitude Defines the amplitude of the function
  4765. */
  4766. constructor(
  4767. /** Defines the amplitude of the function */
  4768. amplitude?: number);
  4769. /** @hidden */
  4770. easeInCore(gradient: number): number;
  4771. }
  4772. /**
  4773. * Easing function with a bouncing shape (see link below).
  4774. * @see https://easings.net/#easeInBounce
  4775. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4776. */
  4777. class BounceEase extends EasingFunction implements IEasingFunction {
  4778. /** Defines the number of bounces */
  4779. bounces: number;
  4780. /** Defines the amplitude of the bounce */
  4781. bounciness: number;
  4782. /**
  4783. * Instantiates a bounce easing
  4784. * @see https://easings.net/#easeInBounce
  4785. * @param bounces Defines the number of bounces
  4786. * @param bounciness Defines the amplitude of the bounce
  4787. */
  4788. constructor(
  4789. /** Defines the number of bounces */
  4790. bounces?: number,
  4791. /** Defines the amplitude of the bounce */
  4792. bounciness?: number);
  4793. /** @hidden */
  4794. easeInCore(gradient: number): number;
  4795. }
  4796. /**
  4797. * Easing function with a power of 3 shape (see link below).
  4798. * @see https://easings.net/#easeInCubic
  4799. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4800. */
  4801. class CubicEase extends EasingFunction implements IEasingFunction {
  4802. /** @hidden */
  4803. easeInCore(gradient: number): number;
  4804. }
  4805. /**
  4806. * Easing function with an elastic shape (see link below).
  4807. * @see https://easings.net/#easeInElastic
  4808. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4809. */
  4810. class ElasticEase extends EasingFunction implements IEasingFunction {
  4811. /** Defines the number of oscillations*/
  4812. oscillations: number;
  4813. /** Defines the amplitude of the oscillations*/
  4814. springiness: number;
  4815. /**
  4816. * Instantiates an elastic easing function
  4817. * @see https://easings.net/#easeInElastic
  4818. * @param oscillations Defines the number of oscillations
  4819. * @param springiness Defines the amplitude of the oscillations
  4820. */
  4821. constructor(
  4822. /** Defines the number of oscillations*/
  4823. oscillations?: number,
  4824. /** Defines the amplitude of the oscillations*/
  4825. springiness?: number);
  4826. /** @hidden */
  4827. easeInCore(gradient: number): number;
  4828. }
  4829. /**
  4830. * Easing function with an exponential shape (see link below).
  4831. * @see https://easings.net/#easeInExpo
  4832. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4833. */
  4834. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4835. /** Defines the exponent of the function */
  4836. exponent: number;
  4837. /**
  4838. * Instantiates an exponential easing function
  4839. * @see https://easings.net/#easeInExpo
  4840. * @param exponent Defines the exponent of the function
  4841. */
  4842. constructor(
  4843. /** Defines the exponent of the function */
  4844. exponent?: number);
  4845. /** @hidden */
  4846. easeInCore(gradient: number): number;
  4847. }
  4848. /**
  4849. * Easing function with a power shape (see link below).
  4850. * @see https://easings.net/#easeInQuad
  4851. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4852. */
  4853. class PowerEase extends EasingFunction implements IEasingFunction {
  4854. /** Defines the power of the function */
  4855. power: number;
  4856. /**
  4857. * Instantiates an power base easing function
  4858. * @see https://easings.net/#easeInQuad
  4859. * @param power Defines the power of the function
  4860. */
  4861. constructor(
  4862. /** Defines the power of the function */
  4863. power?: number);
  4864. /** @hidden */
  4865. easeInCore(gradient: number): number;
  4866. }
  4867. /**
  4868. * Easing function with a power of 2 shape (see link below).
  4869. * @see https://easings.net/#easeInQuad
  4870. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4871. */
  4872. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4873. /** @hidden */
  4874. easeInCore(gradient: number): number;
  4875. }
  4876. /**
  4877. * Easing function with a power of 4 shape (see link below).
  4878. * @see https://easings.net/#easeInQuart
  4879. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4880. */
  4881. class QuarticEase extends EasingFunction implements IEasingFunction {
  4882. /** @hidden */
  4883. easeInCore(gradient: number): number;
  4884. }
  4885. /**
  4886. * Easing function with a power of 5 shape (see link below).
  4887. * @see https://easings.net/#easeInQuint
  4888. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4889. */
  4890. class QuinticEase extends EasingFunction implements IEasingFunction {
  4891. /** @hidden */
  4892. easeInCore(gradient: number): number;
  4893. }
  4894. /**
  4895. * Easing function with a sin shape (see link below).
  4896. * @see https://easings.net/#easeInSine
  4897. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4898. */
  4899. class SineEase extends EasingFunction implements IEasingFunction {
  4900. /** @hidden */
  4901. easeInCore(gradient: number): number;
  4902. }
  4903. /**
  4904. * Easing function with a bezier shape (see link below).
  4905. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4906. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4907. */
  4908. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4909. /** Defines the x component of the start tangent in the bezier curve */
  4910. x1: number;
  4911. /** Defines the y component of the start tangent in the bezier curve */
  4912. y1: number;
  4913. /** Defines the x component of the end tangent in the bezier curve */
  4914. x2: number;
  4915. /** Defines the y component of the end tangent in the bezier curve */
  4916. y2: number;
  4917. /**
  4918. * Instantiates a bezier function
  4919. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4920. * @param x1 Defines the x component of the start tangent in the bezier curve
  4921. * @param y1 Defines the y component of the start tangent in the bezier curve
  4922. * @param x2 Defines the x component of the end tangent in the bezier curve
  4923. * @param y2 Defines the y component of the end tangent in the bezier curve
  4924. */
  4925. constructor(
  4926. /** Defines the x component of the start tangent in the bezier curve */
  4927. x1?: number,
  4928. /** Defines the y component of the start tangent in the bezier curve */
  4929. y1?: number,
  4930. /** Defines the x component of the end tangent in the bezier curve */
  4931. x2?: number,
  4932. /** Defines the y component of the end tangent in the bezier curve */
  4933. y2?: number);
  4934. /** @hidden */
  4935. easeInCore(gradient: number): number;
  4936. }
  4937. }
  4938. declare module BABYLON {
  4939. /**
  4940. * Defines a runtime animation
  4941. */
  4942. class RuntimeAnimation {
  4943. private _events;
  4944. /**
  4945. * The current frame of the runtime animation
  4946. */
  4947. private _currentFrame;
  4948. /**
  4949. * The animation used by the runtime animation
  4950. */
  4951. private _animation;
  4952. /**
  4953. * The target of the runtime animation
  4954. */
  4955. private _target;
  4956. /**
  4957. * The initiating animatable
  4958. */
  4959. private _host;
  4960. /**
  4961. * The original value of the runtime animation
  4962. */
  4963. private _originalValue;
  4964. /**
  4965. * The original blend value of the runtime animation
  4966. */
  4967. private _originalBlendValue;
  4968. /**
  4969. * The offsets cache of the runtime animation
  4970. */
  4971. private _offsetsCache;
  4972. /**
  4973. * The high limits cache of the runtime animation
  4974. */
  4975. private _highLimitsCache;
  4976. /**
  4977. * Specifies if the runtime animation has been stopped
  4978. */
  4979. private _stopped;
  4980. /**
  4981. * The blending factor of the runtime animation
  4982. */
  4983. private _blendingFactor;
  4984. /**
  4985. * The BabylonJS scene
  4986. */
  4987. private _scene;
  4988. /**
  4989. * The current value of the runtime animation
  4990. */
  4991. private _currentValue;
  4992. /** @hidden */
  4993. _workValue: any;
  4994. /**
  4995. * The active target of the runtime animation
  4996. */
  4997. private _activeTarget;
  4998. /**
  4999. * The target path of the runtime animation
  5000. */
  5001. private _targetPath;
  5002. /**
  5003. * The weight of the runtime animation
  5004. */
  5005. private _weight;
  5006. /**
  5007. * The ratio offset of the runtime animation
  5008. */
  5009. private _ratioOffset;
  5010. /**
  5011. * The previous delay of the runtime animation
  5012. */
  5013. private _previousDelay;
  5014. /**
  5015. * The previous ratio of the runtime animation
  5016. */
  5017. private _previousRatio;
  5018. /**
  5019. * Gets the current frame of the runtime animation
  5020. */
  5021. readonly currentFrame: number;
  5022. /**
  5023. * Gets the weight of the runtime animation
  5024. */
  5025. readonly weight: number;
  5026. /**
  5027. * Gets the current value of the runtime animation
  5028. */
  5029. readonly currentValue: any;
  5030. /**
  5031. * Gets the target path of the runtime animation
  5032. */
  5033. readonly targetPath: string;
  5034. /**
  5035. * Gets the actual target of the runtime animation
  5036. */
  5037. readonly target: any;
  5038. /**
  5039. * Create a new RuntimeAnimation object
  5040. * @param target defines the target of the animation
  5041. * @param animation defines the source animation object
  5042. * @param scene defines the hosting scene
  5043. * @param host defines the initiating Animatable
  5044. */
  5045. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5046. /**
  5047. * Gets the animation from the runtime animation
  5048. */
  5049. readonly animation: Animation;
  5050. /**
  5051. * Resets the runtime animation to the beginning
  5052. * @param restoreOriginal defines whether to restore the target property to the original value
  5053. */
  5054. reset(restoreOriginal?: boolean): void;
  5055. /**
  5056. * Specifies if the runtime animation is stopped
  5057. * @returns Boolean specifying if the runtime animation is stopped
  5058. */
  5059. isStopped(): boolean;
  5060. /**
  5061. * Disposes of the runtime animation
  5062. */
  5063. dispose(): void;
  5064. /**
  5065. * Interpolates the animation from the current frame
  5066. * @param currentFrame The frame to interpolate the animation to
  5067. * @param repeatCount The number of times that the animation should loop
  5068. * @param loopMode The type of looping mode to use
  5069. * @param offsetValue Animation offset value
  5070. * @param highLimitValue The high limit value
  5071. * @returns The interpolated value
  5072. */
  5073. private _interpolate;
  5074. /**
  5075. * Apply the interpolated value to the target
  5076. * @param currentValue defines the value computed by the animation
  5077. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5078. */
  5079. setValue(currentValue: any, weight?: number): void;
  5080. private _setValue;
  5081. /**
  5082. * Gets the loop pmode of the runtime animation
  5083. * @returns Loop Mode
  5084. */
  5085. private _getCorrectLoopMode;
  5086. /**
  5087. * Move the current animation to a given frame
  5088. * @param frame defines the frame to move to
  5089. */
  5090. goToFrame(frame: number): void;
  5091. /**
  5092. * @hidden Internal use only
  5093. */
  5094. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5095. /**
  5096. * Execute the current animation
  5097. * @param delay defines the delay to add to the current frame
  5098. * @param from defines the lower bound of the animation range
  5099. * @param to defines the upper bound of the animation range
  5100. * @param loop defines if the current animation must loop
  5101. * @param speedRatio defines the current speed ratio
  5102. * @param weight defines the weight of the animation (default is -1 so no weight)
  5103. * @returns a boolean indicating if the animation is running
  5104. */
  5105. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  5106. }
  5107. }
  5108. declare module BABYLON {
  5109. /**
  5110. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5111. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5112. */
  5113. class Analyser {
  5114. /**
  5115. * Gets or sets the smoothing
  5116. * @ignorenaming
  5117. */
  5118. SMOOTHING: number;
  5119. /**
  5120. * Gets or sets the FFT table size
  5121. * @ignorenaming
  5122. */
  5123. FFT_SIZE: number;
  5124. /**
  5125. * Gets or sets the bar graph amplitude
  5126. * @ignorenaming
  5127. */
  5128. BARGRAPHAMPLITUDE: number;
  5129. /**
  5130. * Gets or sets the position of the debug canvas
  5131. * @ignorenaming
  5132. */
  5133. DEBUGCANVASPOS: {
  5134. x: number;
  5135. y: number;
  5136. };
  5137. /**
  5138. * Gets or sets the debug canvas size
  5139. * @ignorenaming
  5140. */
  5141. DEBUGCANVASSIZE: {
  5142. width: number;
  5143. height: number;
  5144. };
  5145. private _byteFreqs;
  5146. private _byteTime;
  5147. private _floatFreqs;
  5148. private _webAudioAnalyser;
  5149. private _debugCanvas;
  5150. private _debugCanvasContext;
  5151. private _scene;
  5152. private _registerFunc;
  5153. private _audioEngine;
  5154. /**
  5155. * Creates a new analyser
  5156. * @param scene defines hosting scene
  5157. */
  5158. constructor(scene: Scene);
  5159. /**
  5160. * Get the number of data values you will have to play with for the visualization
  5161. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5162. * @returns a number
  5163. */
  5164. getFrequencyBinCount(): number;
  5165. /**
  5166. * Gets the current frequency data as a byte array
  5167. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5168. * @returns a Uint8Array
  5169. */
  5170. getByteFrequencyData(): Uint8Array;
  5171. /**
  5172. * Gets the current waveform as a byte array
  5173. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5174. * @returns a Uint8Array
  5175. */
  5176. getByteTimeDomainData(): Uint8Array;
  5177. /**
  5178. * Gets the current frequency data as a float array
  5179. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5180. * @returns a Float32Array
  5181. */
  5182. getFloatFrequencyData(): Float32Array;
  5183. /**
  5184. * Renders the debug canvas
  5185. */
  5186. drawDebugCanvas(): void;
  5187. /**
  5188. * Stops rendering the debug canvas and removes it
  5189. */
  5190. stopDebugCanvas(): void;
  5191. /**
  5192. * Connects two audio nodes
  5193. * @param inputAudioNode defines first node to connect
  5194. * @param outputAudioNode defines second node to connect
  5195. */
  5196. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5197. /**
  5198. * Releases all associated resources
  5199. */
  5200. dispose(): void;
  5201. }
  5202. }
  5203. declare module BABYLON {
  5204. /**
  5205. * This represents an audio engine and it is responsible
  5206. * to play, synchronize and analyse sounds throughout the application.
  5207. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5208. */
  5209. interface IAudioEngine extends IDisposable {
  5210. /**
  5211. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5212. */
  5213. readonly canUseWebAudio: boolean;
  5214. /**
  5215. * Gets the current AudioContext if available.
  5216. */
  5217. readonly audioContext: Nullable<AudioContext>;
  5218. /**
  5219. * The master gain node defines the global audio volume of your audio engine.
  5220. */
  5221. readonly masterGain: GainNode;
  5222. /**
  5223. * Gets whether or not mp3 are supported by your browser.
  5224. */
  5225. readonly isMP3supported: boolean;
  5226. /**
  5227. * Gets whether or not ogg are supported by your browser.
  5228. */
  5229. readonly isOGGsupported: boolean;
  5230. /**
  5231. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5232. * @ignoreNaming
  5233. */
  5234. WarnedWebAudioUnsupported: boolean;
  5235. /**
  5236. * Defines if the audio engine relies on a custom unlocked button.
  5237. * In this case, the embedded button will not be displayed.
  5238. */
  5239. useCustomUnlockedButton: boolean;
  5240. /**
  5241. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5242. */
  5243. readonly unlocked: boolean;
  5244. /**
  5245. * Event raised when audio has been unlocked on the browser.
  5246. */
  5247. onAudioUnlockedObservable: Observable<AudioEngine>;
  5248. /**
  5249. * Event raised when audio has been locked on the browser.
  5250. */
  5251. onAudioLockedObservable: Observable<AudioEngine>;
  5252. /**
  5253. * Flags the audio engine in Locked state.
  5254. * This happens due to new browser policies preventing audio to autoplay.
  5255. */
  5256. lock(): void;
  5257. /**
  5258. * Unlocks the audio engine once a user action has been done on the dom.
  5259. * This is helpful to resume play once browser policies have been satisfied.
  5260. */
  5261. unlock(): void;
  5262. }
  5263. /**
  5264. * This represents the default audio engine used in babylon.
  5265. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5266. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5267. */
  5268. class AudioEngine implements IAudioEngine {
  5269. private _audioContext;
  5270. private _audioContextInitialized;
  5271. private _muteButton;
  5272. private _hostElement;
  5273. /**
  5274. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5275. */
  5276. canUseWebAudio: boolean;
  5277. /**
  5278. * The master gain node defines the global audio volume of your audio engine.
  5279. */
  5280. masterGain: GainNode;
  5281. /**
  5282. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5283. * @ignoreNaming
  5284. */
  5285. WarnedWebAudioUnsupported: boolean;
  5286. /**
  5287. * Gets whether or not mp3 are supported by your browser.
  5288. */
  5289. isMP3supported: boolean;
  5290. /**
  5291. * Gets whether or not ogg are supported by your browser.
  5292. */
  5293. isOGGsupported: boolean;
  5294. /**
  5295. * Gets whether audio has been unlocked on the device.
  5296. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5297. * a user interaction has happened.
  5298. */
  5299. unlocked: boolean;
  5300. /**
  5301. * Defines if the audio engine relies on a custom unlocked button.
  5302. * In this case, the embedded button will not be displayed.
  5303. */
  5304. useCustomUnlockedButton: boolean;
  5305. /**
  5306. * Event raised when audio has been unlocked on the browser.
  5307. */
  5308. onAudioUnlockedObservable: Observable<AudioEngine>;
  5309. /**
  5310. * Event raised when audio has been locked on the browser.
  5311. */
  5312. onAudioLockedObservable: Observable<AudioEngine>;
  5313. /**
  5314. * Gets the current AudioContext if available.
  5315. */
  5316. readonly audioContext: Nullable<AudioContext>;
  5317. private _connectedAnalyser;
  5318. /**
  5319. * Instantiates a new audio engine.
  5320. *
  5321. * There should be only one per page as some browsers restrict the number
  5322. * of audio contexts you can create.
  5323. * @param hostElement defines the host element where to display the mute icon if necessary
  5324. */
  5325. constructor(hostElement?: Nullable<HTMLElement>);
  5326. /**
  5327. * Flags the audio engine in Locked state.
  5328. * This happens due to new browser policies preventing audio to autoplay.
  5329. */
  5330. lock(): void;
  5331. /**
  5332. * Unlocks the audio engine once a user action has been done on the dom.
  5333. * This is helpful to resume play once browser policies have been satisfied.
  5334. */
  5335. unlock(): void;
  5336. private _resumeAudioContext;
  5337. private _initializeAudioContext;
  5338. private _tryToRun;
  5339. private _triggerRunningState;
  5340. private _triggerSuspendedState;
  5341. private _displayMuteButton;
  5342. private _moveButtonToTopLeft;
  5343. private _onResize;
  5344. private _hideMuteButton;
  5345. /**
  5346. * Destroy and release the resources associated with the audio ccontext.
  5347. */
  5348. dispose(): void;
  5349. /**
  5350. * Gets the global volume sets on the master gain.
  5351. * @returns the global volume if set or -1 otherwise
  5352. */
  5353. getGlobalVolume(): number;
  5354. /**
  5355. * Sets the global volume of your experience (sets on the master gain).
  5356. * @param newVolume Defines the new global volume of the application
  5357. */
  5358. setGlobalVolume(newVolume: number): void;
  5359. /**
  5360. * Connect the audio engine to an audio analyser allowing some amazing
  5361. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5363. * @param analyser The analyser to connect to the engine
  5364. */
  5365. connectToAnalyser(analyser: Analyser): void;
  5366. }
  5367. }
  5368. declare module BABYLON {
  5369. interface AbstractScene {
  5370. /**
  5371. * The list of sounds used in the scene.
  5372. */
  5373. sounds: Nullable<Array<Sound>>;
  5374. }
  5375. interface Scene {
  5376. /**
  5377. * @hidden
  5378. * Backing field
  5379. */
  5380. _mainSoundTrack: SoundTrack;
  5381. /**
  5382. * The main sound track played by the scene.
  5383. * It cotains your primary collection of sounds.
  5384. */
  5385. mainSoundTrack: SoundTrack;
  5386. /**
  5387. * The list of sound tracks added to the scene
  5388. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5389. */
  5390. soundTracks: Nullable<Array<SoundTrack>>;
  5391. /**
  5392. * Gets a sound using a given name
  5393. * @param name defines the name to search for
  5394. * @return the found sound or null if not found at all.
  5395. */
  5396. getSoundByName(name: string): Nullable<Sound>;
  5397. /**
  5398. * Gets or sets if audio support is enabled
  5399. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5400. */
  5401. audioEnabled: boolean;
  5402. /**
  5403. * Gets or sets if audio will be output to headphones
  5404. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5405. */
  5406. headphone: boolean;
  5407. }
  5408. /**
  5409. * Defines the sound scene component responsible to manage any sounds
  5410. * in a given scene.
  5411. */
  5412. class AudioSceneComponent implements ISceneSerializableComponent {
  5413. /**
  5414. * The component name helpfull to identify the component in the list of scene components.
  5415. */
  5416. readonly name: string;
  5417. /**
  5418. * The scene the component belongs to.
  5419. */
  5420. scene: Scene;
  5421. private _audioEnabled;
  5422. /**
  5423. * Gets whether audio is enabled or not.
  5424. * Please use related enable/disable method to switch state.
  5425. */
  5426. readonly audioEnabled: boolean;
  5427. private _headphone;
  5428. /**
  5429. * Gets whether audio is outputing to headphone or not.
  5430. * Please use the according Switch methods to change output.
  5431. */
  5432. readonly headphone: boolean;
  5433. /**
  5434. * Creates a new instance of the component for the given scene
  5435. * @param scene Defines the scene to register the component in
  5436. */
  5437. constructor(scene: Scene);
  5438. /**
  5439. * Registers the component in a given scene
  5440. */
  5441. register(): void;
  5442. /**
  5443. * Rebuilds the elements related to this component in case of
  5444. * context lost for instance.
  5445. */
  5446. rebuild(): void;
  5447. /**
  5448. * Serializes the component data to the specified json object
  5449. * @param serializationObject The object to serialize to
  5450. */
  5451. serialize(serializationObject: any): void;
  5452. /**
  5453. * Adds all the element from the container to the scene
  5454. * @param container the container holding the elements
  5455. */
  5456. addFromContainer(container: AbstractScene): void;
  5457. /**
  5458. * Removes all the elements in the container from the scene
  5459. * @param container contains the elements to remove
  5460. */
  5461. removeFromContainer(container: AbstractScene): void;
  5462. /**
  5463. * Disposes the component and the associated ressources.
  5464. */
  5465. dispose(): void;
  5466. /**
  5467. * Disables audio in the associated scene.
  5468. */
  5469. disableAudio(): void;
  5470. /**
  5471. * Enables audio in the associated scene.
  5472. */
  5473. enableAudio(): void;
  5474. /**
  5475. * Switch audio to headphone output.
  5476. */
  5477. switchAudioModeForHeadphones(): void;
  5478. /**
  5479. * Switch audio to normal speakers.
  5480. */
  5481. switchAudioModeForNormalSpeakers(): void;
  5482. private _afterRender;
  5483. }
  5484. }
  5485. declare module BABYLON {
  5486. /**
  5487. * Defines a sound that can be played in the application.
  5488. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5490. */
  5491. class Sound {
  5492. /**
  5493. * The name of the sound in the scene.
  5494. */
  5495. name: string;
  5496. /**
  5497. * Does the sound autoplay once loaded.
  5498. */
  5499. autoplay: boolean;
  5500. /**
  5501. * Does the sound loop after it finishes playing once.
  5502. */
  5503. loop: boolean;
  5504. /**
  5505. * Does the sound use a custom attenuation curve to simulate the falloff
  5506. * happening when the source gets further away from the camera.
  5507. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5508. */
  5509. useCustomAttenuation: boolean;
  5510. /**
  5511. * The sound track id this sound belongs to.
  5512. */
  5513. soundTrackId: number;
  5514. /**
  5515. * Is this sound currently played.
  5516. */
  5517. isPlaying: boolean;
  5518. /**
  5519. * Is this sound currently paused.
  5520. */
  5521. isPaused: boolean;
  5522. /**
  5523. * Does this sound enables spatial sound.
  5524. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5525. */
  5526. spatialSound: boolean;
  5527. /**
  5528. * Define the reference distance the sound should be heard perfectly.
  5529. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5530. */
  5531. refDistance: number;
  5532. /**
  5533. * Define the roll off factor of spatial sounds.
  5534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5535. */
  5536. rolloffFactor: number;
  5537. /**
  5538. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5539. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5540. */
  5541. maxDistance: number;
  5542. /**
  5543. * Define the distance attenuation model the sound will follow.
  5544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5545. */
  5546. distanceModel: string;
  5547. /**
  5548. * @hidden
  5549. * Back Compat
  5550. **/
  5551. onended: () => any;
  5552. /**
  5553. * Observable event when the current playing sound finishes.
  5554. */
  5555. onEndedObservable: Observable<Sound>;
  5556. private _panningModel;
  5557. private _playbackRate;
  5558. private _streaming;
  5559. private _startTime;
  5560. private _startOffset;
  5561. private _position;
  5562. /** @hidden */
  5563. _positionInEmitterSpace: boolean;
  5564. private _localDirection;
  5565. private _volume;
  5566. private _isReadyToPlay;
  5567. private _isDirectional;
  5568. private _readyToPlayCallback;
  5569. private _audioBuffer;
  5570. private _soundSource;
  5571. private _streamingSource;
  5572. private _soundPanner;
  5573. private _soundGain;
  5574. private _inputAudioNode;
  5575. private _outputAudioNode;
  5576. private _coneInnerAngle;
  5577. private _coneOuterAngle;
  5578. private _coneOuterGain;
  5579. private _scene;
  5580. private _connectedMesh;
  5581. private _customAttenuationFunction;
  5582. private _registerFunc;
  5583. private _isOutputConnected;
  5584. private _htmlAudioElement;
  5585. private _urlType;
  5586. /**
  5587. * Create a sound and attach it to a scene
  5588. * @param name Name of your sound
  5589. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5590. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5591. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5592. */
  5593. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5594. /**
  5595. * Release the sound and its associated resources
  5596. */
  5597. dispose(): void;
  5598. /**
  5599. * Gets if the sounds is ready to be played or not.
  5600. * @returns true if ready, otherwise false
  5601. */
  5602. isReady(): boolean;
  5603. private _soundLoaded;
  5604. /**
  5605. * Sets the data of the sound from an audiobuffer
  5606. * @param audioBuffer The audioBuffer containing the data
  5607. */
  5608. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5609. /**
  5610. * Updates the current sounds options such as maxdistance, loop...
  5611. * @param options A JSON object containing values named as the object properties
  5612. */
  5613. updateOptions(options: any): void;
  5614. private _createSpatialParameters;
  5615. private _updateSpatialParameters;
  5616. /**
  5617. * Switch the panning model to HRTF:
  5618. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5620. */
  5621. switchPanningModelToHRTF(): void;
  5622. /**
  5623. * Switch the panning model to Equal Power:
  5624. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5626. */
  5627. switchPanningModelToEqualPower(): void;
  5628. private _switchPanningModel;
  5629. /**
  5630. * Connect this sound to a sound track audio node like gain...
  5631. * @param soundTrackAudioNode the sound track audio node to connect to
  5632. */
  5633. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5634. /**
  5635. * Transform this sound into a directional source
  5636. * @param coneInnerAngle Size of the inner cone in degree
  5637. * @param coneOuterAngle Size of the outer cone in degree
  5638. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5639. */
  5640. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5641. /**
  5642. * Gets or sets the inner angle for the directional cone.
  5643. */
  5644. /**
  5645. * Gets or sets the inner angle for the directional cone.
  5646. */
  5647. directionalConeInnerAngle: number;
  5648. /**
  5649. * Gets or sets the outer angle for the directional cone.
  5650. */
  5651. /**
  5652. * Gets or sets the outer angle for the directional cone.
  5653. */
  5654. directionalConeOuterAngle: number;
  5655. /**
  5656. * Sets the position of the emitter if spatial sound is enabled
  5657. * @param newPosition Defines the new posisiton
  5658. */
  5659. setPosition(newPosition: Vector3): void;
  5660. /**
  5661. * Sets the local direction of the emitter if spatial sound is enabled
  5662. * @param newLocalDirection Defines the new local direction
  5663. */
  5664. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5665. private _updateDirection;
  5666. /** @hidden */
  5667. updateDistanceFromListener(): void;
  5668. /**
  5669. * Sets a new custom attenuation function for the sound.
  5670. * @param callback Defines the function used for the attenuation
  5671. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5672. */
  5673. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5674. /**
  5675. * Play the sound
  5676. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5677. * @param offset (optional) Start the sound setting it at a specific time
  5678. */
  5679. play(time?: number, offset?: number): void;
  5680. private _onended;
  5681. /**
  5682. * Stop the sound
  5683. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5684. */
  5685. stop(time?: number): void;
  5686. /**
  5687. * Put the sound in pause
  5688. */
  5689. pause(): void;
  5690. /**
  5691. * Sets a dedicated volume for this sounds
  5692. * @param newVolume Define the new volume of the sound
  5693. * @param time Define in how long the sound should be at this value
  5694. */
  5695. setVolume(newVolume: number, time?: number): void;
  5696. /**
  5697. * Set the sound play back rate
  5698. * @param newPlaybackRate Define the playback rate the sound should be played at
  5699. */
  5700. setPlaybackRate(newPlaybackRate: number): void;
  5701. /**
  5702. * Gets the volume of the sound.
  5703. * @returns the volume of the sound
  5704. */
  5705. getVolume(): number;
  5706. /**
  5707. * Attach the sound to a dedicated mesh
  5708. * @param meshToConnectTo The mesh to connect the sound with
  5709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5710. */
  5711. attachToMesh(meshToConnectTo: AbstractMesh): void;
  5712. /**
  5713. * Detach the sound from the previously attached mesh
  5714. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5715. */
  5716. detachFromMesh(): void;
  5717. private _onRegisterAfterWorldMatrixUpdate;
  5718. /**
  5719. * Clone the current sound in the scene.
  5720. * @returns the new sound clone
  5721. */
  5722. clone(): Nullable<Sound>;
  5723. /**
  5724. * Gets the current underlying audio buffer containing the data
  5725. * @returns the audio buffer
  5726. */
  5727. getAudioBuffer(): Nullable<AudioBuffer>;
  5728. /**
  5729. * Serializes the Sound in a JSON representation
  5730. * @returns the JSON representation of the sound
  5731. */
  5732. serialize(): any;
  5733. /**
  5734. * Parse a JSON representation of a sound to innstantiate in a given scene
  5735. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5736. * @param scene Define the scene the new parsed sound should be created in
  5737. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5738. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5739. * @returns the newly parsed sound
  5740. */
  5741. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5742. }
  5743. }
  5744. declare module BABYLON {
  5745. /**
  5746. * Options allowed during the creation of a sound track.
  5747. */
  5748. interface ISoundTrackOptions {
  5749. /**
  5750. * The volume the sound track should take during creation
  5751. */
  5752. volume?: number;
  5753. /**
  5754. * Define if the sound track is the main sound track of the scene
  5755. */
  5756. mainTrack?: boolean;
  5757. }
  5758. /**
  5759. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5760. * It will be also used in a future release to apply effects on a specific track.
  5761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5762. */
  5763. class SoundTrack {
  5764. /**
  5765. * The unique identifier of the sound track in the scene.
  5766. */
  5767. id: number;
  5768. /**
  5769. * The list of sounds included in the sound track.
  5770. */
  5771. soundCollection: Array<Sound>;
  5772. private _outputAudioNode;
  5773. private _scene;
  5774. private _isMainTrack;
  5775. private _connectedAnalyser;
  5776. private _options;
  5777. private _isInitialized;
  5778. /**
  5779. * Creates a new sound track.
  5780. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5781. * @param scene Define the scene the sound track belongs to
  5782. * @param options
  5783. */
  5784. constructor(scene: Scene, options?: ISoundTrackOptions);
  5785. private _initializeSoundTrackAudioGraph;
  5786. /**
  5787. * Release the sound track and its associated resources
  5788. */
  5789. dispose(): void;
  5790. /**
  5791. * Adds a sound to this sound track
  5792. * @param sound define the cound to add
  5793. * @ignoreNaming
  5794. */
  5795. AddSound(sound: Sound): void;
  5796. /**
  5797. * Removes a sound to this sound track
  5798. * @param sound define the cound to remove
  5799. * @ignoreNaming
  5800. */
  5801. RemoveSound(sound: Sound): void;
  5802. /**
  5803. * Set a global volume for the full sound track.
  5804. * @param newVolume Define the new volume of the sound track
  5805. */
  5806. setVolume(newVolume: number): void;
  5807. /**
  5808. * Switch the panning model to HRTF:
  5809. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5810. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5811. */
  5812. switchPanningModelToHRTF(): void;
  5813. /**
  5814. * Switch the panning model to Equal Power:
  5815. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5817. */
  5818. switchPanningModelToEqualPower(): void;
  5819. /**
  5820. * Connect the sound track to an audio analyser allowing some amazing
  5821. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5822. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5823. * @param analyser The analyser to connect to the engine
  5824. */
  5825. connectToAnalyser(analyser: Analyser): void;
  5826. }
  5827. }
  5828. declare module BABYLON {
  5829. /**
  5830. * Wraps one or more Sound objects and selects one with random weight for playback.
  5831. */
  5832. class WeightedSound {
  5833. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5834. loop: boolean;
  5835. private _coneInnerAngle;
  5836. private _coneOuterAngle;
  5837. private _volume;
  5838. /** A Sound is currently playing. */
  5839. isPlaying: boolean;
  5840. /** A Sound is currently paused. */
  5841. isPaused: boolean;
  5842. private _sounds;
  5843. private _weights;
  5844. private _currentIndex?;
  5845. /**
  5846. * Creates a new WeightedSound from the list of sounds given.
  5847. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5848. * @param sounds Array of Sounds that will be selected from.
  5849. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5850. */
  5851. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5852. /**
  5853. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5854. */
  5855. /**
  5856. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5857. */
  5858. directionalConeInnerAngle: number;
  5859. /**
  5860. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5861. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5862. */
  5863. /**
  5864. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5865. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5866. */
  5867. directionalConeOuterAngle: number;
  5868. /**
  5869. * Playback volume.
  5870. */
  5871. /**
  5872. * Playback volume.
  5873. */
  5874. volume: number;
  5875. private _onended;
  5876. /**
  5877. * Suspend playback
  5878. */
  5879. pause(): void;
  5880. /**
  5881. * Stop playback
  5882. */
  5883. stop(): void;
  5884. /**
  5885. * Start playback.
  5886. * @param startOffset Position the clip head at a specific time in seconds.
  5887. */
  5888. play(startOffset?: number): void;
  5889. }
  5890. }
  5891. declare module BABYLON {
  5892. /**
  5893. * Interface used to define a behavior
  5894. */
  5895. interface Behavior<T> {
  5896. /** gets or sets behavior's name */
  5897. name: string;
  5898. /**
  5899. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5900. */
  5901. init(): void;
  5902. /**
  5903. * Called when the behavior is attached to a target
  5904. * @param target defines the target where the behavior is attached to
  5905. */
  5906. attach(target: T): void;
  5907. /**
  5908. * Called when the behavior is detached from its target
  5909. */
  5910. detach(): void;
  5911. }
  5912. /**
  5913. * Interface implemented by classes supporting behaviors
  5914. */
  5915. interface IBehaviorAware<T> {
  5916. /**
  5917. * Attach a behavior
  5918. * @param behavior defines the behavior to attach
  5919. * @returns the current host
  5920. */
  5921. addBehavior(behavior: Behavior<T>): T;
  5922. /**
  5923. * Remove a behavior from the current object
  5924. * @param behavior defines the behavior to detach
  5925. * @returns the current host
  5926. */
  5927. removeBehavior(behavior: Behavior<T>): T;
  5928. /**
  5929. * Gets a behavior using its name to search
  5930. * @param name defines the name to search
  5931. * @returns the behavior or null if not found
  5932. */
  5933. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5934. }
  5935. }
  5936. declare module BABYLON {
  5937. /**
  5938. * Class used to store bone information
  5939. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5940. */
  5941. class Bone extends Node {
  5942. /**
  5943. * defines the bone name
  5944. */
  5945. name: string;
  5946. private static _tmpVecs;
  5947. private static _tmpQuat;
  5948. private static _tmpMats;
  5949. /**
  5950. * Gets the list of child bones
  5951. */
  5952. children: Bone[];
  5953. /** Gets the animations associated with this bone */
  5954. animations: Animation[];
  5955. /**
  5956. * Gets or sets bone length
  5957. */
  5958. length: number;
  5959. /**
  5960. * @hidden Internal only
  5961. * Set this value to map this bone to a different index in the transform matrices
  5962. * Set this value to -1 to exclude the bone from the transform matrices
  5963. */
  5964. _index: Nullable<number>;
  5965. private _skeleton;
  5966. private _localMatrix;
  5967. private _restPose;
  5968. private _baseMatrix;
  5969. private _absoluteTransform;
  5970. private _invertedAbsoluteTransform;
  5971. private _parent;
  5972. private _scalingDeterminant;
  5973. private _worldTransform;
  5974. private _localScaling;
  5975. private _localRotation;
  5976. private _localPosition;
  5977. private _needToDecompose;
  5978. private _needToCompose;
  5979. /** @hidden */
  5980. /** @hidden */
  5981. _matrix: Matrix;
  5982. /**
  5983. * Create a new bone
  5984. * @param name defines the bone name
  5985. * @param skeleton defines the parent skeleton
  5986. * @param parentBone defines the parent (can be null if the bone is the root)
  5987. * @param localMatrix defines the local matrix
  5988. * @param restPose defines the rest pose matrix
  5989. * @param baseMatrix defines the base matrix
  5990. * @param index defines index of the bone in the hiearchy
  5991. */
  5992. constructor(
  5993. /**
  5994. * defines the bone name
  5995. */
  5996. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  5997. /**
  5998. * Gets the parent skeleton
  5999. * @returns a skeleton
  6000. */
  6001. getSkeleton(): Skeleton;
  6002. /**
  6003. * Gets parent bone
  6004. * @returns a bone or null if the bone is the root of the bone hierarchy
  6005. */
  6006. getParent(): Nullable<Bone>;
  6007. /**
  6008. * Sets the parent bone
  6009. * @param parent defines the parent (can be null if the bone is the root)
  6010. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6011. */
  6012. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  6013. /**
  6014. * Gets the local matrix
  6015. * @returns a matrix
  6016. */
  6017. getLocalMatrix(): Matrix;
  6018. /**
  6019. * Gets the base matrix (initial matrix which remains unchanged)
  6020. * @returns a matrix
  6021. */
  6022. getBaseMatrix(): Matrix;
  6023. /**
  6024. * Gets the rest pose matrix
  6025. * @returns a matrix
  6026. */
  6027. getRestPose(): Matrix;
  6028. /**
  6029. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  6030. */
  6031. getWorldMatrix(): Matrix;
  6032. /**
  6033. * Sets the local matrix to rest pose matrix
  6034. */
  6035. returnToRest(): void;
  6036. /**
  6037. * Gets the inverse of the absolute transform matrix.
  6038. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  6039. * @returns a matrix
  6040. */
  6041. getInvertedAbsoluteTransform(): Matrix;
  6042. /**
  6043. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  6044. * @returns a matrix
  6045. */
  6046. getAbsoluteTransform(): Matrix;
  6047. /** Gets or sets current position (in local space) */
  6048. position: Vector3;
  6049. /** Gets or sets current rotation (in local space) */
  6050. rotation: Vector3;
  6051. /** Gets or sets current rotation quaternion (in local space) */
  6052. rotationQuaternion: Quaternion;
  6053. /** Gets or sets current scaling (in local space) */
  6054. scaling: Vector3;
  6055. /**
  6056. * Gets the animation properties override
  6057. */
  6058. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6059. private _decompose;
  6060. private _compose;
  6061. /**
  6062. * Update the base and local matrices
  6063. * @param matrix defines the new base or local matrix
  6064. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6065. * @param updateLocalMatrix defines if the local matrix should be updated
  6066. */
  6067. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6068. /** @hidden */
  6069. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6070. /**
  6071. * Flag the bone as dirty (Forcing it to update everything)
  6072. */
  6073. markAsDirty(): void;
  6074. private _markAsDirtyAndCompose;
  6075. private _markAsDirtyAndDecompose;
  6076. /**
  6077. * Copy an animation range from another bone
  6078. * @param source defines the source bone
  6079. * @param rangeName defines the range name to copy
  6080. * @param frameOffset defines the frame offset
  6081. * @param rescaleAsRequired defines if rescaling must be applied if required
  6082. * @param skelDimensionsRatio defines the scaling ratio
  6083. * @returns true if operation was successful
  6084. */
  6085. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6086. /**
  6087. * Translate the bone in local or world space
  6088. * @param vec The amount to translate the bone
  6089. * @param space The space that the translation is in
  6090. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6091. */
  6092. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6093. /**
  6094. * Set the postion of the bone in local or world space
  6095. * @param position The position to set the bone
  6096. * @param space The space that the position is in
  6097. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6098. */
  6099. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6100. /**
  6101. * Set the absolute position of the bone (world space)
  6102. * @param position The position to set the bone
  6103. * @param mesh The mesh that this bone is attached to
  6104. */
  6105. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6106. /**
  6107. * Scale the bone on the x, y and z axes (in local space)
  6108. * @param x The amount to scale the bone on the x axis
  6109. * @param y The amount to scale the bone on the y axis
  6110. * @param z The amount to scale the bone on the z axis
  6111. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6112. */
  6113. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6114. /**
  6115. * Set the bone scaling in local space
  6116. * @param scale defines the scaling vector
  6117. */
  6118. setScale(scale: Vector3): void;
  6119. /**
  6120. * Gets the current scaling in local space
  6121. * @returns the current scaling vector
  6122. */
  6123. getScale(): Vector3;
  6124. /**
  6125. * Gets the current scaling in local space and stores it in a target vector
  6126. * @param result defines the target vector
  6127. */
  6128. getScaleToRef(result: Vector3): void;
  6129. /**
  6130. * Set the yaw, pitch, and roll of the bone in local or world space
  6131. * @param yaw The rotation of the bone on the y axis
  6132. * @param pitch The rotation of the bone on the x axis
  6133. * @param roll The rotation of the bone on the z axis
  6134. * @param space The space that the axes of rotation are in
  6135. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6136. */
  6137. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6138. /**
  6139. * Add a rotation to the bone on an axis in local or world space
  6140. * @param axis The axis to rotate the bone on
  6141. * @param amount The amount to rotate the bone
  6142. * @param space The space that the axis is in
  6143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6144. */
  6145. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6146. /**
  6147. * Set the rotation of the bone to a particular axis angle in local or world space
  6148. * @param axis The axis to rotate the bone on
  6149. * @param angle The angle that the bone should be rotated to
  6150. * @param space The space that the axis is in
  6151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6152. */
  6153. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6154. /**
  6155. * Set the euler rotation of the bone in local of world space
  6156. * @param rotation The euler rotation that the bone should be set to
  6157. * @param space The space that the rotation is in
  6158. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6159. */
  6160. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6161. /**
  6162. * Set the quaternion rotation of the bone in local of world space
  6163. * @param quat The quaternion rotation that the bone should be set to
  6164. * @param space The space that the rotation is in
  6165. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6166. */
  6167. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6168. /**
  6169. * Set the rotation matrix of the bone in local of world space
  6170. * @param rotMat The rotation matrix that the bone should be set to
  6171. * @param space The space that the rotation is in
  6172. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6173. */
  6174. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6175. private _rotateWithMatrix;
  6176. private _getNegativeRotationToRef;
  6177. /**
  6178. * Get the position of the bone in local or world space
  6179. * @param space The space that the returned position is in
  6180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6181. * @returns The position of the bone
  6182. */
  6183. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6184. /**
  6185. * Copy the position of the bone to a vector3 in local or world space
  6186. * @param space The space that the returned position is in
  6187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6188. * @param result The vector3 to copy the position to
  6189. */
  6190. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6191. /**
  6192. * Get the absolute position of the bone (world space)
  6193. * @param mesh The mesh that this bone is attached to
  6194. * @returns The absolute position of the bone
  6195. */
  6196. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6197. /**
  6198. * Copy the absolute position of the bone (world space) to the result param
  6199. * @param mesh The mesh that this bone is attached to
  6200. * @param result The vector3 to copy the absolute position to
  6201. */
  6202. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6203. /**
  6204. * Compute the absolute transforms of this bone and its children
  6205. */
  6206. computeAbsoluteTransforms(): void;
  6207. /**
  6208. * Get the world direction from an axis that is in the local space of the bone
  6209. * @param localAxis The local direction that is used to compute the world direction
  6210. * @param mesh The mesh that this bone is attached to
  6211. * @returns The world direction
  6212. */
  6213. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6214. /**
  6215. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6216. * @param localAxis The local direction that is used to compute the world direction
  6217. * @param mesh The mesh that this bone is attached to
  6218. * @param result The vector3 that the world direction will be copied to
  6219. */
  6220. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6221. /**
  6222. * Get the euler rotation of the bone in local or world space
  6223. * @param space The space that the rotation should be in
  6224. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6225. * @returns The euler rotation
  6226. */
  6227. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6228. /**
  6229. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6230. * @param space The space that the rotation should be in
  6231. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6232. * @param result The vector3 that the rotation should be copied to
  6233. */
  6234. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6235. /**
  6236. * Get the quaternion rotation of the bone in either local or world space
  6237. * @param space The space that the rotation should be in
  6238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6239. * @returns The quaternion rotation
  6240. */
  6241. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6242. /**
  6243. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6244. * @param space The space that the rotation should be in
  6245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6246. * @param result The quaternion that the rotation should be copied to
  6247. */
  6248. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6249. /**
  6250. * Get the rotation matrix of the bone in local or world space
  6251. * @param space The space that the rotation should be in
  6252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6253. * @returns The rotation matrix
  6254. */
  6255. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6256. /**
  6257. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6258. * @param space The space that the rotation should be in
  6259. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6260. * @param result The quaternion that the rotation should be copied to
  6261. */
  6262. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6263. /**
  6264. * Get the world position of a point that is in the local space of the bone
  6265. * @param position The local position
  6266. * @param mesh The mesh that this bone is attached to
  6267. * @returns The world position
  6268. */
  6269. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6270. /**
  6271. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6272. * @param position The local position
  6273. * @param mesh The mesh that this bone is attached to
  6274. * @param result The vector3 that the world position should be copied to
  6275. */
  6276. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6277. /**
  6278. * Get the local position of a point that is in world space
  6279. * @param position The world position
  6280. * @param mesh The mesh that this bone is attached to
  6281. * @returns The local position
  6282. */
  6283. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6284. /**
  6285. * Get the local position of a point that is in world space and copy it to the result param
  6286. * @param position The world position
  6287. * @param mesh The mesh that this bone is attached to
  6288. * @param result The vector3 that the local position should be copied to
  6289. */
  6290. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6291. }
  6292. }
  6293. declare module BABYLON {
  6294. /**
  6295. * Class used to apply inverse kinematics to bones
  6296. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6297. */
  6298. class BoneIKController {
  6299. private static _tmpVecs;
  6300. private static _tmpQuat;
  6301. private static _tmpMats;
  6302. /**
  6303. * Gets or sets the target mesh
  6304. */
  6305. targetMesh: AbstractMesh;
  6306. /** Gets or sets the mesh used as pole */
  6307. poleTargetMesh: AbstractMesh;
  6308. /**
  6309. * Gets or sets the bone used as pole
  6310. */
  6311. poleTargetBone: Nullable<Bone>;
  6312. /**
  6313. * Gets or sets the target position
  6314. */
  6315. targetPosition: Vector3;
  6316. /**
  6317. * Gets or sets the pole target position
  6318. */
  6319. poleTargetPosition: Vector3;
  6320. /**
  6321. * Gets or sets the pole target local offset
  6322. */
  6323. poleTargetLocalOffset: Vector3;
  6324. /**
  6325. * Gets or sets the pole angle
  6326. */
  6327. poleAngle: number;
  6328. /**
  6329. * Gets or sets the mesh associated with the controller
  6330. */
  6331. mesh: AbstractMesh;
  6332. /**
  6333. * 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)
  6334. */
  6335. slerpAmount: number;
  6336. private _bone1Quat;
  6337. private _bone1Mat;
  6338. private _bone2Ang;
  6339. private _bone1;
  6340. private _bone2;
  6341. private _bone1Length;
  6342. private _bone2Length;
  6343. private _maxAngle;
  6344. private _maxReach;
  6345. private _rightHandedSystem;
  6346. private _bendAxis;
  6347. private _slerping;
  6348. private _adjustRoll;
  6349. /**
  6350. * Gets or sets maximum allowed angle
  6351. */
  6352. maxAngle: number;
  6353. /**
  6354. * Creates a new BoneIKController
  6355. * @param mesh defines the mesh to control
  6356. * @param bone defines the bone to control
  6357. * @param options defines options to set up the controller
  6358. */
  6359. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6360. targetMesh?: AbstractMesh;
  6361. poleTargetMesh?: AbstractMesh;
  6362. poleTargetBone?: Bone;
  6363. poleTargetLocalOffset?: Vector3;
  6364. poleAngle?: number;
  6365. bendAxis?: Vector3;
  6366. maxAngle?: number;
  6367. slerpAmount?: number;
  6368. });
  6369. private _setMaxAngle;
  6370. /**
  6371. * Force the controller to update the bones
  6372. */
  6373. update(): void;
  6374. }
  6375. }
  6376. declare module BABYLON {
  6377. /**
  6378. * Class used to make a bone look toward a point in space
  6379. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6380. */
  6381. class BoneLookController {
  6382. private static _tmpVecs;
  6383. private static _tmpQuat;
  6384. private static _tmpMats;
  6385. /**
  6386. * The target Vector3 that the bone will look at
  6387. */
  6388. target: Vector3;
  6389. /**
  6390. * The mesh that the bone is attached to
  6391. */
  6392. mesh: AbstractMesh;
  6393. /**
  6394. * The bone that will be looking to the target
  6395. */
  6396. bone: Bone;
  6397. /**
  6398. * The up axis of the coordinate system that is used when the bone is rotated
  6399. */
  6400. upAxis: Vector3;
  6401. /**
  6402. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6403. */
  6404. upAxisSpace: Space;
  6405. /**
  6406. * Used to make an adjustment to the yaw of the bone
  6407. */
  6408. adjustYaw: number;
  6409. /**
  6410. * Used to make an adjustment to the pitch of the bone
  6411. */
  6412. adjustPitch: number;
  6413. /**
  6414. * Used to make an adjustment to the roll of the bone
  6415. */
  6416. adjustRoll: number;
  6417. /**
  6418. * 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)
  6419. */
  6420. slerpAmount: number;
  6421. private _minYaw;
  6422. private _maxYaw;
  6423. private _minPitch;
  6424. private _maxPitch;
  6425. private _minYawSin;
  6426. private _minYawCos;
  6427. private _maxYawSin;
  6428. private _maxYawCos;
  6429. private _midYawConstraint;
  6430. private _minPitchTan;
  6431. private _maxPitchTan;
  6432. private _boneQuat;
  6433. private _slerping;
  6434. private _transformYawPitch;
  6435. private _transformYawPitchInv;
  6436. private _firstFrameSkipped;
  6437. private _yawRange;
  6438. private _fowardAxis;
  6439. /**
  6440. * Gets or sets the minimum yaw angle that the bone can look to
  6441. */
  6442. minYaw: number;
  6443. /**
  6444. * Gets or sets the maximum yaw angle that the bone can look to
  6445. */
  6446. maxYaw: number;
  6447. /**
  6448. * Gets or sets the minimum pitch angle that the bone can look to
  6449. */
  6450. minPitch: number;
  6451. /**
  6452. * Gets or sets the maximum pitch angle that the bone can look to
  6453. */
  6454. maxPitch: number;
  6455. /**
  6456. * Create a BoneLookController
  6457. * @param mesh the mesh that the bone belongs to
  6458. * @param bone the bone that will be looking to the target
  6459. * @param target the target Vector3 to look at
  6460. * @param settings optional settings:
  6461. * * maxYaw: the maximum angle the bone will yaw to
  6462. * * minYaw: the minimum angle the bone will yaw to
  6463. * * maxPitch: the maximum angle the bone will pitch to
  6464. * * minPitch: the minimum angle the bone will yaw to
  6465. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6466. * * upAxis: the up axis of the coordinate system
  6467. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6468. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6469. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6470. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6471. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6472. * * adjustRoll: used to make an adjustment to the roll of the bone
  6473. **/
  6474. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6475. maxYaw?: number;
  6476. minYaw?: number;
  6477. maxPitch?: number;
  6478. minPitch?: number;
  6479. slerpAmount?: number;
  6480. upAxis?: Vector3;
  6481. upAxisSpace?: Space;
  6482. yawAxis?: Vector3;
  6483. pitchAxis?: Vector3;
  6484. adjustYaw?: number;
  6485. adjustPitch?: number;
  6486. adjustRoll?: number;
  6487. });
  6488. /**
  6489. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6490. */
  6491. update(): void;
  6492. private _getAngleDiff;
  6493. private _getAngleBetween;
  6494. private _isAngleBetween;
  6495. }
  6496. }
  6497. declare module BABYLON {
  6498. /**
  6499. * Class used to handle skinning animations
  6500. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6501. */
  6502. class Skeleton implements IAnimatable {
  6503. /** defines the skeleton name */
  6504. name: string;
  6505. /** defines the skeleton Id */
  6506. id: string;
  6507. /**
  6508. * Gets the list of child bones
  6509. */
  6510. bones: Bone[];
  6511. /**
  6512. * Gets an estimate of the dimension of the skeleton at rest
  6513. */
  6514. dimensionsAtRest: Vector3;
  6515. /**
  6516. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6517. */
  6518. needInitialSkinMatrix: boolean;
  6519. /**
  6520. * Gets the list of animations attached to this skeleton
  6521. */
  6522. animations: Array<Animation>;
  6523. private _scene;
  6524. private _isDirty;
  6525. private _transformMatrices;
  6526. private _transformMatrixTexture;
  6527. private _meshesWithPoseMatrix;
  6528. private _animatables;
  6529. private _identity;
  6530. private _synchronizedWithMesh;
  6531. private _ranges;
  6532. private _lastAbsoluteTransformsUpdateId;
  6533. private _canUseTextureForBones;
  6534. /**
  6535. * Specifies if the skeleton should be serialized
  6536. */
  6537. doNotSerialize: boolean;
  6538. /**
  6539. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  6540. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  6541. */
  6542. useTextureToStoreBoneMatrices: boolean;
  6543. private _animationPropertiesOverride;
  6544. /**
  6545. * Gets or sets the animation properties override
  6546. */
  6547. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6548. /**
  6549. * An observable triggered before computing the skeleton's matrices
  6550. */
  6551. onBeforeComputeObservable: Observable<Skeleton>;
  6552. /**
  6553. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  6554. */
  6555. readonly isUsingTextureForMatrices: boolean;
  6556. /**
  6557. * Creates a new skeleton
  6558. * @param name defines the skeleton name
  6559. * @param id defines the skeleton Id
  6560. * @param scene defines the hosting scene
  6561. */
  6562. constructor(
  6563. /** defines the skeleton name */
  6564. name: string,
  6565. /** defines the skeleton Id */
  6566. id: string, scene: Scene);
  6567. /**
  6568. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6569. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6570. * @returns a Float32Array containing matrices data
  6571. */
  6572. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6573. /**
  6574. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  6575. * @returns a raw texture containing the data
  6576. */
  6577. getTransformMatrixTexture(): Nullable<RawTexture>;
  6578. /**
  6579. * Gets the current hosting scene
  6580. * @returns a scene object
  6581. */
  6582. getScene(): Scene;
  6583. /**
  6584. * Gets a string representing the current skeleton data
  6585. * @param fullDetails defines a boolean indicating if we want a verbose version
  6586. * @returns a string representing the current skeleton data
  6587. */
  6588. toString(fullDetails?: boolean): string;
  6589. /**
  6590. * Get bone's index searching by name
  6591. * @param name defines bone's name to search for
  6592. * @return the indice of the bone. Returns -1 if not found
  6593. */
  6594. getBoneIndexByName(name: string): number;
  6595. /**
  6596. * Creater a new animation range
  6597. * @param name defines the name of the range
  6598. * @param from defines the start key
  6599. * @param to defines the end key
  6600. */
  6601. createAnimationRange(name: string, from: number, to: number): void;
  6602. /**
  6603. * Delete a specific animation range
  6604. * @param name defines the name of the range
  6605. * @param deleteFrames defines if frames must be removed as well
  6606. */
  6607. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6608. /**
  6609. * Gets a specific animation range
  6610. * @param name defines the name of the range to look for
  6611. * @returns the requested animation range or null if not found
  6612. */
  6613. getAnimationRange(name: string): Nullable<AnimationRange>;
  6614. /**
  6615. * Gets the list of all animation ranges defined on this skeleton
  6616. * @returns an array
  6617. */
  6618. getAnimationRanges(): Nullable<AnimationRange>[];
  6619. /**
  6620. * Copy animation range from a source skeleton.
  6621. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6622. * @param source defines the source skeleton
  6623. * @param name defines the name of the range to copy
  6624. * @param rescaleAsRequired defines if rescaling must be applied if required
  6625. * @returns true if operation was successful
  6626. */
  6627. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6628. /**
  6629. * Forces the skeleton to go to rest pose
  6630. */
  6631. returnToRest(): void;
  6632. private _getHighestAnimationFrame;
  6633. /**
  6634. * Begin a specific animation range
  6635. * @param name defines the name of the range to start
  6636. * @param loop defines if looping must be turned on (false by default)
  6637. * @param speedRatio defines the speed ratio to apply (1 by default)
  6638. * @param onAnimationEnd defines a callback which will be called when animation will end
  6639. * @returns a new animatable
  6640. */
  6641. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6642. /** @hidden */
  6643. _markAsDirty(): void;
  6644. /** @hidden */
  6645. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6646. /** @hidden */
  6647. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6648. private _computeTransformMatrices;
  6649. /**
  6650. * Build all resources required to render a skeleton
  6651. */
  6652. prepare(): void;
  6653. /**
  6654. * Gets the list of animatables currently running for this skeleton
  6655. * @returns an array of animatables
  6656. */
  6657. getAnimatables(): IAnimatable[];
  6658. /**
  6659. * Clone the current skeleton
  6660. * @param name defines the name of the new skeleton
  6661. * @param id defines the id of the enw skeleton
  6662. * @returns the new skeleton
  6663. */
  6664. clone(name: string, id: string): Skeleton;
  6665. /**
  6666. * Enable animation blending for this skeleton
  6667. * @param blendingSpeed defines the blending speed to apply
  6668. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6669. */
  6670. enableBlending(blendingSpeed?: number): void;
  6671. /**
  6672. * Releases all resources associated with the current skeleton
  6673. */
  6674. dispose(): void;
  6675. /**
  6676. * Serialize the skeleton in a JSON object
  6677. * @returns a JSON object
  6678. */
  6679. serialize(): any;
  6680. /**
  6681. * Creates a new skeleton from serialized data
  6682. * @param parsedSkeleton defines the serialized data
  6683. * @param scene defines the hosting scene
  6684. * @returns a new skeleton
  6685. */
  6686. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6687. /**
  6688. * Compute all node absolute transforms
  6689. * @param forceUpdate defines if computation must be done even if cache is up to date
  6690. */
  6691. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6692. /**
  6693. * Gets the root pose matrix
  6694. * @returns a matrix
  6695. */
  6696. getPoseMatrix(): Nullable<Matrix>;
  6697. /**
  6698. * Sorts bones per internal index
  6699. */
  6700. sortBones(): void;
  6701. private _sortBones;
  6702. }
  6703. }
  6704. declare module BABYLON {
  6705. /** @hidden */
  6706. class Collider {
  6707. /** Define if a collision was found */
  6708. collisionFound: boolean;
  6709. /**
  6710. * Define last intersection point in local space
  6711. */
  6712. intersectionPoint: Vector3;
  6713. /**
  6714. * Define last collided mesh
  6715. */
  6716. collidedMesh: Nullable<AbstractMesh>;
  6717. private _collisionPoint;
  6718. private _planeIntersectionPoint;
  6719. private _tempVector;
  6720. private _tempVector2;
  6721. private _tempVector3;
  6722. private _tempVector4;
  6723. private _edge;
  6724. private _baseToVertex;
  6725. private _destinationPoint;
  6726. private _slidePlaneNormal;
  6727. private _displacementVector;
  6728. /** @hidden */
  6729. _radius: Vector3;
  6730. /** @hidden */
  6731. _retry: number;
  6732. private _velocity;
  6733. private _basePoint;
  6734. private _epsilon;
  6735. /** @hidden */
  6736. _velocityWorldLength: number;
  6737. /** @hidden */
  6738. _basePointWorld: Vector3;
  6739. private _velocityWorld;
  6740. private _normalizedVelocity;
  6741. /** @hidden */
  6742. _initialVelocity: Vector3;
  6743. /** @hidden */
  6744. _initialPosition: Vector3;
  6745. private _nearestDistance;
  6746. private _collisionMask;
  6747. collisionMask: number;
  6748. /**
  6749. * Gets the plane normal used to compute the sliding response (in local space)
  6750. */
  6751. readonly slidePlaneNormal: Vector3;
  6752. /** @hidden */
  6753. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6754. /** @hidden */
  6755. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6756. /** @hidden */
  6757. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6758. /** @hidden */
  6759. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6760. /** @hidden */
  6761. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6762. /** @hidden */
  6763. _getResponse(pos: Vector3, vel: Vector3): void;
  6764. }
  6765. }
  6766. declare module BABYLON {
  6767. /** @hidden */
  6768. var CollisionWorker: string;
  6769. /** @hidden */
  6770. interface ICollisionCoordinator {
  6771. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6772. init(scene: Scene): void;
  6773. destroy(): void;
  6774. onMeshAdded(mesh: AbstractMesh): void;
  6775. onMeshUpdated(mesh: AbstractMesh): void;
  6776. onMeshRemoved(mesh: AbstractMesh): void;
  6777. onGeometryAdded(geometry: Geometry): void;
  6778. onGeometryUpdated(geometry: Geometry): void;
  6779. onGeometryDeleted(geometry: Geometry): void;
  6780. }
  6781. /** @hidden */
  6782. interface SerializedMesh {
  6783. id: string;
  6784. name: string;
  6785. uniqueId: number;
  6786. geometryId: Nullable<string>;
  6787. sphereCenter: Array<number>;
  6788. sphereRadius: number;
  6789. boxMinimum: Array<number>;
  6790. boxMaximum: Array<number>;
  6791. worldMatrixFromCache: any;
  6792. subMeshes: Array<SerializedSubMesh>;
  6793. checkCollisions: boolean;
  6794. }
  6795. /** @hidden */
  6796. interface SerializedSubMesh {
  6797. position: number;
  6798. verticesStart: number;
  6799. verticesCount: number;
  6800. indexStart: number;
  6801. indexCount: number;
  6802. hasMaterial: boolean;
  6803. sphereCenter: Array<number>;
  6804. sphereRadius: number;
  6805. boxMinimum: Array<number>;
  6806. boxMaximum: Array<number>;
  6807. }
  6808. /**
  6809. * Interface describing the value associated with a geometry.
  6810. * @hidden
  6811. */
  6812. interface SerializedGeometry {
  6813. /**
  6814. * Defines the unique ID of the geometry
  6815. */
  6816. id: string;
  6817. /**
  6818. * Defines the array containing the positions
  6819. */
  6820. positions: Float32Array;
  6821. /**
  6822. * Defines the array containing the indices
  6823. */
  6824. indices: Uint32Array;
  6825. /**
  6826. * Defines the array containing the normals
  6827. */
  6828. normals: Float32Array;
  6829. }
  6830. /** @hidden */
  6831. interface BabylonMessage {
  6832. taskType: WorkerTaskType;
  6833. payload: InitPayload | CollidePayload | UpdatePayload;
  6834. }
  6835. /** @hidden */
  6836. interface SerializedColliderToWorker {
  6837. position: Array<number>;
  6838. velocity: Array<number>;
  6839. radius: Array<number>;
  6840. }
  6841. /** Defines supported task for worker process */
  6842. enum WorkerTaskType {
  6843. /** Initialization */
  6844. INIT = 0,
  6845. /** Update of geometry */
  6846. UPDATE = 1,
  6847. /** Evaluate collision */
  6848. COLLIDE = 2
  6849. }
  6850. /** @hidden */
  6851. interface WorkerReply {
  6852. error: WorkerReplyType;
  6853. taskType: WorkerTaskType;
  6854. payload?: any;
  6855. }
  6856. /** @hidden */
  6857. interface CollisionReplyPayload {
  6858. newPosition: Array<number>;
  6859. collisionId: number;
  6860. collidedMeshUniqueId: number;
  6861. }
  6862. /** @hidden */
  6863. interface InitPayload {
  6864. }
  6865. /** @hidden */
  6866. interface CollidePayload {
  6867. collisionId: number;
  6868. collider: SerializedColliderToWorker;
  6869. maximumRetry: number;
  6870. excludedMeshUniqueId: Nullable<number>;
  6871. }
  6872. /** @hidden */
  6873. interface UpdatePayload {
  6874. updatedMeshes: {
  6875. [n: number]: SerializedMesh;
  6876. };
  6877. updatedGeometries: {
  6878. [s: string]: SerializedGeometry;
  6879. };
  6880. removedMeshes: Array<number>;
  6881. removedGeometries: Array<string>;
  6882. }
  6883. /** Defines kind of replies returned by worker */
  6884. enum WorkerReplyType {
  6885. /** Success */
  6886. SUCCESS = 0,
  6887. /** Unkown error */
  6888. UNKNOWN_ERROR = 1
  6889. }
  6890. /** @hidden */
  6891. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6892. private _scene;
  6893. private _scaledPosition;
  6894. private _scaledVelocity;
  6895. private _collisionsCallbackArray;
  6896. private _init;
  6897. private _runningUpdated;
  6898. private _worker;
  6899. private _addUpdateMeshesList;
  6900. private _addUpdateGeometriesList;
  6901. private _toRemoveMeshesArray;
  6902. private _toRemoveGeometryArray;
  6903. constructor();
  6904. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  6905. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  6906. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6907. init(scene: Scene): void;
  6908. destroy(): void;
  6909. onMeshAdded(mesh: AbstractMesh): void;
  6910. onMeshUpdated: (transformNode: TransformNode) => void;
  6911. onMeshRemoved(mesh: AbstractMesh): void;
  6912. onGeometryAdded(geometry: Geometry): void;
  6913. onGeometryUpdated: (geometry: Geometry) => void;
  6914. onGeometryDeleted(geometry: Geometry): void;
  6915. private _afterRender;
  6916. private _onMessageFromWorker;
  6917. }
  6918. /** @hidden */
  6919. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  6920. private _scene;
  6921. private _scaledPosition;
  6922. private _scaledVelocity;
  6923. private _finalPosition;
  6924. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6925. init(scene: Scene): void;
  6926. destroy(): void;
  6927. onMeshAdded(mesh: AbstractMesh): void;
  6928. onMeshUpdated(mesh: AbstractMesh): void;
  6929. onMeshRemoved(mesh: AbstractMesh): void;
  6930. onGeometryAdded(geometry: Geometry): void;
  6931. onGeometryUpdated(geometry: Geometry): void;
  6932. onGeometryDeleted(geometry: Geometry): void;
  6933. private _collideWithWorld;
  6934. }
  6935. }
  6936. declare function importScripts(...urls: string[]): void;
  6937. declare const safePostMessage: any;
  6938. declare module BABYLON {
  6939. /** @hidden */
  6940. var WorkerIncluded: boolean;
  6941. /** @hidden */
  6942. class CollisionCache {
  6943. private _meshes;
  6944. private _geometries;
  6945. getMeshes(): {
  6946. [n: number]: SerializedMesh;
  6947. };
  6948. getGeometries(): {
  6949. [s: number]: SerializedGeometry;
  6950. };
  6951. getMesh(id: any): SerializedMesh;
  6952. addMesh(mesh: SerializedMesh): void;
  6953. removeMesh(uniqueId: number): void;
  6954. getGeometry(id: string): SerializedGeometry;
  6955. addGeometry(geometry: SerializedGeometry): void;
  6956. removeGeometry(id: string): void;
  6957. }
  6958. /** @hidden */
  6959. class CollideWorker {
  6960. collider: Collider;
  6961. private _collisionCache;
  6962. private finalPosition;
  6963. private collisionsScalingMatrix;
  6964. private collisionTranformationMatrix;
  6965. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  6966. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  6967. private checkCollision;
  6968. private processCollisionsForSubMeshes;
  6969. private collideForSubMesh;
  6970. private checkSubmeshCollision;
  6971. }
  6972. /** @hidden */
  6973. interface ICollisionDetector {
  6974. onInit(payload: InitPayload): void;
  6975. onUpdate(payload: UpdatePayload): void;
  6976. onCollision(payload: CollidePayload): void;
  6977. }
  6978. /** @hidden */
  6979. class CollisionDetectorTransferable implements ICollisionDetector {
  6980. private _collisionCache;
  6981. onInit(payload: InitPayload): void;
  6982. onUpdate(payload: UpdatePayload): void;
  6983. onCollision(payload: CollidePayload): void;
  6984. }
  6985. }
  6986. declare module BABYLON {
  6987. /**
  6988. * @hidden
  6989. */
  6990. class IntersectionInfo {
  6991. bu: Nullable<number>;
  6992. bv: Nullable<number>;
  6993. distance: number;
  6994. faceId: number;
  6995. subMeshId: number;
  6996. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6997. }
  6998. /**
  6999. * Information about the result of picking within a scene
  7000. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  7001. */
  7002. class PickingInfo {
  7003. /**
  7004. * If the pick collided with an object
  7005. */
  7006. hit: boolean;
  7007. /**
  7008. * Distance away where the pick collided
  7009. */
  7010. distance: number;
  7011. /**
  7012. * The location of pick collision
  7013. */
  7014. pickedPoint: Nullable<Vector3>;
  7015. /**
  7016. * The mesh corresponding the the pick collision
  7017. */
  7018. pickedMesh: Nullable<AbstractMesh>;
  7019. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  7020. bu: number;
  7021. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  7022. bv: number;
  7023. /** The id of the face on the mesh that was picked */
  7024. faceId: number;
  7025. /** Id of the the submesh that was picked */
  7026. subMeshId: number;
  7027. /** If a sprite was picked, this will be the sprite the pick collided with */
  7028. pickedSprite: Nullable<Sprite>;
  7029. /**
  7030. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  7031. */
  7032. originMesh: Nullable<AbstractMesh>;
  7033. /**
  7034. * The ray that was used to perform the picking.
  7035. */
  7036. ray: Nullable<Ray>;
  7037. /**
  7038. * Gets the normal correspodning to the face the pick collided with
  7039. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  7040. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  7041. * @returns The normal correspodning to the face the pick collided with
  7042. */
  7043. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  7044. /**
  7045. * Gets the texture coordinates of where the pick occured
  7046. * @returns the vector containing the coordnates of the texture
  7047. */
  7048. getTextureCoordinates(): Nullable<Vector2>;
  7049. }
  7050. }
  7051. declare module BABYLON {
  7052. /**
  7053. * Class used to store bounding box information
  7054. */
  7055. class BoundingBox implements ICullable {
  7056. /**
  7057. * Gets the 8 vectors representing the bounding box in local space
  7058. */
  7059. readonly vectors: Vector3[];
  7060. /**
  7061. * Gets the center of the bounding box in local space
  7062. */
  7063. readonly center: Vector3;
  7064. /**
  7065. * Gets the center of the bounding box in world space
  7066. */
  7067. readonly centerWorld: Vector3;
  7068. /**
  7069. * Gets the extend size in local space
  7070. */
  7071. readonly extendSize: Vector3;
  7072. /**
  7073. * Gets the extend size in world space
  7074. */
  7075. readonly extendSizeWorld: Vector3;
  7076. /**
  7077. * Gets the OBB (object bounding box) directions
  7078. */
  7079. readonly directions: Vector3[];
  7080. /**
  7081. * Gets the 8 vectors representing the bounding box in world space
  7082. */
  7083. readonly vectorsWorld: Vector3[];
  7084. /**
  7085. * Gets the minimum vector in world space
  7086. */
  7087. readonly minimumWorld: Vector3;
  7088. /**
  7089. * Gets the maximum vector in world space
  7090. */
  7091. readonly maximumWorld: Vector3;
  7092. /**
  7093. * Gets the minimum vector in local space
  7094. */
  7095. readonly minimum: Vector3;
  7096. /**
  7097. * Gets the maximum vector in local space
  7098. */
  7099. readonly maximum: Vector3;
  7100. private _worldMatrix;
  7101. private static readonly TmpVector3;
  7102. /**
  7103. * @hidden
  7104. */
  7105. _tag: number;
  7106. /**
  7107. * Creates a new bounding box
  7108. * @param min defines the minimum vector (in local space)
  7109. * @param max defines the maximum vector (in local space)
  7110. * @param worldMatrix defines the new world matrix
  7111. */
  7112. constructor(min: Readonly<Vector3>, max: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>);
  7113. /**
  7114. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7115. * @param min defines the new minimum vector (in local space)
  7116. * @param max defines the new maximum vector (in local space)
  7117. * @param worldMatrix defines the new world matrix
  7118. */
  7119. reConstruct(min: Readonly<Vector3>, max: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>): void;
  7120. /**
  7121. * Scale the current bounding box by applying a scale factor
  7122. * @param factor defines the scale factor to apply
  7123. * @returns the current bounding box
  7124. */
  7125. scale(factor: number): BoundingBox;
  7126. /**
  7127. * Gets the world matrix of the bounding box
  7128. * @returns a matrix
  7129. */
  7130. getWorldMatrix(): Readonly<Matrix>;
  7131. /** @hidden */
  7132. _update(world: Readonly<Matrix>): void;
  7133. /**
  7134. * Tests if the bounding box is intersecting the frustum planes
  7135. * @param frustumPlanes defines the frustum planes to test
  7136. * @returns true if there is an intersection
  7137. */
  7138. isInFrustum(frustumPlanes: Array<Readonly<Plane>>): boolean;
  7139. /**
  7140. * Tests if the bounding box is entirely inside the frustum planes
  7141. * @param frustumPlanes defines the frustum planes to test
  7142. * @returns true if there is an inclusion
  7143. */
  7144. isCompletelyInFrustum(frustumPlanes: Array<Readonly<Plane>>): boolean;
  7145. /**
  7146. * Tests if a point is inside the bounding box
  7147. * @param point defines the point to test
  7148. * @returns true if the point is inside the bounding box
  7149. */
  7150. intersectsPoint(point: Readonly<Vector3>): boolean;
  7151. /**
  7152. * Tests if the bounding box intersects with a bounding sphere
  7153. * @param sphere defines the sphere to test
  7154. * @returns true if there is an intersection
  7155. */
  7156. intersectsSphere(sphere: Readonly<BoundingSphere>): boolean;
  7157. /**
  7158. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7159. * @param min defines the min vector to use
  7160. * @param max defines the max vector to use
  7161. * @returns true if there is an intersection
  7162. */
  7163. intersectsMinMax(min: Readonly<Vector3>, max: Readonly<Vector3>): boolean;
  7164. /**
  7165. * Tests if two bounding boxes are intersections
  7166. * @param box0 defines the first box to test
  7167. * @param box1 defines the second box to test
  7168. * @returns true if there is an intersection
  7169. */
  7170. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  7171. /**
  7172. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7173. * @param minPoint defines the minimum vector of the bounding box
  7174. * @param maxPoint defines the maximum vector of the bounding box
  7175. * @param sphereCenter defines the sphere center
  7176. * @param sphereRadius defines the sphere radius
  7177. * @returns true if there is an intersection
  7178. */
  7179. static IntersectsSphere(minPoint: Readonly<Vector3>, maxPoint: Readonly<Vector3>, sphereCenter: Readonly<Vector3>, sphereRadius: number): boolean;
  7180. /**
  7181. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7182. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7183. * @param frustumPlanes defines the frustum planes to test
  7184. * @return true if there is an inclusion
  7185. */
  7186. static IsCompletelyInFrustum(boundingVectors: Array<Readonly<Vector3>>, frustumPlanes: Array<Readonly<Plane>>): boolean;
  7187. /**
  7188. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7189. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7190. * @param frustumPlanes defines the frustum planes to test
  7191. * @return true if there is an intersection
  7192. */
  7193. static IsInFrustum(boundingVectors: Array<Readonly<Vector3>>, frustumPlanes: Array<Readonly<Plane>>): boolean;
  7194. }
  7195. }
  7196. declare module BABYLON {
  7197. /**
  7198. * Interface for cullable objects
  7199. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7200. */
  7201. interface ICullable {
  7202. /**
  7203. * Checks if the object or part of the object is in the frustum
  7204. * @param frustumPlanes Camera near/planes
  7205. * @returns true if the object is in frustum otherwise false
  7206. */
  7207. isInFrustum(frustumPlanes: Plane[]): boolean;
  7208. /**
  7209. * Checks if a cullable object (mesh...) is in the camera frustum
  7210. * Unlike isInFrustum this cheks the full bounding box
  7211. * @param frustumPlanes Camera near/planes
  7212. * @returns true if the object is in frustum otherwise false
  7213. */
  7214. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7215. }
  7216. /**
  7217. * Info for a bounding data of a mesh
  7218. */
  7219. class BoundingInfo implements ICullable {
  7220. /**
  7221. * Bounding box for the mesh
  7222. */
  7223. readonly boundingBox: BoundingBox;
  7224. /**
  7225. * Bounding sphere for the mesh
  7226. */
  7227. readonly boundingSphere: BoundingSphere;
  7228. private _isLocked;
  7229. private static readonly TmpVector3;
  7230. /**
  7231. * Constructs bounding info
  7232. * @param minimum min vector of the bounding box/sphere
  7233. * @param maximum max vector of the bounding box/sphere
  7234. * @param worldMatrix defines the new world matrix
  7235. */
  7236. constructor(minimum: Readonly<Vector3>, maximum: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>);
  7237. /**
  7238. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7239. * @param min defines the new minimum vector (in local space)
  7240. * @param max defines the new maximum vector (in local space)
  7241. * @param worldMatrix defines the new world matrix
  7242. */
  7243. reConstruct(min: Readonly<Vector3>, max: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>): void;
  7244. /**
  7245. * min vector of the bounding box/sphere
  7246. */
  7247. readonly minimum: Vector3;
  7248. /**
  7249. * max vector of the bounding box/sphere
  7250. */
  7251. readonly maximum: Vector3;
  7252. /**
  7253. * If the info is locked and won't be updated to avoid perf overhead
  7254. */
  7255. isLocked: boolean;
  7256. /**
  7257. * Updates the bounding sphere and box
  7258. * @param world world matrix to be used to update
  7259. */
  7260. update(world: Readonly<Matrix>): void;
  7261. /**
  7262. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7263. * @param center New center of the bounding info
  7264. * @param extend New extend of the bounding info
  7265. * @returns the current bounding info
  7266. */
  7267. centerOn(center: Readonly<Vector3>, extend: Readonly<Vector3>): BoundingInfo;
  7268. /**
  7269. * Scale the current bounding info by applying a scale factor
  7270. * @param factor defines the scale factor to apply
  7271. * @returns the current bounding info
  7272. */
  7273. scale(factor: number): BoundingInfo;
  7274. /**
  7275. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7276. * @param frustumPlanes defines the frustum to test
  7277. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  7278. * @returns true if the bounding info is in the frustum planes
  7279. */
  7280. isInFrustum(frustumPlanes: Array<Readonly<Plane>>, strategy?: number): boolean;
  7281. /**
  7282. * Gets the world distance between the min and max points of the bounding box
  7283. */
  7284. readonly diagonalLength: number;
  7285. /**
  7286. * Checks if a cullable object (mesh...) is in the camera frustum
  7287. * Unlike isInFrustum this cheks the full bounding box
  7288. * @param frustumPlanes Camera near/planes
  7289. * @returns true if the object is in frustum otherwise false
  7290. */
  7291. isCompletelyInFrustum(frustumPlanes: Array<Readonly<Plane>>): boolean;
  7292. /** @hidden */
  7293. _checkCollision(collider: Collider): boolean;
  7294. /**
  7295. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7296. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7297. * @param point the point to check intersection with
  7298. * @returns if the point intersects
  7299. */
  7300. intersectsPoint(point: Readonly<Vector3>): boolean;
  7301. /**
  7302. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7303. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7304. * @param boundingInfo the bounding info to check intersection with
  7305. * @param precise if the intersection should be done using OBB
  7306. * @returns if the bounding info intersects
  7307. */
  7308. intersects(boundingInfo: Readonly<BoundingInfo>, precise: boolean): boolean;
  7309. }
  7310. }
  7311. declare module BABYLON {
  7312. /**
  7313. * Class used to store bounding sphere information
  7314. */
  7315. class BoundingSphere {
  7316. /**
  7317. * Gets the center of the bounding sphere in local space
  7318. */
  7319. readonly center: Vector3;
  7320. /**
  7321. * Radius of the bounding sphere in local space
  7322. */
  7323. radius: number;
  7324. /**
  7325. * Gets the center of the bounding sphere in world space
  7326. */
  7327. readonly centerWorld: Vector3;
  7328. /**
  7329. * Radius of the bounding sphere in world space
  7330. */
  7331. radiusWorld: number;
  7332. /**
  7333. * Gets the minimum vector in local space
  7334. */
  7335. readonly minimum: Vector3;
  7336. /**
  7337. * Gets the maximum vector in local space
  7338. */
  7339. readonly maximum: Vector3;
  7340. private _worldMatrix;
  7341. private static readonly TmpVector3;
  7342. /**
  7343. * Creates a new bounding sphere
  7344. * @param min defines the minimum vector (in local space)
  7345. * @param max defines the maximum vector (in local space)
  7346. * @param worldMatrix defines the new world matrix
  7347. */
  7348. constructor(min: Readonly<Vector3>, max: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>);
  7349. /**
  7350. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7351. * @param min defines the new minimum vector (in local space)
  7352. * @param max defines the new maximum vector (in local space)
  7353. * @param worldMatrix defines the new world matrix
  7354. */
  7355. reConstruct(min: Readonly<Vector3>, max: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>): void;
  7356. /**
  7357. * Scale the current bounding sphere by applying a scale factor
  7358. * @param factor defines the scale factor to apply
  7359. * @returns the current bounding box
  7360. */
  7361. scale(factor: number): BoundingSphere;
  7362. /**
  7363. * Gets the world matrix of the bounding box
  7364. * @returns a matrix
  7365. */
  7366. getWorldMatrix(): Readonly<Matrix>;
  7367. /** @hidden */
  7368. _update(worldMatrix: Readonly<Matrix>): void;
  7369. /**
  7370. * Tests if the bounding sphere is intersecting the frustum planes
  7371. * @param frustumPlanes defines the frustum planes to test
  7372. * @returns true if there is an intersection
  7373. */
  7374. isInFrustum(frustumPlanes: Array<Readonly<Plane>>): boolean;
  7375. /**
  7376. * Tests if a point is inside the bounding sphere
  7377. * @param point defines the point to test
  7378. * @returns true if the point is inside the bounding sphere
  7379. */
  7380. intersectsPoint(point: Readonly<Vector3>): boolean;
  7381. /**
  7382. * Checks if two sphere intersct
  7383. * @param sphere0 sphere 0
  7384. * @param sphere1 sphere 1
  7385. * @returns true if the speres intersect
  7386. */
  7387. static Intersects(sphere0: Readonly<BoundingSphere>, sphere1: Readonly<BoundingSphere>): boolean;
  7388. }
  7389. }
  7390. declare module BABYLON {
  7391. /**
  7392. * Class representing a ray with position and direction
  7393. */
  7394. class Ray {
  7395. /** origin point */
  7396. origin: Vector3;
  7397. /** direction */
  7398. direction: Vector3;
  7399. /** length of the ray */
  7400. length: number;
  7401. private static readonly _edge1;
  7402. private static readonly _edge2;
  7403. private static readonly _pvec;
  7404. private static readonly _tvec;
  7405. private static readonly _qvec;
  7406. private static readonly _min;
  7407. private static readonly _max;
  7408. private _tmpRay;
  7409. /**
  7410. * Creates a new ray
  7411. * @param origin origin point
  7412. * @param direction direction
  7413. * @param length length of the ray
  7414. */
  7415. constructor(
  7416. /** origin point */
  7417. origin: Vector3,
  7418. /** direction */
  7419. direction: Vector3,
  7420. /** length of the ray */
  7421. length?: number);
  7422. /**
  7423. * Checks if the ray intersects a box
  7424. * @param minimum bound of the box
  7425. * @param maximum bound of the box
  7426. * @param intersectionTreshold extra extend to be added to the box in all direction
  7427. * @returns if the box was hit
  7428. */
  7429. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3, intersectionTreshold?: number): boolean;
  7430. /**
  7431. * Checks if the ray intersects a box
  7432. * @param box the bounding box to check
  7433. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  7434. * @returns if the box was hit
  7435. */
  7436. intersectsBox(box: BoundingBox, intersectionTreshold?: number): boolean;
  7437. /**
  7438. * If the ray hits a sphere
  7439. * @param sphere the bounding sphere to check
  7440. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  7441. * @returns true if it hits the sphere
  7442. */
  7443. intersectsSphere(sphere: BoundingSphere, intersectionTreshold?: number): boolean;
  7444. /**
  7445. * If the ray hits a triange
  7446. * @param vertex0 triangle vertex
  7447. * @param vertex1 triangle vertex
  7448. * @param vertex2 triangle vertex
  7449. * @returns intersection information if hit
  7450. */
  7451. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  7452. /**
  7453. * Checks if ray intersects a plane
  7454. * @param plane the plane to check
  7455. * @returns the distance away it was hit
  7456. */
  7457. intersectsPlane(plane: Plane): Nullable<number>;
  7458. /**
  7459. * Checks if ray intersects a mesh
  7460. * @param mesh the mesh to check
  7461. * @param fastCheck if only the bounding box should checked
  7462. * @returns picking info of the intersecton
  7463. */
  7464. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  7465. /**
  7466. * Checks if ray intersects a mesh
  7467. * @param meshes the meshes to check
  7468. * @param fastCheck if only the bounding box should checked
  7469. * @param results array to store result in
  7470. * @returns Array of picking infos
  7471. */
  7472. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  7473. private _comparePickingInfo;
  7474. private static smallnum;
  7475. private static rayl;
  7476. /**
  7477. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  7478. * @param sega the first point of the segment to test the intersection against
  7479. * @param segb the second point of the segment to test the intersection against
  7480. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  7481. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  7482. */
  7483. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  7484. /**
  7485. * Update the ray from viewport position
  7486. * @param x position
  7487. * @param y y position
  7488. * @param viewportWidth viewport width
  7489. * @param viewportHeight viewport height
  7490. * @param world world matrix
  7491. * @param view view matrix
  7492. * @param projection projection matrix
  7493. * @returns this ray updated
  7494. */
  7495. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  7496. /**
  7497. * Creates a ray with origin and direction of 0,0,0
  7498. * @returns the new ray
  7499. */
  7500. static Zero(): Ray;
  7501. /**
  7502. * Creates a new ray from screen space and viewport
  7503. * @param x position
  7504. * @param y y position
  7505. * @param viewportWidth viewport width
  7506. * @param viewportHeight viewport height
  7507. * @param world world matrix
  7508. * @param view view matrix
  7509. * @param projection projection matrix
  7510. * @returns new ray
  7511. */
  7512. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  7513. /**
  7514. * 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
  7515. * transformed to the given world matrix.
  7516. * @param origin The origin point
  7517. * @param end The end point
  7518. * @param world a matrix to transform the ray to. Default is the identity matrix.
  7519. * @returns the new ray
  7520. */
  7521. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Readonly<Matrix>): Ray;
  7522. /**
  7523. * Transforms a ray by a matrix
  7524. * @param ray ray to transform
  7525. * @param matrix matrix to apply
  7526. * @returns the resulting new ray
  7527. */
  7528. static Transform(ray: Ray, matrix: Readonly<Matrix>): Ray;
  7529. /**
  7530. * Transforms a ray by a matrix
  7531. * @param ray ray to transform
  7532. * @param matrix matrix to apply
  7533. * @param result ray to store result in
  7534. */
  7535. static TransformToRef(ray: Ray, matrix: Readonly<Matrix>, result: Ray): void;
  7536. }
  7537. }
  7538. declare module BABYLON {
  7539. /**
  7540. * This represents an orbital type of camera.
  7541. *
  7542. * 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.
  7543. * 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.
  7544. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  7545. */
  7546. class ArcRotateCamera extends TargetCamera {
  7547. /**
  7548. * Defines the rotation angle of the camera along the longitudinal axis.
  7549. */
  7550. alpha: number;
  7551. /**
  7552. * Defines the rotation angle of the camera along the latitudinal axis.
  7553. */
  7554. beta: number;
  7555. /**
  7556. * Defines the radius of the camera from it s target point.
  7557. */
  7558. radius: number;
  7559. protected _target: Vector3;
  7560. protected _targetHost: Nullable<AbstractMesh>;
  7561. /**
  7562. * Defines the target point of the camera.
  7563. * The camera looks towards it form the radius distance.
  7564. */
  7565. target: Vector3;
  7566. /**
  7567. * Current inertia value on the longitudinal axis.
  7568. * The bigger this number the longer it will take for the camera to stop.
  7569. */
  7570. inertialAlphaOffset: number;
  7571. /**
  7572. * Current inertia value on the latitudinal axis.
  7573. * The bigger this number the longer it will take for the camera to stop.
  7574. */
  7575. inertialBetaOffset: number;
  7576. /**
  7577. * Current inertia value on the radius axis.
  7578. * The bigger this number the longer it will take for the camera to stop.
  7579. */
  7580. inertialRadiusOffset: number;
  7581. /**
  7582. * Minimum allowed angle on the longitudinal axis.
  7583. * This can help limiting how the Camera is able to move in the scene.
  7584. */
  7585. lowerAlphaLimit: Nullable<number>;
  7586. /**
  7587. * Maximum allowed angle on the longitudinal axis.
  7588. * This can help limiting how the Camera is able to move in the scene.
  7589. */
  7590. upperAlphaLimit: Nullable<number>;
  7591. /**
  7592. * Minimum allowed angle on the latitudinal axis.
  7593. * This can help limiting how the Camera is able to move in the scene.
  7594. */
  7595. lowerBetaLimit: number;
  7596. /**
  7597. * Maximum allowed angle on the latitudinal axis.
  7598. * This can help limiting how the Camera is able to move in the scene.
  7599. */
  7600. upperBetaLimit: number;
  7601. /**
  7602. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  7603. * This can help limiting how the Camera is able to move in the scene.
  7604. */
  7605. lowerRadiusLimit: Nullable<number>;
  7606. /**
  7607. * Maximum allowed distance of the camera to the target (The camera can not get further).
  7608. * This can help limiting how the Camera is able to move in the scene.
  7609. */
  7610. upperRadiusLimit: Nullable<number>;
  7611. /**
  7612. * Defines the current inertia value used during panning of the camera along the X axis.
  7613. */
  7614. inertialPanningX: number;
  7615. /**
  7616. * Defines the current inertia value used during panning of the camera along the Y axis.
  7617. */
  7618. inertialPanningY: number;
  7619. /**
  7620. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  7621. * Basically if your fingers moves away from more than this distance you will be considered
  7622. * in pinch mode.
  7623. */
  7624. pinchToPanMaxDistance: number;
  7625. /**
  7626. * Defines the maximum distance the camera can pan.
  7627. * This could help keeping the cammera always in your scene.
  7628. */
  7629. panningDistanceLimit: Nullable<number>;
  7630. /**
  7631. * Defines the target of the camera before paning.
  7632. */
  7633. panningOriginTarget: Vector3;
  7634. /**
  7635. * Defines the value of the inertia used during panning.
  7636. * 0 would mean stop inertia and one would mean no decelleration at all.
  7637. */
  7638. panningInertia: number;
  7639. /**
  7640. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  7641. */
  7642. angularSensibilityX: number;
  7643. /**
  7644. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  7645. */
  7646. angularSensibilityY: number;
  7647. /**
  7648. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  7649. */
  7650. pinchPrecision: number;
  7651. /**
  7652. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  7653. * It will be used instead of pinchDeltaPrecision if different from 0.
  7654. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7655. */
  7656. pinchDeltaPercentage: number;
  7657. /**
  7658. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  7659. */
  7660. panningSensibility: number;
  7661. /**
  7662. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  7663. */
  7664. keysUp: number[];
  7665. /**
  7666. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  7667. */
  7668. keysDown: number[];
  7669. /**
  7670. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  7671. */
  7672. keysLeft: number[];
  7673. /**
  7674. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  7675. */
  7676. keysRight: number[];
  7677. /**
  7678. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  7679. */
  7680. wheelPrecision: number;
  7681. /**
  7682. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  7683. * It will be used instead of pinchDeltaPrecision if different from 0.
  7684. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7685. */
  7686. wheelDeltaPercentage: number;
  7687. /**
  7688. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  7689. */
  7690. zoomOnFactor: number;
  7691. /**
  7692. * Defines a screen offset for the camera position.
  7693. */
  7694. targetScreenOffset: Vector2;
  7695. /**
  7696. * Allows the camera to be completely reversed.
  7697. * If false the camera can not arrive upside down.
  7698. */
  7699. allowUpsideDown: boolean;
  7700. /**
  7701. * Define if double tap/click is used to restore the previously saved state of the camera.
  7702. */
  7703. useInputToRestoreState: boolean;
  7704. /** @hidden */
  7705. _viewMatrix: Matrix;
  7706. /** @hidden */
  7707. _useCtrlForPanning: boolean;
  7708. /** @hidden */
  7709. _panningMouseButton: number;
  7710. /**
  7711. * Defines the inpute associated to the camera.
  7712. */
  7713. inputs: ArcRotateCameraInputsManager;
  7714. /** @hidden */
  7715. _reset: () => void;
  7716. /**
  7717. * Defines the allowed panning axis.
  7718. */
  7719. panningAxis: Vector3;
  7720. protected _localDirection: Vector3;
  7721. protected _transformedDirection: Vector3;
  7722. private _bouncingBehavior;
  7723. /**
  7724. * Gets the bouncing behavior of the camera if it has been enabled.
  7725. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7726. */
  7727. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  7728. /**
  7729. * Defines if the bouncing behavior of the camera is enabled on the camera.
  7730. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7731. */
  7732. useBouncingBehavior: boolean;
  7733. private _framingBehavior;
  7734. /**
  7735. * Gets the framing behavior of the camera if it has been enabled.
  7736. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7737. */
  7738. readonly framingBehavior: Nullable<FramingBehavior>;
  7739. /**
  7740. * Defines if the framing behavior of the camera is enabled on the camera.
  7741. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7742. */
  7743. useFramingBehavior: boolean;
  7744. private _autoRotationBehavior;
  7745. /**
  7746. * Gets the auto rotation behavior of the camera if it has been enabled.
  7747. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7748. */
  7749. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  7750. /**
  7751. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  7752. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7753. */
  7754. useAutoRotationBehavior: boolean;
  7755. /**
  7756. * Observable triggered when the mesh target has been changed on the camera.
  7757. */
  7758. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  7759. /**
  7760. * Event raised when the camera is colliding with a mesh.
  7761. */
  7762. onCollide: (collidedMesh: AbstractMesh) => void;
  7763. /**
  7764. * Defines whether the camera should check collision with the objects oh the scene.
  7765. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  7766. */
  7767. checkCollisions: boolean;
  7768. /**
  7769. * Defines the collision radius of the camera.
  7770. * This simulates a sphere around the camera.
  7771. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7772. */
  7773. collisionRadius: Vector3;
  7774. protected _collider: Collider;
  7775. protected _previousPosition: Vector3;
  7776. protected _collisionVelocity: Vector3;
  7777. protected _newPosition: Vector3;
  7778. protected _previousAlpha: number;
  7779. protected _previousBeta: number;
  7780. protected _previousRadius: number;
  7781. protected _collisionTriggered: boolean;
  7782. protected _targetBoundingCenter: Nullable<Vector3>;
  7783. private _computationVector;
  7784. /**
  7785. * Instantiates a new ArcRotateCamera in a given scene
  7786. * @param name Defines the name of the camera
  7787. * @param alpha Defines the camera rotation along the logitudinal axis
  7788. * @param beta Defines the camera rotation along the latitudinal axis
  7789. * @param radius Defines the camera distance from its target
  7790. * @param target Defines the camera target
  7791. * @param scene Defines the scene the camera belongs to
  7792. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7793. */
  7794. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7795. /** @hidden */
  7796. _initCache(): void;
  7797. /** @hidden */
  7798. _updateCache(ignoreParentClass?: boolean): void;
  7799. protected _getTargetPosition(): Vector3;
  7800. private _storedAlpha;
  7801. private _storedBeta;
  7802. private _storedRadius;
  7803. private _storedTarget;
  7804. /**
  7805. * Stores the current state of the camera (alpha, beta, radius and target)
  7806. * @returns the camera itself
  7807. */
  7808. storeState(): Camera;
  7809. /**
  7810. * @hidden
  7811. * Restored camera state. You must call storeState() first
  7812. */
  7813. _restoreStateValues(): boolean;
  7814. /** @hidden */
  7815. _isSynchronizedViewMatrix(): boolean;
  7816. /**
  7817. * Attached controls to the current camera.
  7818. * @param element Defines the element the controls should be listened from
  7819. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7820. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  7821. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  7822. */
  7823. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  7824. /**
  7825. * Detach the current controls from the camera.
  7826. * The camera will stop reacting to inputs.
  7827. * @param element Defines the element to stop listening the inputs from
  7828. */
  7829. detachControl(element: HTMLElement): void;
  7830. /** @hidden */
  7831. _checkInputs(): void;
  7832. protected _checkLimits(): void;
  7833. /**
  7834. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  7835. */
  7836. rebuildAnglesAndRadius(): void;
  7837. /**
  7838. * Use a position to define the current camera related information like aplha, beta and radius
  7839. * @param position Defines the position to set the camera at
  7840. */
  7841. setPosition(position: Vector3): void;
  7842. /**
  7843. * Defines the target the camera should look at.
  7844. * This will automatically adapt alpha beta and radius to fit within the new target.
  7845. * @param target Defines the new target as a Vector or a mesh
  7846. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7847. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7848. */
  7849. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7850. /** @hidden */
  7851. _getViewMatrix(): Matrix;
  7852. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7853. /**
  7854. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7855. * @param meshes Defines the mesh to zoom on
  7856. * @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)
  7857. */
  7858. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7859. /**
  7860. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7861. * The target will be changed but the radius
  7862. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7863. * @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)
  7864. */
  7865. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7866. min: Vector3;
  7867. max: Vector3;
  7868. distance: number;
  7869. }, doNotUpdateMaxZ?: boolean): void;
  7870. /**
  7871. * @override
  7872. * Override Camera.createRigCamera
  7873. */
  7874. createRigCamera(name: string, cameraIndex: number): Camera;
  7875. /**
  7876. * @hidden
  7877. * @override
  7878. * Override Camera._updateRigCameras
  7879. */
  7880. _updateRigCameras(): void;
  7881. /**
  7882. * Destroy the camera and release the current resources hold by it.
  7883. */
  7884. dispose(): void;
  7885. /**
  7886. * Gets the current object class name.
  7887. * @return the class name
  7888. */
  7889. getClassName(): string;
  7890. }
  7891. }
  7892. declare module BABYLON {
  7893. /**
  7894. * Default Inputs manager for the ArcRotateCamera.
  7895. * It groups all the default supported inputs for ease of use.
  7896. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7897. */
  7898. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7899. /**
  7900. * Instantiates a new ArcRotateCameraInputsManager.
  7901. * @param camera Defines the camera the inputs belong to
  7902. */
  7903. constructor(camera: ArcRotateCamera);
  7904. /**
  7905. * Add mouse wheel input support to the input manager.
  7906. * @returns the current input manager
  7907. */
  7908. addMouseWheel(): ArcRotateCameraInputsManager;
  7909. /**
  7910. * Add pointers input support to the input manager.
  7911. * @returns the current input manager
  7912. */
  7913. addPointers(): ArcRotateCameraInputsManager;
  7914. /**
  7915. * Add keyboard input support to the input manager.
  7916. * @returns the current input manager
  7917. */
  7918. addKeyboard(): ArcRotateCameraInputsManager;
  7919. /**
  7920. * Add orientation input support to the input manager.
  7921. * @returns the current input manager
  7922. */
  7923. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7924. }
  7925. }
  7926. declare module BABYLON {
  7927. /**
  7928. * This is the base class of all the camera used in the application.
  7929. * @see http://doc.babylonjs.com/features/cameras
  7930. */
  7931. class Camera extends Node {
  7932. /**
  7933. * This is the default projection mode used by the cameras.
  7934. * It helps recreating a feeling of perspective and better appreciate depth.
  7935. * This is the best way to simulate real life cameras.
  7936. */
  7937. static readonly PERSPECTIVE_CAMERA: number;
  7938. /**
  7939. * This helps creating camera with an orthographic mode.
  7940. * 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.
  7941. */
  7942. static readonly ORTHOGRAPHIC_CAMERA: number;
  7943. /**
  7944. * This is the default FOV mode for perspective cameras.
  7945. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7946. */
  7947. static readonly FOVMODE_VERTICAL_FIXED: number;
  7948. /**
  7949. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7950. */
  7951. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7952. /**
  7953. * This specifies ther is no need for a camera rig.
  7954. * Basically only one eye is rendered corresponding to the camera.
  7955. */
  7956. static readonly RIG_MODE_NONE: number;
  7957. /**
  7958. * Simulates a camera Rig with one blue eye and one red eye.
  7959. * This can be use with 3d blue and red glasses.
  7960. */
  7961. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7962. /**
  7963. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7964. */
  7965. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7966. /**
  7967. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7968. */
  7969. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7970. /**
  7971. * Defines that both eyes of the camera will be rendered over under each other.
  7972. */
  7973. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7974. /**
  7975. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7976. */
  7977. static readonly RIG_MODE_VR: number;
  7978. /**
  7979. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7980. */
  7981. static readonly RIG_MODE_WEBVR: number;
  7982. /**
  7983. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  7984. */
  7985. static readonly RIG_MODE_CUSTOM: number;
  7986. /**
  7987. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7988. */
  7989. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7990. /**
  7991. * @hidden
  7992. * Might be removed once multiview will be a thing
  7993. */
  7994. static UseAlternateWebVRRendering: boolean;
  7995. /**
  7996. * Define the input manager associated with the camera.
  7997. */
  7998. inputs: CameraInputsManager<Camera>;
  7999. /**
  8000. * Define the current local position of the camera in the scene
  8001. */
  8002. position: Vector3;
  8003. /**
  8004. * The vector the camera should consider as up.
  8005. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  8006. */
  8007. upVector: Vector3;
  8008. /**
  8009. * Define the current limit on the left side for an orthographic camera
  8010. * In scene unit
  8011. */
  8012. orthoLeft: Nullable<number>;
  8013. /**
  8014. * Define the current limit on the right side for an orthographic camera
  8015. * In scene unit
  8016. */
  8017. orthoRight: Nullable<number>;
  8018. /**
  8019. * Define the current limit on the bottom side for an orthographic camera
  8020. * In scene unit
  8021. */
  8022. orthoBottom: Nullable<number>;
  8023. /**
  8024. * Define the current limit on the top side for an orthographic camera
  8025. * In scene unit
  8026. */
  8027. orthoTop: Nullable<number>;
  8028. /**
  8029. * Field Of View is set in Radians. (default is 0.8)
  8030. */
  8031. fov: number;
  8032. /**
  8033. * Define the minimum distance the camera can see from.
  8034. * This is important to note that the depth buffer are not infinite and the closer it starts
  8035. * the more your scene might encounter depth fighting issue.
  8036. */
  8037. minZ: number;
  8038. /**
  8039. * Define the maximum distance the camera can see to.
  8040. * This is important to note that the depth buffer are not infinite and the further it end
  8041. * the more your scene might encounter depth fighting issue.
  8042. */
  8043. maxZ: number;
  8044. /**
  8045. * Define the default inertia of the camera.
  8046. * This helps giving a smooth feeling to the camera movement.
  8047. */
  8048. inertia: number;
  8049. /**
  8050. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  8051. */
  8052. mode: number;
  8053. /**
  8054. * Define wether the camera is intermediate.
  8055. * This is usefull to not present the output directly to the screen in case of rig without post process for instance
  8056. */
  8057. isIntermediate: boolean;
  8058. /**
  8059. * Define the viewport of the camera.
  8060. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  8061. */
  8062. viewport: Viewport;
  8063. /**
  8064. * Restricts the camera to viewing objects with the same layerMask.
  8065. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  8066. */
  8067. layerMask: number;
  8068. /**
  8069. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  8070. */
  8071. fovMode: number;
  8072. /**
  8073. * Rig mode of the camera.
  8074. * This is usefull to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  8075. * This is normally controlled byt the camera themselves as internal use.
  8076. */
  8077. cameraRigMode: number;
  8078. /**
  8079. * Defines the distance between both "eyes" in case of a RIG
  8080. */
  8081. interaxialDistance: number;
  8082. /**
  8083. * Defines if stereoscopic rendering is done side by side or over under.
  8084. */
  8085. isStereoscopicSideBySide: boolean;
  8086. /**
  8087. * 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
  8088. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  8089. * else in the scene.
  8090. */
  8091. customRenderTargets: RenderTargetTexture[];
  8092. /**
  8093. * When set, the camera will render to this render target instead of the default canvas
  8094. */
  8095. outputRenderTarget: Nullable<RenderTargetTexture>;
  8096. /**
  8097. * Observable triggered when the camera view matrix has changed.
  8098. */
  8099. onViewMatrixChangedObservable: Observable<Camera>;
  8100. /**
  8101. * Observable triggered when the camera Projection matrix has changed.
  8102. */
  8103. onProjectionMatrixChangedObservable: Observable<Camera>;
  8104. /**
  8105. * Observable triggered when the inputs have been processed.
  8106. */
  8107. onAfterCheckInputsObservable: Observable<Camera>;
  8108. /**
  8109. * Observable triggered when reset has been called and applied to the camera.
  8110. */
  8111. onRestoreStateObservable: Observable<Camera>;
  8112. /** @hidden */
  8113. _cameraRigParams: any;
  8114. /** @hidden */
  8115. _rigCameras: Camera[];
  8116. /** @hidden */
  8117. _rigPostProcess: Nullable<PostProcess>;
  8118. protected _webvrViewMatrix: Matrix;
  8119. /** @hidden */
  8120. _skipRendering: boolean;
  8121. /** @hidden */
  8122. _alternateCamera: Camera;
  8123. /** @hidden */
  8124. _projectionMatrix: Matrix;
  8125. /** @hidden */
  8126. _postProcesses: Nullable<PostProcess>[];
  8127. /** @hidden */
  8128. _activeMeshes: SmartArray<AbstractMesh>;
  8129. protected _globalPosition: Vector3;
  8130. /** hidden */
  8131. _computedViewMatrix: Matrix;
  8132. private _doNotComputeProjectionMatrix;
  8133. private _transformMatrix;
  8134. private _frustumPlanes;
  8135. private _refreshFrustumPlanes;
  8136. private _storedFov;
  8137. private _stateStored;
  8138. /**
  8139. * Instantiates a new camera object.
  8140. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  8141. * @see http://doc.babylonjs.com/features/cameras
  8142. * @param name Defines the name of the camera in the scene
  8143. * @param position Defines the position of the camera
  8144. * @param scene Defines the scene the camera belongs too
  8145. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  8146. */
  8147. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8148. /**
  8149. * Store current camera state (fov, position, etc..)
  8150. * @returns the camera
  8151. */
  8152. storeState(): Camera;
  8153. /**
  8154. * Restores the camera state values if it has been stored. You must call storeState() first
  8155. */
  8156. protected _restoreStateValues(): boolean;
  8157. /**
  8158. * Restored camera state. You must call storeState() first.
  8159. * @returns true if restored and false otherwise
  8160. */
  8161. restoreState(): boolean;
  8162. /**
  8163. * Gets the class name of the camera.
  8164. * @returns the class name
  8165. */
  8166. getClassName(): string;
  8167. /**
  8168. * Gets a string representation of the camera usefull for debug purpose.
  8169. * @param fullDetails Defines that a more verboe level of logging is required
  8170. * @returns the string representation
  8171. */
  8172. toString(fullDetails?: boolean): string;
  8173. /**
  8174. * Gets the current world space position of the camera.
  8175. */
  8176. readonly globalPosition: Vector3;
  8177. /**
  8178. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  8179. * @returns the active meshe list
  8180. */
  8181. getActiveMeshes(): SmartArray<AbstractMesh>;
  8182. /**
  8183. * Check wether a mesh is part of the current active mesh list of the camera
  8184. * @param mesh Defines the mesh to check
  8185. * @returns true if active, false otherwise
  8186. */
  8187. isActiveMesh(mesh: Mesh): boolean;
  8188. /**
  8189. * Is this camera ready to be used/rendered
  8190. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  8191. * @return true if the camera is ready
  8192. */
  8193. isReady(completeCheck?: boolean): boolean;
  8194. /** @hidden */
  8195. _initCache(): void;
  8196. /** @hidden */
  8197. _updateCache(ignoreParentClass?: boolean): void;
  8198. /** @hidden */
  8199. _isSynchronized(): boolean;
  8200. /** @hidden */
  8201. _isSynchronizedViewMatrix(): boolean;
  8202. /** @hidden */
  8203. _isSynchronizedProjectionMatrix(): boolean;
  8204. /**
  8205. * Attach the input controls to a specific dom element to get the input from.
  8206. * @param element Defines the element the controls should be listened from
  8207. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8208. */
  8209. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8210. /**
  8211. * Detach the current controls from the specified dom element.
  8212. * @param element Defines the element to stop listening the inputs from
  8213. */
  8214. detachControl(element: HTMLElement): void;
  8215. /**
  8216. * Update the camera state according to the different inputs gathered during the frame.
  8217. */
  8218. update(): void;
  8219. /** @hidden */
  8220. _checkInputs(): void;
  8221. /** @hidden */
  8222. readonly rigCameras: Camera[];
  8223. /**
  8224. * Gets the post process used by the rig cameras
  8225. */
  8226. readonly rigPostProcess: Nullable<PostProcess>;
  8227. /**
  8228. * Internal, gets the first post proces.
  8229. * @returns the first post process to be run on this camera.
  8230. */
  8231. _getFirstPostProcess(): Nullable<PostProcess>;
  8232. private _cascadePostProcessesToRigCams;
  8233. /**
  8234. * Attach a post process to the camera.
  8235. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8236. * @param postProcess The post process to attach to the camera
  8237. * @param insertAt The position of the post process in case several of them are in use in the scene
  8238. * @returns the position the post process has been inserted at
  8239. */
  8240. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  8241. /**
  8242. * Detach a post process to the camera.
  8243. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8244. * @param postProcess The post process to detach from the camera
  8245. */
  8246. detachPostProcess(postProcess: PostProcess): void;
  8247. /**
  8248. * Gets the current world matrix of the camera
  8249. */
  8250. getWorldMatrix(): Matrix;
  8251. /** @hidden */
  8252. protected _getViewMatrix(): Matrix;
  8253. /**
  8254. * Gets the current view matrix of the camera.
  8255. * @param force forces the camera to recompute the matrix without looking at the cached state
  8256. * @returns the view matrix
  8257. */
  8258. getViewMatrix(force?: boolean): Matrix;
  8259. /**
  8260. * Freeze the projection matrix.
  8261. * It will prevent the cache check of the camera projection compute and can speed up perf
  8262. * if no parameter of the camera are meant to change
  8263. * @param projection Defines manually a projection if necessary
  8264. */
  8265. freezeProjectionMatrix(projection?: Matrix): void;
  8266. /**
  8267. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  8268. */
  8269. unfreezeProjectionMatrix(): void;
  8270. /**
  8271. * Gets the current projection matrix of the camera.
  8272. * @param force forces the camera to recompute the matrix without looking at the cached state
  8273. * @returns the projection matrix
  8274. */
  8275. getProjectionMatrix(force?: boolean): Matrix;
  8276. /**
  8277. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  8278. * @returns a Matrix
  8279. */
  8280. getTransformationMatrix(): Matrix;
  8281. private _updateFrustumPlanes;
  8282. /**
  8283. * Checks if a cullable object (mesh...) is in the camera frustum
  8284. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  8285. * @param target The object to check
  8286. * @returns true if the object is in frustum otherwise false
  8287. */
  8288. isInFrustum(target: ICullable): boolean;
  8289. /**
  8290. * Checks if a cullable object (mesh...) is in the camera frustum
  8291. * Unlike isInFrustum this cheks the full bounding box
  8292. * @param target The object to check
  8293. * @returns true if the object is in frustum otherwise false
  8294. */
  8295. isCompletelyInFrustum(target: ICullable): boolean;
  8296. /**
  8297. * Gets a ray in the forward direction from the camera.
  8298. * @param length Defines the length of the ray to create
  8299. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  8300. * @param origin Defines the start point of the ray which defaults to the camera position
  8301. * @returns the forward ray
  8302. */
  8303. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  8304. /**
  8305. * Releases resources associated with this node.
  8306. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8307. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8308. */
  8309. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8310. /**
  8311. * Gets the left camera of a rig setup in case of Rigged Camera
  8312. */
  8313. readonly leftCamera: Nullable<FreeCamera>;
  8314. /**
  8315. * Gets the right camera of a rig setup in case of Rigged Camera
  8316. */
  8317. readonly rightCamera: Nullable<FreeCamera>;
  8318. /**
  8319. * Gets the left camera target of a rig setup in case of Rigged Camera
  8320. * @returns the target position
  8321. */
  8322. getLeftTarget(): Nullable<Vector3>;
  8323. /**
  8324. * Gets the right camera target of a rig setup in case of Rigged Camera
  8325. * @returns the target position
  8326. */
  8327. getRightTarget(): Nullable<Vector3>;
  8328. /**
  8329. * @hidden
  8330. */
  8331. setCameraRigMode(mode: number, rigParams: any): void;
  8332. private _getVRProjectionMatrix;
  8333. protected _updateCameraRotationMatrix(): void;
  8334. protected _updateWebVRCameraRotationMatrix(): void;
  8335. /**
  8336. * This function MUST be overwritten by the different WebVR cameras available.
  8337. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8338. */
  8339. protected _getWebVRProjectionMatrix(): Matrix;
  8340. /**
  8341. * This function MUST be overwritten by the different WebVR cameras available.
  8342. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8343. */
  8344. protected _getWebVRViewMatrix(): Matrix;
  8345. /** @hidden */
  8346. setCameraRigParameter(name: string, value: any): void;
  8347. /**
  8348. * needs to be overridden by children so sub has required properties to be copied
  8349. * @hidden
  8350. */
  8351. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8352. /**
  8353. * May need to be overridden by children
  8354. * @hidden
  8355. */
  8356. _updateRigCameras(): void;
  8357. /** @hidden */
  8358. _setupInputs(): void;
  8359. /**
  8360. * Serialiaze the camera setup to a json represention
  8361. * @returns the JSON representation
  8362. */
  8363. serialize(): any;
  8364. /**
  8365. * Clones the current camera.
  8366. * @param name The cloned camera name
  8367. * @returns the cloned camera
  8368. */
  8369. clone(name: string): Camera;
  8370. /**
  8371. * Gets the direction of the camera relative to a given local axis.
  8372. * @param localAxis Defines the reference axis to provide a relative direction.
  8373. * @return the direction
  8374. */
  8375. getDirection(localAxis: Vector3): Vector3;
  8376. /**
  8377. * Gets the direction of the camera relative to a given local axis into a passed vector.
  8378. * @param localAxis Defines the reference axis to provide a relative direction.
  8379. * @param result Defines the vector to store the result in
  8380. */
  8381. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  8382. /**
  8383. * Gets a camera constructor for a given camera type
  8384. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  8385. * @param name The name of the camera the result will be able to instantiate
  8386. * @param scene The scene the result will construct the camera in
  8387. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  8388. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  8389. * @returns a factory method to construc the camera
  8390. */
  8391. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  8392. /**
  8393. * Compute the world matrix of the camera.
  8394. * @returns the camera workd matrix
  8395. */
  8396. computeWorldMatrix(): Matrix;
  8397. /**
  8398. * Parse a JSON and creates the camera from the parsed information
  8399. * @param parsedCamera The JSON to parse
  8400. * @param scene The scene to instantiate the camera in
  8401. * @returns the newly constructed camera
  8402. */
  8403. static Parse(parsedCamera: any, scene: Scene): Camera;
  8404. }
  8405. }
  8406. declare module BABYLON {
  8407. /**
  8408. * @ignore
  8409. * This is a list of all the different input types that are available in the application.
  8410. * Fo instance: ArcRotateCameraGamepadInput...
  8411. */
  8412. var CameraInputTypes: {};
  8413. /**
  8414. * This is the contract to implement in order to create a new input class.
  8415. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8416. */
  8417. interface ICameraInput<TCamera extends Camera> {
  8418. /**
  8419. * Defines the camera the input is attached to.
  8420. */
  8421. camera: Nullable<TCamera>;
  8422. /**
  8423. * Gets the class name of the current intput.
  8424. * @returns the class name
  8425. */
  8426. getClassName(): string;
  8427. /**
  8428. * Get the friendly name associated with the input class.
  8429. * @returns the input friendly name
  8430. */
  8431. getSimpleName(): string;
  8432. /**
  8433. * Attach the input controls to a specific dom element to get the input from.
  8434. * @param element Defines the element the controls should be listened from
  8435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8436. */
  8437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8438. /**
  8439. * Detach the current controls from the specified dom element.
  8440. * @param element Defines the element to stop listening the inputs from
  8441. */
  8442. detachControl(element: Nullable<HTMLElement>): void;
  8443. /**
  8444. * Update the current camera state depending on the inputs that have been used this frame.
  8445. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8446. */
  8447. checkInputs?: () => void;
  8448. }
  8449. /**
  8450. * Represents a map of input types to input instance or input index to input instance.
  8451. */
  8452. interface CameraInputsMap<TCamera extends Camera> {
  8453. /**
  8454. * Accessor to the input by input type.
  8455. */
  8456. [name: string]: ICameraInput<TCamera>;
  8457. /**
  8458. * Accessor to the input by input index.
  8459. */
  8460. [idx: number]: ICameraInput<TCamera>;
  8461. }
  8462. /**
  8463. * This represents the input manager used within a camera.
  8464. * It helps dealing with all the different kind of input attached to a camera.
  8465. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8466. */
  8467. class CameraInputsManager<TCamera extends Camera> {
  8468. /**
  8469. * Defines the list of inputs attahed to the camera.
  8470. */
  8471. attached: CameraInputsMap<TCamera>;
  8472. /**
  8473. * Defines the dom element the camera is collecting inputs from.
  8474. * This is null if the controls have not been attached.
  8475. */
  8476. attachedElement: Nullable<HTMLElement>;
  8477. /**
  8478. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8479. */
  8480. noPreventDefault: boolean;
  8481. /**
  8482. * Defined the camera the input manager belongs to.
  8483. */
  8484. camera: TCamera;
  8485. /**
  8486. * Update the current camera state depending on the inputs that have been used this frame.
  8487. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8488. */
  8489. checkInputs: () => void;
  8490. /**
  8491. * Instantiate a new Camera Input Manager.
  8492. * @param camera Defines the camera the input manager blongs to
  8493. */
  8494. constructor(camera: TCamera);
  8495. /**
  8496. * Add an input method to a camera
  8497. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8498. * @param input camera input method
  8499. */
  8500. add(input: ICameraInput<TCamera>): void;
  8501. /**
  8502. * Remove a specific input method from a camera
  8503. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8504. * @param inputToRemove camera input method
  8505. */
  8506. remove(inputToRemove: ICameraInput<TCamera>): void;
  8507. /**
  8508. * Remove a specific input type from a camera
  8509. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8510. * @param inputType the type of the input to remove
  8511. */
  8512. removeByType(inputType: string): void;
  8513. private _addCheckInputs;
  8514. /**
  8515. * Attach the input controls to the currently attached dom element to listen the events from.
  8516. * @param input Defines the input to attach
  8517. */
  8518. attachInput(input: ICameraInput<TCamera>): void;
  8519. /**
  8520. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8521. * @param element Defines the dom element to collect the events from
  8522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8523. */
  8524. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8525. /**
  8526. * Detach the current manager inputs controls from a specific dom element.
  8527. * @param element Defines the dom element to collect the events from
  8528. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8529. */
  8530. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8531. /**
  8532. * Rebuild the dynamic inputCheck function from the current list of
  8533. * defined inputs in the manager.
  8534. */
  8535. rebuildInputCheck(): void;
  8536. /**
  8537. * Remove all attached input methods from a camera
  8538. */
  8539. clear(): void;
  8540. /**
  8541. * Serialize the current input manager attached to a camera.
  8542. * This ensures than once parsed,
  8543. * the input associated to the camera will be identical to the current ones
  8544. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8545. */
  8546. serialize(serializedCamera: any): void;
  8547. /**
  8548. * Parses an input manager serialized JSON to restore the previous list of inputs
  8549. * and states associated to a camera.
  8550. * @param parsedCamera Defines the JSON to parse
  8551. */
  8552. parse(parsedCamera: any): void;
  8553. }
  8554. }
  8555. declare module BABYLON {
  8556. /**
  8557. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  8558. * being tilted forward or back and left or right.
  8559. */
  8560. class DeviceOrientationCamera extends FreeCamera {
  8561. private _initialQuaternion;
  8562. private _quaternionCache;
  8563. /**
  8564. * Creates a new device orientation camera
  8565. * @param name The name of the camera
  8566. * @param position The start position camera
  8567. * @param scene The scene the camera belongs to
  8568. */
  8569. constructor(name: string, position: Vector3, scene: Scene);
  8570. /**
  8571. * Gets the current instance class name ("DeviceOrientationCamera").
  8572. * This helps avoiding instanceof at run time.
  8573. * @returns the class name
  8574. */
  8575. getClassName(): string;
  8576. /**
  8577. * @hidden
  8578. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  8579. */
  8580. _checkInputs(): void;
  8581. /**
  8582. * Reset the camera to its default orientation on the specified axis only.
  8583. * @param axis The axis to reset
  8584. */
  8585. resetToCurrentRotation(axis?: Axis): void;
  8586. }
  8587. }
  8588. declare module BABYLON {
  8589. /**
  8590. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8591. * such as in a 3D Space Shooter or a Flight Simulator.
  8592. */
  8593. class FlyCamera extends TargetCamera {
  8594. /**
  8595. * Define the collision ellipsoid of the camera.
  8596. * This is helpful for simulating a camera body, like a player's body.
  8597. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8598. */
  8599. ellipsoid: Vector3;
  8600. /**
  8601. * Define an offset for the position of the ellipsoid around the camera.
  8602. * This can be helpful if the camera is attached away from the player's body center,
  8603. * such as at its head.
  8604. */
  8605. ellipsoidOffset: Vector3;
  8606. /**
  8607. * Enable or disable collisions of the camera with the rest of the scene objects.
  8608. */
  8609. checkCollisions: boolean;
  8610. /**
  8611. * Enable or disable gravity on the camera.
  8612. */
  8613. applyGravity: boolean;
  8614. /**
  8615. * Define the current direction the camera is moving to.
  8616. */
  8617. cameraDirection: Vector3;
  8618. /**
  8619. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  8620. * This overrides and empties cameraRotation.
  8621. */
  8622. rotationQuaternion: BABYLON.Quaternion;
  8623. /**
  8624. * Track Roll to maintain the wanted Rolling when looking around.
  8625. */
  8626. _trackRoll: number;
  8627. /**
  8628. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  8629. */
  8630. rollCorrect: number;
  8631. /**
  8632. * Mimic a banked turn, Rolling the camera when Yawing.
  8633. * It's recommended to use rollCorrect = 10 for faster banking correction.
  8634. */
  8635. bankedTurn: boolean;
  8636. /**
  8637. * Limit in radians for how much Roll banking will add. (Default: 90°)
  8638. */
  8639. bankedTurnLimit: number;
  8640. /**
  8641. * Value of 0 disables the banked Roll.
  8642. * Value of 1 is equal to the Yaw angle in radians.
  8643. */
  8644. bankedTurnMultiplier: number;
  8645. /**
  8646. * The inputs manager loads all the input sources, such as keyboard and mouse.
  8647. */
  8648. inputs: FlyCameraInputsManager;
  8649. /**
  8650. * Gets the input sensibility for mouse input.
  8651. * Higher values reduce sensitivity.
  8652. */
  8653. /**
  8654. * Sets the input sensibility for a mouse input.
  8655. * Higher values reduce sensitivity.
  8656. */
  8657. angularSensibility: number;
  8658. /**
  8659. * Get the keys for camera movement forward.
  8660. */
  8661. /**
  8662. * Set the keys for camera movement forward.
  8663. */
  8664. keysForward: number[];
  8665. /**
  8666. * Get the keys for camera movement backward.
  8667. */
  8668. keysBackward: number[];
  8669. /**
  8670. * Get the keys for camera movement up.
  8671. */
  8672. /**
  8673. * Set the keys for camera movement up.
  8674. */
  8675. keysUp: number[];
  8676. /**
  8677. * Get the keys for camera movement down.
  8678. */
  8679. /**
  8680. * Set the keys for camera movement down.
  8681. */
  8682. keysDown: number[];
  8683. /**
  8684. * Get the keys for camera movement left.
  8685. */
  8686. /**
  8687. * Set the keys for camera movement left.
  8688. */
  8689. keysLeft: number[];
  8690. /**
  8691. * Set the keys for camera movement right.
  8692. */
  8693. /**
  8694. * Set the keys for camera movement right.
  8695. */
  8696. keysRight: number[];
  8697. /**
  8698. * Event raised when the camera collides with a mesh in the scene.
  8699. */
  8700. onCollide: (collidedMesh: AbstractMesh) => void;
  8701. private _collider;
  8702. private _needMoveForGravity;
  8703. private _oldPosition;
  8704. private _diffPosition;
  8705. private _newPosition;
  8706. /** @hidden */
  8707. _localDirection: Vector3;
  8708. /** @hidden */
  8709. _transformedDirection: Vector3;
  8710. /**
  8711. * Instantiates a FlyCamera.
  8712. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8713. * such as in a 3D Space Shooter or a Flight Simulator.
  8714. * @param name Define the name of the camera in the scene.
  8715. * @param position Define the starting position of the camera in the scene.
  8716. * @param scene Define the scene the camera belongs to.
  8717. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  8718. */
  8719. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8720. /**
  8721. * Attach a control to the HTML DOM element.
  8722. * @param element Defines the element that listens to the input events.
  8723. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  8724. */
  8725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8726. /**
  8727. * Detach a control from the HTML DOM element.
  8728. * The camera will stop reacting to that input.
  8729. * @param element Defines the element that listens to the input events.
  8730. */
  8731. detachControl(element: HTMLElement): void;
  8732. private _collisionMask;
  8733. /**
  8734. * Get the mask that the camera ignores in collision events.
  8735. */
  8736. /**
  8737. * Set the mask that the camera ignores in collision events.
  8738. */
  8739. collisionMask: number;
  8740. /** @hidden */
  8741. _collideWithWorld(displacement: Vector3): void;
  8742. /** @hidden */
  8743. private _onCollisionPositionChange;
  8744. /** @hidden */
  8745. _checkInputs(): void;
  8746. /** @hidden */
  8747. _decideIfNeedsToMove(): boolean;
  8748. /** @hidden */
  8749. _updatePosition(): void;
  8750. /**
  8751. * Restore the Roll to its target value at the rate specified.
  8752. * @param rate - Higher means slower restoring.
  8753. * @hidden
  8754. */
  8755. restoreRoll(rate: number): void;
  8756. /**
  8757. * Destroy the camera and release the current resources held by it.
  8758. */
  8759. dispose(): void;
  8760. /**
  8761. * Get the current object class name.
  8762. * @returns the class name.
  8763. */
  8764. getClassName(): string;
  8765. }
  8766. }
  8767. declare module BABYLON {
  8768. /**
  8769. * Default Inputs manager for the FlyCamera.
  8770. * It groups all the default supported inputs for ease of use.
  8771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8772. */
  8773. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  8774. /**
  8775. * Instantiates a new FlyCameraInputsManager.
  8776. * @param camera Defines the camera the inputs belong to.
  8777. */
  8778. constructor(camera: FlyCamera);
  8779. /**
  8780. * Add keyboard input support to the input manager.
  8781. * @returns the new FlyCameraKeyboardMoveInput().
  8782. */
  8783. addKeyboard(): FlyCameraInputsManager;
  8784. /**
  8785. * Add mouse input support to the input manager.
  8786. * @param touchEnabled Enable touch screen support.
  8787. * @returns the new FlyCameraMouseInput().
  8788. */
  8789. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  8790. }
  8791. }
  8792. declare module BABYLON {
  8793. /**
  8794. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  8795. * an arc rotate version arcFollowCamera are available.
  8796. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8797. */
  8798. class FollowCamera extends TargetCamera {
  8799. /**
  8800. * Distance the follow camera should follow an object at
  8801. */
  8802. radius: number;
  8803. /**
  8804. * Define a rotation offset between the camera and the object it follows
  8805. */
  8806. rotationOffset: number;
  8807. /**
  8808. * Define a height offset between the camera and the object it follows.
  8809. * It can help following an object from the top (like a car chaing a plane)
  8810. */
  8811. heightOffset: number;
  8812. /**
  8813. * Define how fast the camera can accelerate to follow it s target.
  8814. */
  8815. cameraAcceleration: number;
  8816. /**
  8817. * Define the speed limit of the camera following an object.
  8818. */
  8819. maxCameraSpeed: number;
  8820. /**
  8821. * Define the target of the camera.
  8822. */
  8823. lockedTarget: Nullable<AbstractMesh>;
  8824. /**
  8825. * Instantiates the follow camera.
  8826. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8827. * @param name Define the name of the camera in the scene
  8828. * @param position Define the position of the camera
  8829. * @param scene Define the scene the camera belong to
  8830. * @param lockedTarget Define the target of the camera
  8831. */
  8832. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8833. private _follow;
  8834. /** @hidden */
  8835. _checkInputs(): void;
  8836. /**
  8837. * Gets the camera class name.
  8838. * @returns the class name
  8839. */
  8840. getClassName(): string;
  8841. }
  8842. /**
  8843. * Arc Rotate version of the follow camera.
  8844. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8845. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8846. */
  8847. class ArcFollowCamera extends TargetCamera {
  8848. /** The longitudinal angle of the camera */
  8849. alpha: number;
  8850. /** The latitudinal angle of the camera */
  8851. beta: number;
  8852. /** The radius of the camera from its target */
  8853. radius: number;
  8854. /** Define the camera target (the messh it should follow) */
  8855. target: Nullable<AbstractMesh>;
  8856. private _cartesianCoordinates;
  8857. /**
  8858. * Instantiates a new ArcFollowCamera
  8859. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8860. * @param name Define the name of the camera
  8861. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8862. * @param beta Define the rotation angle of the camera around the elevation axis
  8863. * @param radius Define the radius of the camera from its target point
  8864. * @param target Define the target of the camera
  8865. * @param scene Define the scene the camera belongs to
  8866. */
  8867. constructor(name: string,
  8868. /** The longitudinal angle of the camera */
  8869. alpha: number,
  8870. /** The latitudinal angle of the camera */
  8871. beta: number,
  8872. /** The radius of the camera from its target */
  8873. radius: number,
  8874. /** Define the camera target (the messh it should follow) */
  8875. target: Nullable<AbstractMesh>, scene: Scene);
  8876. private _follow;
  8877. /** @hidden */
  8878. _checkInputs(): void;
  8879. /**
  8880. * Returns the class name of the object.
  8881. * It is mostly used internally for serialization purposes.
  8882. */
  8883. getClassName(): string;
  8884. }
  8885. }
  8886. declare module BABYLON {
  8887. /**
  8888. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8889. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8890. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8891. */
  8892. class FreeCamera extends TargetCamera {
  8893. /**
  8894. * Define the collision ellipsoid of the camera.
  8895. * This is helpful to simulate a camera body like the player body around the camera
  8896. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8897. */
  8898. ellipsoid: Vector3;
  8899. /**
  8900. * Define an offset for the position of the ellipsoid around the camera.
  8901. * This can be helpful to determine the center of the body near the gravity center of the body
  8902. * instead of its head.
  8903. */
  8904. ellipsoidOffset: Vector3;
  8905. /**
  8906. * Enable or disable collisions of the camera with the rest of the scene objects.
  8907. */
  8908. checkCollisions: boolean;
  8909. /**
  8910. * Enable or disable gravity on the camera.
  8911. */
  8912. applyGravity: boolean;
  8913. /**
  8914. * Define the input manager associated to the camera.
  8915. */
  8916. inputs: FreeCameraInputsManager;
  8917. /**
  8918. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8919. * Higher values reduce sensitivity.
  8920. */
  8921. /**
  8922. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8923. * Higher values reduce sensitivity.
  8924. */
  8925. angularSensibility: number;
  8926. /**
  8927. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8928. */
  8929. keysUp: number[];
  8930. /**
  8931. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8932. */
  8933. keysDown: number[];
  8934. /**
  8935. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8936. */
  8937. keysLeft: number[];
  8938. /**
  8939. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8940. */
  8941. keysRight: number[];
  8942. /**
  8943. * Event raised when the camera collide with a mesh in the scene.
  8944. */
  8945. onCollide: (collidedMesh: AbstractMesh) => void;
  8946. private _collider;
  8947. private _needMoveForGravity;
  8948. private _oldPosition;
  8949. private _diffPosition;
  8950. private _newPosition;
  8951. /** @hidden */
  8952. _localDirection: Vector3;
  8953. /** @hidden */
  8954. _transformedDirection: Vector3;
  8955. /**
  8956. * Instantiates a Free Camera.
  8957. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8958. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8959. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8960. * @param name Define the name of the camera in the scene
  8961. * @param position Define the start position of the camera in the scene
  8962. * @param scene Define the scene the camera belongs to
  8963. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8964. */
  8965. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8966. /**
  8967. * Attached controls to the current camera.
  8968. * @param element Defines the element the controls should be listened from
  8969. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8970. */
  8971. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8972. /**
  8973. * Detach the current controls from the camera.
  8974. * The camera will stop reacting to inputs.
  8975. * @param element Defines the element to stop listening the inputs from
  8976. */
  8977. detachControl(element: HTMLElement): void;
  8978. private _collisionMask;
  8979. /**
  8980. * Define a collision mask to limit the list of object the camera can collide with
  8981. */
  8982. collisionMask: number;
  8983. /** @hidden */
  8984. _collideWithWorld(displacement: Vector3): void;
  8985. private _onCollisionPositionChange;
  8986. /** @hidden */
  8987. _checkInputs(): void;
  8988. /** @hidden */
  8989. _decideIfNeedsToMove(): boolean;
  8990. /** @hidden */
  8991. _updatePosition(): void;
  8992. /**
  8993. * Destroy the camera and release the current resources hold by it.
  8994. */
  8995. dispose(): void;
  8996. /**
  8997. * Gets the current object class name.
  8998. * @return the class name
  8999. */
  9000. getClassName(): string;
  9001. }
  9002. }
  9003. declare module BABYLON {
  9004. /**
  9005. * Default Inputs manager for the FreeCamera.
  9006. * It groups all the default supported inputs for ease of use.
  9007. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9008. */
  9009. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  9010. /**
  9011. * Instantiates a new FreeCameraInputsManager.
  9012. * @param camera Defines the camera the inputs belong to
  9013. */
  9014. constructor(camera: FreeCamera);
  9015. /**
  9016. * Add keyboard input support to the input manager.
  9017. * @returns the current input manager
  9018. */
  9019. addKeyboard(): FreeCameraInputsManager;
  9020. /**
  9021. * Add mouse input support to the input manager.
  9022. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  9023. * @returns the current input manager
  9024. */
  9025. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  9026. /**
  9027. * Add orientation input support to the input manager.
  9028. * @returns the current input manager
  9029. */
  9030. addDeviceOrientation(): FreeCameraInputsManager;
  9031. /**
  9032. * Add touch input support to the input manager.
  9033. * @returns the current input manager
  9034. */
  9035. addTouch(): FreeCameraInputsManager;
  9036. /**
  9037. * Add virtual joystick input support to the input manager.
  9038. * @returns the current input manager
  9039. */
  9040. addVirtualJoystick(): FreeCameraInputsManager;
  9041. }
  9042. }
  9043. declare module BABYLON {
  9044. /**
  9045. * This represents a FPS type of camera. This is only here for back compat purpose.
  9046. * Please use the UniversalCamera instead as both are identical.
  9047. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9048. */
  9049. class GamepadCamera extends UniversalCamera {
  9050. /**
  9051. * Instantiates a new Gamepad Camera
  9052. * This represents a FPS type of camera. This is only here for back compat purpose.
  9053. * Please use the UniversalCamera instead as both are identical.
  9054. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9055. * @param name Define the name of the camera in the scene
  9056. * @param position Define the start position of the camera in the scene
  9057. * @param scene Define the scene the camera belongs to
  9058. */
  9059. constructor(name: string, position: Vector3, scene: Scene);
  9060. /**
  9061. * Gets the current object class name.
  9062. * @return the class name
  9063. */
  9064. getClassName(): string;
  9065. }
  9066. }
  9067. declare module BABYLON {
  9068. /**
  9069. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9070. * This is the base of the follow, arc rotate cameras and Free camera
  9071. * @see http://doc.babylonjs.com/features/cameras
  9072. */
  9073. class TargetCamera extends Camera {
  9074. /**
  9075. * Define the current direction the camera is moving to
  9076. */
  9077. cameraDirection: Vector3;
  9078. /**
  9079. * Define the current rotation the camera is rotating to
  9080. */
  9081. cameraRotation: Vector2;
  9082. /**
  9083. * Define the current rotation of the camera
  9084. */
  9085. rotation: Vector3;
  9086. /**
  9087. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9088. */
  9089. rotationQuaternion: Quaternion;
  9090. /**
  9091. * Define the current speed of the camera
  9092. */
  9093. speed: number;
  9094. /**
  9095. * Add cconstraint to the camera to prevent it to move freely in all directions and
  9096. * around all axis.
  9097. */
  9098. noRotationConstraint: boolean;
  9099. /**
  9100. * Define the current target of the camera as an object or a position.
  9101. */
  9102. lockedTarget: any;
  9103. /** @hidden */
  9104. _currentTarget: Vector3;
  9105. /** @hidden */
  9106. _viewMatrix: Matrix;
  9107. /** @hidden */
  9108. _camMatrix: Matrix;
  9109. /** @hidden */
  9110. _cameraTransformMatrix: Matrix;
  9111. /** @hidden */
  9112. _cameraRotationMatrix: Matrix;
  9113. private _rigCamTransformMatrix;
  9114. /** @hidden */
  9115. _referencePoint: Vector3;
  9116. /** @hidden */
  9117. _transformedReferencePoint: Vector3;
  9118. protected _globalCurrentTarget: Vector3;
  9119. protected _globalCurrentUpVector: Vector3;
  9120. /** @hidden */
  9121. _reset: () => void;
  9122. private _defaultUp;
  9123. /**
  9124. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  9125. * This is the base of the follow, arc rotate cameras and Free camera
  9126. * @see http://doc.babylonjs.com/features/cameras
  9127. * @param name Defines the name of the camera in the scene
  9128. * @param position Defines the start position of the camera in the scene
  9129. * @param scene Defines the scene the camera belongs to
  9130. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9131. */
  9132. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9133. /**
  9134. * Gets the position in front of the camera at a given distance.
  9135. * @param distance The distance from the camera we want the position to be
  9136. * @returns the position
  9137. */
  9138. getFrontPosition(distance: number): Vector3;
  9139. /** @hidden */
  9140. _getLockedTargetPosition(): Nullable<Vector3>;
  9141. private _storedPosition;
  9142. private _storedRotation;
  9143. private _storedRotationQuaternion;
  9144. /**
  9145. * Store current camera state of the camera (fov, position, rotation, etc..)
  9146. * @returns the camera
  9147. */
  9148. storeState(): Camera;
  9149. /**
  9150. * Restored camera state. You must call storeState() first
  9151. * @returns whether it was successful or not
  9152. * @hidden
  9153. */
  9154. _restoreStateValues(): boolean;
  9155. /** @hidden */
  9156. _initCache(): void;
  9157. /** @hidden */
  9158. _updateCache(ignoreParentClass?: boolean): void;
  9159. /** @hidden */
  9160. _isSynchronizedViewMatrix(): boolean;
  9161. /** @hidden */
  9162. _computeLocalCameraSpeed(): number;
  9163. /** @hidden */
  9164. setTarget(target: Vector3): void;
  9165. /**
  9166. * Return the current target position of the camera. This value is expressed in local space.
  9167. * @returns the target position
  9168. */
  9169. getTarget(): Vector3;
  9170. /** @hidden */
  9171. _decideIfNeedsToMove(): boolean;
  9172. /** @hidden */
  9173. _updatePosition(): void;
  9174. /** @hidden */
  9175. _checkInputs(): void;
  9176. protected _updateCameraRotationMatrix(): void;
  9177. /**
  9178. * 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)
  9179. * @returns the current camera
  9180. */
  9181. private _rotateUpVectorWithCameraRotationMatrix;
  9182. private _cachedRotationZ;
  9183. private _cachedQuaternionRotationZ;
  9184. /** @hidden */
  9185. _getViewMatrix(): Matrix;
  9186. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9187. /**
  9188. * @hidden
  9189. */
  9190. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9191. /**
  9192. * @hidden
  9193. */
  9194. _updateRigCameras(): void;
  9195. private _getRigCamPosition;
  9196. /**
  9197. * Gets the current object class name.
  9198. * @return the class name
  9199. */
  9200. getClassName(): string;
  9201. }
  9202. }
  9203. declare module BABYLON {
  9204. /**
  9205. * This represents a FPS type of camera controlled by touch.
  9206. * This is like a universal camera minus the Gamepad controls.
  9207. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9208. */
  9209. class TouchCamera extends FreeCamera {
  9210. /**
  9211. * Defines the touch sensibility for rotation.
  9212. * The higher the faster.
  9213. */
  9214. touchAngularSensibility: number;
  9215. /**
  9216. * Defines the touch sensibility for move.
  9217. * The higher the faster.
  9218. */
  9219. touchMoveSensibility: number;
  9220. /**
  9221. * Instantiates a new touch camera.
  9222. * This represents a FPS type of camera controlled by touch.
  9223. * This is like a universal camera minus the Gamepad controls.
  9224. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9225. * @param name Define the name of the camera in the scene
  9226. * @param position Define the start position of the camera in the scene
  9227. * @param scene Define the scene the camera belongs to
  9228. */
  9229. constructor(name: string, position: Vector3, scene: Scene);
  9230. /**
  9231. * Gets the current object class name.
  9232. * @return the class name
  9233. */
  9234. getClassName(): string;
  9235. /** @hidden */
  9236. _setupInputs(): void;
  9237. }
  9238. }
  9239. declare module BABYLON {
  9240. /**
  9241. * 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,
  9242. * which still works and will still be found in many Playgrounds.
  9243. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9244. */
  9245. class UniversalCamera extends TouchCamera {
  9246. /**
  9247. * Defines the gamepad rotation sensiblity.
  9248. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  9249. */
  9250. gamepadAngularSensibility: number;
  9251. /**
  9252. * Defines the gamepad move sensiblity.
  9253. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  9254. */
  9255. gamepadMoveSensibility: number;
  9256. /**
  9257. * 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,
  9258. * which still works and will still be found in many Playgrounds.
  9259. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9260. * @param name Define the name of the camera in the scene
  9261. * @param position Define the start position of the camera in the scene
  9262. * @param scene Define the scene the camera belongs to
  9263. */
  9264. constructor(name: string, position: Vector3, scene: Scene);
  9265. /**
  9266. * Gets the current object class name.
  9267. * @return the class name
  9268. */
  9269. getClassName(): string;
  9270. }
  9271. }
  9272. declare module BABYLON {
  9273. /**
  9274. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  9275. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9276. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9277. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9278. */
  9279. class VirtualJoysticksCamera extends FreeCamera {
  9280. /**
  9281. * Intantiates a VirtualJoysticksCamera. It can be usefull in First Person Shooter game for instance.
  9282. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9283. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9284. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9285. * @param name Define the name of the camera in the scene
  9286. * @param position Define the start position of the camera in the scene
  9287. * @param scene Define the scene the camera belongs to
  9288. */
  9289. constructor(name: string, position: Vector3, scene: Scene);
  9290. /**
  9291. * Gets the current object class name.
  9292. * @return the class name
  9293. */
  9294. getClassName(): string;
  9295. }
  9296. }
  9297. interface VRDisplay extends EventTarget {
  9298. /**
  9299. * Dictionary of capabilities describing the VRDisplay.
  9300. */
  9301. readonly capabilities: VRDisplayCapabilities;
  9302. /**
  9303. * z-depth defining the far plane of the eye view frustum
  9304. * enables mapping of values in the render target depth
  9305. * attachment to scene coordinates. Initially set to 10000.0.
  9306. */
  9307. depthFar: number;
  9308. /**
  9309. * z-depth defining the near plane of the eye view frustum
  9310. * enables mapping of values in the render target depth
  9311. * attachment to scene coordinates. Initially set to 0.01.
  9312. */
  9313. depthNear: number;
  9314. /**
  9315. * An identifier for this distinct VRDisplay. Used as an
  9316. * association point in the Gamepad API.
  9317. */
  9318. readonly displayId: number;
  9319. /**
  9320. * A display name, a user-readable name identifying it.
  9321. */
  9322. readonly displayName: string;
  9323. readonly isConnected: boolean;
  9324. readonly isPresenting: boolean;
  9325. /**
  9326. * If this VRDisplay supports room-scale experiences, the optional
  9327. * stage attribute contains details on the room-scale parameters.
  9328. */
  9329. readonly stageParameters: VRStageParameters | null;
  9330. /**
  9331. * Passing the value returned by `requestAnimationFrame` to
  9332. * `cancelAnimationFrame` will unregister the callback.
  9333. * @param handle Define the hanle of the request to cancel
  9334. */
  9335. cancelAnimationFrame(handle: number): void;
  9336. /**
  9337. * Stops presenting to the VRDisplay.
  9338. * @returns a promise to know when it stopped
  9339. */
  9340. exitPresent(): Promise<void>;
  9341. /**
  9342. * Return the current VREyeParameters for the given eye.
  9343. * @param whichEye Define the eye we want the parameter for
  9344. * @returns the eye parameters
  9345. */
  9346. getEyeParameters(whichEye: string): VREyeParameters;
  9347. /**
  9348. * Populates the passed VRFrameData with the information required to render
  9349. * the current frame.
  9350. * @param frameData Define the data structure to populate
  9351. * @returns true if ok otherwise false
  9352. */
  9353. getFrameData(frameData: VRFrameData): boolean;
  9354. /**
  9355. * Get the layers currently being presented.
  9356. * @returns the list of VR layers
  9357. */
  9358. getLayers(): VRLayer[];
  9359. /**
  9360. * Return a VRPose containing the future predicted pose of the VRDisplay
  9361. * when the current frame will be presented. The value returned will not
  9362. * change until JavaScript has returned control to the browser.
  9363. *
  9364. * The VRPose will contain the position, orientation, velocity,
  9365. * and acceleration of each of these properties.
  9366. * @returns the pose object
  9367. */
  9368. getPose(): VRPose;
  9369. /**
  9370. * Return the current instantaneous pose of the VRDisplay, with no
  9371. * prediction applied.
  9372. * @returns the current instantaneous pose
  9373. */
  9374. getImmediatePose(): VRPose;
  9375. /**
  9376. * The callback passed to `requestAnimationFrame` will be called
  9377. * any time a new frame should be rendered. When the VRDisplay is
  9378. * presenting the callback will be called at the native refresh
  9379. * rate of the HMD. When not presenting this function acts
  9380. * identically to how window.requestAnimationFrame acts. Content should
  9381. * make no assumptions of frame rate or vsync behavior as the HMD runs
  9382. * asynchronously from other displays and at differing refresh rates.
  9383. * @param callback Define the eaction to run next frame
  9384. * @returns the request handle it
  9385. */
  9386. requestAnimationFrame(callback: FrameRequestCallback): number;
  9387. /**
  9388. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  9389. * Repeat calls while already presenting will update the VRLayers being displayed.
  9390. * @param layers Define the list of layer to present
  9391. * @returns a promise to know when the request has been fulfilled
  9392. */
  9393. requestPresent(layers: VRLayer[]): Promise<void>;
  9394. /**
  9395. * Reset the pose for this display, treating its current position and
  9396. * orientation as the "origin/zero" values. VRPose.position,
  9397. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  9398. * updated when calling resetPose(). This should be called in only
  9399. * sitting-space experiences.
  9400. */
  9401. resetPose(): void;
  9402. /**
  9403. * The VRLayer provided to the VRDisplay will be captured and presented
  9404. * in the HMD. Calling this function has the same effect on the source
  9405. * canvas as any other operation that uses its source image, and canvases
  9406. * created without preserveDrawingBuffer set to true will be cleared.
  9407. * @param pose Define the pose to submit
  9408. */
  9409. submitFrame(pose?: VRPose): void;
  9410. }
  9411. declare var VRDisplay: {
  9412. prototype: VRDisplay;
  9413. new (): VRDisplay;
  9414. };
  9415. interface VRLayer {
  9416. leftBounds?: number[] | Float32Array | null;
  9417. rightBounds?: number[] | Float32Array | null;
  9418. source?: HTMLCanvasElement | null;
  9419. }
  9420. interface VRDisplayCapabilities {
  9421. readonly canPresent: boolean;
  9422. readonly hasExternalDisplay: boolean;
  9423. readonly hasOrientation: boolean;
  9424. readonly hasPosition: boolean;
  9425. readonly maxLayers: number;
  9426. }
  9427. interface VREyeParameters {
  9428. /** @deprecated */
  9429. readonly fieldOfView: VRFieldOfView;
  9430. readonly offset: Float32Array;
  9431. readonly renderHeight: number;
  9432. readonly renderWidth: number;
  9433. }
  9434. interface VRFieldOfView {
  9435. readonly downDegrees: number;
  9436. readonly leftDegrees: number;
  9437. readonly rightDegrees: number;
  9438. readonly upDegrees: number;
  9439. }
  9440. interface VRFrameData {
  9441. readonly leftProjectionMatrix: Float32Array;
  9442. readonly leftViewMatrix: Float32Array;
  9443. readonly pose: VRPose;
  9444. readonly rightProjectionMatrix: Float32Array;
  9445. readonly rightViewMatrix: Float32Array;
  9446. readonly timestamp: number;
  9447. }
  9448. interface VRPose {
  9449. readonly angularAcceleration: Float32Array | null;
  9450. readonly angularVelocity: Float32Array | null;
  9451. readonly linearAcceleration: Float32Array | null;
  9452. readonly linearVelocity: Float32Array | null;
  9453. readonly orientation: Float32Array | null;
  9454. readonly position: Float32Array | null;
  9455. readonly timestamp: number;
  9456. }
  9457. interface VRStageParameters {
  9458. sittingToStandingTransform?: Float32Array;
  9459. sizeX?: number;
  9460. sizeY?: number;
  9461. }
  9462. interface Navigator {
  9463. getVRDisplays(): Promise<VRDisplay[]>;
  9464. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  9465. }
  9466. interface Window {
  9467. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  9468. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  9469. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  9470. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9471. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9472. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  9473. }
  9474. interface Gamepad {
  9475. readonly displayId: number;
  9476. }
  9477. /**
  9478. * Module Debug contains the (visual) components to debug a scene correctly
  9479. */
  9480. declare module BABYLON.Debug {
  9481. /**
  9482. * The Axes viewer will show 3 axes in a specific point in space
  9483. */
  9484. class AxesViewer {
  9485. private _xline;
  9486. private _yline;
  9487. private _zline;
  9488. private _xmesh;
  9489. private _ymesh;
  9490. private _zmesh;
  9491. /**
  9492. * Gets the hosting scene
  9493. */
  9494. scene: Nullable<Scene>;
  9495. /**
  9496. * Gets or sets a number used to scale line length
  9497. */
  9498. scaleLines: number;
  9499. /**
  9500. * Creates a new AxesViewer
  9501. * @param scene defines the hosting scene
  9502. * @param scaleLines defines a number used to scale line length (1 by default)
  9503. */
  9504. constructor(scene: Scene, scaleLines?: number);
  9505. /**
  9506. * Force the viewer to update
  9507. * @param position defines the position of the viewer
  9508. * @param xaxis defines the x axis of the viewer
  9509. * @param yaxis defines the y axis of the viewer
  9510. * @param zaxis defines the z axis of the viewer
  9511. */
  9512. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9513. /** Releases resources */
  9514. dispose(): void;
  9515. }
  9516. }
  9517. declare module BABYLON.Debug {
  9518. /**
  9519. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9520. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9521. */
  9522. class BoneAxesViewer extends AxesViewer {
  9523. /**
  9524. * Gets or sets the target mesh where to display the axes viewer
  9525. */
  9526. mesh: Nullable<Mesh>;
  9527. /**
  9528. * Gets or sets the target bone where to display the axes viewer
  9529. */
  9530. bone: Nullable<Bone>;
  9531. /** Gets current position */
  9532. pos: Vector3;
  9533. /** Gets direction of X axis */
  9534. xaxis: Vector3;
  9535. /** Gets direction of Y axis */
  9536. yaxis: Vector3;
  9537. /** Gets direction of Z axis */
  9538. zaxis: Vector3;
  9539. /**
  9540. * Creates a new BoneAxesViewer
  9541. * @param scene defines the hosting scene
  9542. * @param bone defines the target bone
  9543. * @param mesh defines the target mesh
  9544. * @param scaleLines defines a scaling factor for line length (1 by default)
  9545. */
  9546. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9547. /**
  9548. * Force the viewer to update
  9549. */
  9550. update(): void;
  9551. /** Releases resources */
  9552. dispose(): void;
  9553. }
  9554. }
  9555. declare module BABYLON {
  9556. interface Scene {
  9557. /**
  9558. * @hidden
  9559. * Backing field
  9560. */
  9561. _debugLayer: DebugLayer;
  9562. /**
  9563. * Gets the debug layer (aka Inspector) associated with the scene
  9564. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9565. */
  9566. debugLayer: DebugLayer;
  9567. }
  9568. /**
  9569. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9570. * what is happening in your scene
  9571. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9572. */
  9573. class DebugLayer {
  9574. /**
  9575. * Define the url to get the inspector script from.
  9576. * By default it uses the babylonjs CDN.
  9577. * @ignoreNaming
  9578. */
  9579. static InspectorURL: string;
  9580. private _scene;
  9581. private _inspector;
  9582. private BJSINSPECTOR;
  9583. /**
  9584. * Observable triggered when a property is changed through the inspector.
  9585. */
  9586. onPropertyChangedObservable: Observable<{
  9587. object: any;
  9588. property: string;
  9589. value: any;
  9590. initialValue: any;
  9591. }>;
  9592. /**
  9593. * Instantiates a new debug layer.
  9594. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9595. * what is happening in your scene
  9596. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9597. * @param scene Defines the scene to inspect
  9598. */
  9599. constructor(scene: Scene);
  9600. /** Creates the inspector window. */
  9601. private _createInspector;
  9602. /**
  9603. * Get if the inspector is visible or not.
  9604. * @returns true if visible otherwise, false
  9605. */
  9606. isVisible(): boolean;
  9607. /**
  9608. * Hide the inspector and close its window.
  9609. */
  9610. hide(): void;
  9611. /**
  9612. *
  9613. * Launch the debugLayer.
  9614. *
  9615. * initialTab:
  9616. * | Value | Tab Name |
  9617. * | --- | --- |
  9618. * | 0 | Scene |
  9619. * | 1 | Console |
  9620. * | 2 | Stats |
  9621. * | 3 | Textures |
  9622. * | 4 | Mesh |
  9623. * | 5 | Light |
  9624. * | 6 | Material |
  9625. * | 7 | GLTF |
  9626. * | 8 | GUI |
  9627. * | 9 | Physics |
  9628. * | 10 | Camera |
  9629. * | 11 | Audio |
  9630. *
  9631. * @param config Define the configuration of the inspector
  9632. */
  9633. show(config?: {
  9634. popup?: boolean;
  9635. initialTab?: number | string;
  9636. parentElement?: HTMLElement;
  9637. newColors?: {
  9638. backgroundColor?: string;
  9639. backgroundColorLighter?: string;
  9640. backgroundColorLighter2?: string;
  9641. backgroundColorLighter3?: string;
  9642. color?: string;
  9643. colorTop?: string;
  9644. colorBot?: string;
  9645. };
  9646. }): void;
  9647. /**
  9648. * Gets the active tab
  9649. * @return the index of the active tab or -1 if the inspector is hidden
  9650. */
  9651. getActiveTab(): number;
  9652. }
  9653. }
  9654. declare module BABYLON.Debug {
  9655. /**
  9656. * Used to show the physics impostor around the specific mesh
  9657. */
  9658. class PhysicsViewer {
  9659. /** @hidden */
  9660. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9661. /** @hidden */
  9662. protected _meshes: Array<Nullable<AbstractMesh>>;
  9663. /** @hidden */
  9664. protected _scene: Nullable<Scene>;
  9665. /** @hidden */
  9666. protected _numMeshes: number;
  9667. /** @hidden */
  9668. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9669. private _renderFunction;
  9670. private _debugBoxMesh;
  9671. private _debugSphereMesh;
  9672. private _debugMaterial;
  9673. /**
  9674. * Creates a new PhysicsViewer
  9675. * @param scene defines the hosting scene
  9676. */
  9677. constructor(scene: Scene);
  9678. /** @hidden */
  9679. protected _updateDebugMeshes(): void;
  9680. /**
  9681. * Renders a specified physic impostor
  9682. * @param impostor defines the impostor to render
  9683. */
  9684. showImpostor(impostor: PhysicsImpostor): void;
  9685. /**
  9686. * Hides a specified physic impostor
  9687. * @param impostor defines the impostor to hide
  9688. */
  9689. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9690. private _getDebugMaterial;
  9691. private _getDebugBoxMesh;
  9692. private _getDebugSphereMesh;
  9693. private _getDebugMesh;
  9694. /** Releases all resources */
  9695. dispose(): void;
  9696. }
  9697. }
  9698. declare module BABYLON {
  9699. /**
  9700. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9701. * in order to better appreciate the issue one might have.
  9702. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9703. */
  9704. class RayHelper {
  9705. /**
  9706. * Defines the ray we are currently tryin to visualize.
  9707. */
  9708. ray: Nullable<Ray>;
  9709. private _renderPoints;
  9710. private _renderLine;
  9711. private _renderFunction;
  9712. private _scene;
  9713. private _updateToMeshFunction;
  9714. private _attachedToMesh;
  9715. private _meshSpaceDirection;
  9716. private _meshSpaceOrigin;
  9717. /**
  9718. * Helper function to create a colored helper in a scene in one line.
  9719. * @param ray Defines the ray we are currently tryin to visualize
  9720. * @param scene Defines the scene the ray is used in
  9721. * @param color Defines the color we want to see the ray in
  9722. * @returns The newly created ray helper.
  9723. */
  9724. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9725. /**
  9726. * Instantiate a new ray helper.
  9727. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9728. * in order to better appreciate the issue one might have.
  9729. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9730. * @param ray Defines the ray we are currently tryin to visualize
  9731. */
  9732. constructor(ray: Ray);
  9733. /**
  9734. * Shows the ray we are willing to debug.
  9735. * @param scene Defines the scene the ray needs to be rendered in
  9736. * @param color Defines the color the ray needs to be rendered in
  9737. */
  9738. show(scene: Scene, color?: Color3): void;
  9739. /**
  9740. * Hides the ray we are debugging.
  9741. */
  9742. hide(): void;
  9743. private _render;
  9744. /**
  9745. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  9746. * @param mesh Defines the mesh we want the helper attached to
  9747. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  9748. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  9749. * @param length Defines the length of the ray
  9750. */
  9751. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9752. /**
  9753. * Detach the ray helper from the mesh it has previously been attached to.
  9754. */
  9755. detachFromMesh(): void;
  9756. private _updateToMesh;
  9757. /**
  9758. * Dispose the helper and release its associated resources.
  9759. */
  9760. dispose(): void;
  9761. }
  9762. }
  9763. declare module BABYLON.Debug {
  9764. /**
  9765. * Class used to render a debug view of a given skeleton
  9766. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9767. */
  9768. class SkeletonViewer {
  9769. /** defines the skeleton to render */
  9770. skeleton: Skeleton;
  9771. /** defines the mesh attached to the skeleton */
  9772. mesh: AbstractMesh;
  9773. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9774. autoUpdateBonesMatrices: boolean;
  9775. /** defines the rendering group id to use with the viewer */
  9776. renderingGroupId: number;
  9777. /** Gets or sets the color used to render the skeleton */
  9778. color: Color3;
  9779. private _scene;
  9780. private _debugLines;
  9781. private _debugMesh;
  9782. private _isEnabled;
  9783. private _renderFunction;
  9784. /**
  9785. * Creates a new SkeletonViewer
  9786. * @param skeleton defines the skeleton to render
  9787. * @param mesh defines the mesh attached to the skeleton
  9788. * @param scene defines the hosting scene
  9789. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9790. * @param renderingGroupId defines the rendering group id to use with the viewer
  9791. */
  9792. constructor(
  9793. /** defines the skeleton to render */
  9794. skeleton: Skeleton,
  9795. /** defines the mesh attached to the skeleton */
  9796. mesh: AbstractMesh, scene: Scene,
  9797. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9798. autoUpdateBonesMatrices?: boolean,
  9799. /** defines the rendering group id to use with the viewer */
  9800. renderingGroupId?: number);
  9801. /** Gets or sets a boolean indicating if the viewer is enabled */
  9802. isEnabled: boolean;
  9803. private _getBonePosition;
  9804. private _getLinesForBonesWithLength;
  9805. private _getLinesForBonesNoLength;
  9806. /** Update the viewer to sync with current skeleton state */
  9807. update(): void;
  9808. /** Release associated resources */
  9809. dispose(): void;
  9810. }
  9811. }
  9812. declare module BABYLON {
  9813. /**
  9814. * Interface for attribute information associated with buffer instanciation
  9815. */
  9816. class InstancingAttributeInfo {
  9817. /**
  9818. * Index/offset of the attribute in the vertex shader
  9819. */
  9820. index: number;
  9821. /**
  9822. * size of the attribute, 1, 2, 3 or 4
  9823. */
  9824. attributeSize: number;
  9825. /**
  9826. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9827. * default is FLOAT
  9828. */
  9829. attribyteType: number;
  9830. /**
  9831. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9832. */
  9833. normalized: boolean;
  9834. /**
  9835. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9836. */
  9837. offset: number;
  9838. /**
  9839. * Name of the GLSL attribute, for debugging purpose only
  9840. */
  9841. attributeName: string;
  9842. }
  9843. /**
  9844. * Define options used to create a render target texture
  9845. */
  9846. class RenderTargetCreationOptions {
  9847. /**
  9848. * Specifies is mipmaps must be generated
  9849. */
  9850. generateMipMaps?: boolean;
  9851. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9852. generateDepthBuffer?: boolean;
  9853. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9854. generateStencilBuffer?: boolean;
  9855. /** Defines texture type (int by default) */
  9856. type?: number;
  9857. /** Defines sampling mode (trilinear by default) */
  9858. samplingMode?: number;
  9859. /** Defines format (RGBA by default) */
  9860. format?: number;
  9861. }
  9862. /**
  9863. * Define options used to create a depth texture
  9864. */
  9865. class DepthTextureCreationOptions {
  9866. /** Specifies whether or not a stencil should be allocated in the texture */
  9867. generateStencil?: boolean;
  9868. /** Specifies whether or not bilinear filtering is enable on the texture */
  9869. bilinearFiltering?: boolean;
  9870. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  9871. comparisonFunction?: number;
  9872. /** Specifies if the created texture is a cube texture */
  9873. isCube?: boolean;
  9874. }
  9875. /**
  9876. * Class used to describe the capabilities of the engine relatively to the current browser
  9877. */
  9878. class EngineCapabilities {
  9879. /** Maximum textures units per fragment shader */
  9880. maxTexturesImageUnits: number;
  9881. /** Maximum texture units per vertex shader */
  9882. maxVertexTextureImageUnits: number;
  9883. /** Maximum textures units in the entire pipeline */
  9884. maxCombinedTexturesImageUnits: number;
  9885. /** Maximum texture size */
  9886. maxTextureSize: number;
  9887. /** Maximum cube texture size */
  9888. maxCubemapTextureSize: number;
  9889. /** Maximum render texture size */
  9890. maxRenderTextureSize: number;
  9891. /** Maximum number of vertex attributes */
  9892. maxVertexAttribs: number;
  9893. /** Maximum number of varyings */
  9894. maxVaryingVectors: number;
  9895. /** Maximum number of uniforms per vertex shader */
  9896. maxVertexUniformVectors: number;
  9897. /** Maximum number of uniforms per fragment shader */
  9898. maxFragmentUniformVectors: number;
  9899. /** Defines if standard derivates (dx/dy) are supported */
  9900. standardDerivatives: boolean;
  9901. /** Defines if s3tc texture compression is supported */
  9902. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  9903. /** Defines if pvrtc texture compression is supported */
  9904. pvrtc: any;
  9905. /** Defines if etc1 texture compression is supported */
  9906. etc1: any;
  9907. /** Defines if etc2 texture compression is supported */
  9908. etc2: any;
  9909. /** Defines if astc texture compression is supported */
  9910. astc: any;
  9911. /** Defines if float textures are supported */
  9912. textureFloat: boolean;
  9913. /** Defines if vertex array objects are supported */
  9914. vertexArrayObject: boolean;
  9915. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  9916. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  9917. /** Gets the maximum level of anisotropy supported */
  9918. maxAnisotropy: number;
  9919. /** Defines if instancing is supported */
  9920. instancedArrays: boolean;
  9921. /** Defines if 32 bits indices are supported */
  9922. uintIndices: boolean;
  9923. /** Defines if high precision shaders are supported */
  9924. highPrecisionShaderSupported: boolean;
  9925. /** Defines if depth reading in the fragment shader is supported */
  9926. fragmentDepthSupported: boolean;
  9927. /** Defines if float texture linear filtering is supported*/
  9928. textureFloatLinearFiltering: boolean;
  9929. /** Defines if rendering to float textures is supported */
  9930. textureFloatRender: boolean;
  9931. /** Defines if half float textures are supported*/
  9932. textureHalfFloat: boolean;
  9933. /** Defines if half float texture linear filtering is supported*/
  9934. textureHalfFloatLinearFiltering: boolean;
  9935. /** Defines if rendering to half float textures is supported */
  9936. textureHalfFloatRender: boolean;
  9937. /** Defines if textureLOD shader command is supported */
  9938. textureLOD: boolean;
  9939. /** Defines if draw buffers extension is supported */
  9940. drawBuffersExtension: boolean;
  9941. /** Defines if depth textures are supported */
  9942. depthTextureExtension: boolean;
  9943. /** Defines if float color buffer are supported */
  9944. colorBufferFloat: boolean;
  9945. /** Gets disjoint timer query extension (null if not supported) */
  9946. timerQuery: EXT_disjoint_timer_query;
  9947. /** Defines if timestamp can be used with timer query */
  9948. canUseTimestampForTimerQuery: boolean;
  9949. /** Function used to let the system compiles shaders in background */
  9950. parallelShaderCompile: {
  9951. MAX_SHADER_COMPILER_THREADS_KHR: number;
  9952. maxShaderCompilerThreadsKHR: (thread: number) => void;
  9953. COMPLETION_STATUS_KHR: number;
  9954. };
  9955. }
  9956. /** Interface defining initialization parameters for Engine class */
  9957. interface EngineOptions extends WebGLContextAttributes {
  9958. /**
  9959. * Defines if the engine should no exceed a specified device ratio
  9960. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  9961. */
  9962. limitDeviceRatio?: number;
  9963. /**
  9964. * Defines if webvr should be enabled automatically
  9965. * @see http://doc.babylonjs.com/how_to/webvr_camera
  9966. */
  9967. autoEnableWebVR?: boolean;
  9968. /**
  9969. * Defines if webgl2 should be turned off even if supported
  9970. * @see http://doc.babylonjs.com/features/webgl2
  9971. */
  9972. disableWebGL2Support?: boolean;
  9973. /**
  9974. * Defines if webaudio should be initialized as well
  9975. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  9976. */
  9977. audioEngine?: boolean;
  9978. /**
  9979. * Defines if animations should run using a deterministic lock step
  9980. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9981. */
  9982. deterministicLockstep?: boolean;
  9983. /** Defines the maximum steps to use with deterministic lock step mode */
  9984. lockstepMaxSteps?: number;
  9985. /**
  9986. * Defines that engine should ignore context lost events
  9987. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  9988. */
  9989. doNotHandleContextLost?: boolean;
  9990. }
  9991. /**
  9992. * Defines the interface used by display changed events
  9993. */
  9994. interface IDisplayChangedEventArgs {
  9995. /** Gets the vrDisplay object (if any) */
  9996. vrDisplay: Nullable<any>;
  9997. /** Gets a boolean indicating if webVR is supported */
  9998. vrSupported: boolean;
  9999. }
  10000. /**
  10001. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  10002. */
  10003. class Engine {
  10004. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  10005. static ExceptionList: ({
  10006. key: string;
  10007. capture: string;
  10008. captureConstraint: number;
  10009. targets: string[];
  10010. } | {
  10011. key: string;
  10012. capture: null;
  10013. captureConstraint: null;
  10014. targets: string[];
  10015. })[];
  10016. /** Gets the list of created engines */
  10017. static Instances: Engine[];
  10018. /**
  10019. * Gets the latest created engine
  10020. */
  10021. static readonly LastCreatedEngine: Nullable<Engine>;
  10022. /**
  10023. * Gets the latest created scene
  10024. */
  10025. static readonly LastCreatedScene: Nullable<Scene>;
  10026. /**
  10027. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  10028. * @param flag defines which part of the materials must be marked as dirty
  10029. * @param predicate defines a predicate used to filter which materials should be affected
  10030. */
  10031. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  10032. /**
  10033. * Hidden
  10034. */
  10035. static _TextureLoaders: IInternalTextureLoader[];
  10036. /** Defines that alpha blending is disabled */
  10037. static readonly ALPHA_DISABLE: number;
  10038. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  10039. static readonly ALPHA_ADD: number;
  10040. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  10041. static readonly ALPHA_COMBINE: number;
  10042. /** Defines that alpha blending to DEST - SRC * DEST */
  10043. static readonly ALPHA_SUBTRACT: number;
  10044. /** Defines that alpha blending to SRC * DEST */
  10045. static readonly ALPHA_MULTIPLY: number;
  10046. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  10047. static readonly ALPHA_MAXIMIZED: number;
  10048. /** Defines that alpha blending to SRC + DEST */
  10049. static readonly ALPHA_ONEONE: number;
  10050. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  10051. static readonly ALPHA_PREMULTIPLIED: number;
  10052. /**
  10053. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  10054. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  10055. */
  10056. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  10057. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  10058. static readonly ALPHA_INTERPOLATE: number;
  10059. /**
  10060. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  10061. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  10062. */
  10063. static readonly ALPHA_SCREENMODE: number;
  10064. /** Defines that the ressource is not delayed*/
  10065. static readonly DELAYLOADSTATE_NONE: number;
  10066. /** Defines that the ressource was successfully delay loaded */
  10067. static readonly DELAYLOADSTATE_LOADED: number;
  10068. /** Defines that the ressource is currently delay loading */
  10069. static readonly DELAYLOADSTATE_LOADING: number;
  10070. /** Defines that the ressource is delayed and has not started loading */
  10071. static readonly DELAYLOADSTATE_NOTLOADED: number;
  10072. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  10073. static readonly NEVER: number;
  10074. /** 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 */
  10075. static readonly ALWAYS: number;
  10076. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  10077. static readonly LESS: number;
  10078. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  10079. static readonly EQUAL: number;
  10080. /** 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 */
  10081. static readonly LEQUAL: number;
  10082. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  10083. static readonly GREATER: number;
  10084. /** 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 */
  10085. static readonly GEQUAL: number;
  10086. /** 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 */
  10087. static readonly NOTEQUAL: number;
  10088. /** Passed to stencilOperation to specify that stencil value must be kept */
  10089. static readonly KEEP: number;
  10090. /** Passed to stencilOperation to specify that stencil value must be replaced */
  10091. static readonly REPLACE: number;
  10092. /** Passed to stencilOperation to specify that stencil value must be incremented */
  10093. static readonly INCR: number;
  10094. /** Passed to stencilOperation to specify that stencil value must be decremented */
  10095. static readonly DECR: number;
  10096. /** Passed to stencilOperation to specify that stencil value must be inverted */
  10097. static readonly INVERT: number;
  10098. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10099. static readonly INCR_WRAP: number;
  10100. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10101. static readonly DECR_WRAP: number;
  10102. /** Texture is not repeating outside of 0..1 UVs */
  10103. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10104. /** Texture is repeating outside of 0..1 UVs */
  10105. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10106. /** Texture is repeating and mirrored */
  10107. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10108. /** ALPHA */
  10109. static readonly TEXTUREFORMAT_ALPHA: number;
  10110. /** LUMINANCE */
  10111. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10112. /** LUMINANCE_ALPHA */
  10113. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10114. /** RGB */
  10115. static readonly TEXTUREFORMAT_RGB: number;
  10116. /** RGBA */
  10117. static readonly TEXTUREFORMAT_RGBA: number;
  10118. /** RED */
  10119. static readonly TEXTUREFORMAT_RED: number;
  10120. /** RED (2nd reference) */
  10121. static readonly TEXTUREFORMAT_R: number;
  10122. /** RG */
  10123. static readonly TEXTUREFORMAT_RG: number;
  10124. /** RED_INTEGER */
  10125. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10126. /** RED_INTEGER (2nd reference) */
  10127. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10128. /** RG_INTEGER */
  10129. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10130. /** RGB_INTEGER */
  10131. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10132. /** RGBA_INTEGER */
  10133. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10134. /** UNSIGNED_BYTE */
  10135. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10136. /** UNSIGNED_BYTE (2nd reference) */
  10137. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10138. /** FLOAT */
  10139. static readonly TEXTURETYPE_FLOAT: number;
  10140. /** HALF_FLOAT */
  10141. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10142. /** BYTE */
  10143. static readonly TEXTURETYPE_BYTE: number;
  10144. /** SHORT */
  10145. static readonly TEXTURETYPE_SHORT: number;
  10146. /** UNSIGNED_SHORT */
  10147. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10148. /** INT */
  10149. static readonly TEXTURETYPE_INT: number;
  10150. /** UNSIGNED_INT */
  10151. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10152. /** UNSIGNED_SHORT_4_4_4_4 */
  10153. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10154. /** UNSIGNED_SHORT_5_5_5_1 */
  10155. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10156. /** UNSIGNED_SHORT_5_6_5 */
  10157. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10158. /** UNSIGNED_INT_2_10_10_10_REV */
  10159. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10160. /** UNSIGNED_INT_24_8 */
  10161. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10162. /** UNSIGNED_INT_10F_11F_11F_REV */
  10163. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10164. /** UNSIGNED_INT_5_9_9_9_REV */
  10165. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10166. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10167. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10168. /** nearest is mag = nearest and min = nearest and mip = linear */
  10169. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10170. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10171. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10172. /** Trilinear is mag = linear and min = linear and mip = linear */
  10173. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10174. /** nearest is mag = nearest and min = nearest and mip = linear */
  10175. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10176. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10177. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10178. /** Trilinear is mag = linear and min = linear and mip = linear */
  10179. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10180. /** mag = nearest and min = nearest and mip = nearest */
  10181. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10182. /** mag = nearest and min = linear and mip = nearest */
  10183. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10184. /** mag = nearest and min = linear and mip = linear */
  10185. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10186. /** mag = nearest and min = linear and mip = none */
  10187. static readonly TEXTURE_NEAREST_LINEAR: number;
  10188. /** mag = nearest and min = nearest and mip = none */
  10189. static readonly TEXTURE_NEAREST_NEAREST: number;
  10190. /** mag = linear and min = nearest and mip = nearest */
  10191. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10192. /** mag = linear and min = nearest and mip = linear */
  10193. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10194. /** mag = linear and min = linear and mip = none */
  10195. static readonly TEXTURE_LINEAR_LINEAR: number;
  10196. /** mag = linear and min = nearest and mip = none */
  10197. static readonly TEXTURE_LINEAR_NEAREST: number;
  10198. /** Explicit coordinates mode */
  10199. static readonly TEXTURE_EXPLICIT_MODE: number;
  10200. /** Spherical coordinates mode */
  10201. static readonly TEXTURE_SPHERICAL_MODE: number;
  10202. /** Planar coordinates mode */
  10203. static readonly TEXTURE_PLANAR_MODE: number;
  10204. /** Cubic coordinates mode */
  10205. static readonly TEXTURE_CUBIC_MODE: number;
  10206. /** Projection coordinates mode */
  10207. static readonly TEXTURE_PROJECTION_MODE: number;
  10208. /** Skybox coordinates mode */
  10209. static readonly TEXTURE_SKYBOX_MODE: number;
  10210. /** Inverse Cubic coordinates mode */
  10211. static readonly TEXTURE_INVCUBIC_MODE: number;
  10212. /** Equirectangular coordinates mode */
  10213. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10214. /** Equirectangular Fixed coordinates mode */
  10215. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10216. /** Equirectangular Fixed Mirrored coordinates mode */
  10217. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10218. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10219. static readonly SCALEMODE_FLOOR: number;
  10220. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10221. static readonly SCALEMODE_NEAREST: number;
  10222. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10223. static readonly SCALEMODE_CEILING: number;
  10224. /**
  10225. * Returns the current version of the framework
  10226. */
  10227. static readonly Version: string;
  10228. /**
  10229. * Returns a string describing the current engine
  10230. */
  10231. readonly description: string;
  10232. /**
  10233. * Gets or sets the epsilon value used by collision engine
  10234. */
  10235. static CollisionsEpsilon: number;
  10236. /**
  10237. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10238. */
  10239. static CodeRepository: string;
  10240. /**
  10241. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10242. */
  10243. static ShadersRepository: string;
  10244. /**
  10245. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10246. */
  10247. forcePOTTextures: boolean;
  10248. /**
  10249. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10250. */
  10251. isFullscreen: boolean;
  10252. /**
  10253. * Gets a boolean indicating if the pointer is currently locked
  10254. */
  10255. isPointerLock: boolean;
  10256. /**
  10257. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10258. */
  10259. cullBackFaces: boolean;
  10260. /**
  10261. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10262. */
  10263. renderEvenInBackground: boolean;
  10264. /**
  10265. * Gets or sets a boolean indicating that cache can be kept between frames
  10266. */
  10267. preventCacheWipeBetweenFrames: boolean;
  10268. /**
  10269. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10270. **/
  10271. enableOfflineSupport: boolean;
  10272. /**
  10273. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (Babylon.js will always consider the database is up to date)
  10274. **/
  10275. disableManifestCheck: boolean;
  10276. /**
  10277. * Gets the list of created scenes
  10278. */
  10279. scenes: Scene[];
  10280. /**
  10281. * Gets the list of created postprocesses
  10282. */
  10283. postProcesses: PostProcess[];
  10284. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10285. validateShaderPrograms: boolean;
  10286. /**
  10287. * Observable event triggered each time the rendering canvas is resized
  10288. */
  10289. onResizeObservable: Observable<Engine>;
  10290. /**
  10291. * Observable event triggered each time the canvas loses focus
  10292. */
  10293. onCanvasBlurObservable: Observable<Engine>;
  10294. /**
  10295. * Observable event triggered each time the canvas gains focus
  10296. */
  10297. onCanvasFocusObservable: Observable<Engine>;
  10298. /**
  10299. * Observable event triggered each time the canvas receives pointerout event
  10300. */
  10301. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10302. /**
  10303. * Observable event triggered before each texture is initialized
  10304. */
  10305. onBeforeTextureInitObservable: Observable<Texture>;
  10306. private _vrDisplay;
  10307. private _vrSupported;
  10308. private _oldSize;
  10309. private _oldHardwareScaleFactor;
  10310. private _vrExclusivePointerMode;
  10311. private _webVRInitPromise;
  10312. /**
  10313. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10314. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10315. */
  10316. readonly isInVRExclusivePointerMode: boolean;
  10317. /**
  10318. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10319. */
  10320. disableUniformBuffers: boolean;
  10321. /** @hidden */
  10322. _uniformBuffers: UniformBuffer[];
  10323. /**
  10324. * Gets a boolean indicating that the engine supports uniform buffers
  10325. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10326. */
  10327. readonly supportsUniformBuffers: boolean;
  10328. /**
  10329. * Observable raised when the engine begins a new frame
  10330. */
  10331. onBeginFrameObservable: Observable<Engine>;
  10332. /**
  10333. * If set, will be used to request the next animation frame for the render loop
  10334. */
  10335. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  10336. /**
  10337. * Observable raised when the engine ends the current frame
  10338. */
  10339. onEndFrameObservable: Observable<Engine>;
  10340. /**
  10341. * Observable raised when the engine is about to compile a shader
  10342. */
  10343. onBeforeShaderCompilationObservable: Observable<Engine>;
  10344. /**
  10345. * Observable raised when the engine has jsut compiled a shader
  10346. */
  10347. onAfterShaderCompilationObservable: Observable<Engine>;
  10348. /** @hidden */
  10349. _gl: WebGLRenderingContext;
  10350. private _renderingCanvas;
  10351. private _windowIsBackground;
  10352. private _webGLVersion;
  10353. /**
  10354. * Gets a boolean indicating that only power of 2 textures are supported
  10355. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10356. */
  10357. readonly needPOTTextures: boolean;
  10358. /** @hidden */
  10359. _badOS: boolean;
  10360. /** @hidden */
  10361. _badDesktopOS: boolean;
  10362. /**
  10363. * Gets or sets a value indicating if we want to disable texture binding optimization.
  10364. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10365. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10366. */
  10367. disableTextureBindingOptimization: boolean;
  10368. /**
  10369. * Gets the audio engine
  10370. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10371. * @ignorenaming
  10372. */
  10373. static audioEngine: IAudioEngine;
  10374. /**
  10375. * Default AudioEngine factory responsible of creating the Audio Engine.
  10376. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  10377. */
  10378. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10379. /**
  10380. * Default offline support factory responsible of creating a tool used to store data locally.
  10381. * By default, this will create a Database object if the workload has been embedded.
  10382. */
  10383. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  10384. private _onFocus;
  10385. private _onBlur;
  10386. private _onCanvasPointerOut;
  10387. private _onCanvasBlur;
  10388. private _onCanvasFocus;
  10389. private _onFullscreenChange;
  10390. private _onPointerLockChange;
  10391. private _onVRDisplayPointerRestricted;
  10392. private _onVRDisplayPointerUnrestricted;
  10393. private _onVrDisplayConnect;
  10394. private _onVrDisplayDisconnect;
  10395. private _onVrDisplayPresentChange;
  10396. /**
  10397. * Observable signaled when VR display mode changes
  10398. */
  10399. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10400. /**
  10401. * Observable signaled when VR request present is complete
  10402. */
  10403. onVRRequestPresentComplete: Observable<boolean>;
  10404. /**
  10405. * Observable signaled when VR request present starts
  10406. */
  10407. onVRRequestPresentStart: Observable<Engine>;
  10408. private _hardwareScalingLevel;
  10409. /** @hidden */
  10410. protected _caps: EngineCapabilities;
  10411. private _pointerLockRequested;
  10412. private _isStencilEnable;
  10413. private _colorWrite;
  10414. private _loadingScreen;
  10415. /** @hidden */
  10416. _drawCalls: PerfCounter;
  10417. /** @hidden */
  10418. _textureCollisions: PerfCounter;
  10419. private _glVersion;
  10420. private _glRenderer;
  10421. private _glVendor;
  10422. private _videoTextureSupported;
  10423. private _renderingQueueLaunched;
  10424. private _activeRenderLoops;
  10425. private _deterministicLockstep;
  10426. private _lockstepMaxSteps;
  10427. /**
  10428. * Observable signaled when a context lost event is raised
  10429. */
  10430. onContextLostObservable: Observable<Engine>;
  10431. /**
  10432. * Observable signaled when a context restored event is raised
  10433. */
  10434. onContextRestoredObservable: Observable<Engine>;
  10435. private _onContextLost;
  10436. private _onContextRestored;
  10437. private _contextWasLost;
  10438. private _doNotHandleContextLost;
  10439. /**
  10440. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10441. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10442. */
  10443. doNotHandleContextLost: boolean;
  10444. private _performanceMonitor;
  10445. private _fps;
  10446. private _deltaTime;
  10447. /**
  10448. * Turn this value on if you want to pause FPS computation when in background
  10449. */
  10450. disablePerformanceMonitorInBackground: boolean;
  10451. /**
  10452. * Gets the performance monitor attached to this engine
  10453. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10454. */
  10455. readonly performanceMonitor: PerformanceMonitor;
  10456. /** @hidden */
  10457. protected _depthCullingState: _DepthCullingState;
  10458. /** @hidden */
  10459. protected _stencilState: _StencilState;
  10460. /** @hidden */
  10461. protected _alphaState: _AlphaState;
  10462. /** @hidden */
  10463. protected _alphaMode: number;
  10464. protected _internalTexturesCache: InternalTexture[];
  10465. /** @hidden */
  10466. protected _activeChannel: number;
  10467. private _currentTextureChannel;
  10468. /** @hidden */
  10469. protected _boundTexturesCache: {
  10470. [key: string]: Nullable<InternalTexture>;
  10471. };
  10472. /** @hidden */
  10473. protected _currentEffect: Nullable<Effect>;
  10474. /** @hidden */
  10475. protected _currentProgram: Nullable<WebGLProgram>;
  10476. private _compiledEffects;
  10477. private _vertexAttribArraysEnabled;
  10478. /** @hidden */
  10479. protected _cachedViewport: Nullable<Viewport>;
  10480. private _cachedVertexArrayObject;
  10481. /** @hidden */
  10482. protected _cachedVertexBuffers: any;
  10483. /** @hidden */
  10484. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10485. /** @hidden */
  10486. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10487. /** @hidden */
  10488. protected _currentRenderTarget: Nullable<InternalTexture>;
  10489. private _uintIndicesCurrentlySet;
  10490. private _currentBoundBuffer;
  10491. /** @hidden */
  10492. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10493. private _currentBufferPointers;
  10494. private _currentInstanceLocations;
  10495. private _currentInstanceBuffers;
  10496. private _textureUnits;
  10497. private _firstBoundInternalTextureTracker;
  10498. private _lastBoundInternalTextureTracker;
  10499. private _workingCanvas;
  10500. private _workingContext;
  10501. private _rescalePostProcess;
  10502. private _dummyFramebuffer;
  10503. private _externalData;
  10504. private _bindedRenderFunction;
  10505. private _vaoRecordInProgress;
  10506. private _mustWipeVertexAttributes;
  10507. private _emptyTexture;
  10508. private _emptyCubeTexture;
  10509. private _emptyTexture3D;
  10510. /** @hidden */
  10511. _frameHandler: number;
  10512. private _nextFreeTextureSlots;
  10513. private _maxSimultaneousTextures;
  10514. private _activeRequests;
  10515. private _texturesSupported;
  10516. private _textureFormatInUse;
  10517. /**
  10518. * Gets the list of texture formats supported
  10519. */
  10520. readonly texturesSupported: Array<string>;
  10521. /**
  10522. * Gets the list of texture formats in use
  10523. */
  10524. readonly textureFormatInUse: Nullable<string>;
  10525. /**
  10526. * Gets the current viewport
  10527. */
  10528. readonly currentViewport: Nullable<Viewport>;
  10529. /**
  10530. * Gets the default empty texture
  10531. */
  10532. readonly emptyTexture: InternalTexture;
  10533. /**
  10534. * Gets the default empty 3D texture
  10535. */
  10536. readonly emptyTexture3D: InternalTexture;
  10537. /**
  10538. * Gets the default empty cube texture
  10539. */
  10540. readonly emptyCubeTexture: InternalTexture;
  10541. /**
  10542. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10543. */
  10544. readonly premultipliedAlpha: boolean;
  10545. /**
  10546. * Creates a new engine
  10547. * @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
  10548. * @param antialias defines enable antialiasing (default: false)
  10549. * @param options defines further options to be sent to the getContext() function
  10550. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10551. */
  10552. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10553. private _rebuildInternalTextures;
  10554. private _rebuildEffects;
  10555. /**
  10556. * Gets a boolean indicating if all created effects are ready
  10557. * @returns true if all effects are ready
  10558. */
  10559. areAllEffectsReady(): boolean;
  10560. private _rebuildBuffers;
  10561. private _initGLContext;
  10562. /**
  10563. * Gets version of the current webGL context
  10564. */
  10565. readonly webGLVersion: number;
  10566. /**
  10567. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10568. */
  10569. readonly isStencilEnable: boolean;
  10570. private _prepareWorkingCanvas;
  10571. /**
  10572. * Reset the texture cache to empty state
  10573. */
  10574. resetTextureCache(): void;
  10575. /**
  10576. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10577. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10578. * @returns true if engine is in deterministic lock step mode
  10579. */
  10580. isDeterministicLockStep(): boolean;
  10581. /**
  10582. * Gets the max steps when engine is running in deterministic lock step
  10583. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10584. * @returns the max steps
  10585. */
  10586. getLockstepMaxSteps(): number;
  10587. /**
  10588. * Gets an object containing information about the current webGL context
  10589. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10590. */
  10591. getGlInfo(): {
  10592. vendor: string;
  10593. renderer: string;
  10594. version: string;
  10595. };
  10596. /**
  10597. * Gets current aspect ratio
  10598. * @param camera defines the camera to use to get the aspect ratio
  10599. * @param useScreen defines if screen size must be used (or the current render target if any)
  10600. * @returns a number defining the aspect ratio
  10601. */
  10602. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10603. /**
  10604. * Gets current screen aspect ratio
  10605. * @returns a number defining the aspect ratio
  10606. */
  10607. getScreenAspectRatio(): number;
  10608. /**
  10609. * Gets the current render width
  10610. * @param useScreen defines if screen size must be used (or the current render target if any)
  10611. * @returns a number defining the current render width
  10612. */
  10613. getRenderWidth(useScreen?: boolean): number;
  10614. /**
  10615. * Gets the current render height
  10616. * @param useScreen defines if screen size must be used (or the current render target if any)
  10617. * @returns a number defining the current render height
  10618. */
  10619. getRenderHeight(useScreen?: boolean): number;
  10620. /**
  10621. * Gets the HTML canvas attached with the current webGL context
  10622. * @returns a HTML canvas
  10623. */
  10624. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10625. /**
  10626. * Gets the client rect of the HTML canvas attached with the current webGL context
  10627. * @returns a client rectanglee
  10628. */
  10629. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10630. /**
  10631. * Defines the hardware scaling level.
  10632. * By default the hardware scaling level is computed from the window device ratio.
  10633. * 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.
  10634. * @param level defines the level to use
  10635. */
  10636. setHardwareScalingLevel(level: number): void;
  10637. /**
  10638. * Gets the current hardware scaling level.
  10639. * By default the hardware scaling level is computed from the window device ratio.
  10640. * 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.
  10641. * @returns a number indicating the current hardware scaling level
  10642. */
  10643. getHardwareScalingLevel(): number;
  10644. /**
  10645. * Gets the list of loaded textures
  10646. * @returns an array containing all loaded textures
  10647. */
  10648. getLoadedTexturesCache(): InternalTexture[];
  10649. /**
  10650. * Gets the object containing all engine capabilities
  10651. * @returns the EngineCapabilities object
  10652. */
  10653. getCaps(): EngineCapabilities;
  10654. /** @hidden */
  10655. readonly drawCalls: number;
  10656. /** @hidden */
  10657. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  10658. /**
  10659. * Gets the current depth function
  10660. * @returns a number defining the depth function
  10661. */
  10662. getDepthFunction(): Nullable<number>;
  10663. /**
  10664. * Sets the current depth function
  10665. * @param depthFunc defines the function to use
  10666. */
  10667. setDepthFunction(depthFunc: number): void;
  10668. /**
  10669. * Sets the current depth function to GREATER
  10670. */
  10671. setDepthFunctionToGreater(): void;
  10672. /**
  10673. * Sets the current depth function to GEQUAL
  10674. */
  10675. setDepthFunctionToGreaterOrEqual(): void;
  10676. /**
  10677. * Sets the current depth function to LESS
  10678. */
  10679. setDepthFunctionToLess(): void;
  10680. /**
  10681. * Sets the current depth function to LEQUAL
  10682. */
  10683. setDepthFunctionToLessOrEqual(): void;
  10684. /**
  10685. * Gets a boolean indicating if stencil buffer is enabled
  10686. * @returns the current stencil buffer state
  10687. */
  10688. getStencilBuffer(): boolean;
  10689. /**
  10690. * Enable or disable the stencil buffer
  10691. * @param enable defines if the stencil buffer must be enabled or disabled
  10692. */
  10693. setStencilBuffer(enable: boolean): void;
  10694. /**
  10695. * Gets the current stencil mask
  10696. * @returns a number defining the new stencil mask to use
  10697. */
  10698. getStencilMask(): number;
  10699. /**
  10700. * Sets the current stencil mask
  10701. * @param mask defines the new stencil mask to use
  10702. */
  10703. setStencilMask(mask: number): void;
  10704. /**
  10705. * Gets the current stencil function
  10706. * @returns a number defining the stencil function to use
  10707. */
  10708. getStencilFunction(): number;
  10709. /**
  10710. * Gets the current stencil reference value
  10711. * @returns a number defining the stencil reference value to use
  10712. */
  10713. getStencilFunctionReference(): number;
  10714. /**
  10715. * Gets the current stencil mask
  10716. * @returns a number defining the stencil mask to use
  10717. */
  10718. getStencilFunctionMask(): number;
  10719. /**
  10720. * Sets the current stencil function
  10721. * @param stencilFunc defines the new stencil function to use
  10722. */
  10723. setStencilFunction(stencilFunc: number): void;
  10724. /**
  10725. * Sets the current stencil reference
  10726. * @param reference defines the new stencil reference to use
  10727. */
  10728. setStencilFunctionReference(reference: number): void;
  10729. /**
  10730. * Sets the current stencil mask
  10731. * @param mask defines the new stencil mask to use
  10732. */
  10733. setStencilFunctionMask(mask: number): void;
  10734. /**
  10735. * Gets the current stencil operation when stencil fails
  10736. * @returns a number defining stencil operation to use when stencil fails
  10737. */
  10738. getStencilOperationFail(): number;
  10739. /**
  10740. * Gets the current stencil operation when depth fails
  10741. * @returns a number defining stencil operation to use when depth fails
  10742. */
  10743. getStencilOperationDepthFail(): number;
  10744. /**
  10745. * Gets the current stencil operation when stencil passes
  10746. * @returns a number defining stencil operation to use when stencil passes
  10747. */
  10748. getStencilOperationPass(): number;
  10749. /**
  10750. * Sets the stencil operation to use when stencil fails
  10751. * @param operation defines the stencil operation to use when stencil fails
  10752. */
  10753. setStencilOperationFail(operation: number): void;
  10754. /**
  10755. * Sets the stencil operation to use when depth fails
  10756. * @param operation defines the stencil operation to use when depth fails
  10757. */
  10758. setStencilOperationDepthFail(operation: number): void;
  10759. /**
  10760. * Sets the stencil operation to use when stencil passes
  10761. * @param operation defines the stencil operation to use when stencil passes
  10762. */
  10763. setStencilOperationPass(operation: number): void;
  10764. /**
  10765. * Sets a boolean indicating if the dithering state is enabled or disabled
  10766. * @param value defines the dithering state
  10767. */
  10768. setDitheringState(value: boolean): void;
  10769. /**
  10770. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10771. * @param value defines the rasterizer state
  10772. */
  10773. setRasterizerState(value: boolean): void;
  10774. /**
  10775. * stop executing a render loop function and remove it from the execution array
  10776. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10777. */
  10778. stopRenderLoop(renderFunction?: () => void): void;
  10779. /** @hidden */
  10780. _renderLoop(): void;
  10781. /**
  10782. * Register and execute a render loop. The engine can have more than one render function
  10783. * @param renderFunction defines the function to continuously execute
  10784. */
  10785. runRenderLoop(renderFunction: () => void): void;
  10786. /**
  10787. * Toggle full screen mode
  10788. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10789. */
  10790. switchFullscreen(requestPointerLock: boolean): void;
  10791. /**
  10792. * Clear the current render buffer or the current render target (if any is set up)
  10793. * @param color defines the color to use
  10794. * @param backBuffer defines if the back buffer must be cleared
  10795. * @param depth defines if the depth buffer must be cleared
  10796. * @param stencil defines if the stencil buffer must be cleared
  10797. */
  10798. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10799. /**
  10800. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10801. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10802. * @param y defines the y-coordinate of the corner of the clear rectangle
  10803. * @param width defines the width of the clear rectangle
  10804. * @param height defines the height of the clear rectangle
  10805. * @param clearColor defines the clear color
  10806. */
  10807. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10808. private _viewportCached;
  10809. /** @hidden */
  10810. _viewport(x: number, y: number, width: number, height: number): void;
  10811. /**
  10812. * Set the WebGL's viewport
  10813. * @param viewport defines the viewport element to be used
  10814. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10815. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10816. */
  10817. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10818. /**
  10819. * Directly set the WebGL Viewport
  10820. * @param x defines the x coordinate of the viewport (in screen space)
  10821. * @param y defines the y coordinate of the viewport (in screen space)
  10822. * @param width defines the width of the viewport (in screen space)
  10823. * @param height defines the height of the viewport (in screen space)
  10824. * @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
  10825. */
  10826. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10827. /**
  10828. * Begin a new frame
  10829. */
  10830. beginFrame(): void;
  10831. /**
  10832. * Enf the current frame
  10833. */
  10834. endFrame(): void;
  10835. /**
  10836. * Resize the view according to the canvas' size
  10837. */
  10838. resize(): void;
  10839. /**
  10840. * Force a specific size of the canvas
  10841. * @param width defines the new canvas' width
  10842. * @param height defines the new canvas' height
  10843. */
  10844. setSize(width: number, height: number): void;
  10845. /**
  10846. * Gets a boolean indicating if a webVR device was detected
  10847. * @returns true if a webVR device was detected
  10848. */
  10849. isVRDevicePresent(): boolean;
  10850. /**
  10851. * Gets the current webVR device
  10852. * @returns the current webVR device (or null)
  10853. */
  10854. getVRDevice(): any;
  10855. /**
  10856. * Initializes a webVR display and starts listening to display change events
  10857. * The onVRDisplayChangedObservable will be notified upon these changes
  10858. * @returns The onVRDisplayChangedObservable
  10859. */
  10860. initWebVR(): Observable<IDisplayChangedEventArgs>;
  10861. /**
  10862. * Initializes a webVR display and starts listening to display change events
  10863. * The onVRDisplayChangedObservable will be notified upon these changes
  10864. * @returns A promise containing a VRDisplay and if vr is supported
  10865. */
  10866. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  10867. /**
  10868. * Call this function to switch to webVR mode
  10869. * Will do nothing if webVR is not supported or if there is no webVR device
  10870. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10871. */
  10872. enableVR(): void;
  10873. /**
  10874. * Call this function to leave webVR mode
  10875. * Will do nothing if webVR is not supported or if there is no webVR device
  10876. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10877. */
  10878. disableVR(): void;
  10879. private _onVRFullScreenTriggered;
  10880. private _getVRDisplaysAsync;
  10881. /**
  10882. * Binds the frame buffer to the specified texture.
  10883. * @param texture The texture to render to or null for the default canvas
  10884. * @param faceIndex The face of the texture to render to in case of cube texture
  10885. * @param requiredWidth The width of the target to render to
  10886. * @param requiredHeight The height of the target to render to
  10887. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  10888. * @param depthStencilTexture The depth stencil texture to use to render
  10889. * @param lodLevel defines le lod level to bind to the frame buffer
  10890. */
  10891. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  10892. private bindUnboundFramebuffer;
  10893. /**
  10894. * Unbind the current render target texture from the webGL context
  10895. * @param texture defines the render target texture to unbind
  10896. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10897. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10898. */
  10899. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10900. /**
  10901. * Unbind a list of render target textures from the webGL context
  10902. * This is used only when drawBuffer extension or webGL2 are active
  10903. * @param textures defines the render target textures to unbind
  10904. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10905. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10906. */
  10907. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10908. /**
  10909. * Force the mipmap generation for the given render target texture
  10910. * @param texture defines the render target texture to use
  10911. */
  10912. generateMipMapsForCubemap(texture: InternalTexture): void;
  10913. /**
  10914. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  10915. */
  10916. flushFramebuffer(): void;
  10917. /**
  10918. * Unbind the current render target and bind the default framebuffer
  10919. */
  10920. restoreDefaultFramebuffer(): void;
  10921. /**
  10922. * Create an uniform buffer
  10923. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10924. * @param elements defines the content of the uniform buffer
  10925. * @returns the webGL uniform buffer
  10926. */
  10927. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  10928. /**
  10929. * Create a dynamic uniform buffer
  10930. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10931. * @param elements defines the content of the uniform buffer
  10932. * @returns the webGL uniform buffer
  10933. */
  10934. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  10935. /**
  10936. * Update an existing uniform buffer
  10937. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10938. * @param uniformBuffer defines the target uniform buffer
  10939. * @param elements defines the content to update
  10940. * @param offset defines the offset in the uniform buffer where update should start
  10941. * @param count defines the size of the data to update
  10942. */
  10943. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  10944. private _resetVertexBufferBinding;
  10945. /**
  10946. * Creates a vertex buffer
  10947. * @param data the data for the vertex buffer
  10948. * @returns the new WebGL static buffer
  10949. */
  10950. createVertexBuffer(data: DataArray): WebGLBuffer;
  10951. /**
  10952. * Creates a dynamic vertex buffer
  10953. * @param data the data for the dynamic vertex buffer
  10954. * @returns the new WebGL dynamic buffer
  10955. */
  10956. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  10957. /**
  10958. * Update a dynamic index buffer
  10959. * @param indexBuffer defines the target index buffer
  10960. * @param indices defines the data to update
  10961. * @param offset defines the offset in the target index buffer where update should start
  10962. */
  10963. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  10964. /**
  10965. * Updates a dynamic vertex buffer.
  10966. * @param vertexBuffer the vertex buffer to update
  10967. * @param data the data used to update the vertex buffer
  10968. * @param byteOffset the byte offset of the data
  10969. * @param byteLength the byte length of the data
  10970. */
  10971. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  10972. private _resetIndexBufferBinding;
  10973. /**
  10974. * Creates a new index buffer
  10975. * @param indices defines the content of the index buffer
  10976. * @param updatable defines if the index buffer must be updatable
  10977. * @returns a new webGL buffer
  10978. */
  10979. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  10980. /**
  10981. * Bind a webGL buffer to the webGL context
  10982. * @param buffer defines the buffer to bind
  10983. */
  10984. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  10985. /**
  10986. * Bind an uniform buffer to the current webGL context
  10987. * @param buffer defines the buffer to bind
  10988. */
  10989. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  10990. /**
  10991. * Bind a buffer to the current webGL context at a given location
  10992. * @param buffer defines the buffer to bind
  10993. * @param location defines the index where to bind the buffer
  10994. */
  10995. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  10996. /**
  10997. * Bind a specific block at a given index in a specific shader program
  10998. * @param shaderProgram defines the shader program
  10999. * @param blockName defines the block name
  11000. * @param index defines the index where to bind the block
  11001. */
  11002. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  11003. private bindIndexBuffer;
  11004. private bindBuffer;
  11005. /**
  11006. * update the bound buffer with the given data
  11007. * @param data defines the data to update
  11008. */
  11009. updateArrayBuffer(data: Float32Array): void;
  11010. private _vertexAttribPointer;
  11011. private _bindIndexBufferWithCache;
  11012. private _bindVertexBuffersAttributes;
  11013. /**
  11014. * Records a vertex array object
  11015. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11016. * @param vertexBuffers defines the list of vertex buffers to store
  11017. * @param indexBuffer defines the index buffer to store
  11018. * @param effect defines the effect to store
  11019. * @returns the new vertex array object
  11020. */
  11021. recordVertexArrayObject(vertexBuffers: {
  11022. [key: string]: VertexBuffer;
  11023. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  11024. /**
  11025. * Bind a specific vertex array object
  11026. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11027. * @param vertexArrayObject defines the vertex array object to bind
  11028. * @param indexBuffer defines the index buffer to bind
  11029. */
  11030. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  11031. /**
  11032. * Bind webGl buffers directly to the webGL context
  11033. * @param vertexBuffer defines the vertex buffer to bind
  11034. * @param indexBuffer defines the index buffer to bind
  11035. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  11036. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  11037. * @param effect defines the effect associated with the vertex buffer
  11038. */
  11039. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  11040. private _unbindVertexArrayObject;
  11041. /**
  11042. * Bind a list of vertex buffers to the webGL context
  11043. * @param vertexBuffers defines the list of vertex buffers to bind
  11044. * @param indexBuffer defines the index buffer to bind
  11045. * @param effect defines the effect associated with the vertex buffers
  11046. */
  11047. bindBuffers(vertexBuffers: {
  11048. [key: string]: Nullable<VertexBuffer>;
  11049. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  11050. /**
  11051. * Unbind all instance attributes
  11052. */
  11053. unbindInstanceAttributes(): void;
  11054. /**
  11055. * Release and free the memory of a vertex array object
  11056. * @param vao defines the vertex array object to delete
  11057. */
  11058. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  11059. /** @hidden */
  11060. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11061. /**
  11062. * Creates a webGL buffer to use with instanciation
  11063. * @param capacity defines the size of the buffer
  11064. * @returns the webGL buffer
  11065. */
  11066. createInstancesBuffer(capacity: number): WebGLBuffer;
  11067. /**
  11068. * Delete a webGL buffer used with instanciation
  11069. * @param buffer defines the webGL buffer to delete
  11070. */
  11071. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  11072. /**
  11073. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  11074. * @param instancesBuffer defines the webGL buffer to update and bind
  11075. * @param data defines the data to store in the buffer
  11076. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  11077. */
  11078. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  11079. /**
  11080. * Apply all cached states (depth, culling, stencil and alpha)
  11081. */
  11082. applyStates(): void;
  11083. /**
  11084. * Send a draw order
  11085. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11086. * @param indexStart defines the starting index
  11087. * @param indexCount defines the number of index to draw
  11088. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11089. */
  11090. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11091. /**
  11092. * Draw a list of points
  11093. * @param verticesStart defines the index of first vertex to draw
  11094. * @param verticesCount defines the count of vertices to draw
  11095. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11096. */
  11097. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11098. /**
  11099. * Draw a list of unindexed primitives
  11100. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11101. * @param verticesStart defines the index of first vertex to draw
  11102. * @param verticesCount defines the count of vertices to draw
  11103. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11104. */
  11105. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11106. /**
  11107. * Draw a list of indexed primitives
  11108. * @param fillMode defines the primitive to use
  11109. * @param indexStart defines the starting index
  11110. * @param indexCount defines the number of index to draw
  11111. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11112. */
  11113. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11114. /**
  11115. * Draw a list of unindexed primitives
  11116. * @param fillMode defines the primitive to use
  11117. * @param verticesStart defines the index of first vertex to draw
  11118. * @param verticesCount defines the count of vertices to draw
  11119. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11120. */
  11121. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11122. private _drawMode;
  11123. /** @hidden */
  11124. _releaseEffect(effect: Effect): void;
  11125. /** @hidden */
  11126. _deleteProgram(program: WebGLProgram): void;
  11127. /**
  11128. * Create a new effect (used to store vertex/fragment shaders)
  11129. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11130. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11131. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11132. * @param samplers defines an array of string used to represent textures
  11133. * @param defines defines the string containing the defines to use to compile the shaders
  11134. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11135. * @param onCompiled defines a function to call when the effect creation is successful
  11136. * @param onError defines a function to call when the effect creation has failed
  11137. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11138. * @returns the new Effect
  11139. */
  11140. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  11141. private _compileShader;
  11142. private _compileRawShader;
  11143. /**
  11144. * Directly creates a webGL program
  11145. * @param vertexCode defines the vertex shader code to use
  11146. * @param fragmentCode defines the fragment shader code to use
  11147. * @param context defines the webGL context to use (if not set, the current one will be used)
  11148. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11149. * @returns the new webGL program
  11150. */
  11151. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11152. /**
  11153. * Creates a webGL program
  11154. * @param vertexCode defines the vertex shader code to use
  11155. * @param fragmentCode defines the fragment shader code to use
  11156. * @param defines defines the string containing the defines to use to compile the shaders
  11157. * @param context defines the webGL context to use (if not set, the current one will be used)
  11158. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11159. * @returns the new webGL program
  11160. */
  11161. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11162. private _createShaderProgram;
  11163. private _finalizeProgram;
  11164. /** @hidden */
  11165. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11166. /** @hidden */
  11167. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11168. /**
  11169. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11170. * @param shaderProgram defines the webGL program to use
  11171. * @param uniformsNames defines the list of uniform names
  11172. * @returns an array of webGL uniform locations
  11173. */
  11174. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11175. /**
  11176. * Gets the lsit of active attributes for a given webGL program
  11177. * @param shaderProgram defines the webGL program to use
  11178. * @param attributesNames defines the list of attribute names to get
  11179. * @returns an array of indices indicating the offset of each attribute
  11180. */
  11181. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11182. /**
  11183. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11184. * @param effect defines the effect to activate
  11185. */
  11186. enableEffect(effect: Nullable<Effect>): void;
  11187. /**
  11188. * Set the value of an uniform to an array of int32
  11189. * @param uniform defines the webGL uniform location where to store the value
  11190. * @param array defines the array of int32 to store
  11191. */
  11192. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11193. /**
  11194. * Set the value of an uniform to an array of int32 (stored as vec2)
  11195. * @param uniform defines the webGL uniform location where to store the value
  11196. * @param array defines the array of int32 to store
  11197. */
  11198. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11199. /**
  11200. * Set the value of an uniform to an array of int32 (stored as vec3)
  11201. * @param uniform defines the webGL uniform location where to store the value
  11202. * @param array defines the array of int32 to store
  11203. */
  11204. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11205. /**
  11206. * Set the value of an uniform to an array of int32 (stored as vec4)
  11207. * @param uniform defines the webGL uniform location where to store the value
  11208. * @param array defines the array of int32 to store
  11209. */
  11210. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11211. /**
  11212. * Set the value of an uniform to an array of float32
  11213. * @param uniform defines the webGL uniform location where to store the value
  11214. * @param array defines the array of float32 to store
  11215. */
  11216. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11217. /**
  11218. * Set the value of an uniform to an array of float32 (stored as vec2)
  11219. * @param uniform defines the webGL uniform location where to store the value
  11220. * @param array defines the array of float32 to store
  11221. */
  11222. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11223. /**
  11224. * Set the value of an uniform to an array of float32 (stored as vec3)
  11225. * @param uniform defines the webGL uniform location where to store the value
  11226. * @param array defines the array of float32 to store
  11227. */
  11228. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11229. /**
  11230. * Set the value of an uniform to an array of float32 (stored as vec4)
  11231. * @param uniform defines the webGL uniform location where to store the value
  11232. * @param array defines the array of float32 to store
  11233. */
  11234. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11235. /**
  11236. * Set the value of an uniform to an array of number
  11237. * @param uniform defines the webGL uniform location where to store the value
  11238. * @param array defines the array of number to store
  11239. */
  11240. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11241. /**
  11242. * Set the value of an uniform to an array of number (stored as vec2)
  11243. * @param uniform defines the webGL uniform location where to store the value
  11244. * @param array defines the array of number to store
  11245. */
  11246. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11247. /**
  11248. * Set the value of an uniform to an array of number (stored as vec3)
  11249. * @param uniform defines the webGL uniform location where to store the value
  11250. * @param array defines the array of number to store
  11251. */
  11252. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11253. /**
  11254. * Set the value of an uniform to an array of number (stored as vec4)
  11255. * @param uniform defines the webGL uniform location where to store the value
  11256. * @param array defines the array of number to store
  11257. */
  11258. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11259. /**
  11260. * Set the value of an uniform to an array of float32 (stored as matrices)
  11261. * @param uniform defines the webGL uniform location where to store the value
  11262. * @param matrices defines the array of float32 to store
  11263. */
  11264. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11265. /**
  11266. * Set the value of an uniform to a matrix
  11267. * @param uniform defines the webGL uniform location where to store the value
  11268. * @param matrix defines the matrix to store
  11269. */
  11270. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11271. /**
  11272. * Set the value of an uniform to a matrix (3x3)
  11273. * @param uniform defines the webGL uniform location where to store the value
  11274. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11275. */
  11276. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11277. /**
  11278. * Set the value of an uniform to a matrix (2x2)
  11279. * @param uniform defines the webGL uniform location where to store the value
  11280. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11281. */
  11282. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11283. /**
  11284. * Set the value of an uniform to a number (int)
  11285. * @param uniform defines the webGL uniform location where to store the value
  11286. * @param value defines the int number to store
  11287. */
  11288. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11289. /**
  11290. * Set the value of an uniform to a number (float)
  11291. * @param uniform defines the webGL uniform location where to store the value
  11292. * @param value defines the float number to store
  11293. */
  11294. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11295. /**
  11296. * Set the value of an uniform to a vec2
  11297. * @param uniform defines the webGL uniform location where to store the value
  11298. * @param x defines the 1st component of the value
  11299. * @param y defines the 2nd component of the value
  11300. */
  11301. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11302. /**
  11303. * Set the value of an uniform to a vec3
  11304. * @param uniform defines the webGL uniform location where to store the value
  11305. * @param x defines the 1st component of the value
  11306. * @param y defines the 2nd component of the value
  11307. * @param z defines the 3rd component of the value
  11308. */
  11309. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11310. /**
  11311. * Set the value of an uniform to a boolean
  11312. * @param uniform defines the webGL uniform location where to store the value
  11313. * @param bool defines the boolean to store
  11314. */
  11315. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11316. /**
  11317. * Set the value of an uniform to a vec4
  11318. * @param uniform defines the webGL uniform location where to store the value
  11319. * @param x defines the 1st component of the value
  11320. * @param y defines the 2nd component of the value
  11321. * @param z defines the 3rd component of the value
  11322. * @param w defines the 4th component of the value
  11323. */
  11324. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11325. /**
  11326. * Set the value of an uniform to a Color3
  11327. * @param uniform defines the webGL uniform location where to store the value
  11328. * @param color3 defines the color to store
  11329. */
  11330. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11331. /**
  11332. * Set the value of an uniform to a Color3 and an alpha value
  11333. * @param uniform defines the webGL uniform location where to store the value
  11334. * @param color3 defines the color to store
  11335. * @param alpha defines the alpha component to store
  11336. */
  11337. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11338. /**
  11339. * Sets a Color4 on a uniform variable
  11340. * @param uniform defines the uniform location
  11341. * @param color4 defines the value to be set
  11342. */
  11343. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11344. /**
  11345. * Set various states to the webGL context
  11346. * @param culling defines backface culling state
  11347. * @param zOffset defines the value to apply to zOffset (0 by default)
  11348. * @param force defines if states must be applied even if cache is up to date
  11349. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11350. */
  11351. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11352. /**
  11353. * Set the z offset to apply to current rendering
  11354. * @param value defines the offset to apply
  11355. */
  11356. setZOffset(value: number): void;
  11357. /**
  11358. * Gets the current value of the zOffset
  11359. * @returns the current zOffset state
  11360. */
  11361. getZOffset(): number;
  11362. /**
  11363. * Enable or disable depth buffering
  11364. * @param enable defines the state to set
  11365. */
  11366. setDepthBuffer(enable: boolean): void;
  11367. /**
  11368. * Gets a boolean indicating if depth writing is enabled
  11369. * @returns the current depth writing state
  11370. */
  11371. getDepthWrite(): boolean;
  11372. /**
  11373. * Enable or disable depth writing
  11374. * @param enable defines the state to set
  11375. */
  11376. setDepthWrite(enable: boolean): void;
  11377. /**
  11378. * Enable or disable color writing
  11379. * @param enable defines the state to set
  11380. */
  11381. setColorWrite(enable: boolean): void;
  11382. /**
  11383. * Gets a boolean indicating if color writing is enabled
  11384. * @returns the current color writing state
  11385. */
  11386. getColorWrite(): boolean;
  11387. /**
  11388. * Sets alpha constants used by some alpha blending modes
  11389. * @param r defines the red component
  11390. * @param g defines the green component
  11391. * @param b defines the blue component
  11392. * @param a defines the alpha component
  11393. */
  11394. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11395. /**
  11396. * Sets the current alpha mode
  11397. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11398. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11399. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11400. */
  11401. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11402. /**
  11403. * Gets the current alpha mode
  11404. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11405. * @returns the current alpha mode
  11406. */
  11407. getAlphaMode(): number;
  11408. /**
  11409. * Clears the list of texture accessible through engine.
  11410. * This can help preventing texture load conflict due to name collision.
  11411. */
  11412. clearInternalTexturesCache(): void;
  11413. /**
  11414. * Force the entire cache to be cleared
  11415. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11416. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11417. */
  11418. wipeCaches(bruteForce?: boolean): void;
  11419. /**
  11420. * Set the compressed texture format to use, based on the formats you have, and the formats
  11421. * supported by the hardware / browser.
  11422. *
  11423. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11424. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11425. * to API arguments needed to compressed textures. This puts the burden on the container
  11426. * generator to house the arcane code for determining these for current & future formats.
  11427. *
  11428. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11429. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11430. *
  11431. * Note: The result of this call is not taken into account when a texture is base64.
  11432. *
  11433. * @param formatsAvailable defines the list of those format families you have created
  11434. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11435. *
  11436. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11437. * @returns The extension selected.
  11438. */
  11439. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11440. private _getSamplingParameters;
  11441. private _partialLoadImg;
  11442. private _cascadeLoadImgs;
  11443. /** @hidden */
  11444. _createTexture(): WebGLTexture;
  11445. /**
  11446. * Usually called from BABYLON.Texture.ts.
  11447. * Passed information to create a WebGLTexture
  11448. * @param urlArg defines a value which contains one of the following:
  11449. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11450. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11451. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11452. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11453. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  11454. * @param scene needed for loading to the correct scene
  11455. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11456. * @param onLoad optional callback to be called upon successful completion
  11457. * @param onError optional callback to be called upon failure
  11458. * @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
  11459. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11460. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11461. * @param forcedExtension defines the extension to use to pick the right loader
  11462. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11463. */
  11464. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  11465. private _rescaleTexture;
  11466. /**
  11467. * Update a raw texture
  11468. * @param texture defines the texture to update
  11469. * @param data defines the data to store in the texture
  11470. * @param format defines the format of the data
  11471. * @param invertY defines if data must be stored with Y axis inverted
  11472. * @param compression defines the compression used (null by default)
  11473. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11474. */
  11475. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11476. /**
  11477. * Creates a raw texture
  11478. * @param data defines the data to store in the texture
  11479. * @param width defines the width of the texture
  11480. * @param height defines the height of the texture
  11481. * @param format defines the format of the data
  11482. * @param generateMipMaps defines if the engine should generate the mip levels
  11483. * @param invertY defines if data must be stored with Y axis inverted
  11484. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11485. * @param compression defines the compression used (null by default)
  11486. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11487. * @returns the raw texture inside an InternalTexture
  11488. */
  11489. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11490. private _unpackFlipYCached;
  11491. /**
  11492. * In case you are sharing the context with other applications, it might
  11493. * be interested to not cache the unpack flip y state to ensure a consistent
  11494. * value would be set.
  11495. */
  11496. enableUnpackFlipYCached: boolean;
  11497. /** @hidden */
  11498. _unpackFlipY(value: boolean): void;
  11499. /** @hidden */
  11500. _getUnpackAlignement(): number;
  11501. /**
  11502. * Creates a dynamic texture
  11503. * @param width defines the width of the texture
  11504. * @param height defines the height of the texture
  11505. * @param generateMipMaps defines if the engine should generate the mip levels
  11506. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11507. * @returns the dynamic texture inside an InternalTexture
  11508. */
  11509. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11510. /**
  11511. * Update the sampling mode of a given texture
  11512. * @param samplingMode defines the required sampling mode
  11513. * @param texture defines the texture to update
  11514. */
  11515. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11516. /**
  11517. * Update the content of a dynamic texture
  11518. * @param texture defines the texture to update
  11519. * @param canvas defines the canvas containing the source
  11520. * @param invertY defines if data must be stored with Y axis inverted
  11521. * @param premulAlpha defines if alpha is stored as premultiplied
  11522. * @param format defines the format of the data
  11523. */
  11524. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  11525. /**
  11526. * Update a video texture
  11527. * @param texture defines the texture to update
  11528. * @param video defines the video element to use
  11529. * @param invertY defines if data must be stored with Y axis inverted
  11530. */
  11531. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11532. /**
  11533. * Updates a depth texture Comparison Mode and Function.
  11534. * If the comparison Function is equal to 0, the mode will be set to none.
  11535. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11536. * @param texture The texture to set the comparison function for
  11537. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11538. */
  11539. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11540. private _setupDepthStencilTexture;
  11541. /**
  11542. * Creates a depth stencil texture.
  11543. * This is only available in WebGL 2 or with the depth texture extension available.
  11544. * @param size The size of face edge in the texture.
  11545. * @param options The options defining the texture.
  11546. * @returns The texture
  11547. */
  11548. createDepthStencilTexture(size: number | {
  11549. width: number;
  11550. height: number;
  11551. }, options: DepthTextureCreationOptions): InternalTexture;
  11552. /**
  11553. * Creates a depth stencil texture.
  11554. * This is only available in WebGL 2 or with the depth texture extension available.
  11555. * @param size The size of face edge in the texture.
  11556. * @param options The options defining the texture.
  11557. * @returns The texture
  11558. */
  11559. private _createDepthStencilTexture;
  11560. /**
  11561. * Creates a depth stencil cube texture.
  11562. * This is only available in WebGL 2.
  11563. * @param size The size of face edge in the cube texture.
  11564. * @param options The options defining the cube texture.
  11565. * @returns The cube texture
  11566. */
  11567. private _createDepthStencilCubeTexture;
  11568. /**
  11569. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11570. * @param renderTarget The render target to set the frame buffer for
  11571. */
  11572. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11573. /**
  11574. * Creates a new render target texture
  11575. * @param size defines the size of the texture
  11576. * @param options defines the options used to create the texture
  11577. * @returns a new render target texture stored in an InternalTexture
  11578. */
  11579. createRenderTargetTexture(size: number | {
  11580. width: number;
  11581. height: number;
  11582. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11583. /**
  11584. * Create a multi render target texture
  11585. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11586. * @param size defines the size of the texture
  11587. * @param options defines the creation options
  11588. * @returns the cube texture as an InternalTexture
  11589. */
  11590. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11591. private _setupFramebufferDepthAttachments;
  11592. /**
  11593. * Updates the sample count of a render target texture
  11594. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11595. * @param texture defines the texture to update
  11596. * @param samples defines the sample count to set
  11597. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11598. */
  11599. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11600. /**
  11601. * Update the sample count for a given multiple render target texture
  11602. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11603. * @param textures defines the textures to update
  11604. * @param samples defines the sample count to set
  11605. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11606. */
  11607. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11608. /** @hidden */
  11609. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11610. /** @hidden */
  11611. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11612. /** @hidden */
  11613. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11614. /** @hidden */
  11615. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11616. /**
  11617. * Creates a new render target cube texture
  11618. * @param size defines the size of the texture
  11619. * @param options defines the options used to create the texture
  11620. * @returns a new render target cube texture stored in an InternalTexture
  11621. */
  11622. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11623. /**
  11624. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11625. * @param rootUrl defines the url where the file to load is located
  11626. * @param scene defines the current scene
  11627. * @param lodScale defines scale to apply to the mip map selection
  11628. * @param lodOffset defines offset to apply to the mip map selection
  11629. * @param onLoad defines an optional callback raised when the texture is loaded
  11630. * @param onError defines an optional callback raised if there is an issue to load the texture
  11631. * @param format defines the format of the data
  11632. * @param forcedExtension defines the extension to use to pick the right loader
  11633. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11634. * @returns the cube texture as an InternalTexture
  11635. */
  11636. 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;
  11637. /**
  11638. * Creates a cube texture
  11639. * @param rootUrl defines the url where the files to load is located
  11640. * @param scene defines the current scene
  11641. * @param files defines the list of files to load (1 per face)
  11642. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11643. * @param onLoad defines an optional callback raised when the texture is loaded
  11644. * @param onError defines an optional callback raised if there is an issue to load the texture
  11645. * @param format defines the format of the data
  11646. * @param forcedExtension defines the extension to use to pick the right loader
  11647. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11648. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11649. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11650. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11651. * @returns the cube texture as an InternalTexture
  11652. */
  11653. 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;
  11654. /**
  11655. * @hidden
  11656. */
  11657. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11658. /**
  11659. * Update a raw cube texture
  11660. * @param texture defines the texture to udpdate
  11661. * @param data defines the data to store
  11662. * @param format defines the data format
  11663. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11664. * @param invertY defines if data must be stored with Y axis inverted
  11665. * @param compression defines the compression used (null by default)
  11666. * @param level defines which level of the texture to update
  11667. */
  11668. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11669. /**
  11670. * Creates a new raw cube texture
  11671. * @param data defines the array of data to use to create each face
  11672. * @param size defines the size of the textures
  11673. * @param format defines the format of the data
  11674. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11675. * @param generateMipMaps defines if the engine should generate the mip levels
  11676. * @param invertY defines if data must be stored with Y axis inverted
  11677. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11678. * @param compression defines the compression used (null by default)
  11679. * @returns the cube texture as an InternalTexture
  11680. */
  11681. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11682. /**
  11683. * Creates a new raw cube texture from a specified url
  11684. * @param url defines the url where the data is located
  11685. * @param scene defines the current scene
  11686. * @param size defines the size of the textures
  11687. * @param format defines the format of the data
  11688. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11689. * @param noMipmap defines if the engine should avoid generating the mip levels
  11690. * @param callback defines a callback used to extract texture data from loaded data
  11691. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11692. * @param onLoad defines a callback called when texture is loaded
  11693. * @param onError defines a callback called if there is an error
  11694. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11695. * @param invertY defines if data must be stored with Y axis inverted
  11696. * @returns the cube texture as an InternalTexture
  11697. */
  11698. 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;
  11699. /**
  11700. * Update a raw 3D texture
  11701. * @param texture defines the texture to update
  11702. * @param data defines the data to store
  11703. * @param format defines the data format
  11704. * @param invertY defines if data must be stored with Y axis inverted
  11705. * @param compression defines the used compression (can be null)
  11706. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11707. */
  11708. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11709. /**
  11710. * Creates a new raw 3D texture
  11711. * @param data defines the data used to create the texture
  11712. * @param width defines the width of the texture
  11713. * @param height defines the height of the texture
  11714. * @param depth defines the depth of the texture
  11715. * @param format defines the format of the texture
  11716. * @param generateMipMaps defines if the engine must generate mip levels
  11717. * @param invertY defines if data must be stored with Y axis inverted
  11718. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11719. * @param compression defines the compressed used (can be null)
  11720. * @param textureType defines the compressed used (can be null)
  11721. * @returns a new raw 3D texture (stored in an InternalTexture)
  11722. */
  11723. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11724. private _prepareWebGLTextureContinuation;
  11725. private _prepareWebGLTexture;
  11726. private _convertRGBtoRGBATextureData;
  11727. /** @hidden */
  11728. _releaseFramebufferObjects(texture: InternalTexture): void;
  11729. /** @hidden */
  11730. _releaseTexture(texture: InternalTexture): void;
  11731. private setProgram;
  11732. private _boundUniforms;
  11733. /**
  11734. * Binds an effect to the webGL context
  11735. * @param effect defines the effect to bind
  11736. */
  11737. bindSamplers(effect: Effect): void;
  11738. private _moveBoundTextureOnTop;
  11739. private _getCorrectTextureChannel;
  11740. private _linkTrackers;
  11741. private _removeDesignatedSlot;
  11742. private _activateCurrentTexture;
  11743. /** @hidden */
  11744. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11745. /** @hidden */
  11746. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11747. /**
  11748. * Sets a texture to the webGL context from a postprocess
  11749. * @param channel defines the channel to use
  11750. * @param postProcess defines the source postprocess
  11751. */
  11752. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11753. /**
  11754. * Binds the output of the passed in post process to the texture channel specified
  11755. * @param channel The channel the texture should be bound to
  11756. * @param postProcess The post process which's output should be bound
  11757. */
  11758. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11759. /**
  11760. * Unbind all textures from the webGL context
  11761. */
  11762. unbindAllTextures(): void;
  11763. /**
  11764. * Sets a texture to the according uniform.
  11765. * @param channel The texture channel
  11766. * @param uniform The uniform to set
  11767. * @param texture The texture to apply
  11768. */
  11769. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11770. /**
  11771. * Sets a depth stencil texture from a render target to the according uniform.
  11772. * @param channel The texture channel
  11773. * @param uniform The uniform to set
  11774. * @param texture The render target texture containing the depth stencil texture to apply
  11775. */
  11776. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11777. private _bindSamplerUniformToChannel;
  11778. private _getTextureWrapMode;
  11779. private _setTexture;
  11780. /**
  11781. * Sets an array of texture to the webGL context
  11782. * @param channel defines the channel where the texture array must be set
  11783. * @param uniform defines the associated uniform location
  11784. * @param textures defines the array of textures to bind
  11785. */
  11786. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11787. /** @hidden */
  11788. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11789. private _setTextureParameterFloat;
  11790. private _setTextureParameterInteger;
  11791. /**
  11792. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11793. * @param x defines the x coordinate of the rectangle where pixels must be read
  11794. * @param y defines the y coordinate of the rectangle where pixels must be read
  11795. * @param width defines the width of the rectangle where pixels must be read
  11796. * @param height defines the height of the rectangle where pixels must be read
  11797. * @returns a Uint8Array containing RGBA colors
  11798. */
  11799. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11800. /**
  11801. * Add an externaly attached data from its key.
  11802. * This method call will fail and return false, if such key already exists.
  11803. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11804. * @param key the unique key that identifies the data
  11805. * @param data the data object to associate to the key for this Engine instance
  11806. * @return true if no such key were already present and the data was added successfully, false otherwise
  11807. */
  11808. addExternalData<T>(key: string, data: T): boolean;
  11809. /**
  11810. * Get an externaly attached data from its key
  11811. * @param key the unique key that identifies the data
  11812. * @return the associated data, if present (can be null), or undefined if not present
  11813. */
  11814. getExternalData<T>(key: string): T;
  11815. /**
  11816. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11817. * @param key the unique key that identifies the data
  11818. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  11819. * @return the associated data, can be null if the factory returned null.
  11820. */
  11821. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  11822. /**
  11823. * Remove an externaly attached data from the Engine instance
  11824. * @param key the unique key that identifies the data
  11825. * @return true if the data was successfully removed, false if it doesn't exist
  11826. */
  11827. removeExternalData(key: string): boolean;
  11828. /**
  11829. * Unbind all vertex attributes from the webGL context
  11830. */
  11831. unbindAllAttributes(): void;
  11832. /**
  11833. * 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
  11834. */
  11835. releaseEffects(): void;
  11836. /**
  11837. * Dispose and release all associated resources
  11838. */
  11839. dispose(): void;
  11840. /**
  11841. * Display the loading screen
  11842. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11843. */
  11844. displayLoadingUI(): void;
  11845. /**
  11846. * Hide the loading screen
  11847. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11848. */
  11849. hideLoadingUI(): void;
  11850. /**
  11851. * Gets the current loading screen object
  11852. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11853. */
  11854. /**
  11855. * Sets the current loading screen object
  11856. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11857. */
  11858. loadingScreen: ILoadingScreen;
  11859. /**
  11860. * Sets the current loading screen text
  11861. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11862. */
  11863. loadingUIText: string;
  11864. /**
  11865. * Sets the current loading screen background color
  11866. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11867. */
  11868. loadingUIBackgroundColor: string;
  11869. /**
  11870. * Attach a new callback raised when context lost event is fired
  11871. * @param callback defines the callback to call
  11872. */
  11873. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11874. /**
  11875. * Attach a new callback raised when context restored event is fired
  11876. * @param callback defines the callback to call
  11877. */
  11878. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11879. /**
  11880. * Gets the source code of the vertex shader associated with a specific webGL program
  11881. * @param program defines the program to use
  11882. * @returns a string containing the source code of the vertex shader associated with the program
  11883. */
  11884. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  11885. /**
  11886. * Gets the source code of the fragment shader associated with a specific webGL program
  11887. * @param program defines the program to use
  11888. * @returns a string containing the source code of the fragment shader associated with the program
  11889. */
  11890. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  11891. /**
  11892. * Get the current error code of the webGL context
  11893. * @returns the error code
  11894. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11895. */
  11896. getError(): number;
  11897. /**
  11898. * Gets the current framerate
  11899. * @returns a number representing the framerate
  11900. */
  11901. getFps(): number;
  11902. /**
  11903. * Gets the time spent between current and previous frame
  11904. * @returns a number representing the delta time in ms
  11905. */
  11906. getDeltaTime(): number;
  11907. private _measureFps;
  11908. /** @hidden */
  11909. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  11910. private _canRenderToFloatFramebuffer;
  11911. private _canRenderToHalfFloatFramebuffer;
  11912. private _canRenderToFramebuffer;
  11913. /** @hidden */
  11914. _getWebGLTextureType(type: number): number;
  11915. private _getInternalFormat;
  11916. /** @hidden */
  11917. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  11918. /** @hidden */
  11919. _getRGBAMultiSampleBufferFormat(type: number): number;
  11920. /** @hidden */
  11921. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  11922. /** @hidden */
  11923. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  11924. private _partialLoadFile;
  11925. private _cascadeLoadFiles;
  11926. /**
  11927. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  11928. * @returns true if the engine can be created
  11929. * @ignorenaming
  11930. */
  11931. static isSupported(): boolean;
  11932. }
  11933. }
  11934. declare module BABYLON {
  11935. /**
  11936. * Options to create the null engine
  11937. */
  11938. class NullEngineOptions {
  11939. /**
  11940. * Render width (Default: 512)
  11941. */
  11942. renderWidth: number;
  11943. /**
  11944. * Render height (Default: 256)
  11945. */
  11946. renderHeight: number;
  11947. /**
  11948. * Texture size (Default: 512)
  11949. */
  11950. textureSize: number;
  11951. /**
  11952. * If delta time between frames should be constant
  11953. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11954. */
  11955. deterministicLockstep: boolean;
  11956. /**
  11957. * Maximum about of steps between frames (Default: 4)
  11958. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11959. */
  11960. lockstepMaxSteps: number;
  11961. }
  11962. /**
  11963. * The null engine class provides support for headless version of babylon.js.
  11964. * This can be used in server side scenario or for testing purposes
  11965. */
  11966. class NullEngine extends Engine {
  11967. private _options;
  11968. /**
  11969. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11970. */
  11971. isDeterministicLockStep(): boolean;
  11972. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  11973. getLockstepMaxSteps(): number;
  11974. /**
  11975. * Sets hardware scaling, used to save performance if needed
  11976. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  11977. */
  11978. getHardwareScalingLevel(): number;
  11979. constructor(options?: NullEngineOptions);
  11980. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11981. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  11982. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  11983. getRenderWidth(useScreen?: boolean): number;
  11984. getRenderHeight(useScreen?: boolean): number;
  11985. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  11986. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  11987. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  11988. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11989. bindSamplers(effect: Effect): void;
  11990. enableEffect(effect: Effect): void;
  11991. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11992. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  11993. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  11994. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  11995. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  11996. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  11997. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  11998. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  11999. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  12000. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  12001. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  12002. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  12003. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  12004. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  12005. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  12006. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12007. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12008. setFloat(uniform: WebGLUniformLocation, value: number): void;
  12009. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  12010. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  12011. setBool(uniform: WebGLUniformLocation, bool: number): void;
  12012. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  12013. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  12014. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  12015. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12016. bindBuffers(vertexBuffers: {
  12017. [key: string]: VertexBuffer;
  12018. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  12019. wipeCaches(bruteForce?: boolean): void;
  12020. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  12021. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  12022. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  12023. /** @hidden */
  12024. _createTexture(): WebGLTexture;
  12025. /** @hidden */
  12026. _releaseTexture(texture: InternalTexture): void;
  12027. 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;
  12028. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12029. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  12030. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  12031. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  12032. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12033. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  12034. areAllEffectsReady(): boolean;
  12035. /**
  12036. * @hidden
  12037. * Get the current error code of the webGL context
  12038. * @returns the error code
  12039. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12040. */
  12041. getError(): number;
  12042. /** @hidden */
  12043. _getUnpackAlignement(): number;
  12044. /** @hidden */
  12045. _unpackFlipY(value: boolean): void;
  12046. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  12047. /**
  12048. * Updates a dynamic vertex buffer.
  12049. * @param vertexBuffer the vertex buffer to update
  12050. * @param data the data used to update the vertex buffer
  12051. * @param byteOffset the byte offset of the data (optional)
  12052. * @param byteLength the byte length of the data (optional)
  12053. */
  12054. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  12055. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  12056. /** @hidden */
  12057. _bindTexture(channel: number, texture: InternalTexture): void;
  12058. /** @hidden */
  12059. _releaseBuffer(buffer: WebGLBuffer): boolean;
  12060. releaseEffects(): void;
  12061. displayLoadingUI(): void;
  12062. hideLoadingUI(): void;
  12063. /** @hidden */
  12064. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12065. /** @hidden */
  12066. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12067. /** @hidden */
  12068. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12069. /** @hidden */
  12070. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  12071. }
  12072. }
  12073. interface WebGLRenderingContext {
  12074. readonly RASTERIZER_DISCARD: number;
  12075. readonly DEPTH_COMPONENT24: number;
  12076. readonly TEXTURE_3D: number;
  12077. readonly TEXTURE_2D_ARRAY: number;
  12078. readonly TEXTURE_COMPARE_FUNC: number;
  12079. readonly TEXTURE_COMPARE_MODE: number;
  12080. readonly COMPARE_REF_TO_TEXTURE: number;
  12081. readonly TEXTURE_WRAP_R: number;
  12082. readonly HALF_FLOAT: number;
  12083. readonly RGB8: number;
  12084. readonly RED_INTEGER: number;
  12085. readonly RG_INTEGER: number;
  12086. readonly RGB_INTEGER: number;
  12087. readonly RGBA_INTEGER: number;
  12088. readonly R8_SNORM: number;
  12089. readonly RG8_SNORM: number;
  12090. readonly RGB8_SNORM: number;
  12091. readonly RGBA8_SNORM: number;
  12092. readonly R8I: number;
  12093. readonly RG8I: number;
  12094. readonly RGB8I: number;
  12095. readonly RGBA8I: number;
  12096. readonly R8UI: number;
  12097. readonly RG8UI: number;
  12098. readonly RGB8UI: number;
  12099. readonly RGBA8UI: number;
  12100. readonly R16I: number;
  12101. readonly RG16I: number;
  12102. readonly RGB16I: number;
  12103. readonly RGBA16I: number;
  12104. readonly R16UI: number;
  12105. readonly RG16UI: number;
  12106. readonly RGB16UI: number;
  12107. readonly RGBA16UI: number;
  12108. readonly R32I: number;
  12109. readonly RG32I: number;
  12110. readonly RGB32I: number;
  12111. readonly RGBA32I: number;
  12112. readonly R32UI: number;
  12113. readonly RG32UI: number;
  12114. readonly RGB32UI: number;
  12115. readonly RGBA32UI: number;
  12116. readonly RGB10_A2UI: number;
  12117. readonly R11F_G11F_B10F: number;
  12118. readonly RGB9_E5: number;
  12119. readonly RGB10_A2: number;
  12120. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12121. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12122. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12123. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12124. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12125. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12126. 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;
  12127. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12128. readonly TRANSFORM_FEEDBACK: number;
  12129. readonly INTERLEAVED_ATTRIBS: number;
  12130. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12131. createTransformFeedback(): WebGLTransformFeedback;
  12132. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12133. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12134. beginTransformFeedback(primitiveMode: number): void;
  12135. endTransformFeedback(): void;
  12136. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12137. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12138. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12139. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12140. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12141. }
  12142. interface ImageBitmap {
  12143. readonly width: number;
  12144. readonly height: number;
  12145. close(): void;
  12146. }
  12147. interface WebGLQuery extends WebGLObject {
  12148. }
  12149. declare var WebGLQuery: {
  12150. prototype: WebGLQuery;
  12151. new (): WebGLQuery;
  12152. };
  12153. interface WebGLSampler extends WebGLObject {
  12154. }
  12155. declare var WebGLSampler: {
  12156. prototype: WebGLSampler;
  12157. new (): WebGLSampler;
  12158. };
  12159. interface WebGLSync extends WebGLObject {
  12160. }
  12161. declare var WebGLSync: {
  12162. prototype: WebGLSync;
  12163. new (): WebGLSync;
  12164. };
  12165. interface WebGLTransformFeedback extends WebGLObject {
  12166. }
  12167. declare var WebGLTransformFeedback: {
  12168. prototype: WebGLTransformFeedback;
  12169. new (): WebGLTransformFeedback;
  12170. };
  12171. interface WebGLVertexArrayObject extends WebGLObject {
  12172. }
  12173. declare var WebGLVertexArrayObject: {
  12174. prototype: WebGLVertexArrayObject;
  12175. new (): WebGLVertexArrayObject;
  12176. };
  12177. declare module BABYLON {
  12178. /**
  12179. * Gather the list of keyboard event types as constants.
  12180. */
  12181. class KeyboardEventTypes {
  12182. /**
  12183. * The keydown event is fired when a key becomes active (pressed).
  12184. */
  12185. static readonly KEYDOWN: number;
  12186. /**
  12187. * The keyup event is fired when a key has been released.
  12188. */
  12189. static readonly KEYUP: number;
  12190. }
  12191. /**
  12192. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12193. */
  12194. class KeyboardInfo {
  12195. /**
  12196. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12197. */
  12198. type: number;
  12199. /**
  12200. * Defines the related dom event
  12201. */
  12202. event: KeyboardEvent;
  12203. /**
  12204. * Instantiates a new keyboard info.
  12205. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12206. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12207. * @param event Defines the related dom event
  12208. */
  12209. constructor(
  12210. /**
  12211. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12212. */
  12213. type: number,
  12214. /**
  12215. * Defines the related dom event
  12216. */
  12217. event: KeyboardEvent);
  12218. }
  12219. /**
  12220. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12221. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12222. */
  12223. class KeyboardInfoPre extends KeyboardInfo {
  12224. /**
  12225. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12226. */
  12227. type: number;
  12228. /**
  12229. * Defines the related dom event
  12230. */
  12231. event: KeyboardEvent;
  12232. /**
  12233. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12234. */
  12235. skipOnPointerObservable: boolean;
  12236. /**
  12237. * Instantiates a new keyboard pre info.
  12238. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12239. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12240. * @param event Defines the related dom event
  12241. */
  12242. constructor(
  12243. /**
  12244. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12245. */
  12246. type: number,
  12247. /**
  12248. * Defines the related dom event
  12249. */
  12250. event: KeyboardEvent);
  12251. }
  12252. }
  12253. declare module BABYLON {
  12254. /**
  12255. * Gather the list of pointer event types as constants.
  12256. */
  12257. class PointerEventTypes {
  12258. /**
  12259. * 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.
  12260. */
  12261. static readonly POINTERDOWN: number;
  12262. /**
  12263. * The pointerup event is fired when a pointer is no longer active.
  12264. */
  12265. static readonly POINTERUP: number;
  12266. /**
  12267. * The pointermove event is fired when a pointer changes coordinates.
  12268. */
  12269. static readonly POINTERMOVE: number;
  12270. /**
  12271. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12272. */
  12273. static readonly POINTERWHEEL: number;
  12274. /**
  12275. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12276. */
  12277. static readonly POINTERPICK: number;
  12278. /**
  12279. * The pointertap event is fired when a the object has been touched and released without drag.
  12280. */
  12281. static readonly POINTERTAP: number;
  12282. /**
  12283. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12284. */
  12285. static readonly POINTERDOUBLETAP: number;
  12286. }
  12287. /**
  12288. * Base class of pointer info types.
  12289. */
  12290. class PointerInfoBase {
  12291. /**
  12292. * Defines the type of event (BABYLON.PointerEventTypes)
  12293. */
  12294. type: number;
  12295. /**
  12296. * Defines the related dom event
  12297. */
  12298. event: PointerEvent | MouseWheelEvent;
  12299. /**
  12300. * Instantiates the base class of pointers info.
  12301. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12302. * @param event Defines the related dom event
  12303. */
  12304. constructor(
  12305. /**
  12306. * Defines the type of event (BABYLON.PointerEventTypes)
  12307. */
  12308. type: number,
  12309. /**
  12310. * Defines the related dom event
  12311. */
  12312. event: PointerEvent | MouseWheelEvent);
  12313. }
  12314. /**
  12315. * This class is used to store pointer related info for the onPrePointerObservable event.
  12316. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12317. */
  12318. class PointerInfoPre extends PointerInfoBase {
  12319. /**
  12320. * Ray from a pointer if availible (eg. 6dof controller)
  12321. */
  12322. ray: Nullable<Ray>;
  12323. /**
  12324. * Defines the local position of the pointer on the canvas.
  12325. */
  12326. localPosition: Vector2;
  12327. /**
  12328. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12329. */
  12330. skipOnPointerObservable: boolean;
  12331. /**
  12332. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12333. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12334. * @param event Defines the related dom event
  12335. * @param localX Defines the local x coordinates of the pointer when the event occured
  12336. * @param localY Defines the local y coordinates of the pointer when the event occured
  12337. */
  12338. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12339. }
  12340. /**
  12341. * This type contains all the data related to a pointer event in Babylon.js.
  12342. * 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.
  12343. */
  12344. class PointerInfo extends PointerInfoBase {
  12345. /**
  12346. * Defines the picking info associated to the info (if any)\
  12347. */
  12348. pickInfo: Nullable<PickingInfo>;
  12349. /**
  12350. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12351. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12352. * @param event Defines the related dom event
  12353. * @param pickInfo Defines the picking info associated to the info (if any)\
  12354. */
  12355. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12356. /**
  12357. * Defines the picking info associated to the info (if any)\
  12358. */
  12359. pickInfo: Nullable<PickingInfo>);
  12360. }
  12361. }
  12362. declare module BABYLON {
  12363. /**
  12364. * Single axis drag gizmo
  12365. */
  12366. class AxisDragGizmo extends Gizmo {
  12367. /**
  12368. * Drag behavior responsible for the gizmos dragging interactions
  12369. */
  12370. dragBehavior: PointerDragBehavior;
  12371. private _pointerObserver;
  12372. /**
  12373. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12374. */
  12375. snapDistance: number;
  12376. /**
  12377. * Event that fires each time the gizmo snaps to a new location.
  12378. * * snapDistance is the the change in distance
  12379. */
  12380. onSnapObservable: Observable<{
  12381. snapDistance: number;
  12382. }>;
  12383. /**
  12384. * Creates an AxisDragGizmo
  12385. * @param gizmoLayer The utility layer the gizmo will be added to
  12386. * @param dragAxis The axis which the gizmo will be able to drag on
  12387. * @param color The color of the gizmo
  12388. */
  12389. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12390. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12391. /**
  12392. * Disposes of the gizmo
  12393. */
  12394. dispose(): void;
  12395. }
  12396. }
  12397. declare module BABYLON {
  12398. /**
  12399. * Single axis scale gizmo
  12400. */
  12401. class AxisScaleGizmo extends Gizmo {
  12402. private _coloredMaterial;
  12403. /**
  12404. * Drag behavior responsible for the gizmos dragging interactions
  12405. */
  12406. dragBehavior: PointerDragBehavior;
  12407. private _pointerObserver;
  12408. /**
  12409. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12410. */
  12411. snapDistance: number;
  12412. /**
  12413. * Event that fires each time the gizmo snaps to a new location.
  12414. * * snapDistance is the the change in distance
  12415. */
  12416. onSnapObservable: Observable<{
  12417. snapDistance: number;
  12418. }>;
  12419. /**
  12420. * If the scaling operation should be done on all axis (default: false)
  12421. */
  12422. uniformScaling: boolean;
  12423. /**
  12424. * Creates an AxisScaleGizmo
  12425. * @param gizmoLayer The utility layer the gizmo will be added to
  12426. * @param dragAxis The axis which the gizmo will be able to scale on
  12427. * @param color The color of the gizmo
  12428. */
  12429. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12430. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12431. /**
  12432. * Disposes of the gizmo
  12433. */
  12434. dispose(): void;
  12435. /**
  12436. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  12437. * @param mesh The mesh to replace the default mesh of the gizmo
  12438. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  12439. */
  12440. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  12441. }
  12442. }
  12443. declare module BABYLON {
  12444. /**
  12445. * Bounding box gizmo
  12446. */
  12447. class BoundingBoxGizmo extends Gizmo {
  12448. private _lineBoundingBox;
  12449. private _rotateSpheresParent;
  12450. private _scaleBoxesParent;
  12451. private _boundingDimensions;
  12452. private _renderObserver;
  12453. private _pointerObserver;
  12454. private _scaleDragSpeed;
  12455. private _tmpQuaternion;
  12456. private _tmpVector;
  12457. private _tmpRotationMatrix;
  12458. /**
  12459. * 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)
  12460. */
  12461. ignoreChildren: boolean;
  12462. /**
  12463. * 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)
  12464. */
  12465. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  12466. /**
  12467. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  12468. */
  12469. rotationSphereSize: number;
  12470. /**
  12471. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  12472. */
  12473. scaleBoxSize: number;
  12474. /**
  12475. * 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)
  12476. */
  12477. fixedDragMeshScreenSize: boolean;
  12478. /**
  12479. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  12480. */
  12481. fixedDragMeshScreenSizeDistanceFactor: number;
  12482. /**
  12483. * Fired when a rotation sphere or scale box is dragged
  12484. */
  12485. onDragStartObservable: Observable<{}>;
  12486. /**
  12487. * Fired when a scale box is dragged
  12488. */
  12489. onScaleBoxDragObservable: Observable<{}>;
  12490. /**
  12491. * Fired when a scale box drag is ended
  12492. */
  12493. onScaleBoxDragEndObservable: Observable<{}>;
  12494. /**
  12495. * Fired when a rotation sphere is dragged
  12496. */
  12497. onRotationSphereDragObservable: Observable<{}>;
  12498. /**
  12499. * Fired when a rotation sphere drag is ended
  12500. */
  12501. onRotationSphereDragEndObservable: Observable<{}>;
  12502. /**
  12503. * 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)
  12504. */
  12505. scalePivot: Nullable<Vector3>;
  12506. private _anchorMesh;
  12507. private _existingMeshScale;
  12508. private static _PivotCached;
  12509. private static _OldPivotPoint;
  12510. private static _PivotTranslation;
  12511. private static _PivotTmpVector;
  12512. /** @hidden */
  12513. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  12514. /** @hidden */
  12515. static _RestorePivotPoint(mesh: AbstractMesh): void;
  12516. /**
  12517. * Creates an BoundingBoxGizmo
  12518. * @param gizmoLayer The utility layer the gizmo will be added to
  12519. * @param color The color of the gizmo
  12520. */
  12521. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12522. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12523. private _selectNode;
  12524. /**
  12525. * Updates the bounding box information for the Gizmo
  12526. */
  12527. updateBoundingBox(): void;
  12528. /**
  12529. * Enables rotation on the specified axis and disables rotation on the others
  12530. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  12531. */
  12532. setEnabledRotationAxis(axis: string): void;
  12533. /**
  12534. * Disposes of the gizmo
  12535. */
  12536. dispose(): void;
  12537. /**
  12538. * 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)
  12539. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  12540. * @returns the bounding box mesh with the passed in mesh as a child
  12541. */
  12542. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  12543. /**
  12544. * CustomMeshes are not supported by this gizmo
  12545. * @param mesh The mesh to replace the default mesh of the gizmo
  12546. */
  12547. setCustomMesh(mesh: Mesh): void;
  12548. }
  12549. }
  12550. declare module BABYLON {
  12551. /**
  12552. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  12553. */
  12554. class Gizmo implements IDisposable {
  12555. /** The utility layer the gizmo will be added to */
  12556. gizmoLayer: UtilityLayerRenderer;
  12557. /**
  12558. * The root mesh of the gizmo
  12559. */
  12560. protected _rootMesh: Mesh;
  12561. private _attachedMesh;
  12562. /**
  12563. * Ratio for the scale of the gizmo (Default: 1)
  12564. */
  12565. scaleRatio: number;
  12566. private _tmpMatrix;
  12567. /**
  12568. * If a custom mesh has been set (Default: false)
  12569. */
  12570. protected _customMeshSet: boolean;
  12571. /**
  12572. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  12573. * * When set, interactions will be enabled
  12574. */
  12575. attachedMesh: Nullable<AbstractMesh>;
  12576. /**
  12577. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  12578. * @param mesh The mesh to replace the default mesh of the gizmo
  12579. */
  12580. setCustomMesh(mesh: Mesh): void;
  12581. /**
  12582. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  12583. */
  12584. updateGizmoRotationToMatchAttachedMesh: boolean;
  12585. /**
  12586. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  12587. */
  12588. updateGizmoPositionToMatchAttachedMesh: boolean;
  12589. /**
  12590. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  12591. */
  12592. protected _updateScale: boolean;
  12593. protected _interactionsEnabled: boolean;
  12594. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12595. private _beforeRenderObserver;
  12596. /**
  12597. * Creates a gizmo
  12598. * @param gizmoLayer The utility layer the gizmo will be added to
  12599. */
  12600. constructor(
  12601. /** The utility layer the gizmo will be added to */
  12602. gizmoLayer?: UtilityLayerRenderer);
  12603. private _tempVector;
  12604. /**
  12605. * @hidden
  12606. * Updates the gizmo to match the attached mesh's position/rotation
  12607. */
  12608. protected _update(): void;
  12609. /**
  12610. * Disposes of the gizmo
  12611. */
  12612. dispose(): void;
  12613. }
  12614. }
  12615. declare module BABYLON {
  12616. /**
  12617. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  12618. */
  12619. class GizmoManager implements IDisposable {
  12620. private scene;
  12621. /**
  12622. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  12623. */
  12624. gizmos: {
  12625. positionGizmo: Nullable<PositionGizmo>;
  12626. rotationGizmo: Nullable<RotationGizmo>;
  12627. scaleGizmo: Nullable<ScaleGizmo>;
  12628. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  12629. };
  12630. private _gizmosEnabled;
  12631. private _pointerObserver;
  12632. private _attachedMesh;
  12633. private _boundingBoxColor;
  12634. private _defaultUtilityLayer;
  12635. private _defaultKeepDepthUtilityLayer;
  12636. /**
  12637. * When bounding box gizmo is enabled, this can be used to track drag/end events
  12638. */
  12639. boundingBoxDragBehavior: SixDofDragBehavior;
  12640. /**
  12641. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  12642. */
  12643. attachableMeshes: Nullable<Array<AbstractMesh>>;
  12644. /**
  12645. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  12646. */
  12647. usePointerToAttachGizmos: boolean;
  12648. /**
  12649. * Instatiates a gizmo manager
  12650. * @param scene the scene to overlay the gizmos on top of
  12651. */
  12652. constructor(scene: Scene);
  12653. /**
  12654. * Attaches a set of gizmos to the specified mesh
  12655. * @param mesh The mesh the gizmo's should be attached to
  12656. */
  12657. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  12658. /**
  12659. * If the position gizmo is enabled
  12660. */
  12661. positionGizmoEnabled: boolean;
  12662. /**
  12663. * If the rotation gizmo is enabled
  12664. */
  12665. rotationGizmoEnabled: boolean;
  12666. /**
  12667. * If the scale gizmo is enabled
  12668. */
  12669. scaleGizmoEnabled: boolean;
  12670. /**
  12671. * If the boundingBox gizmo is enabled
  12672. */
  12673. boundingBoxGizmoEnabled: boolean;
  12674. /**
  12675. * Disposes of the gizmo manager
  12676. */
  12677. dispose(): void;
  12678. }
  12679. }
  12680. declare module BABYLON {
  12681. /**
  12682. * Single plane rotation gizmo
  12683. */
  12684. class PlaneRotationGizmo extends Gizmo {
  12685. /**
  12686. * Drag behavior responsible for the gizmos dragging interactions
  12687. */
  12688. dragBehavior: PointerDragBehavior;
  12689. private _pointerObserver;
  12690. /**
  12691. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  12692. */
  12693. snapDistance: number;
  12694. /**
  12695. * Event that fires each time the gizmo snaps to a new location.
  12696. * * snapDistance is the the change in distance
  12697. */
  12698. onSnapObservable: Observable<{
  12699. snapDistance: number;
  12700. }>;
  12701. /**
  12702. * Creates a PlaneRotationGizmo
  12703. * @param gizmoLayer The utility layer the gizmo will be added to
  12704. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  12705. * @param color The color of the gizmo
  12706. * @param tessellation Amount of tessellation to be used when creating rotation circles
  12707. */
  12708. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  12709. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12710. /**
  12711. * Disposes of the gizmo
  12712. */
  12713. dispose(): void;
  12714. }
  12715. }
  12716. declare module BABYLON {
  12717. /**
  12718. * Gizmo that enables dragging a mesh along 3 axis
  12719. */
  12720. class PositionGizmo extends Gizmo {
  12721. /**
  12722. * Internal gizmo used for interactions on the x axis
  12723. */
  12724. xGizmo: AxisDragGizmo;
  12725. /**
  12726. * Internal gizmo used for interactions on the y axis
  12727. */
  12728. yGizmo: AxisDragGizmo;
  12729. /**
  12730. * Internal gizmo used for interactions on the z axis
  12731. */
  12732. zGizmo: AxisDragGizmo;
  12733. /** Fires an event when any of it's sub gizmos are dragged */
  12734. onDragStartObservable: Observable<{}>;
  12735. /** Fires an event when any of it's sub gizmos are released from dragging */
  12736. onDragEndObservable: Observable<{}>;
  12737. attachedMesh: Nullable<AbstractMesh>;
  12738. /**
  12739. * Creates a PositionGizmo
  12740. * @param gizmoLayer The utility layer the gizmo will be added to
  12741. */
  12742. constructor(gizmoLayer?: UtilityLayerRenderer);
  12743. updateGizmoRotationToMatchAttachedMesh: boolean;
  12744. /**
  12745. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12746. */
  12747. snapDistance: number;
  12748. /**
  12749. * Ratio for the scale of the gizmo (Default: 1)
  12750. */
  12751. scaleRatio: number;
  12752. /**
  12753. * Disposes of the gizmo
  12754. */
  12755. dispose(): void;
  12756. /**
  12757. * CustomMeshes are not supported by this gizmo
  12758. * @param mesh The mesh to replace the default mesh of the gizmo
  12759. */
  12760. setCustomMesh(mesh: Mesh): void;
  12761. }
  12762. }
  12763. declare module BABYLON {
  12764. /**
  12765. * Gizmo that enables rotating a mesh along 3 axis
  12766. */
  12767. class RotationGizmo extends Gizmo {
  12768. /**
  12769. * Internal gizmo used for interactions on the x axis
  12770. */
  12771. xGizmo: PlaneRotationGizmo;
  12772. /**
  12773. * Internal gizmo used for interactions on the y axis
  12774. */
  12775. yGizmo: PlaneRotationGizmo;
  12776. /**
  12777. * Internal gizmo used for interactions on the z axis
  12778. */
  12779. zGizmo: PlaneRotationGizmo;
  12780. /** Fires an event when any of it's sub gizmos are dragged */
  12781. onDragStartObservable: Observable<{}>;
  12782. /** Fires an event when any of it's sub gizmos are released from dragging */
  12783. onDragEndObservable: Observable<{}>;
  12784. attachedMesh: Nullable<AbstractMesh>;
  12785. /**
  12786. * Creates a RotationGizmo
  12787. * @param gizmoLayer The utility layer the gizmo will be added to
  12788. * @param tessellation Amount of tessellation to be used when creating rotation circles
  12789. */
  12790. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  12791. updateGizmoRotationToMatchAttachedMesh: boolean;
  12792. /**
  12793. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12794. */
  12795. snapDistance: number;
  12796. /**
  12797. * Ratio for the scale of the gizmo (Default: 1)
  12798. */
  12799. scaleRatio: number;
  12800. /**
  12801. * Disposes of the gizmo
  12802. */
  12803. dispose(): void;
  12804. /**
  12805. * CustomMeshes are not supported by this gizmo
  12806. * @param mesh The mesh to replace the default mesh of the gizmo
  12807. */
  12808. setCustomMesh(mesh: Mesh): void;
  12809. }
  12810. }
  12811. declare module BABYLON {
  12812. /**
  12813. * Gizmo that enables scaling a mesh along 3 axis
  12814. */
  12815. class ScaleGizmo extends Gizmo {
  12816. /**
  12817. * Internal gizmo used for interactions on the x axis
  12818. */
  12819. xGizmo: AxisScaleGizmo;
  12820. /**
  12821. * Internal gizmo used for interactions on the y axis
  12822. */
  12823. yGizmo: AxisScaleGizmo;
  12824. /**
  12825. * Internal gizmo used for interactions on the z axis
  12826. */
  12827. zGizmo: AxisScaleGizmo;
  12828. /**
  12829. * Internal gizmo used to scale all axis equally
  12830. */
  12831. uniformScaleGizmo: AxisScaleGizmo;
  12832. /** Fires an event when any of it's sub gizmos are dragged */
  12833. onDragStartObservable: Observable<{}>;
  12834. /** Fires an event when any of it's sub gizmos are released from dragging */
  12835. onDragEndObservable: Observable<{}>;
  12836. attachedMesh: Nullable<AbstractMesh>;
  12837. /**
  12838. * Creates a ScaleGizmo
  12839. * @param gizmoLayer The utility layer the gizmo will be added to
  12840. */
  12841. constructor(gizmoLayer?: UtilityLayerRenderer);
  12842. updateGizmoRotationToMatchAttachedMesh: boolean;
  12843. /**
  12844. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12845. */
  12846. snapDistance: number;
  12847. /**
  12848. * Ratio for the scale of the gizmo (Default: 1)
  12849. */
  12850. scaleRatio: number;
  12851. /**
  12852. * Disposes of the gizmo
  12853. */
  12854. dispose(): void;
  12855. }
  12856. }
  12857. declare module BABYLON {
  12858. /**
  12859. * Represents a gamepad control stick position
  12860. */
  12861. class StickValues {
  12862. /**
  12863. * The x component of the control stick
  12864. */
  12865. x: number;
  12866. /**
  12867. * The y component of the control stick
  12868. */
  12869. y: number;
  12870. /**
  12871. * Initializes the gamepad x and y control stick values
  12872. * @param x The x component of the gamepad control stick value
  12873. * @param y The y component of the gamepad control stick value
  12874. */
  12875. constructor(
  12876. /**
  12877. * The x component of the control stick
  12878. */
  12879. x: number,
  12880. /**
  12881. * The y component of the control stick
  12882. */
  12883. y: number);
  12884. }
  12885. /**
  12886. * An interface which manages callbacks for gamepad button changes
  12887. */
  12888. interface GamepadButtonChanges {
  12889. /**
  12890. * Called when a gamepad has been changed
  12891. */
  12892. changed: boolean;
  12893. /**
  12894. * Called when a gamepad press event has been triggered
  12895. */
  12896. pressChanged: boolean;
  12897. /**
  12898. * Called when a touch event has been triggered
  12899. */
  12900. touchChanged: boolean;
  12901. /**
  12902. * Called when a value has changed
  12903. */
  12904. valueChanged: boolean;
  12905. }
  12906. /**
  12907. * Represents a gamepad
  12908. */
  12909. class Gamepad {
  12910. /**
  12911. * The id of the gamepad
  12912. */
  12913. id: string;
  12914. /**
  12915. * The index of the gamepad
  12916. */
  12917. index: number;
  12918. /**
  12919. * The browser gamepad
  12920. */
  12921. browserGamepad: any;
  12922. /**
  12923. * Specifies what type of gamepad this represents
  12924. */
  12925. type: number;
  12926. private _leftStick;
  12927. private _rightStick;
  12928. /** @hidden */
  12929. _isConnected: boolean;
  12930. private _leftStickAxisX;
  12931. private _leftStickAxisY;
  12932. private _rightStickAxisX;
  12933. private _rightStickAxisY;
  12934. /**
  12935. * Triggered when the left control stick has been changed
  12936. */
  12937. private _onleftstickchanged;
  12938. /**
  12939. * Triggered when the right control stick has been changed
  12940. */
  12941. private _onrightstickchanged;
  12942. /**
  12943. * Represents a gamepad controller
  12944. */
  12945. static GAMEPAD: number;
  12946. /**
  12947. * Represents a generic controller
  12948. */
  12949. static GENERIC: number;
  12950. /**
  12951. * Represents an XBox controller
  12952. */
  12953. static XBOX: number;
  12954. /**
  12955. * Represents a pose-enabled controller
  12956. */
  12957. static POSE_ENABLED: number;
  12958. /**
  12959. * Specifies whether the left control stick should be Y-inverted
  12960. */
  12961. protected _invertLeftStickY: boolean;
  12962. /**
  12963. * Specifies if the gamepad has been connected
  12964. */
  12965. readonly isConnected: boolean;
  12966. /**
  12967. * Initializes the gamepad
  12968. * @param id The id of the gamepad
  12969. * @param index The index of the gamepad
  12970. * @param browserGamepad The browser gamepad
  12971. * @param leftStickX The x component of the left joystick
  12972. * @param leftStickY The y component of the left joystick
  12973. * @param rightStickX The x component of the right joystick
  12974. * @param rightStickY The y component of the right joystick
  12975. */
  12976. constructor(
  12977. /**
  12978. * The id of the gamepad
  12979. */
  12980. id: string,
  12981. /**
  12982. * The index of the gamepad
  12983. */
  12984. index: number,
  12985. /**
  12986. * The browser gamepad
  12987. */
  12988. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12989. /**
  12990. * Callback triggered when the left joystick has changed
  12991. * @param callback
  12992. */
  12993. onleftstickchanged(callback: (values: StickValues) => void): void;
  12994. /**
  12995. * Callback triggered when the right joystick has changed
  12996. * @param callback
  12997. */
  12998. onrightstickchanged(callback: (values: StickValues) => void): void;
  12999. /**
  13000. * Gets the left joystick
  13001. */
  13002. /**
  13003. * Sets the left joystick values
  13004. */
  13005. leftStick: StickValues;
  13006. /**
  13007. * Gets the right joystick
  13008. */
  13009. /**
  13010. * Sets the right joystick value
  13011. */
  13012. rightStick: StickValues;
  13013. /**
  13014. * Updates the gamepad joystick positions
  13015. */
  13016. update(): void;
  13017. /**
  13018. * Disposes the gamepad
  13019. */
  13020. dispose(): void;
  13021. }
  13022. /**
  13023. * Represents a generic gamepad
  13024. */
  13025. class GenericPad extends Gamepad {
  13026. private _buttons;
  13027. private _onbuttondown;
  13028. private _onbuttonup;
  13029. /**
  13030. * Observable triggered when a button has been pressed
  13031. */
  13032. onButtonDownObservable: Observable<number>;
  13033. /**
  13034. * Observable triggered when a button has been released
  13035. */
  13036. onButtonUpObservable: Observable<number>;
  13037. /**
  13038. * Callback triggered when a button has been pressed
  13039. * @param callback Called when a button has been pressed
  13040. */
  13041. onbuttondown(callback: (buttonPressed: number) => void): void;
  13042. /**
  13043. * Callback triggered when a button has been released
  13044. * @param callback Called when a button has been released
  13045. */
  13046. onbuttonup(callback: (buttonReleased: number) => void): void;
  13047. /**
  13048. * Initializes the generic gamepad
  13049. * @param id The id of the generic gamepad
  13050. * @param index The index of the generic gamepad
  13051. * @param browserGamepad The browser gamepad
  13052. */
  13053. constructor(id: string, index: number, browserGamepad: any);
  13054. private _setButtonValue;
  13055. /**
  13056. * Updates the generic gamepad
  13057. */
  13058. update(): void;
  13059. /**
  13060. * Disposes the generic gamepad
  13061. */
  13062. dispose(): void;
  13063. }
  13064. }
  13065. declare module BABYLON {
  13066. /**
  13067. * Manager for handling gamepads
  13068. */
  13069. class GamepadManager {
  13070. private _scene?;
  13071. private _babylonGamepads;
  13072. private _oneGamepadConnected;
  13073. /** @hidden */
  13074. _isMonitoring: boolean;
  13075. private _gamepadEventSupported;
  13076. private _gamepadSupport;
  13077. /**
  13078. * observable to be triggered when the gamepad controller has been connected
  13079. */
  13080. onGamepadConnectedObservable: Observable<Gamepad>;
  13081. /**
  13082. * observable to be triggered when the gamepad controller has been disconnected
  13083. */
  13084. onGamepadDisconnectedObservable: Observable<Gamepad>;
  13085. private _onGamepadConnectedEvent;
  13086. private _onGamepadDisconnectedEvent;
  13087. /**
  13088. * Initializes the gamepad manager
  13089. * @param _scene BabylonJS scene
  13090. */
  13091. constructor(_scene?: Scene | undefined);
  13092. /**
  13093. * The gamepads in the game pad manager
  13094. */
  13095. readonly gamepads: Gamepad[];
  13096. /**
  13097. * Get the gamepad controllers based on type
  13098. * @param type The type of gamepad controller
  13099. * @returns Nullable gamepad
  13100. */
  13101. getGamepadByType(type?: number): Nullable<Gamepad>;
  13102. /**
  13103. * Disposes the gamepad manager
  13104. */
  13105. dispose(): void;
  13106. private _addNewGamepad;
  13107. private _startMonitoringGamepads;
  13108. private _stopMonitoringGamepads;
  13109. /** @hidden */
  13110. _checkGamepadsStatus(): void;
  13111. private _updateGamepadObjects;
  13112. }
  13113. }
  13114. declare module BABYLON {
  13115. interface Scene {
  13116. /** @hidden */
  13117. _gamepadManager: Nullable<GamepadManager>;
  13118. /**
  13119. * Gets the gamepad manager associated with the scene
  13120. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  13121. */
  13122. gamepadManager: GamepadManager;
  13123. }
  13124. /**
  13125. * Interface representing a free camera inputs manager
  13126. */
  13127. interface FreeCameraInputsManager {
  13128. /**
  13129. * Adds gamepad input support to the FreeCameraInputsManager.
  13130. * @returns the FreeCameraInputsManager
  13131. */
  13132. addGamepad(): FreeCameraInputsManager;
  13133. }
  13134. /**
  13135. * Interface representing an arc rotate camera inputs manager
  13136. */
  13137. interface ArcRotateCameraInputsManager {
  13138. /**
  13139. * Adds gamepad input support to the ArcRotateCamera InputManager.
  13140. * @returns the camera inputs manager
  13141. */
  13142. addGamepad(): ArcRotateCameraInputsManager;
  13143. }
  13144. /**
  13145. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  13146. */
  13147. class GamepadSystemSceneComponent implements ISceneComponent {
  13148. /**
  13149. * The component name helpfull to identify the component in the list of scene components.
  13150. */
  13151. readonly name: string;
  13152. /**
  13153. * The scene the component belongs to.
  13154. */
  13155. scene: Scene;
  13156. /**
  13157. * Creates a new instance of the component for the given scene
  13158. * @param scene Defines the scene to register the component in
  13159. */
  13160. constructor(scene: Scene);
  13161. /**
  13162. * Registers the component in a given scene
  13163. */
  13164. register(): void;
  13165. /**
  13166. * Rebuilds the elements related to this component in case of
  13167. * context lost for instance.
  13168. */
  13169. rebuild(): void;
  13170. /**
  13171. * Disposes the component and the associated ressources
  13172. */
  13173. dispose(): void;
  13174. private _beforeCameraUpdate;
  13175. }
  13176. }
  13177. declare module BABYLON {
  13178. /**
  13179. * Defines supported buttons for XBox360 compatible gamepads
  13180. */
  13181. enum Xbox360Button {
  13182. /** A */
  13183. A = 0,
  13184. /** B */
  13185. B = 1,
  13186. /** X */
  13187. X = 2,
  13188. /** Y */
  13189. Y = 3,
  13190. /** Start */
  13191. Start = 4,
  13192. /** Back */
  13193. Back = 5,
  13194. /** Left button */
  13195. LB = 6,
  13196. /** Right button */
  13197. RB = 7,
  13198. /** Left stick */
  13199. LeftStick = 8,
  13200. /** Right stick */
  13201. RightStick = 9
  13202. }
  13203. /** Defines values for XBox360 DPad */
  13204. enum Xbox360Dpad {
  13205. /** Up */
  13206. Up = 0,
  13207. /** Down */
  13208. Down = 1,
  13209. /** Left */
  13210. Left = 2,
  13211. /** Right */
  13212. Right = 3
  13213. }
  13214. /**
  13215. * Defines a XBox360 gamepad
  13216. */
  13217. class Xbox360Pad extends Gamepad {
  13218. private _leftTrigger;
  13219. private _rightTrigger;
  13220. private _onlefttriggerchanged;
  13221. private _onrighttriggerchanged;
  13222. private _onbuttondown;
  13223. private _onbuttonup;
  13224. private _ondpaddown;
  13225. private _ondpadup;
  13226. /** Observable raised when a button is pressed */
  13227. onButtonDownObservable: Observable<Xbox360Button>;
  13228. /** Observable raised when a button is released */
  13229. onButtonUpObservable: Observable<Xbox360Button>;
  13230. /** Observable raised when a pad is pressed */
  13231. onPadDownObservable: Observable<Xbox360Dpad>;
  13232. /** Observable raised when a pad is released */
  13233. onPadUpObservable: Observable<Xbox360Dpad>;
  13234. private _buttonA;
  13235. private _buttonB;
  13236. private _buttonX;
  13237. private _buttonY;
  13238. private _buttonBack;
  13239. private _buttonStart;
  13240. private _buttonLB;
  13241. private _buttonRB;
  13242. private _buttonLeftStick;
  13243. private _buttonRightStick;
  13244. private _dPadUp;
  13245. private _dPadDown;
  13246. private _dPadLeft;
  13247. private _dPadRight;
  13248. private _isXboxOnePad;
  13249. /**
  13250. * Creates a new XBox360 gamepad object
  13251. * @param id defines the id of this gamepad
  13252. * @param index defines its index
  13253. * @param gamepad defines the internal HTML gamepad object
  13254. * @param xboxOne defines if it is a XBox One gamepad
  13255. */
  13256. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  13257. /**
  13258. * Defines the callback to call when left trigger is pressed
  13259. * @param callback defines the callback to use
  13260. */
  13261. onlefttriggerchanged(callback: (value: number) => void): void;
  13262. /**
  13263. * Defines the callback to call when right trigger is pressed
  13264. * @param callback defines the callback to use
  13265. */
  13266. onrighttriggerchanged(callback: (value: number) => void): void;
  13267. /**
  13268. * Gets the left trigger value
  13269. */
  13270. /**
  13271. * Sets the left trigger value
  13272. */
  13273. leftTrigger: number;
  13274. /**
  13275. * Gets the right trigger value
  13276. */
  13277. /**
  13278. * Sets the right trigger value
  13279. */
  13280. rightTrigger: number;
  13281. /**
  13282. * Defines the callback to call when a button is pressed
  13283. * @param callback defines the callback to use
  13284. */
  13285. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  13286. /**
  13287. * Defines the callback to call when a button is released
  13288. * @param callback defines the callback to use
  13289. */
  13290. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  13291. /**
  13292. * Defines the callback to call when a pad is pressed
  13293. * @param callback defines the callback to use
  13294. */
  13295. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  13296. /**
  13297. * Defines the callback to call when a pad is released
  13298. * @param callback defines the callback to use
  13299. */
  13300. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  13301. private _setButtonValue;
  13302. private _setDPadValue;
  13303. /**
  13304. * Gets the value of the `A` button
  13305. */
  13306. /**
  13307. * Sets the value of the `A` button
  13308. */
  13309. buttonA: number;
  13310. /**
  13311. * Gets the value of the `B` button
  13312. */
  13313. /**
  13314. * Sets the value of the `B` button
  13315. */
  13316. buttonB: number;
  13317. /**
  13318. * Gets the value of the `X` button
  13319. */
  13320. /**
  13321. * Sets the value of the `X` button
  13322. */
  13323. buttonX: number;
  13324. /**
  13325. * Gets the value of the `Y` button
  13326. */
  13327. /**
  13328. * Sets the value of the `Y` button
  13329. */
  13330. buttonY: number;
  13331. /**
  13332. * Gets the value of the `Start` button
  13333. */
  13334. /**
  13335. * Sets the value of the `Start` button
  13336. */
  13337. buttonStart: number;
  13338. /**
  13339. * Gets the value of the `Back` button
  13340. */
  13341. /**
  13342. * Sets the value of the `Back` button
  13343. */
  13344. buttonBack: number;
  13345. /**
  13346. * Gets the value of the `Left` button
  13347. */
  13348. /**
  13349. * Sets the value of the `Left` button
  13350. */
  13351. buttonLB: number;
  13352. /**
  13353. * Gets the value of the `Right` button
  13354. */
  13355. /**
  13356. * Sets the value of the `Right` button
  13357. */
  13358. buttonRB: number;
  13359. /**
  13360. * Gets the value of the Left joystick
  13361. */
  13362. /**
  13363. * Sets the value of the Left joystick
  13364. */
  13365. buttonLeftStick: number;
  13366. /**
  13367. * Gets the value of the Right joystick
  13368. */
  13369. /**
  13370. * Sets the value of the Right joystick
  13371. */
  13372. buttonRightStick: number;
  13373. /**
  13374. * Gets the value of D-pad up
  13375. */
  13376. /**
  13377. * Sets the value of D-pad up
  13378. */
  13379. dPadUp: number;
  13380. /**
  13381. * Gets the value of D-pad down
  13382. */
  13383. /**
  13384. * Sets the value of D-pad down
  13385. */
  13386. dPadDown: number;
  13387. /**
  13388. * Gets the value of D-pad left
  13389. */
  13390. /**
  13391. * Sets the value of D-pad left
  13392. */
  13393. dPadLeft: number;
  13394. /**
  13395. * Gets the value of D-pad right
  13396. */
  13397. /**
  13398. * Sets the value of D-pad right
  13399. */
  13400. dPadRight: number;
  13401. /**
  13402. * Force the gamepad to synchronize with device values
  13403. */
  13404. update(): void;
  13405. /**
  13406. * Disposes the gamepad
  13407. */
  13408. dispose(): void;
  13409. }
  13410. }
  13411. declare module BABYLON {
  13412. /**
  13413. * Represents the different options available during the creation of
  13414. * a Environment helper.
  13415. *
  13416. * This can control the default ground, skybox and image processing setup of your scene.
  13417. */
  13418. interface IEnvironmentHelperOptions {
  13419. /**
  13420. * Specifies wether or not to create a ground.
  13421. * True by default.
  13422. */
  13423. createGround: boolean;
  13424. /**
  13425. * Specifies the ground size.
  13426. * 15 by default.
  13427. */
  13428. groundSize: number;
  13429. /**
  13430. * The texture used on the ground for the main color.
  13431. * Comes from the BabylonJS CDN by default.
  13432. *
  13433. * Remarks: Can be either a texture or a url.
  13434. */
  13435. groundTexture: string | BaseTexture;
  13436. /**
  13437. * The color mixed in the ground texture by default.
  13438. * BabylonJS clearColor by default.
  13439. */
  13440. groundColor: Color3;
  13441. /**
  13442. * Specifies the ground opacity.
  13443. * 1 by default.
  13444. */
  13445. groundOpacity: number;
  13446. /**
  13447. * Enables the ground to receive shadows.
  13448. * True by default.
  13449. */
  13450. enableGroundShadow: boolean;
  13451. /**
  13452. * Helps preventing the shadow to be fully black on the ground.
  13453. * 0.5 by default.
  13454. */
  13455. groundShadowLevel: number;
  13456. /**
  13457. * Creates a mirror texture attach to the ground.
  13458. * false by default.
  13459. */
  13460. enableGroundMirror: boolean;
  13461. /**
  13462. * Specifies the ground mirror size ratio.
  13463. * 0.3 by default as the default kernel is 64.
  13464. */
  13465. groundMirrorSizeRatio: number;
  13466. /**
  13467. * Specifies the ground mirror blur kernel size.
  13468. * 64 by default.
  13469. */
  13470. groundMirrorBlurKernel: number;
  13471. /**
  13472. * Specifies the ground mirror visibility amount.
  13473. * 1 by default
  13474. */
  13475. groundMirrorAmount: number;
  13476. /**
  13477. * Specifies the ground mirror reflectance weight.
  13478. * This uses the standard weight of the background material to setup the fresnel effect
  13479. * of the mirror.
  13480. * 1 by default.
  13481. */
  13482. groundMirrorFresnelWeight: number;
  13483. /**
  13484. * Specifies the ground mirror Falloff distance.
  13485. * This can helps reducing the size of the reflection.
  13486. * 0 by Default.
  13487. */
  13488. groundMirrorFallOffDistance: number;
  13489. /**
  13490. * Specifies the ground mirror texture type.
  13491. * Unsigned Int by Default.
  13492. */
  13493. groundMirrorTextureType: number;
  13494. /**
  13495. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13496. * the shown objects.
  13497. */
  13498. groundYBias: number;
  13499. /**
  13500. * Specifies wether or not to create a skybox.
  13501. * True by default.
  13502. */
  13503. createSkybox: boolean;
  13504. /**
  13505. * Specifies the skybox size.
  13506. * 20 by default.
  13507. */
  13508. skyboxSize: number;
  13509. /**
  13510. * The texture used on the skybox for the main color.
  13511. * Comes from the BabylonJS CDN by default.
  13512. *
  13513. * Remarks: Can be either a texture or a url.
  13514. */
  13515. skyboxTexture: string | BaseTexture;
  13516. /**
  13517. * The color mixed in the skybox texture by default.
  13518. * BabylonJS clearColor by default.
  13519. */
  13520. skyboxColor: Color3;
  13521. /**
  13522. * The background rotation around the Y axis of the scene.
  13523. * This helps aligning the key lights of your scene with the background.
  13524. * 0 by default.
  13525. */
  13526. backgroundYRotation: number;
  13527. /**
  13528. * Compute automatically the size of the elements to best fit with the scene.
  13529. */
  13530. sizeAuto: boolean;
  13531. /**
  13532. * Default position of the rootMesh if autoSize is not true.
  13533. */
  13534. rootPosition: Vector3;
  13535. /**
  13536. * Sets up the image processing in the scene.
  13537. * true by default.
  13538. */
  13539. setupImageProcessing: boolean;
  13540. /**
  13541. * The texture used as your environment texture in the scene.
  13542. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13543. *
  13544. * Remarks: Can be either a texture or a url.
  13545. */
  13546. environmentTexture: string | BaseTexture;
  13547. /**
  13548. * The value of the exposure to apply to the scene.
  13549. * 0.6 by default if setupImageProcessing is true.
  13550. */
  13551. cameraExposure: number;
  13552. /**
  13553. * The value of the contrast to apply to the scene.
  13554. * 1.6 by default if setupImageProcessing is true.
  13555. */
  13556. cameraContrast: number;
  13557. /**
  13558. * Specifies wether or not tonemapping should be enabled in the scene.
  13559. * true by default if setupImageProcessing is true.
  13560. */
  13561. toneMappingEnabled: boolean;
  13562. }
  13563. /**
  13564. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13565. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13566. * It also helps with the default setup of your imageProcessing configuration.
  13567. */
  13568. class EnvironmentHelper {
  13569. /**
  13570. * Default ground texture URL.
  13571. */
  13572. private static _groundTextureCDNUrl;
  13573. /**
  13574. * Default skybox texture URL.
  13575. */
  13576. private static _skyboxTextureCDNUrl;
  13577. /**
  13578. * Default environment texture URL.
  13579. */
  13580. private static _environmentTextureCDNUrl;
  13581. /**
  13582. * Creates the default options for the helper.
  13583. */
  13584. private static _getDefaultOptions;
  13585. private _rootMesh;
  13586. /**
  13587. * Gets the root mesh created by the helper.
  13588. */
  13589. readonly rootMesh: Mesh;
  13590. private _skybox;
  13591. /**
  13592. * Gets the skybox created by the helper.
  13593. */
  13594. readonly skybox: Nullable<Mesh>;
  13595. private _skyboxTexture;
  13596. /**
  13597. * Gets the skybox texture created by the helper.
  13598. */
  13599. readonly skyboxTexture: Nullable<BaseTexture>;
  13600. private _skyboxMaterial;
  13601. /**
  13602. * Gets the skybox material created by the helper.
  13603. */
  13604. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13605. private _ground;
  13606. /**
  13607. * Gets the ground mesh created by the helper.
  13608. */
  13609. readonly ground: Nullable<Mesh>;
  13610. private _groundTexture;
  13611. /**
  13612. * Gets the ground texture created by the helper.
  13613. */
  13614. readonly groundTexture: Nullable<BaseTexture>;
  13615. private _groundMirror;
  13616. /**
  13617. * Gets the ground mirror created by the helper.
  13618. */
  13619. readonly groundMirror: Nullable<MirrorTexture>;
  13620. /**
  13621. * Gets the ground mirror render list to helps pushing the meshes
  13622. * you wish in the ground reflection.
  13623. */
  13624. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13625. private _groundMaterial;
  13626. /**
  13627. * Gets the ground material created by the helper.
  13628. */
  13629. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13630. /**
  13631. * Stores the creation options.
  13632. */
  13633. private readonly _scene;
  13634. private _options;
  13635. /**
  13636. * This observable will be notified with any error during the creation of the environment,
  13637. * mainly texture creation errors.
  13638. */
  13639. onErrorObservable: Observable<{
  13640. message?: string;
  13641. exception?: any;
  13642. }>;
  13643. /**
  13644. * constructor
  13645. * @param options
  13646. * @param scene The scene to add the material to
  13647. */
  13648. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13649. /**
  13650. * Updates the background according to the new options
  13651. * @param options
  13652. */
  13653. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13654. /**
  13655. * Sets the primary color of all the available elements.
  13656. * @param color the main color to affect to the ground and the background
  13657. */
  13658. setMainColor(color: Color3): void;
  13659. /**
  13660. * Setup the image processing according to the specified options.
  13661. */
  13662. private _setupImageProcessing;
  13663. /**
  13664. * Setup the environment texture according to the specified options.
  13665. */
  13666. private _setupEnvironmentTexture;
  13667. /**
  13668. * Setup the background according to the specified options.
  13669. */
  13670. private _setupBackground;
  13671. /**
  13672. * Get the scene sizes according to the setup.
  13673. */
  13674. private _getSceneSize;
  13675. /**
  13676. * Setup the ground according to the specified options.
  13677. */
  13678. private _setupGround;
  13679. /**
  13680. * Setup the ground material according to the specified options.
  13681. */
  13682. private _setupGroundMaterial;
  13683. /**
  13684. * Setup the ground diffuse texture according to the specified options.
  13685. */
  13686. private _setupGroundDiffuseTexture;
  13687. /**
  13688. * Setup the ground mirror texture according to the specified options.
  13689. */
  13690. private _setupGroundMirrorTexture;
  13691. /**
  13692. * Setup the ground to receive the mirror texture.
  13693. */
  13694. private _setupMirrorInGroundMaterial;
  13695. /**
  13696. * Setup the skybox according to the specified options.
  13697. */
  13698. private _setupSkybox;
  13699. /**
  13700. * Setup the skybox material according to the specified options.
  13701. */
  13702. private _setupSkyboxMaterial;
  13703. /**
  13704. * Setup the skybox reflection texture according to the specified options.
  13705. */
  13706. private _setupSkyboxReflectionTexture;
  13707. private _errorHandler;
  13708. /**
  13709. * Dispose all the elements created by the Helper.
  13710. */
  13711. dispose(): void;
  13712. }
  13713. }
  13714. declare module BABYLON {
  13715. /**
  13716. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13717. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13718. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13719. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13720. */
  13721. class PhotoDome extends TransformNode {
  13722. private _useDirectMapping;
  13723. /**
  13724. * The texture being displayed on the sphere
  13725. */
  13726. protected _photoTexture: Texture;
  13727. /**
  13728. * Gets or sets the texture being displayed on the sphere
  13729. */
  13730. photoTexture: Texture;
  13731. /**
  13732. * Observable raised when an error occured while loading the 360 image
  13733. */
  13734. onLoadErrorObservable: Observable<string>;
  13735. /**
  13736. * The skybox material
  13737. */
  13738. protected _material: BackgroundMaterial;
  13739. /**
  13740. * The surface used for the skybox
  13741. */
  13742. protected _mesh: Mesh;
  13743. /**
  13744. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13745. * Also see the options.resolution property.
  13746. */
  13747. fovMultiplier: number;
  13748. /**
  13749. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13750. * @param name Element's name, child elements will append suffixes for their own names.
  13751. * @param urlsOfPhoto defines the url of the photo to display
  13752. * @param options defines an object containing optional or exposed sub element properties
  13753. * @param onError defines a callback called when an error occured while loading the texture
  13754. */
  13755. constructor(name: string, urlOfPhoto: string, options: {
  13756. resolution?: number;
  13757. size?: number;
  13758. useDirectMapping?: boolean;
  13759. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13760. /**
  13761. * Releases resources associated with this node.
  13762. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13763. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13764. */
  13765. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13766. }
  13767. }
  13768. declare module BABYLON {
  13769. interface Scene {
  13770. /**
  13771. * Creates a default light for the scene.
  13772. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13773. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13774. */
  13775. createDefaultLight(replace?: boolean): void;
  13776. /**
  13777. * Creates a default camera for the scene.
  13778. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13779. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13780. * @param replace has default false, when true replaces the active camera in the scene
  13781. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13782. */
  13783. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13784. /**
  13785. * Creates a default camera and a default light.
  13786. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  13787. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13788. * @param replace has the default false, when true replaces the active camera/light in the scene
  13789. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  13790. */
  13791. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13792. /**
  13793. * Creates a new sky box
  13794. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  13795. * @param environmentTexture defines the texture to use as environment texture
  13796. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  13797. * @param scale defines the overall scale of the skybox
  13798. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  13799. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  13800. * @returns a new mesh holding the sky box
  13801. */
  13802. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  13803. /**
  13804. * Creates a new environment
  13805. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  13806. * @param options defines the options you can use to configure the environment
  13807. * @returns the new EnvironmentHelper
  13808. */
  13809. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  13810. /**
  13811. * Creates a new VREXperienceHelper
  13812. * @see http://doc.babylonjs.com/how_to/webvr_helper
  13813. * @param webVROptions defines the options used to create the new VREXperienceHelper
  13814. * @returns a new VREXperienceHelper
  13815. */
  13816. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  13817. /**
  13818. * Creates a new XREXperienceHelper
  13819. * @see http://doc.babylonjs.com/how_to/webxr
  13820. * @returns a promise for a new XREXperienceHelper
  13821. */
  13822. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  13823. }
  13824. }
  13825. declare module BABYLON {
  13826. /**
  13827. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  13828. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  13829. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  13830. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13831. */
  13832. class VideoDome extends TransformNode {
  13833. private _useDirectMapping;
  13834. /**
  13835. * The video texture being displayed on the sphere
  13836. */
  13837. protected _videoTexture: VideoTexture;
  13838. /**
  13839. * Gets the video texture being displayed on the sphere
  13840. */
  13841. readonly videoTexture: VideoTexture;
  13842. /**
  13843. * The skybox material
  13844. */
  13845. protected _material: BackgroundMaterial;
  13846. /**
  13847. * The surface used for the skybox
  13848. */
  13849. protected _mesh: Mesh;
  13850. /**
  13851. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13852. * Also see the options.resolution property.
  13853. */
  13854. fovMultiplier: number;
  13855. /**
  13856. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  13857. * @param name Element's name, child elements will append suffixes for their own names.
  13858. * @param urlsOrVideo defines the url(s) or the video element to use
  13859. * @param options An object containing optional or exposed sub element properties
  13860. */
  13861. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  13862. resolution?: number;
  13863. clickToPlay?: boolean;
  13864. autoPlay?: boolean;
  13865. loop?: boolean;
  13866. size?: number;
  13867. poster?: string;
  13868. useDirectMapping?: boolean;
  13869. }, scene: Scene);
  13870. /**
  13871. * Releases resources associated with this node.
  13872. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13873. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13874. */
  13875. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13876. }
  13877. }
  13878. declare module BABYLON {
  13879. /**
  13880. * This class can be used to get instrumentation data from a Babylon engine
  13881. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13882. */
  13883. class EngineInstrumentation implements IDisposable {
  13884. /**
  13885. * Define the instrumented engine.
  13886. */
  13887. engine: Engine;
  13888. private _captureGPUFrameTime;
  13889. private _gpuFrameTimeToken;
  13890. private _gpuFrameTime;
  13891. private _captureShaderCompilationTime;
  13892. private _shaderCompilationTime;
  13893. private _onBeginFrameObserver;
  13894. private _onEndFrameObserver;
  13895. private _onBeforeShaderCompilationObserver;
  13896. private _onAfterShaderCompilationObserver;
  13897. /**
  13898. * Gets the perf counter used for GPU frame time
  13899. */
  13900. readonly gpuFrameTimeCounter: PerfCounter;
  13901. /**
  13902. * Gets the GPU frame time capture status
  13903. */
  13904. /**
  13905. * Enable or disable the GPU frame time capture
  13906. */
  13907. captureGPUFrameTime: boolean;
  13908. /**
  13909. * Gets the perf counter used for shader compilation time
  13910. */
  13911. readonly shaderCompilationTimeCounter: PerfCounter;
  13912. /**
  13913. * Gets the shader compilation time capture status
  13914. */
  13915. /**
  13916. * Enable or disable the shader compilation time capture
  13917. */
  13918. captureShaderCompilationTime: boolean;
  13919. /**
  13920. * Instantiates a new engine instrumentation.
  13921. * This class can be used to get instrumentation data from a Babylon engine
  13922. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13923. * @param engine Defines the engine to instrument
  13924. */
  13925. constructor(
  13926. /**
  13927. * Define the instrumented engine.
  13928. */
  13929. engine: Engine);
  13930. /**
  13931. * Dispose and release associated resources.
  13932. */
  13933. dispose(): void;
  13934. }
  13935. }
  13936. declare module BABYLON {
  13937. /**
  13938. * This class can be used to get instrumentation data from a Babylon engine
  13939. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  13940. */
  13941. class SceneInstrumentation implements IDisposable {
  13942. /**
  13943. * Defines the scene to instrument
  13944. */
  13945. scene: Scene;
  13946. private _captureActiveMeshesEvaluationTime;
  13947. private _activeMeshesEvaluationTime;
  13948. private _captureRenderTargetsRenderTime;
  13949. private _renderTargetsRenderTime;
  13950. private _captureFrameTime;
  13951. private _frameTime;
  13952. private _captureRenderTime;
  13953. private _renderTime;
  13954. private _captureInterFrameTime;
  13955. private _interFrameTime;
  13956. private _captureParticlesRenderTime;
  13957. private _particlesRenderTime;
  13958. private _captureSpritesRenderTime;
  13959. private _spritesRenderTime;
  13960. private _capturePhysicsTime;
  13961. private _physicsTime;
  13962. private _captureAnimationsTime;
  13963. private _animationsTime;
  13964. private _captureCameraRenderTime;
  13965. private _cameraRenderTime;
  13966. private _onBeforeActiveMeshesEvaluationObserver;
  13967. private _onAfterActiveMeshesEvaluationObserver;
  13968. private _onBeforeRenderTargetsRenderObserver;
  13969. private _onAfterRenderTargetsRenderObserver;
  13970. private _onAfterRenderObserver;
  13971. private _onBeforeDrawPhaseObserver;
  13972. private _onAfterDrawPhaseObserver;
  13973. private _onBeforeAnimationsObserver;
  13974. private _onBeforeParticlesRenderingObserver;
  13975. private _onAfterParticlesRenderingObserver;
  13976. private _onBeforeSpritesRenderingObserver;
  13977. private _onAfterSpritesRenderingObserver;
  13978. private _onBeforePhysicsObserver;
  13979. private _onAfterPhysicsObserver;
  13980. private _onAfterAnimationsObserver;
  13981. private _onBeforeCameraRenderObserver;
  13982. private _onAfterCameraRenderObserver;
  13983. /**
  13984. * Gets the perf counter used for active meshes evaluation time
  13985. */
  13986. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  13987. /**
  13988. * Gets the active meshes evaluation time capture status
  13989. */
  13990. /**
  13991. * Enable or disable the active meshes evaluation time capture
  13992. */
  13993. captureActiveMeshesEvaluationTime: boolean;
  13994. /**
  13995. * Gets the perf counter used for render targets render time
  13996. */
  13997. readonly renderTargetsRenderTimeCounter: PerfCounter;
  13998. /**
  13999. * Gets the render targets render time capture status
  14000. */
  14001. /**
  14002. * Enable or disable the render targets render time capture
  14003. */
  14004. captureRenderTargetsRenderTime: boolean;
  14005. /**
  14006. * Gets the perf counter used for particles render time
  14007. */
  14008. readonly particlesRenderTimeCounter: PerfCounter;
  14009. /**
  14010. * Gets the particles render time capture status
  14011. */
  14012. /**
  14013. * Enable or disable the particles render time capture
  14014. */
  14015. captureParticlesRenderTime: boolean;
  14016. /**
  14017. * Gets the perf counter used for sprites render time
  14018. */
  14019. readonly spritesRenderTimeCounter: PerfCounter;
  14020. /**
  14021. * Gets the sprites render time capture status
  14022. */
  14023. /**
  14024. * Enable or disable the sprites render time capture
  14025. */
  14026. captureSpritesRenderTime: boolean;
  14027. /**
  14028. * Gets the perf counter used for physics time
  14029. */
  14030. readonly physicsTimeCounter: PerfCounter;
  14031. /**
  14032. * Gets the physics time capture status
  14033. */
  14034. /**
  14035. * Enable or disable the physics time capture
  14036. */
  14037. capturePhysicsTime: boolean;
  14038. /**
  14039. * Gets the perf counter used for animations time
  14040. */
  14041. readonly animationsTimeCounter: PerfCounter;
  14042. /**
  14043. * Gets the animations time capture status
  14044. */
  14045. /**
  14046. * Enable or disable the animations time capture
  14047. */
  14048. captureAnimationsTime: boolean;
  14049. /**
  14050. * Gets the perf counter used for frame time capture
  14051. */
  14052. readonly frameTimeCounter: PerfCounter;
  14053. /**
  14054. * Gets the frame time capture status
  14055. */
  14056. /**
  14057. * Enable or disable the frame time capture
  14058. */
  14059. captureFrameTime: boolean;
  14060. /**
  14061. * Gets the perf counter used for inter-frames time capture
  14062. */
  14063. readonly interFrameTimeCounter: PerfCounter;
  14064. /**
  14065. * Gets the inter-frames time capture status
  14066. */
  14067. /**
  14068. * Enable or disable the inter-frames time capture
  14069. */
  14070. captureInterFrameTime: boolean;
  14071. /**
  14072. * Gets the perf counter used for render time capture
  14073. */
  14074. readonly renderTimeCounter: PerfCounter;
  14075. /**
  14076. * Gets the render time capture status
  14077. */
  14078. /**
  14079. * Enable or disable the render time capture
  14080. */
  14081. captureRenderTime: boolean;
  14082. /**
  14083. * Gets the perf counter used for camera render time capture
  14084. */
  14085. readonly cameraRenderTimeCounter: PerfCounter;
  14086. /**
  14087. * Gets the camera render time capture status
  14088. */
  14089. /**
  14090. * Enable or disable the camera render time capture
  14091. */
  14092. captureCameraRenderTime: boolean;
  14093. /**
  14094. * Gets the perf counter used for draw calls
  14095. */
  14096. readonly drawCallsCounter: PerfCounter;
  14097. /**
  14098. * Gets the perf counter used for texture collisions
  14099. */
  14100. readonly textureCollisionsCounter: PerfCounter;
  14101. /**
  14102. * Instantiates a new scene instrumentation.
  14103. * This class can be used to get instrumentation data from a Babylon engine
  14104. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14105. * @param scene Defines the scene to instrument
  14106. */
  14107. constructor(
  14108. /**
  14109. * Defines the scene to instrument
  14110. */
  14111. scene: Scene);
  14112. /**
  14113. * Dispose and release associated resources.
  14114. */
  14115. dispose(): void;
  14116. }
  14117. }
  14118. declare module BABYLON {
  14119. /**
  14120. * @hidden
  14121. **/
  14122. class _TimeToken {
  14123. _startTimeQuery: Nullable<WebGLQuery>;
  14124. _endTimeQuery: Nullable<WebGLQuery>;
  14125. _timeElapsedQuery: Nullable<WebGLQuery>;
  14126. _timeElapsedQueryEnded: boolean;
  14127. }
  14128. }
  14129. declare module BABYLON {
  14130. /**
  14131. * Effect layer options. This helps customizing the behaviour
  14132. * of the effect layer.
  14133. */
  14134. interface IEffectLayerOptions {
  14135. /**
  14136. * Multiplication factor apply to the canvas size to compute the render target size
  14137. * used to generated the objects (the smaller the faster).
  14138. */
  14139. mainTextureRatio: number;
  14140. /**
  14141. * Enforces a fixed size texture to ensure effect stability across devices.
  14142. */
  14143. mainTextureFixedSize?: number;
  14144. /**
  14145. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14146. */
  14147. alphaBlendingMode: number;
  14148. /**
  14149. * The camera attached to the layer.
  14150. */
  14151. camera: Nullable<Camera>;
  14152. /**
  14153. * The rendering group to draw the layer in.
  14154. */
  14155. renderingGroupId: number;
  14156. }
  14157. /**
  14158. * The effect layer Helps adding post process effect blended with the main pass.
  14159. *
  14160. * This can be for instance use to generate glow or higlight effects on the scene.
  14161. *
  14162. * The effect layer class can not be used directly and is intented to inherited from to be
  14163. * customized per effects.
  14164. */
  14165. abstract class EffectLayer {
  14166. private _vertexBuffers;
  14167. private _indexBuffer;
  14168. private _cachedDefines;
  14169. private _effectLayerMapGenerationEffect;
  14170. private _effectLayerOptions;
  14171. private _mergeEffect;
  14172. protected _scene: Scene;
  14173. protected _engine: Engine;
  14174. protected _maxSize: number;
  14175. protected _mainTextureDesiredSize: ISize;
  14176. protected _mainTexture: RenderTargetTexture;
  14177. protected _shouldRender: boolean;
  14178. protected _postProcesses: PostProcess[];
  14179. protected _textures: BaseTexture[];
  14180. protected _emissiveTextureAndColor: {
  14181. texture: Nullable<BaseTexture>;
  14182. color: Color4;
  14183. };
  14184. /**
  14185. * The name of the layer
  14186. */
  14187. name: string;
  14188. /**
  14189. * The clear color of the texture used to generate the glow map.
  14190. */
  14191. neutralColor: Color4;
  14192. /**
  14193. * Specifies wether the highlight layer is enabled or not.
  14194. */
  14195. isEnabled: boolean;
  14196. /**
  14197. * Gets the camera attached to the layer.
  14198. */
  14199. readonly camera: Nullable<Camera>;
  14200. /**
  14201. * Gets the rendering group id the layer should render in.
  14202. */
  14203. readonly renderingGroupId: number;
  14204. /**
  14205. * An event triggered when the effect layer has been disposed.
  14206. */
  14207. onDisposeObservable: Observable<EffectLayer>;
  14208. /**
  14209. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14210. */
  14211. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14212. /**
  14213. * An event triggered when the generated texture is being merged in the scene.
  14214. */
  14215. onBeforeComposeObservable: Observable<EffectLayer>;
  14216. /**
  14217. * An event triggered when the generated texture has been merged in the scene.
  14218. */
  14219. onAfterComposeObservable: Observable<EffectLayer>;
  14220. /**
  14221. * An event triggered when the efffect layer changes its size.
  14222. */
  14223. onSizeChangedObservable: Observable<EffectLayer>;
  14224. /**
  14225. * Instantiates a new effect Layer and references it in the scene.
  14226. * @param name The name of the layer
  14227. * @param scene The scene to use the layer in
  14228. */
  14229. constructor(
  14230. /** The Friendly of the effect in the scene */
  14231. name: string, scene: Scene);
  14232. /**
  14233. * Get the effect name of the layer.
  14234. * @return The effect name
  14235. */
  14236. abstract getEffectName(): string;
  14237. /**
  14238. * Checks for the readiness of the element composing the layer.
  14239. * @param subMesh the mesh to check for
  14240. * @param useInstances specify wether or not to use instances to render the mesh
  14241. * @return true if ready otherwise, false
  14242. */
  14243. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14244. /**
  14245. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14246. * @returns true if the effect requires stencil during the main canvas render pass.
  14247. */
  14248. abstract needStencil(): boolean;
  14249. /**
  14250. * Create the merge effect. This is the shader use to blit the information back
  14251. * to the main canvas at the end of the scene rendering.
  14252. * @returns The effect containing the shader used to merge the effect on the main canvas
  14253. */
  14254. protected abstract _createMergeEffect(): Effect;
  14255. /**
  14256. * Creates the render target textures and post processes used in the effect layer.
  14257. */
  14258. protected abstract _createTextureAndPostProcesses(): void;
  14259. /**
  14260. * Implementation specific of rendering the generating effect on the main canvas.
  14261. * @param effect The effect used to render through
  14262. */
  14263. protected abstract _internalRender(effect: Effect): void;
  14264. /**
  14265. * Sets the required values for both the emissive texture and and the main color.
  14266. */
  14267. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14268. /**
  14269. * Free any resources and references associated to a mesh.
  14270. * Internal use
  14271. * @param mesh The mesh to free.
  14272. */
  14273. abstract _disposeMesh(mesh: Mesh): void;
  14274. /**
  14275. * Serializes this layer (Glow or Highlight for example)
  14276. * @returns a serialized layer object
  14277. */
  14278. abstract serialize?(): any;
  14279. /**
  14280. * Initializes the effect layer with the required options.
  14281. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14282. */
  14283. protected _init(options: Partial<IEffectLayerOptions>): void;
  14284. /**
  14285. * Generates the index buffer of the full screen quad blending to the main canvas.
  14286. */
  14287. private _generateIndexBuffer;
  14288. /**
  14289. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14290. */
  14291. private _genrateVertexBuffer;
  14292. /**
  14293. * Sets the main texture desired size which is the closest power of two
  14294. * of the engine canvas size.
  14295. */
  14296. private _setMainTextureSize;
  14297. /**
  14298. * Creates the main texture for the effect layer.
  14299. */
  14300. protected _createMainTexture(): void;
  14301. /**
  14302. * Checks for the readiness of the element composing the layer.
  14303. * @param subMesh the mesh to check for
  14304. * @param useInstances specify wether or not to use instances to render the mesh
  14305. * @param emissiveTexture the associated emissive texture used to generate the glow
  14306. * @return true if ready otherwise, false
  14307. */
  14308. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14309. /**
  14310. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14311. */
  14312. render(): void;
  14313. /**
  14314. * Determine if a given mesh will be used in the current effect.
  14315. * @param mesh mesh to test
  14316. * @returns true if the mesh will be used
  14317. */
  14318. hasMesh(mesh: AbstractMesh): boolean;
  14319. /**
  14320. * Returns true if the layer contains information to display, otherwise false.
  14321. * @returns true if the glow layer should be rendered
  14322. */
  14323. shouldRender(): boolean;
  14324. /**
  14325. * Returns true if the mesh should render, otherwise false.
  14326. * @param mesh The mesh to render
  14327. * @returns true if it should render otherwise false
  14328. */
  14329. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14330. /**
  14331. * Returns true if the mesh should render, otherwise false.
  14332. * @param mesh The mesh to render
  14333. * @returns true if it should render otherwise false
  14334. */
  14335. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14336. /**
  14337. * Renders the submesh passed in parameter to the generation map.
  14338. */
  14339. protected _renderSubMesh(subMesh: SubMesh): void;
  14340. /**
  14341. * Rebuild the required buffers.
  14342. * @hidden Internal use only.
  14343. */
  14344. _rebuild(): void;
  14345. /**
  14346. * Dispose only the render target textures and post process.
  14347. */
  14348. private _disposeTextureAndPostProcesses;
  14349. /**
  14350. * Dispose the highlight layer and free resources.
  14351. */
  14352. dispose(): void;
  14353. /**
  14354. * Gets the class name of the effect layer
  14355. * @returns the string with the class name of the effect layer
  14356. */
  14357. getClassName(): string;
  14358. /**
  14359. * Creates an effect layer from parsed effect layer data
  14360. * @param parsedEffectLayer defines effect layer data
  14361. * @param scene defines the current scene
  14362. * @param rootUrl defines the root URL containing the effect layer information
  14363. * @returns a parsed effect Layer
  14364. */
  14365. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14366. }
  14367. }
  14368. declare module BABYLON {
  14369. interface AbstractScene {
  14370. /**
  14371. * The list of effect layers (highlights/glow) added to the scene
  14372. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14373. * @see http://doc.babylonjs.com/how_to/glow_layer
  14374. */
  14375. effectLayers: Array<EffectLayer>;
  14376. /**
  14377. * Removes the given effect layer from this scene.
  14378. * @param toRemove defines the effect layer to remove
  14379. * @returns the index of the removed effect layer
  14380. */
  14381. removeEffectLayer(toRemove: EffectLayer): number;
  14382. /**
  14383. * Adds the given effect layer to this scene
  14384. * @param newEffectLayer defines the effect layer to add
  14385. */
  14386. addEffectLayer(newEffectLayer: EffectLayer): void;
  14387. }
  14388. /**
  14389. * Defines the layer scene component responsible to manage any effect layers
  14390. * in a given scene.
  14391. */
  14392. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14393. /**
  14394. * The component name helpfull to identify the component in the list of scene components.
  14395. */
  14396. readonly name: string;
  14397. /**
  14398. * The scene the component belongs to.
  14399. */
  14400. scene: Scene;
  14401. private _engine;
  14402. private _renderEffects;
  14403. private _needStencil;
  14404. private _previousStencilState;
  14405. /**
  14406. * Creates a new instance of the component for the given scene
  14407. * @param scene Defines the scene to register the component in
  14408. */
  14409. constructor(scene: Scene);
  14410. /**
  14411. * Registers the component in a given scene
  14412. */
  14413. register(): void;
  14414. /**
  14415. * Rebuilds the elements related to this component in case of
  14416. * context lost for instance.
  14417. */
  14418. rebuild(): void;
  14419. /**
  14420. * Serializes the component data to the specified json object
  14421. * @param serializationObject The object to serialize to
  14422. */
  14423. serialize(serializationObject: any): void;
  14424. /**
  14425. * Adds all the element from the container to the scene
  14426. * @param container the container holding the elements
  14427. */
  14428. addFromContainer(container: AbstractScene): void;
  14429. /**
  14430. * Removes all the elements in the container from the scene
  14431. * @param container contains the elements to remove
  14432. */
  14433. removeFromContainer(container: AbstractScene): void;
  14434. /**
  14435. * Disposes the component and the associated ressources.
  14436. */
  14437. dispose(): void;
  14438. private _isReadyForMesh;
  14439. private _renderMainTexture;
  14440. private _setStencil;
  14441. private _setStencilBack;
  14442. private _draw;
  14443. private _drawCamera;
  14444. private _drawRenderingGroup;
  14445. }
  14446. }
  14447. declare module BABYLON {
  14448. interface AbstractScene {
  14449. /**
  14450. * Return a the first highlight layer of the scene with a given name.
  14451. * @param name The name of the highlight layer to look for.
  14452. * @return The highlight layer if found otherwise null.
  14453. */
  14454. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14455. }
  14456. /**
  14457. * Glow layer options. This helps customizing the behaviour
  14458. * of the glow layer.
  14459. */
  14460. interface IGlowLayerOptions {
  14461. /**
  14462. * Multiplication factor apply to the canvas size to compute the render target size
  14463. * used to generated the glowing objects (the smaller the faster).
  14464. */
  14465. mainTextureRatio: number;
  14466. /**
  14467. * Enforces a fixed size texture to ensure resize independant blur.
  14468. */
  14469. mainTextureFixedSize?: number;
  14470. /**
  14471. * How big is the kernel of the blur texture.
  14472. */
  14473. blurKernelSize: number;
  14474. /**
  14475. * The camera attached to the layer.
  14476. */
  14477. camera: Nullable<Camera>;
  14478. /**
  14479. * Enable MSAA by chosing the number of samples.
  14480. */
  14481. mainTextureSamples?: number;
  14482. /**
  14483. * The rendering group to draw the layer in.
  14484. */
  14485. renderingGroupId: number;
  14486. }
  14487. /**
  14488. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14489. *
  14490. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14491. * glowy meshes to your scene.
  14492. *
  14493. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14494. */
  14495. class GlowLayer extends EffectLayer {
  14496. /**
  14497. * Effect Name of the layer.
  14498. */
  14499. static readonly EffectName: string;
  14500. /**
  14501. * The default blur kernel size used for the glow.
  14502. */
  14503. static DefaultBlurKernelSize: number;
  14504. /**
  14505. * The default texture size ratio used for the glow.
  14506. */
  14507. static DefaultTextureRatio: number;
  14508. /**
  14509. * Sets the kernel size of the blur.
  14510. */
  14511. /**
  14512. * Gets the kernel size of the blur.
  14513. */
  14514. blurKernelSize: number;
  14515. /**
  14516. * Sets the glow intensity.
  14517. */
  14518. /**
  14519. * Gets the glow intensity.
  14520. */
  14521. intensity: number;
  14522. private _options;
  14523. private _intensity;
  14524. private _horizontalBlurPostprocess1;
  14525. private _verticalBlurPostprocess1;
  14526. private _horizontalBlurPostprocess2;
  14527. private _verticalBlurPostprocess2;
  14528. private _blurTexture1;
  14529. private _blurTexture2;
  14530. private _postProcesses1;
  14531. private _postProcesses2;
  14532. private _includedOnlyMeshes;
  14533. private _excludedMeshes;
  14534. /**
  14535. * Callback used to let the user override the color selection on a per mesh basis
  14536. */
  14537. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14538. /**
  14539. * Callback used to let the user override the texture selection on a per mesh basis
  14540. */
  14541. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14542. /**
  14543. * Instantiates a new glow Layer and references it to the scene.
  14544. * @param name The name of the layer
  14545. * @param scene The scene to use the layer in
  14546. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14547. */
  14548. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14549. /**
  14550. * Get the effect name of the layer.
  14551. * @return The effect name
  14552. */
  14553. getEffectName(): string;
  14554. /**
  14555. * Create the merge effect. This is the shader use to blit the information back
  14556. * to the main canvas at the end of the scene rendering.
  14557. */
  14558. protected _createMergeEffect(): Effect;
  14559. /**
  14560. * Creates the render target textures and post processes used in the glow layer.
  14561. */
  14562. protected _createTextureAndPostProcesses(): void;
  14563. /**
  14564. * Checks for the readiness of the element composing the layer.
  14565. * @param subMesh the mesh to check for
  14566. * @param useInstances specify wether or not to use instances to render the mesh
  14567. * @param emissiveTexture the associated emissive texture used to generate the glow
  14568. * @return true if ready otherwise, false
  14569. */
  14570. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14571. /**
  14572. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14573. */
  14574. needStencil(): boolean;
  14575. /**
  14576. * Implementation specific of rendering the generating effect on the main canvas.
  14577. * @param effect The effect used to render through
  14578. */
  14579. protected _internalRender(effect: Effect): void;
  14580. /**
  14581. * Sets the required values for both the emissive texture and and the main color.
  14582. */
  14583. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14584. /**
  14585. * Returns true if the mesh should render, otherwise false.
  14586. * @param mesh The mesh to render
  14587. * @returns true if it should render otherwise false
  14588. */
  14589. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14590. /**
  14591. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14592. * @param mesh The mesh to exclude from the glow layer
  14593. */
  14594. addExcludedMesh(mesh: Mesh): void;
  14595. /**
  14596. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14597. * @param mesh The mesh to remove
  14598. */
  14599. removeExcludedMesh(mesh: Mesh): void;
  14600. /**
  14601. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14602. * @param mesh The mesh to include in the glow layer
  14603. */
  14604. addIncludedOnlyMesh(mesh: Mesh): void;
  14605. /**
  14606. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14607. * @param mesh The mesh to remove
  14608. */
  14609. removeIncludedOnlyMesh(mesh: Mesh): void;
  14610. /**
  14611. * Determine if a given mesh will be used in the glow layer
  14612. * @param mesh The mesh to test
  14613. * @returns true if the mesh will be highlighted by the current glow layer
  14614. */
  14615. hasMesh(mesh: AbstractMesh): boolean;
  14616. /**
  14617. * Free any resources and references associated to a mesh.
  14618. * Internal use
  14619. * @param mesh The mesh to free.
  14620. * @hidden
  14621. */
  14622. _disposeMesh(mesh: Mesh): void;
  14623. /**
  14624. * Gets the class name of the effect layer
  14625. * @returns the string with the class name of the effect layer
  14626. */
  14627. getClassName(): string;
  14628. /**
  14629. * Serializes this glow layer
  14630. * @returns a serialized glow layer object
  14631. */
  14632. serialize(): any;
  14633. /**
  14634. * Creates a Glow Layer from parsed glow layer data
  14635. * @param parsedGlowLayer defines glow layer data
  14636. * @param scene defines the current scene
  14637. * @param rootUrl defines the root URL containing the glow layer information
  14638. * @returns a parsed Glow Layer
  14639. */
  14640. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14641. }
  14642. }
  14643. declare module BABYLON {
  14644. interface AbstractScene {
  14645. /**
  14646. * Return a the first highlight layer of the scene with a given name.
  14647. * @param name The name of the highlight layer to look for.
  14648. * @return The highlight layer if found otherwise null.
  14649. */
  14650. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14651. }
  14652. /**
  14653. * Highlight layer options. This helps customizing the behaviour
  14654. * of the highlight layer.
  14655. */
  14656. interface IHighlightLayerOptions {
  14657. /**
  14658. * Multiplication factor apply to the canvas size to compute the render target size
  14659. * used to generated the glowing objects (the smaller the faster).
  14660. */
  14661. mainTextureRatio: number;
  14662. /**
  14663. * Enforces a fixed size texture to ensure resize independant blur.
  14664. */
  14665. mainTextureFixedSize?: number;
  14666. /**
  14667. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14668. * of the picture to blur (the smaller the faster).
  14669. */
  14670. blurTextureSizeRatio: number;
  14671. /**
  14672. * How big in texel of the blur texture is the vertical blur.
  14673. */
  14674. blurVerticalSize: number;
  14675. /**
  14676. * How big in texel of the blur texture is the horizontal blur.
  14677. */
  14678. blurHorizontalSize: number;
  14679. /**
  14680. * Alpha blending mode used to apply the blur. Default is combine.
  14681. */
  14682. alphaBlendingMode: number;
  14683. /**
  14684. * The camera attached to the layer.
  14685. */
  14686. camera: Nullable<Camera>;
  14687. /**
  14688. * Should we display highlight as a solid stroke?
  14689. */
  14690. isStroke?: boolean;
  14691. /**
  14692. * The rendering group to draw the layer in.
  14693. */
  14694. renderingGroupId: number;
  14695. }
  14696. /**
  14697. * The highlight layer Helps adding a glow effect around a mesh.
  14698. *
  14699. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14700. * glowy meshes to your scene.
  14701. *
  14702. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14703. */
  14704. class HighlightLayer extends EffectLayer {
  14705. name: string;
  14706. /**
  14707. * Effect Name of the highlight layer.
  14708. */
  14709. static readonly EffectName: string;
  14710. /**
  14711. * The neutral color used during the preparation of the glow effect.
  14712. * This is black by default as the blend operation is a blend operation.
  14713. */
  14714. static NeutralColor: Color4;
  14715. /**
  14716. * Stencil value used for glowing meshes.
  14717. */
  14718. static GlowingMeshStencilReference: number;
  14719. /**
  14720. * Stencil value used for the other meshes in the scene.
  14721. */
  14722. static NormalMeshStencilReference: number;
  14723. /**
  14724. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14725. */
  14726. innerGlow: boolean;
  14727. /**
  14728. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14729. */
  14730. outerGlow: boolean;
  14731. /**
  14732. * Specifies the horizontal size of the blur.
  14733. */
  14734. /**
  14735. * Gets the horizontal size of the blur.
  14736. */
  14737. blurHorizontalSize: number;
  14738. /**
  14739. * Specifies the vertical size of the blur.
  14740. */
  14741. /**
  14742. * Gets the vertical size of the blur.
  14743. */
  14744. blurVerticalSize: number;
  14745. /**
  14746. * An event triggered when the highlight layer is being blurred.
  14747. */
  14748. onBeforeBlurObservable: Observable<HighlightLayer>;
  14749. /**
  14750. * An event triggered when the highlight layer has been blurred.
  14751. */
  14752. onAfterBlurObservable: Observable<HighlightLayer>;
  14753. private _instanceGlowingMeshStencilReference;
  14754. private _options;
  14755. private _downSamplePostprocess;
  14756. private _horizontalBlurPostprocess;
  14757. private _verticalBlurPostprocess;
  14758. private _blurTexture;
  14759. private _meshes;
  14760. private _excludedMeshes;
  14761. /**
  14762. * Instantiates a new highlight Layer and references it to the scene..
  14763. * @param name The name of the layer
  14764. * @param scene The scene to use the layer in
  14765. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  14766. */
  14767. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  14768. /**
  14769. * Get the effect name of the layer.
  14770. * @return The effect name
  14771. */
  14772. getEffectName(): string;
  14773. /**
  14774. * Create the merge effect. This is the shader use to blit the information back
  14775. * to the main canvas at the end of the scene rendering.
  14776. */
  14777. protected _createMergeEffect(): Effect;
  14778. /**
  14779. * Creates the render target textures and post processes used in the highlight layer.
  14780. */
  14781. protected _createTextureAndPostProcesses(): void;
  14782. /**
  14783. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14784. */
  14785. needStencil(): boolean;
  14786. /**
  14787. * Checks for the readiness of the element composing the layer.
  14788. * @param subMesh the mesh to check for
  14789. * @param useInstances specify wether or not to use instances to render the mesh
  14790. * @param emissiveTexture the associated emissive texture used to generate the glow
  14791. * @return true if ready otherwise, false
  14792. */
  14793. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14794. /**
  14795. * Implementation specific of rendering the generating effect on the main canvas.
  14796. * @param effect The effect used to render through
  14797. */
  14798. protected _internalRender(effect: Effect): void;
  14799. /**
  14800. * Returns true if the layer contains information to display, otherwise false.
  14801. */
  14802. shouldRender(): boolean;
  14803. /**
  14804. * Returns true if the mesh should render, otherwise false.
  14805. * @param mesh The mesh to render
  14806. * @returns true if it should render otherwise false
  14807. */
  14808. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14809. /**
  14810. * Sets the required values for both the emissive texture and and the main color.
  14811. */
  14812. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14813. /**
  14814. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  14815. * @param mesh The mesh to exclude from the highlight layer
  14816. */
  14817. addExcludedMesh(mesh: Mesh): void;
  14818. /**
  14819. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  14820. * @param mesh The mesh to highlight
  14821. */
  14822. removeExcludedMesh(mesh: Mesh): void;
  14823. /**
  14824. * Determine if a given mesh will be highlighted by the current HighlightLayer
  14825. * @param mesh mesh to test
  14826. * @returns true if the mesh will be highlighted by the current HighlightLayer
  14827. */
  14828. hasMesh(mesh: AbstractMesh): boolean;
  14829. /**
  14830. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  14831. * @param mesh The mesh to highlight
  14832. * @param color The color of the highlight
  14833. * @param glowEmissiveOnly Extract the glow from the emissive texture
  14834. */
  14835. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  14836. /**
  14837. * Remove a mesh from the highlight layer in order to make it stop glowing.
  14838. * @param mesh The mesh to highlight
  14839. */
  14840. removeMesh(mesh: Mesh): void;
  14841. /**
  14842. * Force the stencil to the normal expected value for none glowing parts
  14843. */
  14844. private _defaultStencilReference;
  14845. /**
  14846. * Free any resources and references associated to a mesh.
  14847. * Internal use
  14848. * @param mesh The mesh to free.
  14849. * @hidden
  14850. */
  14851. _disposeMesh(mesh: Mesh): void;
  14852. /**
  14853. * Dispose the highlight layer and free resources.
  14854. */
  14855. dispose(): void;
  14856. /**
  14857. * Gets the class name of the effect layer
  14858. * @returns the string with the class name of the effect layer
  14859. */
  14860. getClassName(): string;
  14861. /**
  14862. * Serializes this Highlight layer
  14863. * @returns a serialized Highlight layer object
  14864. */
  14865. serialize(): any;
  14866. /**
  14867. * Creates a Highlight layer from parsed Highlight layer data
  14868. * @param parsedHightlightLayer defines the Highlight layer data
  14869. * @param scene defines the current scene
  14870. * @param rootUrl defines the root URL containing the Highlight layer information
  14871. * @returns a parsed Highlight layer
  14872. */
  14873. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  14874. }
  14875. }
  14876. declare module BABYLON {
  14877. /**
  14878. * This represents a full screen 2d layer.
  14879. * This can be usefull to display a picture in the background of your scene for instance.
  14880. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14881. */
  14882. class Layer {
  14883. /**
  14884. * Define the name of the layer.
  14885. */
  14886. name: string;
  14887. /**
  14888. * Define the texture the layer should display.
  14889. */
  14890. texture: Nullable<Texture>;
  14891. /**
  14892. * Is the layer in background or foreground.
  14893. */
  14894. isBackground: boolean;
  14895. /**
  14896. * Define the color of the layer (instead of texture).
  14897. */
  14898. color: Color4;
  14899. /**
  14900. * Define the scale of the layer in order to zoom in out of the texture.
  14901. */
  14902. scale: Vector2;
  14903. /**
  14904. * Define an offset for the layer in order to shift the texture.
  14905. */
  14906. offset: Vector2;
  14907. /**
  14908. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14909. */
  14910. alphaBlendingMode: number;
  14911. /**
  14912. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14913. * Alpha test will not mix with the background color in case of transparency.
  14914. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14915. */
  14916. alphaTest: boolean;
  14917. /**
  14918. * Define a mask to restrict the layer to only some of the scene cameras.
  14919. */
  14920. layerMask: number;
  14921. private _scene;
  14922. private _vertexBuffers;
  14923. private _indexBuffer;
  14924. private _effect;
  14925. private _alphaTestEffect;
  14926. /**
  14927. * An event triggered when the layer is disposed.
  14928. */
  14929. onDisposeObservable: Observable<Layer>;
  14930. private _onDisposeObserver;
  14931. /**
  14932. * Back compatibility with callback before the onDisposeObservable existed.
  14933. * The set callback will be triggered when the layer has been disposed.
  14934. */
  14935. onDispose: () => void;
  14936. /**
  14937. * An event triggered before rendering the scene
  14938. */
  14939. onBeforeRenderObservable: Observable<Layer>;
  14940. private _onBeforeRenderObserver;
  14941. /**
  14942. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14943. * The set callback will be triggered just before rendering the layer.
  14944. */
  14945. onBeforeRender: () => void;
  14946. /**
  14947. * An event triggered after rendering the scene
  14948. */
  14949. onAfterRenderObservable: Observable<Layer>;
  14950. private _onAfterRenderObserver;
  14951. /**
  14952. * Back compatibility with callback before the onAfterRenderObservable existed.
  14953. * The set callback will be triggered just after rendering the layer.
  14954. */
  14955. onAfterRender: () => void;
  14956. /**
  14957. * Instantiates a new layer.
  14958. * This represents a full screen 2d layer.
  14959. * This can be usefull to display a picture in the background of your scene for instance.
  14960. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14961. * @param name Define the name of the layer in the scene
  14962. * @param imgUrl Define the url of the texture to display in the layer
  14963. * @param scene Define the scene the layer belongs to
  14964. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14965. * @param color Defines a color for the layer
  14966. */
  14967. constructor(
  14968. /**
  14969. * Define the name of the layer.
  14970. */
  14971. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14972. private _createIndexBuffer;
  14973. /** @hidden */
  14974. _rebuild(): void;
  14975. /**
  14976. * Renders the layer in the scene.
  14977. */
  14978. render(): void;
  14979. /**
  14980. * Disposes and releases the associated ressources.
  14981. */
  14982. dispose(): void;
  14983. }
  14984. }
  14985. declare module BABYLON {
  14986. interface AbstractScene {
  14987. /**
  14988. * The list of layers (background and foreground) of the scene
  14989. */
  14990. layers: Array<Layer>;
  14991. }
  14992. /**
  14993. * Defines the layer scene component responsible to manage any layers
  14994. * in a given scene.
  14995. */
  14996. class LayerSceneComponent implements ISceneComponent {
  14997. /**
  14998. * The component name helpfull to identify the component in the list of scene components.
  14999. */
  15000. readonly name: string;
  15001. /**
  15002. * The scene the component belongs to.
  15003. */
  15004. scene: Scene;
  15005. private _engine;
  15006. /**
  15007. * Creates a new instance of the component for the given scene
  15008. * @param scene Defines the scene to register the component in
  15009. */
  15010. constructor(scene: Scene);
  15011. /**
  15012. * Registers the component in a given scene
  15013. */
  15014. register(): void;
  15015. /**
  15016. * Rebuilds the elements related to this component in case of
  15017. * context lost for instance.
  15018. */
  15019. rebuild(): void;
  15020. /**
  15021. * Disposes the component and the associated ressources.
  15022. */
  15023. dispose(): void;
  15024. private _draw;
  15025. private _drawBackground;
  15026. private _drawForeground;
  15027. }
  15028. }
  15029. declare module BABYLON {
  15030. /**
  15031. * A directional light is defined by a direction (what a surprise!).
  15032. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15033. * 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.
  15034. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15035. */
  15036. class DirectionalLight extends ShadowLight {
  15037. private _shadowFrustumSize;
  15038. /**
  15039. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15040. */
  15041. /**
  15042. * Specifies a fix frustum size for the shadow generation.
  15043. */
  15044. shadowFrustumSize: number;
  15045. private _shadowOrthoScale;
  15046. /**
  15047. * Gets the shadow projection scale against the optimal computed one.
  15048. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15049. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15050. */
  15051. /**
  15052. * Sets the shadow projection scale against the optimal computed one.
  15053. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15054. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15055. */
  15056. shadowOrthoScale: number;
  15057. /**
  15058. * Automatically compute the projection matrix to best fit (including all the casters)
  15059. * on each frame.
  15060. */
  15061. autoUpdateExtends: boolean;
  15062. private _orthoLeft;
  15063. private _orthoRight;
  15064. private _orthoTop;
  15065. private _orthoBottom;
  15066. /**
  15067. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15068. * The directional light is emitted from everywhere in the given direction.
  15069. * It can cast shadows.
  15070. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15071. * @param name The friendly name of the light
  15072. * @param direction The direction of the light
  15073. * @param scene The scene the light belongs to
  15074. */
  15075. constructor(name: string, direction: Vector3, scene: Scene);
  15076. /**
  15077. * Returns the string "DirectionalLight".
  15078. * @return The class name
  15079. */
  15080. getClassName(): string;
  15081. /**
  15082. * Returns the integer 1.
  15083. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15084. */
  15085. getTypeID(): number;
  15086. /**
  15087. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15088. * Returns the DirectionalLight Shadow projection matrix.
  15089. */
  15090. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15091. /**
  15092. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15093. * Returns the DirectionalLight Shadow projection matrix.
  15094. */
  15095. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15096. /**
  15097. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15098. * Returns the DirectionalLight Shadow projection matrix.
  15099. */
  15100. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15101. protected _buildUniformLayout(): void;
  15102. /**
  15103. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15104. * @param effect The effect to update
  15105. * @param lightIndex The index of the light in the effect to update
  15106. * @returns The directional light
  15107. */
  15108. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15109. /**
  15110. * Gets the minZ used for shadow according to both the scene and the light.
  15111. *
  15112. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15113. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15114. * @param activeCamera The camera we are returning the min for
  15115. * @returns the depth min z
  15116. */
  15117. getDepthMinZ(activeCamera: Camera): number;
  15118. /**
  15119. * Gets the maxZ used for shadow according to both the scene and the light.
  15120. *
  15121. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15122. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15123. * @param activeCamera The camera we are returning the max for
  15124. * @returns the depth max z
  15125. */
  15126. getDepthMaxZ(activeCamera: Camera): number;
  15127. /**
  15128. * Prepares the list of defines specific to the light type.
  15129. * @param defines the list of defines
  15130. * @param lightIndex defines the index of the light for the effect
  15131. */
  15132. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15133. }
  15134. }
  15135. declare module BABYLON {
  15136. /**
  15137. * The HemisphericLight simulates the ambient environment light,
  15138. * so the passed direction is the light reflection direction, not the incoming direction.
  15139. */
  15140. class HemisphericLight extends Light {
  15141. /**
  15142. * The groundColor is the light in the opposite direction to the one specified during creation.
  15143. * 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.
  15144. */
  15145. groundColor: Color3;
  15146. /**
  15147. * The light reflection direction, not the incoming direction.
  15148. */
  15149. direction: Vector3;
  15150. /**
  15151. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15152. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15153. * The HemisphericLight can't cast shadows.
  15154. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15155. * @param name The friendly name of the light
  15156. * @param direction The direction of the light reflection
  15157. * @param scene The scene the light belongs to
  15158. */
  15159. constructor(name: string, direction: Vector3, scene: Scene);
  15160. protected _buildUniformLayout(): void;
  15161. /**
  15162. * Returns the string "HemisphericLight".
  15163. * @return The class name
  15164. */
  15165. getClassName(): string;
  15166. /**
  15167. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15168. * Returns the updated direction.
  15169. * @param target The target the direction should point to
  15170. * @return The computed direction
  15171. */
  15172. setDirectionToTarget(target: Vector3): Vector3;
  15173. /**
  15174. * Returns the shadow generator associated to the light.
  15175. * @returns Always null for hemispheric lights because it does not support shadows.
  15176. */
  15177. getShadowGenerator(): Nullable<IShadowGenerator>;
  15178. /**
  15179. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15180. * @param effect The effect to update
  15181. * @param lightIndex The index of the light in the effect to update
  15182. * @returns The hemispheric light
  15183. */
  15184. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15185. /**
  15186. * Computes the world matrix of the node
  15187. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15188. * @param useWasUpdatedFlag defines a reserved property
  15189. * @returns the world matrix
  15190. */
  15191. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15192. /**
  15193. * Returns the integer 3.
  15194. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15195. */
  15196. getTypeID(): number;
  15197. /**
  15198. * Prepares the list of defines specific to the light type.
  15199. * @param defines the list of defines
  15200. * @param lightIndex defines the index of the light for the effect
  15201. */
  15202. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15203. }
  15204. }
  15205. declare module BABYLON {
  15206. /**
  15207. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15208. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15209. * 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.
  15210. */
  15211. abstract class Light extends Node {
  15212. /**
  15213. * Falloff Default: light is falling off following the material specification:
  15214. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15215. */
  15216. static readonly FALLOFF_DEFAULT: number;
  15217. /**
  15218. * Falloff Physical: light is falling off following the inverse squared distance law.
  15219. */
  15220. static readonly FALLOFF_PHYSICAL: number;
  15221. /**
  15222. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15223. * to enhance interoperability with other engines.
  15224. */
  15225. static readonly FALLOFF_GLTF: number;
  15226. /**
  15227. * Falloff Standard: light is falling off like in the standard material
  15228. * to enhance interoperability with other materials.
  15229. */
  15230. static readonly FALLOFF_STANDARD: number;
  15231. /**
  15232. * If every light affecting the material is in this lightmapMode,
  15233. * material.lightmapTexture adds or multiplies
  15234. * (depends on material.useLightmapAsShadowmap)
  15235. * after every other light calculations.
  15236. */
  15237. static readonly LIGHTMAP_DEFAULT: number;
  15238. /**
  15239. * material.lightmapTexture as only diffuse lighting from this light
  15240. * adds only specular lighting from this light
  15241. * adds dynamic shadows
  15242. */
  15243. static readonly LIGHTMAP_SPECULAR: number;
  15244. /**
  15245. * material.lightmapTexture as only lighting
  15246. * no light calculation from this light
  15247. * only adds dynamic shadows from this light
  15248. */
  15249. static readonly LIGHTMAP_SHADOWSONLY: number;
  15250. /**
  15251. * Each light type uses the default quantity according to its type:
  15252. * point/spot lights use luminous intensity
  15253. * directional lights use illuminance
  15254. */
  15255. static readonly INTENSITYMODE_AUTOMATIC: number;
  15256. /**
  15257. * lumen (lm)
  15258. */
  15259. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15260. /**
  15261. * candela (lm/sr)
  15262. */
  15263. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15264. /**
  15265. * lux (lm/m^2)
  15266. */
  15267. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15268. /**
  15269. * nit (cd/m^2)
  15270. */
  15271. static readonly INTENSITYMODE_LUMINANCE: number;
  15272. /**
  15273. * Light type const id of the point light.
  15274. */
  15275. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15276. /**
  15277. * Light type const id of the directional light.
  15278. */
  15279. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15280. /**
  15281. * Light type const id of the spot light.
  15282. */
  15283. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15284. /**
  15285. * Light type const id of the hemispheric light.
  15286. */
  15287. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15288. /**
  15289. * Diffuse gives the basic color to an object.
  15290. */
  15291. diffuse: Color3;
  15292. /**
  15293. * Specular produces a highlight color on an object.
  15294. * Note: This is note affecting PBR materials.
  15295. */
  15296. specular: Color3;
  15297. /**
  15298. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15299. * falling off base on range or angle.
  15300. * This can be set to any values in Light.FALLOFF_x.
  15301. *
  15302. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  15303. * other types of materials.
  15304. */
  15305. falloffType: number;
  15306. /**
  15307. * Strength of the light.
  15308. * Note: By default it is define in the framework own unit.
  15309. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15310. */
  15311. intensity: number;
  15312. private _range;
  15313. protected _inverseSquaredRange: number;
  15314. /**
  15315. * Defines how far from the source the light is impacting in scene units.
  15316. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15317. */
  15318. /**
  15319. * Defines how far from the source the light is impacting in scene units.
  15320. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15321. */
  15322. range: number;
  15323. /**
  15324. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15325. * of light.
  15326. */
  15327. private _photometricScale;
  15328. private _intensityMode;
  15329. /**
  15330. * Gets the photometric scale used to interpret the intensity.
  15331. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15332. */
  15333. /**
  15334. * Sets the photometric scale used to interpret the intensity.
  15335. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15336. */
  15337. intensityMode: number;
  15338. private _radius;
  15339. /**
  15340. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15341. */
  15342. /**
  15343. * sets the light radius used by PBR Materials to simulate soft area lights.
  15344. */
  15345. radius: number;
  15346. private _renderPriority;
  15347. /**
  15348. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15349. * exceeding the number allowed of the materials.
  15350. */
  15351. renderPriority: number;
  15352. private _shadowEnabled;
  15353. /**
  15354. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15355. * the current shadow generator.
  15356. */
  15357. /**
  15358. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15359. * the current shadow generator.
  15360. */
  15361. shadowEnabled: boolean;
  15362. private _includedOnlyMeshes;
  15363. /**
  15364. * Gets the only meshes impacted by this light.
  15365. */
  15366. /**
  15367. * Sets the only meshes impacted by this light.
  15368. */
  15369. includedOnlyMeshes: AbstractMesh[];
  15370. private _excludedMeshes;
  15371. /**
  15372. * Gets the meshes not impacted by this light.
  15373. */
  15374. /**
  15375. * Sets the meshes not impacted by this light.
  15376. */
  15377. excludedMeshes: AbstractMesh[];
  15378. private _excludeWithLayerMask;
  15379. /**
  15380. * Gets the layer id use to find what meshes are not impacted by the light.
  15381. * Inactive if 0
  15382. */
  15383. /**
  15384. * Sets the layer id use to find what meshes are not impacted by the light.
  15385. * Inactive if 0
  15386. */
  15387. excludeWithLayerMask: number;
  15388. private _includeOnlyWithLayerMask;
  15389. /**
  15390. * Gets the layer id use to find what meshes are impacted by the light.
  15391. * Inactive if 0
  15392. */
  15393. /**
  15394. * Sets the layer id use to find what meshes are impacted by the light.
  15395. * Inactive if 0
  15396. */
  15397. includeOnlyWithLayerMask: number;
  15398. private _lightmapMode;
  15399. /**
  15400. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15401. */
  15402. /**
  15403. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15404. */
  15405. lightmapMode: number;
  15406. /**
  15407. * Shadow generator associted to the light.
  15408. * @hidden Internal use only.
  15409. */
  15410. _shadowGenerator: Nullable<IShadowGenerator>;
  15411. /**
  15412. * @hidden Internal use only.
  15413. */
  15414. _excludedMeshesIds: string[];
  15415. /**
  15416. * @hidden Internal use only.
  15417. */
  15418. _includedOnlyMeshesIds: string[];
  15419. /**
  15420. * The current light unifom buffer.
  15421. * @hidden Internal use only.
  15422. */
  15423. _uniformBuffer: UniformBuffer;
  15424. /**
  15425. * Creates a Light object in the scene.
  15426. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15427. * @param name The firendly name of the light
  15428. * @param scene The scene the light belongs too
  15429. */
  15430. constructor(name: string, scene: Scene);
  15431. protected abstract _buildUniformLayout(): void;
  15432. /**
  15433. * Sets the passed Effect "effect" with the Light information.
  15434. * @param effect The effect to update
  15435. * @param lightIndex The index of the light in the effect to update
  15436. * @returns The light
  15437. */
  15438. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15439. /**
  15440. * Returns the string "Light".
  15441. * @returns the class name
  15442. */
  15443. getClassName(): string;
  15444. /**
  15445. * Converts the light information to a readable string for debug purpose.
  15446. * @param fullDetails Supports for multiple levels of logging within scene loading
  15447. * @returns the human readable light info
  15448. */
  15449. toString(fullDetails?: boolean): string;
  15450. /** @hidden */
  15451. protected _syncParentEnabledState(): void;
  15452. /**
  15453. * Set the enabled state of this node.
  15454. * @param value - the new enabled state
  15455. */
  15456. setEnabled(value: boolean): void;
  15457. /**
  15458. * Returns the Light associated shadow generator if any.
  15459. * @return the associated shadow generator.
  15460. */
  15461. getShadowGenerator(): Nullable<IShadowGenerator>;
  15462. /**
  15463. * Returns a Vector3, the absolute light position in the World.
  15464. * @returns the world space position of the light
  15465. */
  15466. getAbsolutePosition(): Vector3;
  15467. /**
  15468. * Specifies if the light will affect the passed mesh.
  15469. * @param mesh The mesh to test against the light
  15470. * @return true the mesh is affected otherwise, false.
  15471. */
  15472. canAffectMesh(mesh: AbstractMesh): boolean;
  15473. /**
  15474. * Sort function to order lights for rendering.
  15475. * @param a First Light object to compare to second.
  15476. * @param b Second Light object to compare first.
  15477. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15478. */
  15479. static CompareLightsPriority(a: Light, b: Light): number;
  15480. /**
  15481. * Releases resources associated with this node.
  15482. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15483. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15484. */
  15485. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15486. /**
  15487. * Returns the light type ID (integer).
  15488. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15489. */
  15490. getTypeID(): number;
  15491. /**
  15492. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  15493. * @returns the scaled intensity in intensity mode unit
  15494. */
  15495. getScaledIntensity(): number;
  15496. /**
  15497. * Returns a new Light object, named "name", from the current one.
  15498. * @param name The name of the cloned light
  15499. * @returns the new created light
  15500. */
  15501. clone(name: string): Nullable<Light>;
  15502. /**
  15503. * Serializes the current light into a Serialization object.
  15504. * @returns the serialized object.
  15505. */
  15506. serialize(): any;
  15507. /**
  15508. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  15509. * This new light is named "name" and added to the passed scene.
  15510. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  15511. * @param name The friendly name of the light
  15512. * @param scene The scene the new light will belong to
  15513. * @returns the constructor function
  15514. */
  15515. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  15516. /**
  15517. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  15518. * @param parsedLight The JSON representation of the light
  15519. * @param scene The scene to create the parsed light in
  15520. * @returns the created light after parsing
  15521. */
  15522. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  15523. private _hookArrayForExcluded;
  15524. private _hookArrayForIncludedOnly;
  15525. private _resyncMeshes;
  15526. /**
  15527. * Forces the meshes to update their light related information in their rendering used effects
  15528. * @hidden Internal Use Only
  15529. */
  15530. _markMeshesAsLightDirty(): void;
  15531. /**
  15532. * Recomputes the cached photometric scale if needed.
  15533. */
  15534. private _computePhotometricScale;
  15535. /**
  15536. * Returns the Photometric Scale according to the light type and intensity mode.
  15537. */
  15538. private _getPhotometricScale;
  15539. /**
  15540. * Reorder the light in the scene according to their defined priority.
  15541. * @hidden Internal Use Only
  15542. */
  15543. _reorderLightsInScene(): void;
  15544. /**
  15545. * Prepares the list of defines specific to the light type.
  15546. * @param defines the list of defines
  15547. * @param lightIndex defines the index of the light for the effect
  15548. */
  15549. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15550. }
  15551. }
  15552. declare module BABYLON {
  15553. /**
  15554. * A point light is a light defined by an unique point in world space.
  15555. * The light is emitted in every direction from this point.
  15556. * A good example of a point light is a standard light bulb.
  15557. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15558. */
  15559. class PointLight extends ShadowLight {
  15560. private _shadowAngle;
  15561. /**
  15562. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15563. * This specifies what angle the shadow will use to be created.
  15564. *
  15565. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15566. */
  15567. /**
  15568. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15569. * This specifies what angle the shadow will use to be created.
  15570. *
  15571. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15572. */
  15573. shadowAngle: number;
  15574. /**
  15575. * Gets the direction if it has been set.
  15576. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15577. */
  15578. /**
  15579. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15580. */
  15581. direction: Vector3;
  15582. /**
  15583. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  15584. * A PointLight emits the light in every direction.
  15585. * It can cast shadows.
  15586. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  15587. * ```javascript
  15588. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  15589. * ```
  15590. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15591. * @param name The light friendly name
  15592. * @param position The position of the point light in the scene
  15593. * @param scene The scene the lights belongs to
  15594. */
  15595. constructor(name: string, position: Vector3, scene: Scene);
  15596. /**
  15597. * Returns the string "PointLight"
  15598. * @returns the class name
  15599. */
  15600. getClassName(): string;
  15601. /**
  15602. * Returns the integer 0.
  15603. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15604. */
  15605. getTypeID(): number;
  15606. /**
  15607. * Specifies wether or not the shadowmap should be a cube texture.
  15608. * @returns true if the shadowmap needs to be a cube texture.
  15609. */
  15610. needCube(): boolean;
  15611. /**
  15612. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  15613. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15614. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15615. */
  15616. getShadowDirection(faceIndex?: number): Vector3;
  15617. /**
  15618. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  15619. * - fov = PI / 2
  15620. * - aspect ratio : 1.0
  15621. * - z-near and far equal to the active camera minZ and maxZ.
  15622. * Returns the PointLight.
  15623. */
  15624. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15625. protected _buildUniformLayout(): void;
  15626. /**
  15627. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  15628. * @param effect The effect to update
  15629. * @param lightIndex The index of the light in the effect to update
  15630. * @returns The point light
  15631. */
  15632. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  15633. /**
  15634. * Prepares the list of defines specific to the light type.
  15635. * @param defines the list of defines
  15636. * @param lightIndex defines the index of the light for the effect
  15637. */
  15638. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15639. }
  15640. }
  15641. declare module BABYLON {
  15642. /**
  15643. * Interface describing all the common properties and methods a shadow light needs to implement.
  15644. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  15645. * as well as binding the different shadow properties to the effects.
  15646. */
  15647. interface IShadowLight extends Light {
  15648. /**
  15649. * The light id in the scene (used in scene.findLighById for instance)
  15650. */
  15651. id: string;
  15652. /**
  15653. * The position the shdow will be casted from.
  15654. */
  15655. position: Vector3;
  15656. /**
  15657. * In 2d mode (needCube being false), the direction used to cast the shadow.
  15658. */
  15659. direction: Vector3;
  15660. /**
  15661. * The transformed position. Position of the light in world space taking parenting in account.
  15662. */
  15663. transformedPosition: Vector3;
  15664. /**
  15665. * The transformed direction. Direction of the light in world space taking parenting in account.
  15666. */
  15667. transformedDirection: Vector3;
  15668. /**
  15669. * The friendly name of the light in the scene.
  15670. */
  15671. name: string;
  15672. /**
  15673. * Defines the shadow projection clipping minimum z value.
  15674. */
  15675. shadowMinZ: number;
  15676. /**
  15677. * Defines the shadow projection clipping maximum z value.
  15678. */
  15679. shadowMaxZ: number;
  15680. /**
  15681. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15682. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15683. */
  15684. computeTransformedInformation(): boolean;
  15685. /**
  15686. * Gets the scene the light belongs to.
  15687. * @returns The scene
  15688. */
  15689. getScene(): Scene;
  15690. /**
  15691. * Callback defining a custom Projection Matrix Builder.
  15692. * This can be used to override the default projection matrix computation.
  15693. */
  15694. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15695. /**
  15696. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15697. * @param matrix The materix to updated with the projection information
  15698. * @param viewMatrix The transform matrix of the light
  15699. * @param renderList The list of mesh to render in the map
  15700. * @returns The current light
  15701. */
  15702. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15703. /**
  15704. * Gets the current depth scale used in ESM.
  15705. * @returns The scale
  15706. */
  15707. getDepthScale(): number;
  15708. /**
  15709. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15710. * @returns true if a cube texture needs to be use
  15711. */
  15712. needCube(): boolean;
  15713. /**
  15714. * Detects if the projection matrix requires to be recomputed this frame.
  15715. * @returns true if it requires to be recomputed otherwise, false.
  15716. */
  15717. needProjectionMatrixCompute(): boolean;
  15718. /**
  15719. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15720. */
  15721. forceProjectionMatrixCompute(): void;
  15722. /**
  15723. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15724. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15725. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15726. */
  15727. getShadowDirection(faceIndex?: number): Vector3;
  15728. /**
  15729. * Gets the minZ used for shadow according to both the scene and the light.
  15730. * @param activeCamera The camera we are returning the min for
  15731. * @returns the depth min z
  15732. */
  15733. getDepthMinZ(activeCamera: Camera): number;
  15734. /**
  15735. * Gets the maxZ used for shadow according to both the scene and the light.
  15736. * @param activeCamera The camera we are returning the max for
  15737. * @returns the depth max z
  15738. */
  15739. getDepthMaxZ(activeCamera: Camera): number;
  15740. }
  15741. /**
  15742. * Base implementation IShadowLight
  15743. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  15744. */
  15745. abstract class ShadowLight extends Light implements IShadowLight {
  15746. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15747. protected _position: Vector3;
  15748. protected _setPosition(value: Vector3): void;
  15749. /**
  15750. * Sets the position the shadow will be casted from. Also use as the light position for both
  15751. * point and spot lights.
  15752. */
  15753. /**
  15754. * Sets the position the shadow will be casted from. Also use as the light position for both
  15755. * point and spot lights.
  15756. */
  15757. position: Vector3;
  15758. protected _direction: Vector3;
  15759. protected _setDirection(value: Vector3): void;
  15760. /**
  15761. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  15762. * Also use as the light direction on spot and directional lights.
  15763. */
  15764. /**
  15765. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  15766. * Also use as the light direction on spot and directional lights.
  15767. */
  15768. direction: Vector3;
  15769. private _shadowMinZ;
  15770. /**
  15771. * Gets the shadow projection clipping minimum z value.
  15772. */
  15773. /**
  15774. * Sets the shadow projection clipping minimum z value.
  15775. */
  15776. shadowMinZ: number;
  15777. private _shadowMaxZ;
  15778. /**
  15779. * Sets the shadow projection clipping maximum z value.
  15780. */
  15781. /**
  15782. * Gets the shadow projection clipping maximum z value.
  15783. */
  15784. shadowMaxZ: number;
  15785. /**
  15786. * Callback defining a custom Projection Matrix Builder.
  15787. * This can be used to override the default projection matrix computation.
  15788. */
  15789. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15790. /**
  15791. * The transformed position. Position of the light in world space taking parenting in account.
  15792. */
  15793. transformedPosition: Vector3;
  15794. /**
  15795. * The transformed direction. Direction of the light in world space taking parenting in account.
  15796. */
  15797. transformedDirection: Vector3;
  15798. private _needProjectionMatrixCompute;
  15799. /**
  15800. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15801. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15802. */
  15803. computeTransformedInformation(): boolean;
  15804. /**
  15805. * Return the depth scale used for the shadow map.
  15806. * @returns the depth scale.
  15807. */
  15808. getDepthScale(): number;
  15809. /**
  15810. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15811. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15812. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15813. */
  15814. getShadowDirection(faceIndex?: number): Vector3;
  15815. /**
  15816. * Returns the ShadowLight absolute position in the World.
  15817. * @returns the position vector in world space
  15818. */
  15819. getAbsolutePosition(): Vector3;
  15820. /**
  15821. * Sets the ShadowLight direction toward the passed target.
  15822. * @param target The point tot target in local space
  15823. * @returns the updated ShadowLight direction
  15824. */
  15825. setDirectionToTarget(target: Vector3): Vector3;
  15826. /**
  15827. * Returns the light rotation in euler definition.
  15828. * @returns the x y z rotation in local space.
  15829. */
  15830. getRotation(): Vector3;
  15831. /**
  15832. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15833. * @returns true if a cube texture needs to be use
  15834. */
  15835. needCube(): boolean;
  15836. /**
  15837. * Detects if the projection matrix requires to be recomputed this frame.
  15838. * @returns true if it requires to be recomputed otherwise, false.
  15839. */
  15840. needProjectionMatrixCompute(): boolean;
  15841. /**
  15842. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15843. */
  15844. forceProjectionMatrixCompute(): void;
  15845. /** @hidden */
  15846. _initCache(): void;
  15847. /** @hidden */
  15848. _isSynchronized(): boolean;
  15849. /**
  15850. * Computes the world matrix of the node
  15851. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15852. * @returns the world matrix
  15853. */
  15854. computeWorldMatrix(force?: boolean): Matrix;
  15855. /**
  15856. * Gets the minZ used for shadow according to both the scene and the light.
  15857. * @param activeCamera The camera we are returning the min for
  15858. * @returns the depth min z
  15859. */
  15860. getDepthMinZ(activeCamera: Camera): number;
  15861. /**
  15862. * Gets the maxZ used for shadow according to both the scene and the light.
  15863. * @param activeCamera The camera we are returning the max for
  15864. * @returns the depth max z
  15865. */
  15866. getDepthMaxZ(activeCamera: Camera): number;
  15867. /**
  15868. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15869. * @param matrix The materix to updated with the projection information
  15870. * @param viewMatrix The transform matrix of the light
  15871. * @param renderList The list of mesh to render in the map
  15872. * @returns The current light
  15873. */
  15874. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15875. }
  15876. }
  15877. declare module BABYLON {
  15878. /**
  15879. * A spot light is defined by a position, a direction, an angle, and an exponent.
  15880. * These values define a cone of light starting from the position, emitting toward the direction.
  15881. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  15882. * and the exponent defines the speed of the decay of the light with distance (reach).
  15883. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15884. */
  15885. class SpotLight extends ShadowLight {
  15886. private _angle;
  15887. private _innerAngle;
  15888. private _cosHalfAngle;
  15889. private _lightAngleScale;
  15890. private _lightAngleOffset;
  15891. /**
  15892. * Gets the cone angle of the spot light in Radians.
  15893. */
  15894. /**
  15895. * Sets the cone angle of the spot light in Radians.
  15896. */
  15897. angle: number;
  15898. /**
  15899. * Only used in gltf falloff mode, this defines the angle where
  15900. * the directional falloff will start before cutting at angle which could be seen
  15901. * as outer angle.
  15902. */
  15903. /**
  15904. * Only used in gltf falloff mode, this defines the angle where
  15905. * the directional falloff will start before cutting at angle which could be seen
  15906. * as outer angle.
  15907. */
  15908. innerAngle: number;
  15909. private _shadowAngleScale;
  15910. /**
  15911. * Allows scaling the angle of the light for shadow generation only.
  15912. */
  15913. /**
  15914. * Allows scaling the angle of the light for shadow generation only.
  15915. */
  15916. shadowAngleScale: number;
  15917. /**
  15918. * The light decay speed with the distance from the emission spot.
  15919. */
  15920. exponent: number;
  15921. private _projectionTextureMatrix;
  15922. /**
  15923. * Allows reading the projecton texture
  15924. */
  15925. readonly projectionTextureMatrix: Matrix;
  15926. protected _projectionTextureLightNear: number;
  15927. /**
  15928. * Gets the near clip of the Spotlight for texture projection.
  15929. */
  15930. /**
  15931. * Sets the near clip of the Spotlight for texture projection.
  15932. */
  15933. projectionTextureLightNear: number;
  15934. protected _projectionTextureLightFar: number;
  15935. /**
  15936. * Gets the far clip of the Spotlight for texture projection.
  15937. */
  15938. /**
  15939. * Sets the far clip of the Spotlight for texture projection.
  15940. */
  15941. projectionTextureLightFar: number;
  15942. protected _projectionTextureUpDirection: Vector3;
  15943. /**
  15944. * Gets the Up vector of the Spotlight for texture projection.
  15945. */
  15946. /**
  15947. * Sets the Up vector of the Spotlight for texture projection.
  15948. */
  15949. projectionTextureUpDirection: Vector3;
  15950. private _projectionTexture;
  15951. /**
  15952. * Gets the projection texture of the light.
  15953. */
  15954. /**
  15955. * Sets the projection texture of the light.
  15956. */
  15957. projectionTexture: Nullable<BaseTexture>;
  15958. private _projectionTextureViewLightDirty;
  15959. private _projectionTextureProjectionLightDirty;
  15960. private _projectionTextureDirty;
  15961. private _projectionTextureViewTargetVector;
  15962. private _projectionTextureViewLightMatrix;
  15963. private _projectionTextureProjectionLightMatrix;
  15964. private _projectionTextureScalingMatrix;
  15965. /**
  15966. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  15967. * It can cast shadows.
  15968. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15969. * @param name The light friendly name
  15970. * @param position The position of the spot light in the scene
  15971. * @param direction The direction of the light in the scene
  15972. * @param angle The cone angle of the light in Radians
  15973. * @param exponent The light decay speed with the distance from the emission spot
  15974. * @param scene The scene the lights belongs to
  15975. */
  15976. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  15977. /**
  15978. * Returns the string "SpotLight".
  15979. * @returns the class name
  15980. */
  15981. getClassName(): string;
  15982. /**
  15983. * Returns the integer 2.
  15984. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15985. */
  15986. getTypeID(): number;
  15987. /**
  15988. * Overrides the direction setter to recompute the projection texture view light Matrix.
  15989. */
  15990. protected _setDirection(value: Vector3): void;
  15991. /**
  15992. * Overrides the position setter to recompute the projection texture view light Matrix.
  15993. */
  15994. protected _setPosition(value: Vector3): void;
  15995. /**
  15996. * 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.
  15997. * Returns the SpotLight.
  15998. */
  15999. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16000. protected _computeProjectionTextureViewLightMatrix(): void;
  16001. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16002. /**
  16003. * Main function for light texture projection matrix computing.
  16004. */
  16005. protected _computeProjectionTextureMatrix(): void;
  16006. protected _buildUniformLayout(): void;
  16007. private _computeAngleValues;
  16008. /**
  16009. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16010. * @param effect The effect to update
  16011. * @param lightIndex The index of the light in the effect to update
  16012. * @returns The spot light
  16013. */
  16014. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16015. /**
  16016. * Disposes the light and the associated resources.
  16017. */
  16018. dispose(): void;
  16019. /**
  16020. * Prepares the list of defines specific to the light type.
  16021. * @param defines the list of defines
  16022. * @param lightIndex defines the index of the light for the effect
  16023. */
  16024. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16025. }
  16026. }
  16027. declare module BABYLON {
  16028. /**
  16029. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  16030. * It controls one of the indiviual texture used in the effect.
  16031. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  16032. */
  16033. class LensFlare {
  16034. /**
  16035. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  16036. */
  16037. size: number;
  16038. /**
  16039. * 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.
  16040. */
  16041. position: number;
  16042. /**
  16043. * Define the lens color.
  16044. */
  16045. color: Color3;
  16046. /**
  16047. * Define the lens texture.
  16048. */
  16049. texture: Nullable<Texture>;
  16050. /**
  16051. * Define the alpha mode to render this particular lens.
  16052. */
  16053. alphaMode: number;
  16054. private _system;
  16055. /**
  16056. * Creates a new Lens Flare.
  16057. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  16058. * It controls one of the indiviual texture used in the effect.
  16059. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  16060. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  16061. * @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.
  16062. * @param color Define the lens color
  16063. * @param imgUrl Define the lens texture url
  16064. * @param system Define the `lensFlareSystem` this flare is part of
  16065. * @returns The newly created Lens Flare
  16066. */
  16067. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  16068. /**
  16069. * Instantiates a new Lens Flare.
  16070. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  16071. * It controls one of the indiviual texture used in the effect.
  16072. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  16073. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  16074. * @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.
  16075. * @param color Define the lens color
  16076. * @param imgUrl Define the lens texture url
  16077. * @param system Define the `lensFlareSystem` this flare is part of
  16078. */
  16079. constructor(
  16080. /**
  16081. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  16082. */
  16083. size: number,
  16084. /**
  16085. * 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.
  16086. */
  16087. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  16088. /**
  16089. * Dispose and release the lens flare with its associated resources.
  16090. */
  16091. dispose(): void;
  16092. }
  16093. }
  16094. declare module BABYLON {
  16095. /**
  16096. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  16097. * It is usually composed of several `BABYLON.lensFlare`.
  16098. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  16099. */
  16100. class LensFlareSystem {
  16101. /**
  16102. * Define the name of the lens flare system
  16103. */
  16104. name: string;
  16105. /**
  16106. * List of lens flares used in this system.
  16107. */
  16108. lensFlares: LensFlare[];
  16109. /**
  16110. * Define a limit from the border the lens flare can be visible.
  16111. */
  16112. borderLimit: number;
  16113. /**
  16114. * Define a viewport border we do not want to see the lens flare in.
  16115. */
  16116. viewportBorder: number;
  16117. /**
  16118. * Define a predicate which could limit the list of meshes able to occlude the effect.
  16119. */
  16120. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  16121. /**
  16122. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  16123. */
  16124. layerMask: number;
  16125. /**
  16126. * Define the id of the lens flare system in the scene.
  16127. * (equal to name by default)
  16128. */
  16129. id: string;
  16130. private _scene;
  16131. private _emitter;
  16132. private _vertexBuffers;
  16133. private _indexBuffer;
  16134. private _effect;
  16135. private _positionX;
  16136. private _positionY;
  16137. private _isEnabled;
  16138. /**
  16139. * Instantiates a lens flare system.
  16140. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  16141. * It is usually composed of several `BABYLON.lensFlare`.
  16142. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  16143. * @param name Define the name of the lens flare system in the scene
  16144. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  16145. * @param scene Define the scene the lens flare system belongs to
  16146. */
  16147. constructor(
  16148. /**
  16149. * Define the name of the lens flare system
  16150. */
  16151. name: string, emitter: any, scene: Scene);
  16152. /**
  16153. * Define if the lens flare system is enabled.
  16154. */
  16155. isEnabled: boolean;
  16156. /**
  16157. * Get the scene the effects belongs to.
  16158. * @returns the scene holding the lens flare system
  16159. */
  16160. getScene(): Scene;
  16161. /**
  16162. * Get the emitter of the lens flare system.
  16163. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  16164. * @returns the emitter of the lens flare system
  16165. */
  16166. getEmitter(): any;
  16167. /**
  16168. * Set the emitter of the lens flare system.
  16169. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  16170. * @param newEmitter Define the new emitter of the system
  16171. */
  16172. setEmitter(newEmitter: any): void;
  16173. /**
  16174. * Get the lens flare system emitter position.
  16175. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  16176. * @returns the position
  16177. */
  16178. getEmitterPosition(): Vector3;
  16179. /**
  16180. * @hidden
  16181. */
  16182. computeEffectivePosition(globalViewport: Viewport): boolean;
  16183. /** @hidden */
  16184. _isVisible(): boolean;
  16185. /**
  16186. * @hidden
  16187. */
  16188. render(): boolean;
  16189. /**
  16190. * Dispose and release the lens flare with its associated resources.
  16191. */
  16192. dispose(): void;
  16193. /**
  16194. * Parse a lens flare system from a JSON repressentation
  16195. * @param parsedLensFlareSystem Define the JSON to parse
  16196. * @param scene Define the scene the parsed system should be instantiated in
  16197. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  16198. * @returns the parsed system
  16199. */
  16200. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  16201. /**
  16202. * Serialize the current Lens Flare System into a JSON representation.
  16203. * @returns the serialized JSON
  16204. */
  16205. serialize(): any;
  16206. }
  16207. }
  16208. declare module BABYLON {
  16209. interface AbstractScene {
  16210. /**
  16211. * The list of lens flare system added to the scene
  16212. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  16213. */
  16214. lensFlareSystems: Array<LensFlareSystem>;
  16215. /**
  16216. * Removes the given lens flare system from this scene.
  16217. * @param toRemove The lens flare system to remove
  16218. * @returns The index of the removed lens flare system
  16219. */
  16220. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  16221. /**
  16222. * Adds the given lens flare system to this scene
  16223. * @param newLensFlareSystem The lens flare system to add
  16224. */
  16225. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  16226. /**
  16227. * Gets a lens flare system using its name
  16228. * @param name defines the name to look for
  16229. * @returns the lens flare system or null if not found
  16230. */
  16231. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  16232. /**
  16233. * Gets a lens flare system using its id
  16234. * @param id defines the id to look for
  16235. * @returns the lens flare system or null if not found
  16236. */
  16237. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  16238. }
  16239. /**
  16240. * Defines the lens flare scene component responsible to manage any lens flares
  16241. * in a given scene.
  16242. */
  16243. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  16244. /**
  16245. * The component name helpfull to identify the component in the list of scene components.
  16246. */
  16247. readonly name: string;
  16248. /**
  16249. * The scene the component belongs to.
  16250. */
  16251. scene: Scene;
  16252. /**
  16253. * Creates a new instance of the component for the given scene
  16254. * @param scene Defines the scene to register the component in
  16255. */
  16256. constructor(scene: Scene);
  16257. /**
  16258. * Registers the component in a given scene
  16259. */
  16260. register(): void;
  16261. /**
  16262. * Rebuilds the elements related to this component in case of
  16263. * context lost for instance.
  16264. */
  16265. rebuild(): void;
  16266. /**
  16267. * Adds all the element from the container to the scene
  16268. * @param container the container holding the elements
  16269. */
  16270. addFromContainer(container: AbstractScene): void;
  16271. /**
  16272. * Removes all the elements in the container from the scene
  16273. * @param container contains the elements to remove
  16274. */
  16275. removeFromContainer(container: AbstractScene): void;
  16276. /**
  16277. * Serializes the component data to the specified json object
  16278. * @param serializationObject The object to serialize to
  16279. */
  16280. serialize(serializationObject: any): void;
  16281. /**
  16282. * Disposes the component and the associated ressources.
  16283. */
  16284. dispose(): void;
  16285. private _draw;
  16286. }
  16287. }
  16288. declare module BABYLON {
  16289. /**
  16290. * Interface used to present a loading screen while loading a scene
  16291. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16292. */
  16293. interface ILoadingScreen {
  16294. /**
  16295. * Function called to display the loading screen
  16296. */
  16297. displayLoadingUI: () => void;
  16298. /**
  16299. * Function called to hide the loading screen
  16300. */
  16301. hideLoadingUI: () => void;
  16302. /**
  16303. * Gets or sets the color to use for the background
  16304. */
  16305. loadingUIBackgroundColor: string;
  16306. /**
  16307. * Gets or sets the text to display while loading
  16308. */
  16309. loadingUIText: string;
  16310. }
  16311. /**
  16312. * Class used for the default loading screen
  16313. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16314. */
  16315. class DefaultLoadingScreen implements ILoadingScreen {
  16316. private _renderingCanvas;
  16317. private _loadingText;
  16318. private _loadingDivBackgroundColor;
  16319. private _loadingDiv;
  16320. private _loadingTextDiv;
  16321. /**
  16322. * Creates a new default loading screen
  16323. * @param _renderingCanvas defines the canvas used to render the scene
  16324. * @param _loadingText defines the default text to display
  16325. * @param _loadingDivBackgroundColor defines the default background color
  16326. */
  16327. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  16328. /**
  16329. * Function called to display the loading screen
  16330. */
  16331. displayLoadingUI(): void;
  16332. /**
  16333. * Function called to hide the loading screen
  16334. */
  16335. hideLoadingUI(): void;
  16336. /**
  16337. * Gets or sets the text to display while loading
  16338. */
  16339. loadingUIText: string;
  16340. /**
  16341. * Gets or sets the color to use for the background
  16342. */
  16343. loadingUIBackgroundColor: string;
  16344. private _resizeLoadingUI;
  16345. }
  16346. }
  16347. declare module BABYLON {
  16348. /**
  16349. * Class used to represent data loading progression
  16350. */
  16351. class SceneLoaderProgressEvent {
  16352. /** defines if data length to load can be evaluated */
  16353. readonly lengthComputable: boolean;
  16354. /** defines the loaded data length */
  16355. readonly loaded: number;
  16356. /** defines the data length to load */
  16357. readonly total: number;
  16358. /**
  16359. * Create a new progress event
  16360. * @param lengthComputable defines if data length to load can be evaluated
  16361. * @param loaded defines the loaded data length
  16362. * @param total defines the data length to load
  16363. */
  16364. constructor(
  16365. /** defines if data length to load can be evaluated */
  16366. lengthComputable: boolean,
  16367. /** defines the loaded data length */
  16368. loaded: number,
  16369. /** defines the data length to load */
  16370. total: number);
  16371. /**
  16372. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16373. * @param event defines the source event
  16374. * @returns a new SceneLoaderProgressEvent
  16375. */
  16376. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16377. }
  16378. /**
  16379. * Interface used by SceneLoader plugins to define supported file extensions
  16380. */
  16381. interface ISceneLoaderPluginExtensions {
  16382. /**
  16383. * Defines the list of supported extensions
  16384. */
  16385. [extension: string]: {
  16386. isBinary: boolean;
  16387. };
  16388. }
  16389. /**
  16390. * Interface used by SceneLoader plugin factory
  16391. */
  16392. interface ISceneLoaderPluginFactory {
  16393. /**
  16394. * Defines the name of the factory
  16395. */
  16396. name: string;
  16397. /**
  16398. * Function called to create a new plugin
  16399. * @return the new plugin
  16400. */
  16401. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16402. /**
  16403. * Boolean indicating if the plugin can direct load specific data
  16404. */
  16405. canDirectLoad?: (data: string) => boolean;
  16406. }
  16407. /**
  16408. * Interface used to define a SceneLoader plugin
  16409. */
  16410. interface ISceneLoaderPlugin {
  16411. /**
  16412. * The friendly name of this plugin.
  16413. */
  16414. name: string;
  16415. /**
  16416. * The file extensions supported by this plugin.
  16417. */
  16418. extensions: string | ISceneLoaderPluginExtensions;
  16419. /**
  16420. * Import meshes into a scene.
  16421. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16422. * @param scene The scene to import into
  16423. * @param data The data to import
  16424. * @param rootUrl The root url for scene and resources
  16425. * @param meshes The meshes array to import into
  16426. * @param particleSystems The particle systems array to import into
  16427. * @param skeletons The skeletons array to import into
  16428. * @param onError The callback when import fails
  16429. * @returns True if successful or false otherwise
  16430. */
  16431. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16432. /**
  16433. * Load into a scene.
  16434. * @param scene The scene to load into
  16435. * @param data The data to import
  16436. * @param rootUrl The root url for scene and resources
  16437. * @param onError The callback when import fails
  16438. * @returns true if successful or false otherwise
  16439. */
  16440. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16441. /**
  16442. * The callback that returns true if the data can be directly loaded.
  16443. */
  16444. canDirectLoad?: (data: string) => boolean;
  16445. /**
  16446. * The callback that allows custom handling of the root url based on the response url.
  16447. */
  16448. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16449. /**
  16450. * Load into an asset container.
  16451. * @param scene The scene to load into
  16452. * @param data The data to import
  16453. * @param rootUrl The root url for scene and resources
  16454. * @param onError The callback when import fails
  16455. * @returns The loaded asset container
  16456. */
  16457. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16458. }
  16459. /**
  16460. * Interface used to define an async SceneLoader plugin
  16461. */
  16462. interface ISceneLoaderPluginAsync {
  16463. /**
  16464. * The friendly name of this plugin.
  16465. */
  16466. name: string;
  16467. /**
  16468. * The file extensions supported by this plugin.
  16469. */
  16470. extensions: string | ISceneLoaderPluginExtensions;
  16471. /**
  16472. * Import meshes into a scene.
  16473. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16474. * @param scene The scene to import into
  16475. * @param data The data to import
  16476. * @param rootUrl The root url for scene and resources
  16477. * @param onProgress The callback when the load progresses
  16478. * @param fileName Defines the name of the file to load
  16479. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16480. */
  16481. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16482. meshes: AbstractMesh[];
  16483. particleSystems: IParticleSystem[];
  16484. skeletons: Skeleton[];
  16485. animationGroups: AnimationGroup[];
  16486. }>;
  16487. /**
  16488. * Load into a scene.
  16489. * @param scene The scene to load into
  16490. * @param data The data to import
  16491. * @param rootUrl The root url for scene and resources
  16492. * @param onProgress The callback when the load progresses
  16493. * @param fileName Defines the name of the file to load
  16494. * @returns Nothing
  16495. */
  16496. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16497. /**
  16498. * The callback that returns true if the data can be directly loaded.
  16499. */
  16500. canDirectLoad?: (data: string) => boolean;
  16501. /**
  16502. * The callback that allows custom handling of the root url based on the response url.
  16503. */
  16504. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16505. /**
  16506. * Load into an asset container.
  16507. * @param scene The scene to load into
  16508. * @param data The data to import
  16509. * @param rootUrl The root url for scene and resources
  16510. * @param onProgress The callback when the load progresses
  16511. * @param fileName Defines the name of the file to load
  16512. * @returns The loaded asset container
  16513. */
  16514. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16515. }
  16516. /**
  16517. * Class used to load scene from various file formats using registered plugins
  16518. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16519. */
  16520. class SceneLoader {
  16521. private static _ForceFullSceneLoadingForIncremental;
  16522. private static _ShowLoadingScreen;
  16523. private static _CleanBoneMatrixWeights;
  16524. /**
  16525. * No logging while loading
  16526. */
  16527. static readonly NO_LOGGING: number;
  16528. /**
  16529. * Minimal logging while loading
  16530. */
  16531. static readonly MINIMAL_LOGGING: number;
  16532. /**
  16533. * Summary logging while loading
  16534. */
  16535. static readonly SUMMARY_LOGGING: number;
  16536. /**
  16537. * Detailled logging while loading
  16538. */
  16539. static readonly DETAILED_LOGGING: number;
  16540. private static _loggingLevel;
  16541. /**
  16542. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16543. */
  16544. static ForceFullSceneLoadingForIncremental: boolean;
  16545. /**
  16546. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16547. */
  16548. static ShowLoadingScreen: boolean;
  16549. /**
  16550. * Defines the current logging level (while loading the scene)
  16551. * @ignorenaming
  16552. */
  16553. static loggingLevel: number;
  16554. /**
  16555. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16556. */
  16557. static CleanBoneMatrixWeights: boolean;
  16558. /**
  16559. * Event raised when a plugin is used to load a scene
  16560. */
  16561. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16562. private static _registeredPlugins;
  16563. private static _getDefaultPlugin;
  16564. private static _getPluginForExtension;
  16565. private static _getPluginForDirectLoad;
  16566. private static _getPluginForFilename;
  16567. private static _getDirectLoad;
  16568. private static _loadData;
  16569. private static _getFileInfo;
  16570. /**
  16571. * Gets a plugin that can load the given extension
  16572. * @param extension defines the extension to load
  16573. * @returns a plugin or null if none works
  16574. */
  16575. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16576. /**
  16577. * Gets a boolean indicating that the given extension can be loaded
  16578. * @param extension defines the extension to load
  16579. * @returns true if the extension is supported
  16580. */
  16581. static IsPluginForExtensionAvailable(extension: string): boolean;
  16582. /**
  16583. * Adds a new plugin to the list of registered plugins
  16584. * @param plugin defines the plugin to add
  16585. */
  16586. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16587. /**
  16588. * Import meshes into a scene
  16589. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16590. * @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)
  16591. * @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)
  16592. * @param scene the instance of BABYLON.Scene to append to
  16593. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  16594. * @param onProgress a callback with a progress event for each file being loaded
  16595. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16596. * @param pluginExtension the extension used to determine the plugin
  16597. * @returns The loaded plugin
  16598. */
  16599. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string, 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>;
  16600. /**
  16601. * Import meshes into a scene
  16602. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16603. * @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)
  16604. * @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)
  16605. * @param scene the instance of BABYLON.Scene to append to
  16606. * @param onProgress a callback with a progress event for each file being loaded
  16607. * @param pluginExtension the extension used to determine the plugin
  16608. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16609. */
  16610. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16611. meshes: AbstractMesh[];
  16612. particleSystems: IParticleSystem[];
  16613. skeletons: Skeleton[];
  16614. animationGroups: AnimationGroup[];
  16615. }>;
  16616. /**
  16617. * Load a scene
  16618. * @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)
  16619. * @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)
  16620. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16621. * @param onSuccess a callback with the scene when import succeeds
  16622. * @param onProgress a callback with a progress event for each file being loaded
  16623. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16624. * @param pluginExtension the extension used to determine the plugin
  16625. * @returns The loaded plugin
  16626. */
  16627. static Load(rootUrl: string, sceneFilename: string, engine: 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>;
  16628. /**
  16629. * Load a scene
  16630. * @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)
  16631. * @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)
  16632. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16633. * @param onProgress a callback with a progress event for each file being loaded
  16634. * @param pluginExtension the extension used to determine the plugin
  16635. * @returns The loaded scene
  16636. */
  16637. static LoadAsync(rootUrl: string, sceneFilename: string, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16638. /**
  16639. * Append a scene
  16640. * @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)
  16641. * @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)
  16642. * @param scene is the instance of BABYLON.Scene to append to
  16643. * @param onSuccess a callback with the scene when import succeeds
  16644. * @param onProgress a callback with a progress event for each file being loaded
  16645. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16646. * @param pluginExtension the extension used to determine the plugin
  16647. * @returns The loaded plugin
  16648. */
  16649. static Append(rootUrl: string, sceneFilename?: string, 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>;
  16650. /**
  16651. * Append a scene
  16652. * @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)
  16653. * @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)
  16654. * @param scene is the instance of BABYLON.Scene to append to
  16655. * @param onProgress a callback with a progress event for each file being loaded
  16656. * @param pluginExtension the extension used to determine the plugin
  16657. * @returns The given scene
  16658. */
  16659. static AppendAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16660. /**
  16661. * Load a scene into an asset container
  16662. * @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)
  16663. * @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)
  16664. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16665. * @param onSuccess a callback with the scene when import succeeds
  16666. * @param onProgress a callback with a progress event for each file being loaded
  16667. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16668. * @param pluginExtension the extension used to determine the plugin
  16669. * @returns The loaded plugin
  16670. */
  16671. static LoadAssetContainer(rootUrl: string, sceneFilename?: string, 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>;
  16672. /**
  16673. * Load a scene into an asset container
  16674. * @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)
  16675. * @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)
  16676. * @param scene is the instance of BABYLON.Scene to append to
  16677. * @param onProgress a callback with a progress event for each file being loaded
  16678. * @param pluginExtension the extension used to determine the plugin
  16679. * @returns The loaded asset container
  16680. */
  16681. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16682. }
  16683. }
  16684. declare module BABYLON {
  16685. /**
  16686. * Scalar computation library
  16687. */
  16688. class Scalar {
  16689. /**
  16690. * Two pi constants convenient for computation.
  16691. */
  16692. static TwoPi: number;
  16693. /**
  16694. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  16695. * @param a number
  16696. * @param b number
  16697. * @param epsilon (default = 1.401298E-45)
  16698. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  16699. */
  16700. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  16701. /**
  16702. * Returns a string : the upper case translation of the number i to hexadecimal.
  16703. * @param i number
  16704. * @returns the upper case translation of the number i to hexadecimal.
  16705. */
  16706. static ToHex(i: number): string;
  16707. /**
  16708. * Returns -1 if value is negative and +1 is value is positive.
  16709. * @param value the value
  16710. * @returns the value itself if it's equal to zero.
  16711. */
  16712. static Sign(value: number): number;
  16713. /**
  16714. * Returns the value itself if it's between min and max.
  16715. * Returns min if the value is lower than min.
  16716. * Returns max if the value is greater than max.
  16717. * @param value the value to clmap
  16718. * @param min the min value to clamp to (default: 0)
  16719. * @param max the max value to clamp to (default: 1)
  16720. * @returns the clamped value
  16721. */
  16722. static Clamp(value: number, min?: number, max?: number): number;
  16723. /**
  16724. * the log2 of value.
  16725. * @param value the value to compute log2 of
  16726. * @returns the log2 of value.
  16727. */
  16728. static Log2(value: number): number;
  16729. /**
  16730. * Loops the value, so that it is never larger than length and never smaller than 0.
  16731. *
  16732. * This is similar to the modulo operator but it works with floating point numbers.
  16733. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  16734. * With t = 5 and length = 2.5, the result would be 0.0.
  16735. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  16736. * @param value the value
  16737. * @param length the length
  16738. * @returns the looped value
  16739. */
  16740. static Repeat(value: number, length: number): number;
  16741. /**
  16742. * Normalize the value between 0.0 and 1.0 using min and max values
  16743. * @param value value to normalize
  16744. * @param min max to normalize between
  16745. * @param max min to normalize between
  16746. * @returns the normalized value
  16747. */
  16748. static Normalize(value: number, min: number, max: number): number;
  16749. /**
  16750. * Denormalize the value from 0.0 and 1.0 using min and max values
  16751. * @param normalized value to denormalize
  16752. * @param min max to denormalize between
  16753. * @param max min to denormalize between
  16754. * @returns the denormalized value
  16755. */
  16756. static Denormalize(normalized: number, min: number, max: number): number;
  16757. /**
  16758. * Calculates the shortest difference between two given angles given in degrees.
  16759. * @param current current angle in degrees
  16760. * @param target target angle in degrees
  16761. * @returns the delta
  16762. */
  16763. static DeltaAngle(current: number, target: number): number;
  16764. /**
  16765. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  16766. * @param tx value
  16767. * @param length length
  16768. * @returns The returned value will move back and forth between 0 and length
  16769. */
  16770. static PingPong(tx: number, length: number): number;
  16771. /**
  16772. * Interpolates between min and max with smoothing at the limits.
  16773. *
  16774. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  16775. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  16776. * @param from from
  16777. * @param to to
  16778. * @param tx value
  16779. * @returns the smooth stepped value
  16780. */
  16781. static SmoothStep(from: number, to: number, tx: number): number;
  16782. /**
  16783. * Moves a value current towards target.
  16784. *
  16785. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  16786. * Negative values of maxDelta pushes the value away from target.
  16787. * @param current current value
  16788. * @param target target value
  16789. * @param maxDelta max distance to move
  16790. * @returns resulting value
  16791. */
  16792. static MoveTowards(current: number, target: number, maxDelta: number): number;
  16793. /**
  16794. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  16795. *
  16796. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  16797. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  16798. * @param current current value
  16799. * @param target target value
  16800. * @param maxDelta max distance to move
  16801. * @returns resulting angle
  16802. */
  16803. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  16804. /**
  16805. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  16806. * @param start start value
  16807. * @param end target value
  16808. * @param amount amount to lerp between
  16809. * @returns the lerped value
  16810. */
  16811. static Lerp(start: number, end: number, amount: number): number;
  16812. /**
  16813. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  16814. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  16815. * @param start start value
  16816. * @param end target value
  16817. * @param amount amount to lerp between
  16818. * @returns the lerped value
  16819. */
  16820. static LerpAngle(start: number, end: number, amount: number): number;
  16821. /**
  16822. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  16823. * @param a start value
  16824. * @param b target value
  16825. * @param value value between a and b
  16826. * @returns the inverseLerp value
  16827. */
  16828. static InverseLerp(a: number, b: number, value: number): number;
  16829. /**
  16830. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  16831. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  16832. * @param value1 spline value
  16833. * @param tangent1 spline value
  16834. * @param value2 spline value
  16835. * @param tangent2 spline value
  16836. * @param amount input value
  16837. * @returns hermite result
  16838. */
  16839. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  16840. /**
  16841. * Returns a random float number between and min and max values
  16842. * @param min min value of random
  16843. * @param max max value of random
  16844. * @returns random value
  16845. */
  16846. static RandomRange(min: number, max: number): number;
  16847. /**
  16848. * This function returns percentage of a number in a given range.
  16849. *
  16850. * RangeToPercent(40,20,60) will return 0.5 (50%)
  16851. * RangeToPercent(34,0,100) will return 0.34 (34%)
  16852. * @param number to convert to percentage
  16853. * @param min min range
  16854. * @param max max range
  16855. * @returns the percentage
  16856. */
  16857. static RangeToPercent(number: number, min: number, max: number): number;
  16858. /**
  16859. * This function returns number that corresponds to the percentage in a given range.
  16860. *
  16861. * PercentToRange(0.34,0,100) will return 34.
  16862. * @param percent to convert to number
  16863. * @param min min range
  16864. * @param max max range
  16865. * @returns the number
  16866. */
  16867. static PercentToRange(percent: number, min: number, max: number): number;
  16868. /**
  16869. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  16870. * @param angle The angle to normalize in radian.
  16871. * @return The converted angle.
  16872. */
  16873. static NormalizeRadians(angle: number): number;
  16874. }
  16875. }
  16876. declare module BABYLON {
  16877. /**
  16878. * Constant used to convert a value to gamma space
  16879. * @ignorenaming
  16880. */
  16881. const ToGammaSpace: number;
  16882. /**
  16883. * Constant used to convert a value to linear space
  16884. * @ignorenaming
  16885. */
  16886. const ToLinearSpace = 2.2;
  16887. /**
  16888. * Constant used to define the minimal number value in Babylon.js
  16889. * @ignorenaming
  16890. */
  16891. const Epsilon = 0.001;
  16892. /**
  16893. * Class used to hold a RBG color
  16894. */
  16895. class Color3 {
  16896. /**
  16897. * Defines the red component (between 0 and 1, default is 0)
  16898. */
  16899. r: number;
  16900. /**
  16901. * Defines the green component (between 0 and 1, default is 0)
  16902. */
  16903. g: number;
  16904. /**
  16905. * Defines the blue component (between 0 and 1, default is 0)
  16906. */
  16907. b: number;
  16908. /**
  16909. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  16910. * @param r defines the red component (between 0 and 1, default is 0)
  16911. * @param g defines the green component (between 0 and 1, default is 0)
  16912. * @param b defines the blue component (between 0 and 1, default is 0)
  16913. */
  16914. constructor(
  16915. /**
  16916. * Defines the red component (between 0 and 1, default is 0)
  16917. */
  16918. r?: number,
  16919. /**
  16920. * Defines the green component (between 0 and 1, default is 0)
  16921. */
  16922. g?: number,
  16923. /**
  16924. * Defines the blue component (between 0 and 1, default is 0)
  16925. */
  16926. b?: number);
  16927. /**
  16928. * Creates a string with the Color3 current values
  16929. * @returns the string representation of the Color3 object
  16930. */
  16931. toString(): string;
  16932. /**
  16933. * Returns the string "Color3"
  16934. * @returns "Color3"
  16935. */
  16936. getClassName(): string;
  16937. /**
  16938. * Compute the Color3 hash code
  16939. * @returns an unique number that can be used to hash Color3 objects
  16940. */
  16941. getHashCode(): number;
  16942. /**
  16943. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  16944. * @param array defines the array where to store the r,g,b components
  16945. * @param index defines an optional index in the target array to define where to start storing values
  16946. * @returns the current Color3 object
  16947. */
  16948. toArray(array: FloatArray, index?: number): Color3;
  16949. /**
  16950. * Returns a new Color4 object from the current Color3 and the given alpha
  16951. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  16952. * @returns a new Color4 object
  16953. */
  16954. toColor4(alpha?: number): Color4;
  16955. /**
  16956. * Returns a new array populated with 3 numeric elements : red, green and blue values
  16957. * @returns the new array
  16958. */
  16959. asArray(): number[];
  16960. /**
  16961. * Returns the luminance value
  16962. * @returns a float value
  16963. */
  16964. toLuminance(): number;
  16965. /**
  16966. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  16967. * @param otherColor defines the second operand
  16968. * @returns the new Color3 object
  16969. */
  16970. multiply(otherColor: Color3): Color3;
  16971. /**
  16972. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  16973. * @param otherColor defines the second operand
  16974. * @param result defines the Color3 object where to store the result
  16975. * @returns the current Color3
  16976. */
  16977. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  16978. /**
  16979. * Determines equality between Color3 objects
  16980. * @param otherColor defines the second operand
  16981. * @returns true if the rgb values are equal to the given ones
  16982. */
  16983. equals(otherColor: Color3): boolean;
  16984. /**
  16985. * Determines equality between the current Color3 object and a set of r,b,g values
  16986. * @param r defines the red component to check
  16987. * @param g defines the green component to check
  16988. * @param b defines the blue component to check
  16989. * @returns true if the rgb values are equal to the given ones
  16990. */
  16991. equalsFloats(r: number, g: number, b: number): boolean;
  16992. /**
  16993. * Multiplies in place each rgb value by scale
  16994. * @param scale defines the scaling factor
  16995. * @returns the updated Color3
  16996. */
  16997. scale(scale: number): Color3;
  16998. /**
  16999. * Multiplies the rgb values by scale and stores the result into "result"
  17000. * @param scale defines the scaling factor
  17001. * @param result defines the Color3 object where to store the result
  17002. * @returns the unmodified current Color3
  17003. */
  17004. scaleToRef(scale: number, result: Color3): Color3;
  17005. /**
  17006. * Scale the current Color3 values by a factor and add the result to a given Color3
  17007. * @param scale defines the scale factor
  17008. * @param result defines color to store the result into
  17009. * @returns the unmodified current Color3
  17010. */
  17011. scaleAndAddToRef(scale: number, result: Color3): Color3;
  17012. /**
  17013. * Clamps the rgb values by the min and max values and stores the result into "result"
  17014. * @param min defines minimum clamping value (default is 0)
  17015. * @param max defines maximum clamping value (default is 1)
  17016. * @param result defines color to store the result into
  17017. * @returns the original Color3
  17018. */
  17019. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  17020. /**
  17021. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  17022. * @param otherColor defines the second operand
  17023. * @returns the new Color3
  17024. */
  17025. add(otherColor: Color3): Color3;
  17026. /**
  17027. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  17028. * @param otherColor defines the second operand
  17029. * @param result defines Color3 object to store the result into
  17030. * @returns the unmodified current Color3
  17031. */
  17032. addToRef(otherColor: Color3, result: Color3): Color3;
  17033. /**
  17034. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  17035. * @param otherColor defines the second operand
  17036. * @returns the new Color3
  17037. */
  17038. subtract(otherColor: Color3): Color3;
  17039. /**
  17040. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  17041. * @param otherColor defines the second operand
  17042. * @param result defines Color3 object to store the result into
  17043. * @returns the unmodified current Color3
  17044. */
  17045. subtractToRef(otherColor: Color3, result: Color3): Color3;
  17046. /**
  17047. * Copy the current object
  17048. * @returns a new Color3 copied the current one
  17049. */
  17050. clone(): Color3;
  17051. /**
  17052. * Copies the rgb values from the source in the current Color3
  17053. * @param source defines the source Color3 object
  17054. * @returns the updated Color3 object
  17055. */
  17056. copyFrom(source: Color3): Color3;
  17057. /**
  17058. * Updates the Color3 rgb values from the given floats
  17059. * @param r defines the red component to read from
  17060. * @param g defines the green component to read from
  17061. * @param b defines the blue component to read from
  17062. * @returns the current Color3 object
  17063. */
  17064. copyFromFloats(r: number, g: number, b: number): Color3;
  17065. /**
  17066. * Updates the Color3 rgb values from the given floats
  17067. * @param r defines the red component to read from
  17068. * @param g defines the green component to read from
  17069. * @param b defines the blue component to read from
  17070. * @returns the current Color3 object
  17071. */
  17072. set(r: number, g: number, b: number): Color3;
  17073. /**
  17074. * Compute the Color3 hexadecimal code as a string
  17075. * @returns a string containing the hexadecimal representation of the Color3 object
  17076. */
  17077. toHexString(): string;
  17078. /**
  17079. * Computes a new Color3 converted from the current one to linear space
  17080. * @returns a new Color3 object
  17081. */
  17082. toLinearSpace(): Color3;
  17083. /**
  17084. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  17085. * @param convertedColor defines the Color3 object where to store the linear space version
  17086. * @returns the unmodified Color3
  17087. */
  17088. toLinearSpaceToRef(convertedColor: Color3): Color3;
  17089. /**
  17090. * Computes a new Color3 converted from the current one to gamma space
  17091. * @returns a new Color3 object
  17092. */
  17093. toGammaSpace(): Color3;
  17094. /**
  17095. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  17096. * @param convertedColor defines the Color3 object where to store the gamma space version
  17097. * @returns the unmodified Color3
  17098. */
  17099. toGammaSpaceToRef(convertedColor: Color3): Color3;
  17100. /**
  17101. * Creates a new Color3 from the string containing valid hexadecimal values
  17102. * @param hex defines a string containing valid hexadecimal values
  17103. * @returns a new Color3 object
  17104. */
  17105. static FromHexString(hex: string): Color3;
  17106. /**
  17107. * Creates a new Vector3 from the starting index of the given array
  17108. * @param array defines the source array
  17109. * @param offset defines an offset in the source array
  17110. * @returns a new Color3 object
  17111. */
  17112. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  17113. /**
  17114. * Creates a new Color3 from integer values (< 256)
  17115. * @param r defines the red component to read from (value between 0 and 255)
  17116. * @param g defines the green component to read from (value between 0 and 255)
  17117. * @param b defines the blue component to read from (value between 0 and 255)
  17118. * @returns a new Color3 object
  17119. */
  17120. static FromInts(r: number, g: number, b: number): Color3;
  17121. /**
  17122. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  17123. * @param start defines the start Color3 value
  17124. * @param end defines the end Color3 value
  17125. * @param amount defines the gradient value between start and end
  17126. * @returns a new Color3 object
  17127. */
  17128. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  17129. /**
  17130. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  17131. * @param left defines the start value
  17132. * @param right defines the end value
  17133. * @param amount defines the gradient factor
  17134. * @param result defines the Color3 object where to store the result
  17135. */
  17136. static LerpToRef(left: Color3, right: Color3, amount: number, result: Color3): void;
  17137. /**
  17138. * Returns a Color3 value containing a red color
  17139. * @returns a new Color3 object
  17140. */
  17141. static Red(): Color3;
  17142. /**
  17143. * Returns a Color3 value containing a green color
  17144. * @returns a new Color3 object
  17145. */
  17146. static Green(): Color3;
  17147. /**
  17148. * Returns a Color3 value containing a blue color
  17149. * @returns a new Color3 object
  17150. */
  17151. static Blue(): Color3;
  17152. /**
  17153. * Returns a Color3 value containing a black color
  17154. * @returns a new Color3 object
  17155. */
  17156. static Black(): Color3;
  17157. /**
  17158. * Returns a Color3 value containing a white color
  17159. * @returns a new Color3 object
  17160. */
  17161. static White(): Color3;
  17162. /**
  17163. * Returns a Color3 value containing a purple color
  17164. * @returns a new Color3 object
  17165. */
  17166. static Purple(): Color3;
  17167. /**
  17168. * Returns a Color3 value containing a magenta color
  17169. * @returns a new Color3 object
  17170. */
  17171. static Magenta(): Color3;
  17172. /**
  17173. * Returns a Color3 value containing a yellow color
  17174. * @returns a new Color3 object
  17175. */
  17176. static Yellow(): Color3;
  17177. /**
  17178. * Returns a Color3 value containing a gray color
  17179. * @returns a new Color3 object
  17180. */
  17181. static Gray(): Color3;
  17182. /**
  17183. * Returns a Color3 value containing a teal color
  17184. * @returns a new Color3 object
  17185. */
  17186. static Teal(): Color3;
  17187. /**
  17188. * Returns a Color3 value containing a random color
  17189. * @returns a new Color3 object
  17190. */
  17191. static Random(): Color3;
  17192. }
  17193. /**
  17194. * Class used to hold a RBGA color
  17195. */
  17196. class Color4 {
  17197. /**
  17198. * Defines the red component (between 0 and 1, default is 0)
  17199. */
  17200. r: number;
  17201. /**
  17202. * Defines the green component (between 0 and 1, default is 0)
  17203. */
  17204. g: number;
  17205. /**
  17206. * Defines the blue component (between 0 and 1, default is 0)
  17207. */
  17208. b: number;
  17209. /**
  17210. * Defines the alpha component (between 0 and 1, default is 1)
  17211. */
  17212. a: number;
  17213. /**
  17214. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  17215. * @param r defines the red component (between 0 and 1, default is 0)
  17216. * @param g defines the green component (between 0 and 1, default is 0)
  17217. * @param b defines the blue component (between 0 and 1, default is 0)
  17218. * @param a defines the alpha component (between 0 and 1, default is 1)
  17219. */
  17220. constructor(
  17221. /**
  17222. * Defines the red component (between 0 and 1, default is 0)
  17223. */
  17224. r?: number,
  17225. /**
  17226. * Defines the green component (between 0 and 1, default is 0)
  17227. */
  17228. g?: number,
  17229. /**
  17230. * Defines the blue component (between 0 and 1, default is 0)
  17231. */
  17232. b?: number,
  17233. /**
  17234. * Defines the alpha component (between 0 and 1, default is 1)
  17235. */
  17236. a?: number);
  17237. /**
  17238. * Adds in place the given Color4 values to the current Color4 object
  17239. * @param right defines the second operand
  17240. * @returns the current updated Color4 object
  17241. */
  17242. addInPlace(right: Color4): Color4;
  17243. /**
  17244. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  17245. * @returns the new array
  17246. */
  17247. asArray(): number[];
  17248. /**
  17249. * Stores from the starting index in the given array the Color4 successive values
  17250. * @param array defines the array where to store the r,g,b components
  17251. * @param index defines an optional index in the target array to define where to start storing values
  17252. * @returns the current Color4 object
  17253. */
  17254. toArray(array: number[], index?: number): Color4;
  17255. /**
  17256. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  17257. * @param right defines the second operand
  17258. * @returns a new Color4 object
  17259. */
  17260. add(right: Color4): Color4;
  17261. /**
  17262. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  17263. * @param right defines the second operand
  17264. * @returns a new Color4 object
  17265. */
  17266. subtract(right: Color4): Color4;
  17267. /**
  17268. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  17269. * @param right defines the second operand
  17270. * @param result defines the Color4 object where to store the result
  17271. * @returns the current Color4 object
  17272. */
  17273. subtractToRef(right: Color4, result: Color4): Color4;
  17274. /**
  17275. * Creates a new Color4 with the current Color4 values multiplied by scale
  17276. * @param scale defines the scaling factor to apply
  17277. * @returns a new Color4 object
  17278. */
  17279. scale(scale: number): Color4;
  17280. /**
  17281. * Multiplies the current Color4 values by scale and stores the result in "result"
  17282. * @param scale defines the scaling factor to apply
  17283. * @param result defines the Color4 object where to store the result
  17284. * @returns the current unmodified Color4
  17285. */
  17286. scaleToRef(scale: number, result: Color4): Color4;
  17287. /**
  17288. * Scale the current Color4 values by a factor and add the result to a given Color4
  17289. * @param scale defines the scale factor
  17290. * @param result defines the Color4 object where to store the result
  17291. * @returns the unmodified current Color4
  17292. */
  17293. scaleAndAddToRef(scale: number, result: Color4): Color4;
  17294. /**
  17295. * Clamps the rgb values by the min and max values and stores the result into "result"
  17296. * @param min defines minimum clamping value (default is 0)
  17297. * @param max defines maximum clamping value (default is 1)
  17298. * @param result defines color to store the result into.
  17299. * @returns the cuurent Color4
  17300. */
  17301. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  17302. /**
  17303. * Multipy an Color4 value by another and return a new Color4 object
  17304. * @param color defines the Color4 value to multiply by
  17305. * @returns a new Color4 object
  17306. */
  17307. multiply(color: Color4): Color4;
  17308. /**
  17309. * Multipy a Color4 value by another and push the result in a reference value
  17310. * @param color defines the Color4 value to multiply by
  17311. * @param result defines the Color4 to fill the result in
  17312. * @returns the result Color4
  17313. */
  17314. multiplyToRef(color: Color4, result: Color4): Color4;
  17315. /**
  17316. * Creates a string with the Color4 current values
  17317. * @returns the string representation of the Color4 object
  17318. */
  17319. toString(): string;
  17320. /**
  17321. * Returns the string "Color4"
  17322. * @returns "Color4"
  17323. */
  17324. getClassName(): string;
  17325. /**
  17326. * Compute the Color4 hash code
  17327. * @returns an unique number that can be used to hash Color4 objects
  17328. */
  17329. getHashCode(): number;
  17330. /**
  17331. * Creates a new Color4 copied from the current one
  17332. * @returns a new Color4 object
  17333. */
  17334. clone(): Color4;
  17335. /**
  17336. * Copies the given Color4 values into the current one
  17337. * @param source defines the source Color4 object
  17338. * @returns the current updated Color4 object
  17339. */
  17340. copyFrom(source: Color4): Color4;
  17341. /**
  17342. * Copies the given float values into the current one
  17343. * @param r defines the red component to read from
  17344. * @param g defines the green component to read from
  17345. * @param b defines the blue component to read from
  17346. * @param a defines the alpha component to read from
  17347. * @returns the current updated Color4 object
  17348. */
  17349. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  17350. /**
  17351. * Copies the given float values into the current one
  17352. * @param r defines the red component to read from
  17353. * @param g defines the green component to read from
  17354. * @param b defines the blue component to read from
  17355. * @param a defines the alpha component to read from
  17356. * @returns the current updated Color4 object
  17357. */
  17358. set(r: number, g: number, b: number, a: number): Color4;
  17359. /**
  17360. * Compute the Color4 hexadecimal code as a string
  17361. * @returns a string containing the hexadecimal representation of the Color4 object
  17362. */
  17363. toHexString(): string;
  17364. /**
  17365. * Computes a new Color4 converted from the current one to linear space
  17366. * @returns a new Color4 object
  17367. */
  17368. toLinearSpace(): Color4;
  17369. /**
  17370. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  17371. * @param convertedColor defines the Color4 object where to store the linear space version
  17372. * @returns the unmodified Color4
  17373. */
  17374. toLinearSpaceToRef(convertedColor: Color4): Color4;
  17375. /**
  17376. * Computes a new Color4 converted from the current one to gamma space
  17377. * @returns a new Color4 object
  17378. */
  17379. toGammaSpace(): Color4;
  17380. /**
  17381. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  17382. * @param convertedColor defines the Color4 object where to store the gamma space version
  17383. * @returns the unmodified Color4
  17384. */
  17385. toGammaSpaceToRef(convertedColor: Color4): Color4;
  17386. /**
  17387. * Creates a new Color4 from the string containing valid hexadecimal values
  17388. * @param hex defines a string containing valid hexadecimal values
  17389. * @returns a new Color4 object
  17390. */
  17391. static FromHexString(hex: string): Color4;
  17392. /**
  17393. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  17394. * @param left defines the start value
  17395. * @param right defines the end value
  17396. * @param amount defines the gradient factor
  17397. * @returns a new Color4 object
  17398. */
  17399. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  17400. /**
  17401. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  17402. * @param left defines the start value
  17403. * @param right defines the end value
  17404. * @param amount defines the gradient factor
  17405. * @param result defines the Color4 object where to store data
  17406. */
  17407. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  17408. /**
  17409. * Creates a new Color4 from a Color3 and an alpha value
  17410. * @param color3 defines the source Color3 to read from
  17411. * @param alpha defines the alpha component (1.0 by default)
  17412. * @returns a new Color4 object
  17413. */
  17414. static FromColor3(color3: Color3, alpha?: number): Color4;
  17415. /**
  17416. * Creates a new Color4 from the starting index element of the given array
  17417. * @param array defines the source array to read from
  17418. * @param offset defines the offset in the source array
  17419. * @returns a new Color4 object
  17420. */
  17421. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  17422. /**
  17423. * Creates a new Color3 from integer values (< 256)
  17424. * @param r defines the red component to read from (value between 0 and 255)
  17425. * @param g defines the green component to read from (value between 0 and 255)
  17426. * @param b defines the blue component to read from (value between 0 and 255)
  17427. * @param a defines the alpha component to read from (value between 0 and 255)
  17428. * @returns a new Color3 object
  17429. */
  17430. static FromInts(r: number, g: number, b: number, a: number): Color4;
  17431. /**
  17432. * Check the content of a given array and convert it to an array containing RGBA data
  17433. * If the original array was already containing count * 4 values then it is returned directly
  17434. * @param colors defines the array to check
  17435. * @param count defines the number of RGBA data to expect
  17436. * @returns an array containing count * 4 values (RGBA)
  17437. */
  17438. static CheckColors4(colors: number[], count: number): number[];
  17439. }
  17440. /**
  17441. * Class representing a vector containing 2 coordinates
  17442. */
  17443. class Vector2 {
  17444. /** defines the first coordinate */
  17445. x: number;
  17446. /** defines the second coordinate */
  17447. y: number;
  17448. /**
  17449. * Creates a new Vector2 from the given x and y coordinates
  17450. * @param x defines the first coordinate
  17451. * @param y defines the second coordinate
  17452. */
  17453. constructor(
  17454. /** defines the first coordinate */
  17455. x?: number,
  17456. /** defines the second coordinate */
  17457. y?: number);
  17458. /**
  17459. * Gets a string with the Vector2 coordinates
  17460. * @returns a string with the Vector2 coordinates
  17461. */
  17462. toString(): string;
  17463. /**
  17464. * Gets class name
  17465. * @returns the string "Vector2"
  17466. */
  17467. getClassName(): string;
  17468. /**
  17469. * Gets current vector hash code
  17470. * @returns the Vector2 hash code as a number
  17471. */
  17472. getHashCode(): number;
  17473. /**
  17474. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  17475. * @param array defines the source array
  17476. * @param index defines the offset in source array
  17477. * @returns the current Vector2
  17478. */
  17479. toArray(array: FloatArray, index?: number): Vector2;
  17480. /**
  17481. * Copy the current vector to an array
  17482. * @returns a new array with 2 elements: the Vector2 coordinates.
  17483. */
  17484. asArray(): number[];
  17485. /**
  17486. * Sets the Vector2 coordinates with the given Vector2 coordinates
  17487. * @param source defines the source Vector2
  17488. * @returns the current updated Vector2
  17489. */
  17490. copyFrom(source: Vector2): Vector2;
  17491. /**
  17492. * Sets the Vector2 coordinates with the given floats
  17493. * @param x defines the first coordinate
  17494. * @param y defines the second coordinate
  17495. * @returns the current updated Vector2
  17496. */
  17497. copyFromFloats(x: number, y: number): Vector2;
  17498. /**
  17499. * Sets the Vector2 coordinates with the given floats
  17500. * @param x defines the first coordinate
  17501. * @param y defines the second coordinate
  17502. * @returns the current updated Vector2
  17503. */
  17504. set(x: number, y: number): Vector2;
  17505. /**
  17506. * Add another vector with the current one
  17507. * @param otherVector defines the other vector
  17508. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  17509. */
  17510. add(otherVector: Vector2): Vector2;
  17511. /**
  17512. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  17513. * @param otherVector defines the other vector
  17514. * @param result defines the target vector
  17515. * @returns the unmodified current Vector2
  17516. */
  17517. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  17518. /**
  17519. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  17520. * @param otherVector defines the other vector
  17521. * @returns the current updated Vector2
  17522. */
  17523. addInPlace(otherVector: Vector2): Vector2;
  17524. /**
  17525. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  17526. * @param otherVector defines the other vector
  17527. * @returns a new Vector2
  17528. */
  17529. addVector3(otherVector: Vector3): Vector2;
  17530. /**
  17531. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  17532. * @param otherVector defines the other vector
  17533. * @returns a new Vector2
  17534. */
  17535. subtract(otherVector: Vector2): Vector2;
  17536. /**
  17537. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  17538. * @param otherVector defines the other vector
  17539. * @param result defines the target vector
  17540. * @returns the unmodified current Vector2
  17541. */
  17542. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  17543. /**
  17544. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  17545. * @param otherVector defines the other vector
  17546. * @returns the current updated Vector2
  17547. */
  17548. subtractInPlace(otherVector: Vector2): Vector2;
  17549. /**
  17550. * Multiplies in place the current Vector2 coordinates by the given ones
  17551. * @param otherVector defines the other vector
  17552. * @returns the current updated Vector2
  17553. */
  17554. multiplyInPlace(otherVector: Vector2): Vector2;
  17555. /**
  17556. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  17557. * @param otherVector defines the other vector
  17558. * @returns a new Vector2
  17559. */
  17560. multiply(otherVector: Vector2): Vector2;
  17561. /**
  17562. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  17563. * @param otherVector defines the other vector
  17564. * @param result defines the target vector
  17565. * @returns the unmodified current Vector2
  17566. */
  17567. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  17568. /**
  17569. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  17570. * @param x defines the first coordinate
  17571. * @param y defines the second coordinate
  17572. * @returns a new Vector2
  17573. */
  17574. multiplyByFloats(x: number, y: number): Vector2;
  17575. /**
  17576. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  17577. * @param otherVector defines the other vector
  17578. * @returns a new Vector2
  17579. */
  17580. divide(otherVector: Vector2): Vector2;
  17581. /**
  17582. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  17583. * @param otherVector defines the other vector
  17584. * @param result defines the target vector
  17585. * @returns the unmodified current Vector2
  17586. */
  17587. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  17588. /**
  17589. * Divides the current Vector2 coordinates by the given ones
  17590. * @param otherVector defines the other vector
  17591. * @returns the current updated Vector2
  17592. */
  17593. divideInPlace(otherVector: Vector2): Vector2;
  17594. /**
  17595. * Gets a new Vector2 with current Vector2 negated coordinates
  17596. * @returns a new Vector2
  17597. */
  17598. negate(): Vector2;
  17599. /**
  17600. * Multiply the Vector2 coordinates by scale
  17601. * @param scale defines the scaling factor
  17602. * @returns the current updated Vector2
  17603. */
  17604. scaleInPlace(scale: number): Vector2;
  17605. /**
  17606. * Returns a new Vector2 scaled by "scale" from the current Vector2
  17607. * @param scale defines the scaling factor
  17608. * @returns a new Vector2
  17609. */
  17610. scale(scale: number): Vector2;
  17611. /**
  17612. * Scale the current Vector2 values by a factor to a given Vector2
  17613. * @param scale defines the scale factor
  17614. * @param result defines the Vector2 object where to store the result
  17615. * @returns the unmodified current Vector2
  17616. */
  17617. scaleToRef(scale: number, result: Vector2): Vector2;
  17618. /**
  17619. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  17620. * @param scale defines the scale factor
  17621. * @param result defines the Vector2 object where to store the result
  17622. * @returns the unmodified current Vector2
  17623. */
  17624. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  17625. /**
  17626. * Gets a boolean if two vectors are equals
  17627. * @param otherVector defines the other vector
  17628. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  17629. */
  17630. equals(otherVector: Vector2): boolean;
  17631. /**
  17632. * Gets a boolean if two vectors are equals (using an epsilon value)
  17633. * @param otherVector defines the other vector
  17634. * @param epsilon defines the minimal distance to consider equality
  17635. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  17636. */
  17637. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  17638. /**
  17639. * Gets a new Vector2 from current Vector2 floored values
  17640. * @returns a new Vector2
  17641. */
  17642. floor(): Vector2;
  17643. /**
  17644. * Gets a new Vector2 from current Vector2 floored values
  17645. * @returns a new Vector2
  17646. */
  17647. fract(): Vector2;
  17648. /**
  17649. * Gets the length of the vector
  17650. * @returns the vector length (float)
  17651. */
  17652. length(): number;
  17653. /**
  17654. * Gets the vector squared length
  17655. * @returns the vector squared length (float)
  17656. */
  17657. lengthSquared(): number;
  17658. /**
  17659. * Normalize the vector
  17660. * @returns the current updated Vector2
  17661. */
  17662. normalize(): Vector2;
  17663. /**
  17664. * Gets a new Vector2 copied from the Vector2
  17665. * @returns a new Vector2
  17666. */
  17667. clone(): Vector2;
  17668. /**
  17669. * Gets a new Vector2(0, 0)
  17670. * @returns a new Vector2
  17671. */
  17672. static Zero(): Vector2;
  17673. /**
  17674. * Gets a new Vector2(1, 1)
  17675. * @returns a new Vector2
  17676. */
  17677. static One(): Vector2;
  17678. /**
  17679. * Gets a new Vector2 set from the given index element of the given array
  17680. * @param array defines the data source
  17681. * @param offset defines the offset in the data source
  17682. * @returns a new Vector2
  17683. */
  17684. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  17685. /**
  17686. * Sets "result" from the given index element of the given array
  17687. * @param array defines the data source
  17688. * @param offset defines the offset in the data source
  17689. * @param result defines the target vector
  17690. */
  17691. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  17692. /**
  17693. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  17694. * @param value1 defines 1st point of control
  17695. * @param value2 defines 2nd point of control
  17696. * @param value3 defines 3rd point of control
  17697. * @param value4 defines 4th point of control
  17698. * @param amount defines the interpolation factor
  17699. * @returns a new Vector2
  17700. */
  17701. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  17702. /**
  17703. * 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".
  17704. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  17705. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  17706. * @param value defines the value to clamp
  17707. * @param min defines the lower limit
  17708. * @param max defines the upper limit
  17709. * @returns a new Vector2
  17710. */
  17711. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  17712. /**
  17713. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  17714. * @param value1 defines the 1st control point
  17715. * @param tangent1 defines the outgoing tangent
  17716. * @param value2 defines the 2nd control point
  17717. * @param tangent2 defines the incoming tangent
  17718. * @param amount defines the interpolation factor
  17719. * @returns a new Vector2
  17720. */
  17721. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  17722. /**
  17723. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  17724. * @param start defines the start vector
  17725. * @param end defines the end vector
  17726. * @param amount defines the interpolation factor
  17727. * @returns a new Vector2
  17728. */
  17729. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  17730. /**
  17731. * Gets the dot product of the vector "left" and the vector "right"
  17732. * @param left defines first vector
  17733. * @param right defines second vector
  17734. * @returns the dot product (float)
  17735. */
  17736. static Dot(left: Vector2, right: Vector2): number;
  17737. /**
  17738. * Returns a new Vector2 equal to the normalized given vector
  17739. * @param vector defines the vector to normalize
  17740. * @returns a new Vector2
  17741. */
  17742. static Normalize(vector: Vector2): Vector2;
  17743. /**
  17744. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  17745. * @param left defines 1st vector
  17746. * @param right defines 2nd vector
  17747. * @returns a new Vector2
  17748. */
  17749. static Minimize(left: Vector2, right: Vector2): Vector2;
  17750. /**
  17751. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  17752. * @param left defines 1st vector
  17753. * @param right defines 2nd vector
  17754. * @returns a new Vector2
  17755. */
  17756. static Maximize(left: Vector2, right: Vector2): Vector2;
  17757. /**
  17758. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  17759. * @param vector defines the vector to transform
  17760. * @param transformation defines the matrix to apply
  17761. * @returns a new Vector2
  17762. */
  17763. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  17764. /**
  17765. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  17766. * @param vector defines the vector to transform
  17767. * @param transformation defines the matrix to apply
  17768. * @param result defines the target vector
  17769. */
  17770. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  17771. /**
  17772. * Determines if a given vector is included in a triangle
  17773. * @param p defines the vector to test
  17774. * @param p0 defines 1st triangle point
  17775. * @param p1 defines 2nd triangle point
  17776. * @param p2 defines 3rd triangle point
  17777. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  17778. */
  17779. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  17780. /**
  17781. * Gets the distance between the vectors "value1" and "value2"
  17782. * @param value1 defines first vector
  17783. * @param value2 defines second vector
  17784. * @returns the distance between vectors
  17785. */
  17786. static Distance(value1: Vector2, value2: Vector2): number;
  17787. /**
  17788. * Returns the squared distance between the vectors "value1" and "value2"
  17789. * @param value1 defines first vector
  17790. * @param value2 defines second vector
  17791. * @returns the squared distance between vectors
  17792. */
  17793. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  17794. /**
  17795. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  17796. * @param value1 defines first vector
  17797. * @param value2 defines second vector
  17798. * @returns a new Vector2
  17799. */
  17800. static Center(value1: Vector2, value2: Vector2): Vector2;
  17801. /**
  17802. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  17803. * @param p defines the middle point
  17804. * @param segA defines one point of the segment
  17805. * @param segB defines the other point of the segment
  17806. * @returns the shortest distance
  17807. */
  17808. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  17809. }
  17810. /**
  17811. * Classed used to store (x,y,z) vector representation
  17812. * A Vector3 is the main object used in 3D geometry
  17813. * It can represent etiher the coordinates of a point the space, either a direction
  17814. * Reminder: Babylon.js uses a left handed forward facing system
  17815. */
  17816. class Vector3 {
  17817. /**
  17818. * Defines the first coordinates (on X axis)
  17819. */
  17820. x: number;
  17821. /**
  17822. * Defines the second coordinates (on Y axis)
  17823. */
  17824. y: number;
  17825. /**
  17826. * Defines the third coordinates (on Z axis)
  17827. */
  17828. z: number;
  17829. /**
  17830. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  17831. * @param x defines the first coordinates (on X axis)
  17832. * @param y defines the second coordinates (on Y axis)
  17833. * @param z defines the third coordinates (on Z axis)
  17834. */
  17835. constructor(
  17836. /**
  17837. * Defines the first coordinates (on X axis)
  17838. */
  17839. x?: number,
  17840. /**
  17841. * Defines the second coordinates (on Y axis)
  17842. */
  17843. y?: number,
  17844. /**
  17845. * Defines the third coordinates (on Z axis)
  17846. */
  17847. z?: number);
  17848. /**
  17849. * Creates a string representation of the Vector3
  17850. * @returns a string with the Vector3 coordinates.
  17851. */
  17852. toString(): string;
  17853. /**
  17854. * Gets the class name
  17855. * @returns the string "Vector3"
  17856. */
  17857. getClassName(): string;
  17858. /**
  17859. * Creates the Vector3 hash code
  17860. * @returns a number which tends to be unique between Vector3 instances
  17861. */
  17862. getHashCode(): number;
  17863. /**
  17864. * Creates an array containing three elements : the coordinates of the Vector3
  17865. * @returns a new array of numbers
  17866. */
  17867. asArray(): number[];
  17868. /**
  17869. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  17870. * @param array defines the destination array
  17871. * @param index defines the offset in the destination array
  17872. * @returns the current Vector3
  17873. */
  17874. toArray(array: FloatArray, index?: number): Vector3;
  17875. /**
  17876. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  17877. * @returns a new Quaternion object, computed from the Vector3 coordinates
  17878. */
  17879. toQuaternion(): Quaternion;
  17880. /**
  17881. * Adds the given vector to the current Vector3
  17882. * @param otherVector defines the second operand
  17883. * @returns the current updated Vector3
  17884. */
  17885. addInPlace(otherVector: Vector3): Vector3;
  17886. /**
  17887. * Adds the given coordinates to the current Vector3
  17888. * @param x defines the x coordinate of the operand
  17889. * @param y defines the y coordinate of the operand
  17890. * @param z defines the z coordinate of the operand
  17891. * @returns the current updated Vector3
  17892. */
  17893. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  17894. /**
  17895. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  17896. * @param otherVector defines the second operand
  17897. * @returns the resulting Vector3
  17898. */
  17899. add(otherVector: Vector3): Vector3;
  17900. /**
  17901. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  17902. * @param otherVector defines the second operand
  17903. * @param result defines the Vector3 object where to store the result
  17904. * @returns the current Vector3
  17905. */
  17906. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  17907. /**
  17908. * Subtract the given vector from the current Vector3
  17909. * @param otherVector defines the second operand
  17910. * @returns the current updated Vector3
  17911. */
  17912. subtractInPlace(otherVector: Vector3): Vector3;
  17913. /**
  17914. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  17915. * @param otherVector defines the second operand
  17916. * @returns the resulting Vector3
  17917. */
  17918. subtract(otherVector: Vector3): Vector3;
  17919. /**
  17920. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  17921. * @param otherVector defines the second operand
  17922. * @param result defines the Vector3 object where to store the result
  17923. * @returns the current Vector3
  17924. */
  17925. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  17926. /**
  17927. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  17928. * @param x defines the x coordinate of the operand
  17929. * @param y defines the y coordinate of the operand
  17930. * @param z defines the z coordinate of the operand
  17931. * @returns the resulting Vector3
  17932. */
  17933. subtractFromFloats(x: number, y: number, z: number): Vector3;
  17934. /**
  17935. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  17936. * @param x defines the x coordinate of the operand
  17937. * @param y defines the y coordinate of the operand
  17938. * @param z defines the z coordinate of the operand
  17939. * @param result defines the Vector3 object where to store the result
  17940. * @returns the current Vector3
  17941. */
  17942. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  17943. /**
  17944. * Gets a new Vector3 set with the current Vector3 negated coordinates
  17945. * @returns a new Vector3
  17946. */
  17947. negate(): Vector3;
  17948. /**
  17949. * Multiplies the Vector3 coordinates by the float "scale"
  17950. * @param scale defines the multiplier factor
  17951. * @returns the current updated Vector3
  17952. */
  17953. scaleInPlace(scale: number): Vector3;
  17954. /**
  17955. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  17956. * @param scale defines the multiplier factor
  17957. * @returns a new Vector3
  17958. */
  17959. scale(scale: number): Vector3;
  17960. /**
  17961. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  17962. * @param scale defines the multiplier factor
  17963. * @param result defines the Vector3 object where to store the result
  17964. * @returns the current Vector3
  17965. */
  17966. scaleToRef(scale: number, result: Vector3): Vector3;
  17967. /**
  17968. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  17969. * @param scale defines the scale factor
  17970. * @param result defines the Vector3 object where to store the result
  17971. * @returns the unmodified current Vector3
  17972. */
  17973. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  17974. /**
  17975. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  17976. * @param otherVector defines the second operand
  17977. * @returns true if both vectors are equals
  17978. */
  17979. equals(otherVector: Vector3): boolean;
  17980. /**
  17981. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  17982. * @param otherVector defines the second operand
  17983. * @param epsilon defines the minimal distance to define values as equals
  17984. * @returns true if both vectors are distant less than epsilon
  17985. */
  17986. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  17987. /**
  17988. * Returns true if the current Vector3 coordinates equals the given floats
  17989. * @param x defines the x coordinate of the operand
  17990. * @param y defines the y coordinate of the operand
  17991. * @param z defines the z coordinate of the operand
  17992. * @returns true if both vectors are equals
  17993. */
  17994. equalsToFloats(x: number, y: number, z: number): boolean;
  17995. /**
  17996. * Multiplies the current Vector3 coordinates by the given ones
  17997. * @param otherVector defines the second operand
  17998. * @returns the current updated Vector3
  17999. */
  18000. multiplyInPlace(otherVector: Vector3): Vector3;
  18001. /**
  18002. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  18003. * @param otherVector defines the second operand
  18004. * @returns the new Vector3
  18005. */
  18006. multiply(otherVector: Vector3): Vector3;
  18007. /**
  18008. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  18009. * @param otherVector defines the second operand
  18010. * @param result defines the Vector3 object where to store the result
  18011. * @returns the current Vector3
  18012. */
  18013. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  18014. /**
  18015. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  18016. * @param x defines the x coordinate of the operand
  18017. * @param y defines the y coordinate of the operand
  18018. * @param z defines the z coordinate of the operand
  18019. * @returns the new Vector3
  18020. */
  18021. multiplyByFloats(x: number, y: number, z: number): Vector3;
  18022. /**
  18023. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  18024. * @param otherVector defines the second operand
  18025. * @returns the new Vector3
  18026. */
  18027. divide(otherVector: Vector3): Vector3;
  18028. /**
  18029. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  18030. * @param otherVector defines the second operand
  18031. * @param result defines the Vector3 object where to store the result
  18032. * @returns the current Vector3
  18033. */
  18034. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  18035. /**
  18036. * Divides the current Vector3 coordinates by the given ones.
  18037. * @param otherVector defines the second operand
  18038. * @returns the current updated Vector3
  18039. */
  18040. divideInPlace(otherVector: Vector3): Vector3;
  18041. /**
  18042. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  18043. * @param other defines the second operand
  18044. * @returns the current updated Vector3
  18045. */
  18046. minimizeInPlace(other: Vector3): Vector3;
  18047. /**
  18048. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  18049. * @param other defines the second operand
  18050. * @returns the current updated Vector3
  18051. */
  18052. maximizeInPlace(other: Vector3): Vector3;
  18053. /**
  18054. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  18055. * @param x defines the x coordinate of the operand
  18056. * @param y defines the y coordinate of the operand
  18057. * @param z defines the z coordinate of the operand
  18058. * @returns the current updated Vector3
  18059. */
  18060. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  18061. /**
  18062. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  18063. * @param x defines the x coordinate of the operand
  18064. * @param y defines the y coordinate of the operand
  18065. * @param z defines the z coordinate of the operand
  18066. * @returns the current updated Vector3
  18067. */
  18068. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  18069. /**
  18070. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  18071. */
  18072. readonly isNonUniform: boolean;
  18073. /**
  18074. * Gets a new Vector3 from current Vector3 floored values
  18075. * @returns a new Vector3
  18076. */
  18077. floor(): Vector3;
  18078. /**
  18079. * Gets a new Vector3 from current Vector3 floored values
  18080. * @returns a new Vector3
  18081. */
  18082. fract(): Vector3;
  18083. /**
  18084. * Gets the length of the Vector3
  18085. * @returns the length of the Vecto3
  18086. */
  18087. length(): number;
  18088. /**
  18089. * Gets the squared length of the Vector3
  18090. * @returns squared length of the Vector3
  18091. */
  18092. lengthSquared(): number;
  18093. /**
  18094. * Normalize the current Vector3.
  18095. * Please note that this is an in place operation.
  18096. * @returns the current updated Vector3
  18097. */
  18098. normalize(): Vector3;
  18099. /**
  18100. * Normalize the current Vector3 with the given input length.
  18101. * Please note that this is an in place operation.
  18102. * @param len the length of the vector
  18103. * @returns the current updated Vector3
  18104. */
  18105. normalizeFromLength(len: number): Vector3;
  18106. /**
  18107. * Normalize the current Vector3 to a new vector
  18108. * @returns the new Vector3
  18109. */
  18110. normalizeToNew(): Vector3;
  18111. /**
  18112. * Normalize the current Vector3 to the reference
  18113. * @param reference define the Vector3 to update
  18114. * @returns the updated Vector3
  18115. */
  18116. normalizeToRef(reference: Vector3): Vector3;
  18117. /**
  18118. * Creates a new Vector3 copied from the current Vector3
  18119. * @returns the new Vector3
  18120. */
  18121. clone(): Vector3;
  18122. /**
  18123. * Copies the given vector coordinates to the current Vector3 ones
  18124. * @param source defines the source Vector3
  18125. * @returns the current updated Vector3
  18126. */
  18127. copyFrom(source: Vector3): Vector3;
  18128. /**
  18129. * Copies the given floats to the current Vector3 coordinates
  18130. * @param x defines the x coordinate of the operand
  18131. * @param y defines the y coordinate of the operand
  18132. * @param z defines the z coordinate of the operand
  18133. * @returns the current updated Vector3
  18134. */
  18135. copyFromFloats(x: number, y: number, z: number): Vector3;
  18136. /**
  18137. * Copies the given floats to the current Vector3 coordinates
  18138. * @param x defines the x coordinate of the operand
  18139. * @param y defines the y coordinate of the operand
  18140. * @param z defines the z coordinate of the operand
  18141. * @returns the current updated Vector3
  18142. */
  18143. set(x: number, y: number, z: number): Vector3;
  18144. /**
  18145. * Copies the given float to the current Vector3 coordinates
  18146. * @param v defines the x, y and z coordinates of the operand
  18147. * @returns the current updated Vector3
  18148. */
  18149. setAll(v: number): Vector3;
  18150. /**
  18151. * Get the clip factor between two vectors
  18152. * @param vector0 defines the first operand
  18153. * @param vector1 defines the second operand
  18154. * @param axis defines the axis to use
  18155. * @param size defines the size along the axis
  18156. * @returns the clip factor
  18157. */
  18158. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  18159. /**
  18160. * Get angle between two vectors
  18161. * @param vector0 angle between vector0 and vector1
  18162. * @param vector1 angle between vector0 and vector1
  18163. * @param normal direction of the normal
  18164. * @return the angle between vector0 and vector1
  18165. */
  18166. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  18167. /**
  18168. * Returns a new Vector3 set from the index "offset" of the given array
  18169. * @param array defines the source array
  18170. * @param offset defines the offset in the source array
  18171. * @returns the new Vector3
  18172. */
  18173. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  18174. /**
  18175. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  18176. * This function is deprecated. Use FromArray instead
  18177. * @param array defines the source array
  18178. * @param offset defines the offset in the source array
  18179. * @returns the new Vector3
  18180. */
  18181. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  18182. /**
  18183. * Sets the given vector "result" with the element values from the index "offset" of the given array
  18184. * @param array defines the source array
  18185. * @param offset defines the offset in the source array
  18186. * @param result defines the Vector3 where to store the result
  18187. */
  18188. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  18189. /**
  18190. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  18191. * This function is deprecated. Use FromArrayToRef instead.
  18192. * @param array defines the source array
  18193. * @param offset defines the offset in the source array
  18194. * @param result defines the Vector3 where to store the result
  18195. */
  18196. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  18197. /**
  18198. * Sets the given vector "result" with the given floats.
  18199. * @param x defines the x coordinate of the source
  18200. * @param y defines the y coordinate of the source
  18201. * @param z defines the z coordinate of the source
  18202. * @param result defines the Vector3 where to store the result
  18203. */
  18204. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  18205. /**
  18206. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  18207. * @returns a new empty Vector3
  18208. */
  18209. static Zero(): Vector3;
  18210. /**
  18211. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  18212. * @returns a new unit Vector3
  18213. */
  18214. static One(): Vector3;
  18215. /**
  18216. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  18217. * @returns a new up Vector3
  18218. */
  18219. static Up(): Vector3;
  18220. /**
  18221. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  18222. * @returns a new down Vector3
  18223. */
  18224. static Down(): Vector3;
  18225. /**
  18226. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  18227. * @returns a new forward Vector3
  18228. */
  18229. static Forward(): Vector3;
  18230. /**
  18231. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  18232. * @returns a new forward Vector3
  18233. */
  18234. static Backward(): Vector3;
  18235. /**
  18236. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  18237. * @returns a new right Vector3
  18238. */
  18239. static Right(): Vector3;
  18240. /**
  18241. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  18242. * @returns a new left Vector3
  18243. */
  18244. static Left(): Vector3;
  18245. /**
  18246. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  18247. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  18248. * @param vector defines the Vector3 to transform
  18249. * @param transformation defines the transformation matrix
  18250. * @returns the transformed Vector3
  18251. */
  18252. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  18253. /**
  18254. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  18255. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  18256. * @param vector defines the Vector3 to transform
  18257. * @param transformation defines the transformation matrix
  18258. * @param result defines the Vector3 where to store the result
  18259. */
  18260. static TransformCoordinatesToRef(vector: Vector3, transformation: Readonly<Matrix>, result: Vector3): void;
  18261. /**
  18262. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  18263. * This method computes tranformed coordinates only, not transformed direction vectors
  18264. * @param x define the x coordinate of the source vector
  18265. * @param y define the y coordinate of the source vector
  18266. * @param z define the z coordinate of the source vector
  18267. * @param transformation defines the transformation matrix
  18268. * @param result defines the Vector3 where to store the result
  18269. */
  18270. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Readonly<Matrix>, result: Vector3): void;
  18271. /**
  18272. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  18273. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  18274. * @param vector defines the Vector3 to transform
  18275. * @param transformation defines the transformation matrix
  18276. * @returns the new Vector3
  18277. */
  18278. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  18279. /**
  18280. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  18281. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  18282. * @param vector defines the Vector3 to transform
  18283. * @param transformation defines the transformation matrix
  18284. * @param result defines the Vector3 where to store the result
  18285. */
  18286. static TransformNormalToRef(vector: Vector3, transformation: Readonly<Matrix>, result: Vector3): void;
  18287. /**
  18288. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  18289. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  18290. * @param x define the x coordinate of the source vector
  18291. * @param y define the y coordinate of the source vector
  18292. * @param z define the z coordinate of the source vector
  18293. * @param transformation defines the transformation matrix
  18294. * @param result defines the Vector3 where to store the result
  18295. */
  18296. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Readonly<Matrix>, result: Vector3): void;
  18297. /**
  18298. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  18299. * @param value1 defines the first control point
  18300. * @param value2 defines the second control point
  18301. * @param value3 defines the third control point
  18302. * @param value4 defines the fourth control point
  18303. * @param amount defines the amount on the spline to use
  18304. * @returns the new Vector3
  18305. */
  18306. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  18307. /**
  18308. * 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"
  18309. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  18310. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  18311. * @param value defines the current value
  18312. * @param min defines the lower range value
  18313. * @param max defines the upper range value
  18314. * @returns the new Vector3
  18315. */
  18316. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  18317. /**
  18318. * 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"
  18319. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  18320. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  18321. * @param value defines the current value
  18322. * @param min defines the lower range value
  18323. * @param max defines the upper range value
  18324. * @param result defines the Vector3 where to store the result
  18325. */
  18326. static ClampToRef(value: Vector3, min: Vector3, max: Vector3, result: Vector3): void;
  18327. /**
  18328. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  18329. * @param value1 defines the first control point
  18330. * @param tangent1 defines the first tangent vector
  18331. * @param value2 defines the second control point
  18332. * @param tangent2 defines the second tangent vector
  18333. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  18334. * @returns the new Vector3
  18335. */
  18336. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  18337. /**
  18338. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  18339. * @param start defines the start value
  18340. * @param end defines the end value
  18341. * @param amount max defines amount between both (between 0 and 1)
  18342. * @returns the new Vector3
  18343. */
  18344. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  18345. /**
  18346. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  18347. * @param start defines the start value
  18348. * @param end defines the end value
  18349. * @param amount max defines amount between both (between 0 and 1)
  18350. * @param result defines the Vector3 where to store the result
  18351. */
  18352. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  18353. /**
  18354. * Returns the dot product (float) between the vectors "left" and "right"
  18355. * @param left defines the left operand
  18356. * @param right defines the right operand
  18357. * @returns the dot product
  18358. */
  18359. static Dot(left: Vector3, right: Vector3): number;
  18360. /**
  18361. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  18362. * The cross product is then orthogonal to both "left" and "right"
  18363. * @param left defines the left operand
  18364. * @param right defines the right operand
  18365. * @returns the cross product
  18366. */
  18367. static Cross(left: Vector3, right: Vector3): Vector3;
  18368. /**
  18369. * Sets the given vector "result" with the cross product of "left" and "right"
  18370. * The cross product is then orthogonal to both "left" and "right"
  18371. * @param left defines the left operand
  18372. * @param right defines the right operand
  18373. * @param result defines the Vector3 where to store the result
  18374. */
  18375. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  18376. /**
  18377. * Returns a new Vector3 as the normalization of the given vector
  18378. * @param vector defines the Vector3 to normalize
  18379. * @returns the new Vector3
  18380. */
  18381. static Normalize(vector: Vector3): Vector3;
  18382. /**
  18383. * Sets the given vector "result" with the normalization of the given first vector
  18384. * @param vector defines the Vector3 to normalize
  18385. * @param result defines the Vector3 where to store the result
  18386. */
  18387. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  18388. /**
  18389. * Project a Vector3 onto screen space
  18390. * @param vector defines the Vector3 to project
  18391. * @param world defines the world matrix to use
  18392. * @param transform defines the transform (view x projection) matrix to use
  18393. * @param viewport defines the screen viewport to use
  18394. * @returns the new Vector3
  18395. */
  18396. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  18397. /**
  18398. * Unproject from screen space to object space
  18399. * @param source defines the screen space Vector3 to use
  18400. * @param viewportWidth defines the current width of the viewport
  18401. * @param viewportHeight defines the current height of the viewport
  18402. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18403. * @param transform defines the transform (view x projection) matrix to use
  18404. * @returns the new Vector3
  18405. */
  18406. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  18407. /**
  18408. * Unproject from screen space to object space
  18409. * @param source defines the screen space Vector3 to use
  18410. * @param viewportWidth defines the current width of the viewport
  18411. * @param viewportHeight defines the current height of the viewport
  18412. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18413. * @param view defines the view matrix to use
  18414. * @param projection defines the projection matrix to use
  18415. * @returns the new Vector3
  18416. */
  18417. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  18418. /**
  18419. * Unproject from screen space to object space
  18420. * @param source defines the screen space Vector3 to use
  18421. * @param viewportWidth defines the current width of the viewport
  18422. * @param viewportHeight defines the current height of the viewport
  18423. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18424. * @param view defines the view matrix to use
  18425. * @param projection defines the projection matrix to use
  18426. * @param result defines the Vector3 where to store the result
  18427. */
  18428. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  18429. /**
  18430. * Unproject from screen space to object space
  18431. * @param sourceX defines the screen space x coordinate to use
  18432. * @param sourceY defines the screen space y coordinate to use
  18433. * @param sourceZ defines the screen space z coordinate to use
  18434. * @param viewportWidth defines the current width of the viewport
  18435. * @param viewportHeight defines the current height of the viewport
  18436. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18437. * @param view defines the view matrix to use
  18438. * @param projection defines the projection matrix to use
  18439. * @param result defines the Vector3 where to store the result
  18440. */
  18441. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  18442. /**
  18443. * Gets the minimal coordinate values between two Vector3
  18444. * @param left defines the first operand
  18445. * @param right defines the second operand
  18446. * @returns the new Vector3
  18447. */
  18448. static Minimize(left: Vector3, right: Vector3): Vector3;
  18449. /**
  18450. * Gets the maximal coordinate values between two Vector3
  18451. * @param left defines the first operand
  18452. * @param right defines the second operand
  18453. * @returns the new Vector3
  18454. */
  18455. static Maximize(left: Vector3, right: Vector3): Vector3;
  18456. /**
  18457. * Returns the distance between the vectors "value1" and "value2"
  18458. * @param value1 defines the first operand
  18459. * @param value2 defines the second operand
  18460. * @returns the distance
  18461. */
  18462. static Distance(value1: Vector3, value2: Vector3): number;
  18463. /**
  18464. * Returns the squared distance between the vectors "value1" and "value2"
  18465. * @param value1 defines the first operand
  18466. * @param value2 defines the second operand
  18467. * @returns the squared distance
  18468. */
  18469. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  18470. /**
  18471. * Returns a new Vector3 located at the center between "value1" and "value2"
  18472. * @param value1 defines the first operand
  18473. * @param value2 defines the second operand
  18474. * @returns the new Vector3
  18475. */
  18476. static Center(value1: Vector3, value2: Vector3): Vector3;
  18477. /**
  18478. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  18479. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  18480. * to something in order to rotate it from its local system to the given target system
  18481. * Note: axis1, axis2 and axis3 are normalized during this operation
  18482. * @param axis1 defines the first axis
  18483. * @param axis2 defines the second axis
  18484. * @param axis3 defines the third axis
  18485. * @returns a new Vector3
  18486. */
  18487. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  18488. /**
  18489. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  18490. * @param axis1 defines the first axis
  18491. * @param axis2 defines the second axis
  18492. * @param axis3 defines the third axis
  18493. * @param ref defines the Vector3 where to store the result
  18494. */
  18495. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  18496. }
  18497. /**
  18498. * Vector4 class created for EulerAngle class conversion to Quaternion
  18499. */
  18500. class Vector4 {
  18501. /** x value of the vector */
  18502. x: number;
  18503. /** y value of the vector */
  18504. y: number;
  18505. /** z value of the vector */
  18506. z: number;
  18507. /** w value of the vector */
  18508. w: number;
  18509. /**
  18510. * Creates a Vector4 object from the given floats.
  18511. * @param x x value of the vector
  18512. * @param y y value of the vector
  18513. * @param z z value of the vector
  18514. * @param w w value of the vector
  18515. */
  18516. constructor(
  18517. /** x value of the vector */
  18518. x: number,
  18519. /** y value of the vector */
  18520. y: number,
  18521. /** z value of the vector */
  18522. z: number,
  18523. /** w value of the vector */
  18524. w: number);
  18525. /**
  18526. * Returns the string with the Vector4 coordinates.
  18527. * @returns a string containing all the vector values
  18528. */
  18529. toString(): string;
  18530. /**
  18531. * Returns the string "Vector4".
  18532. * @returns "Vector4"
  18533. */
  18534. getClassName(): string;
  18535. /**
  18536. * Returns the Vector4 hash code.
  18537. * @returns a unique hash code
  18538. */
  18539. getHashCode(): number;
  18540. /**
  18541. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  18542. * @returns the resulting array
  18543. */
  18544. asArray(): number[];
  18545. /**
  18546. * Populates the given array from the given index with the Vector4 coordinates.
  18547. * @param array array to populate
  18548. * @param index index of the array to start at (default: 0)
  18549. * @returns the Vector4.
  18550. */
  18551. toArray(array: FloatArray, index?: number): Vector4;
  18552. /**
  18553. * Adds the given vector to the current Vector4.
  18554. * @param otherVector the vector to add
  18555. * @returns the updated Vector4.
  18556. */
  18557. addInPlace(otherVector: Vector4): Vector4;
  18558. /**
  18559. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  18560. * @param otherVector the vector to add
  18561. * @returns the resulting vector
  18562. */
  18563. add(otherVector: Vector4): Vector4;
  18564. /**
  18565. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  18566. * @param otherVector the vector to add
  18567. * @param result the vector to store the result
  18568. * @returns the current Vector4.
  18569. */
  18570. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  18571. /**
  18572. * Subtract in place the given vector from the current Vector4.
  18573. * @param otherVector the vector to subtract
  18574. * @returns the updated Vector4.
  18575. */
  18576. subtractInPlace(otherVector: Vector4): Vector4;
  18577. /**
  18578. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  18579. * @param otherVector the vector to add
  18580. * @returns the new vector with the result
  18581. */
  18582. subtract(otherVector: Vector4): Vector4;
  18583. /**
  18584. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  18585. * @param otherVector the vector to subtract
  18586. * @param result the vector to store the result
  18587. * @returns the current Vector4.
  18588. */
  18589. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  18590. /**
  18591. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  18592. */
  18593. /**
  18594. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  18595. * @param x value to subtract
  18596. * @param y value to subtract
  18597. * @param z value to subtract
  18598. * @param w value to subtract
  18599. * @returns new vector containing the result
  18600. */
  18601. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  18602. /**
  18603. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  18604. * @param x value to subtract
  18605. * @param y value to subtract
  18606. * @param z value to subtract
  18607. * @param w value to subtract
  18608. * @param result the vector to store the result in
  18609. * @returns the current Vector4.
  18610. */
  18611. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  18612. /**
  18613. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  18614. * @returns a new vector with the negated values
  18615. */
  18616. negate(): Vector4;
  18617. /**
  18618. * Multiplies the current Vector4 coordinates by scale (float).
  18619. * @param scale the number to scale with
  18620. * @returns the updated Vector4.
  18621. */
  18622. scaleInPlace(scale: number): Vector4;
  18623. /**
  18624. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  18625. * @param scale the number to scale with
  18626. * @returns a new vector with the result
  18627. */
  18628. scale(scale: number): Vector4;
  18629. /**
  18630. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  18631. * @param scale the number to scale with
  18632. * @param result a vector to store the result in
  18633. * @returns the current Vector4.
  18634. */
  18635. scaleToRef(scale: number, result: Vector4): Vector4;
  18636. /**
  18637. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  18638. * @param scale defines the scale factor
  18639. * @param result defines the Vector4 object where to store the result
  18640. * @returns the unmodified current Vector4
  18641. */
  18642. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  18643. /**
  18644. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  18645. * @param otherVector the vector to compare against
  18646. * @returns true if they are equal
  18647. */
  18648. equals(otherVector: Vector4): boolean;
  18649. /**
  18650. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  18651. * @param otherVector vector to compare against
  18652. * @param epsilon (Default: very small number)
  18653. * @returns true if they are equal
  18654. */
  18655. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  18656. /**
  18657. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  18658. * @param x x value to compare against
  18659. * @param y y value to compare against
  18660. * @param z z value to compare against
  18661. * @param w w value to compare against
  18662. * @returns true if equal
  18663. */
  18664. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  18665. /**
  18666. * Multiplies in place the current Vector4 by the given one.
  18667. * @param otherVector vector to multiple with
  18668. * @returns the updated Vector4.
  18669. */
  18670. multiplyInPlace(otherVector: Vector4): Vector4;
  18671. /**
  18672. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  18673. * @param otherVector vector to multiple with
  18674. * @returns resulting new vector
  18675. */
  18676. multiply(otherVector: Vector4): Vector4;
  18677. /**
  18678. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  18679. * @param otherVector vector to multiple with
  18680. * @param result vector to store the result
  18681. * @returns the current Vector4.
  18682. */
  18683. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  18684. /**
  18685. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  18686. * @param x x value multiply with
  18687. * @param y y value multiply with
  18688. * @param z z value multiply with
  18689. * @param w w value multiply with
  18690. * @returns resulting new vector
  18691. */
  18692. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  18693. /**
  18694. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  18695. * @param otherVector vector to devide with
  18696. * @returns resulting new vector
  18697. */
  18698. divide(otherVector: Vector4): Vector4;
  18699. /**
  18700. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  18701. * @param otherVector vector to devide with
  18702. * @param result vector to store the result
  18703. * @returns the current Vector4.
  18704. */
  18705. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  18706. /**
  18707. * Divides the current Vector3 coordinates by the given ones.
  18708. * @param otherVector vector to devide with
  18709. * @returns the updated Vector3.
  18710. */
  18711. divideInPlace(otherVector: Vector4): Vector4;
  18712. /**
  18713. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  18714. * @param other defines the second operand
  18715. * @returns the current updated Vector4
  18716. */
  18717. minimizeInPlace(other: Vector4): Vector4;
  18718. /**
  18719. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  18720. * @param other defines the second operand
  18721. * @returns the current updated Vector4
  18722. */
  18723. maximizeInPlace(other: Vector4): Vector4;
  18724. /**
  18725. * Gets a new Vector4 from current Vector4 floored values
  18726. * @returns a new Vector4
  18727. */
  18728. floor(): Vector4;
  18729. /**
  18730. * Gets a new Vector4 from current Vector3 floored values
  18731. * @returns a new Vector4
  18732. */
  18733. fract(): Vector4;
  18734. /**
  18735. * Returns the Vector4 length (float).
  18736. * @returns the length
  18737. */
  18738. length(): number;
  18739. /**
  18740. * Returns the Vector4 squared length (float).
  18741. * @returns the length squared
  18742. */
  18743. lengthSquared(): number;
  18744. /**
  18745. * Normalizes in place the Vector4.
  18746. * @returns the updated Vector4.
  18747. */
  18748. normalize(): Vector4;
  18749. /**
  18750. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  18751. * @returns this converted to a new vector3
  18752. */
  18753. toVector3(): Vector3;
  18754. /**
  18755. * Returns a new Vector4 copied from the current one.
  18756. * @returns the new cloned vector
  18757. */
  18758. clone(): Vector4;
  18759. /**
  18760. * Updates the current Vector4 with the given one coordinates.
  18761. * @param source the source vector to copy from
  18762. * @returns the updated Vector4.
  18763. */
  18764. copyFrom(source: Vector4): Vector4;
  18765. /**
  18766. * Updates the current Vector4 coordinates with the given floats.
  18767. * @param x float to copy from
  18768. * @param y float to copy from
  18769. * @param z float to copy from
  18770. * @param w float to copy from
  18771. * @returns the updated Vector4.
  18772. */
  18773. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  18774. /**
  18775. * Updates the current Vector4 coordinates with the given floats.
  18776. * @param x float to set from
  18777. * @param y float to set from
  18778. * @param z float to set from
  18779. * @param w float to set from
  18780. * @returns the updated Vector4.
  18781. */
  18782. set(x: number, y: number, z: number, w: number): Vector4;
  18783. /**
  18784. * Copies the given float to the current Vector3 coordinates
  18785. * @param v defines the x, y, z and w coordinates of the operand
  18786. * @returns the current updated Vector3
  18787. */
  18788. setAll(v: number): Vector4;
  18789. /**
  18790. * Returns a new Vector4 set from the starting index of the given array.
  18791. * @param array the array to pull values from
  18792. * @param offset the offset into the array to start at
  18793. * @returns the new vector
  18794. */
  18795. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  18796. /**
  18797. * Updates the given vector "result" from the starting index of the given array.
  18798. * @param array the array to pull values from
  18799. * @param offset the offset into the array to start at
  18800. * @param result the vector to store the result in
  18801. */
  18802. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  18803. /**
  18804. * Updates the given vector "result" from the starting index of the given Float32Array.
  18805. * @param array the array to pull values from
  18806. * @param offset the offset into the array to start at
  18807. * @param result the vector to store the result in
  18808. */
  18809. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  18810. /**
  18811. * Updates the given vector "result" coordinates from the given floats.
  18812. * @param x float to set from
  18813. * @param y float to set from
  18814. * @param z float to set from
  18815. * @param w float to set from
  18816. * @param result the vector to the floats in
  18817. */
  18818. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  18819. /**
  18820. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  18821. * @returns the new vector
  18822. */
  18823. static Zero(): Vector4;
  18824. /**
  18825. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  18826. * @returns the new vector
  18827. */
  18828. static One(): Vector4;
  18829. /**
  18830. * Returns a new normalized Vector4 from the given one.
  18831. * @param vector the vector to normalize
  18832. * @returns the vector
  18833. */
  18834. static Normalize(vector: Vector4): Vector4;
  18835. /**
  18836. * Updates the given vector "result" from the normalization of the given one.
  18837. * @param vector the vector to normalize
  18838. * @param result the vector to store the result in
  18839. */
  18840. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  18841. /**
  18842. * Returns a vector with the minimum values from the left and right vectors
  18843. * @param left left vector to minimize
  18844. * @param right right vector to minimize
  18845. * @returns a new vector with the minimum of the left and right vector values
  18846. */
  18847. static Minimize(left: Vector4, right: Vector4): Vector4;
  18848. /**
  18849. * Returns a vector with the maximum values from the left and right vectors
  18850. * @param left left vector to maximize
  18851. * @param right right vector to maximize
  18852. * @returns a new vector with the maximum of the left and right vector values
  18853. */
  18854. static Maximize(left: Vector4, right: Vector4): Vector4;
  18855. /**
  18856. * Returns the distance (float) between the vectors "value1" and "value2".
  18857. * @param value1 value to calulate the distance between
  18858. * @param value2 value to calulate the distance between
  18859. * @return the distance between the two vectors
  18860. */
  18861. static Distance(value1: Vector4, value2: Vector4): number;
  18862. /**
  18863. * Returns the squared distance (float) between the vectors "value1" and "value2".
  18864. * @param value1 value to calulate the distance between
  18865. * @param value2 value to calulate the distance between
  18866. * @return the distance between the two vectors squared
  18867. */
  18868. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  18869. /**
  18870. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  18871. * @param value1 value to calulate the center between
  18872. * @param value2 value to calulate the center between
  18873. * @return the center between the two vectors
  18874. */
  18875. static Center(value1: Vector4, value2: Vector4): Vector4;
  18876. /**
  18877. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  18878. * This methods computes transformed normalized direction vectors only.
  18879. * @param vector the vector to transform
  18880. * @param transformation the transformation matrix to apply
  18881. * @returns the new vector
  18882. */
  18883. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  18884. /**
  18885. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  18886. * This methods computes transformed normalized direction vectors only.
  18887. * @param vector the vector to transform
  18888. * @param transformation the transformation matrix to apply
  18889. * @param result the vector to store the result in
  18890. */
  18891. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  18892. /**
  18893. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  18894. * This methods computes transformed normalized direction vectors only.
  18895. * @param x value to transform
  18896. * @param y value to transform
  18897. * @param z value to transform
  18898. * @param w value to transform
  18899. * @param transformation the transformation matrix to apply
  18900. * @param result the vector to store the results in
  18901. */
  18902. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  18903. }
  18904. /**
  18905. * Interface for the size containing width and height
  18906. */
  18907. interface ISize {
  18908. /**
  18909. * Width
  18910. */
  18911. width: number;
  18912. /**
  18913. * Heighht
  18914. */
  18915. height: number;
  18916. }
  18917. /**
  18918. * Size containing widht and height
  18919. */
  18920. class Size implements ISize {
  18921. /**
  18922. * Width
  18923. */
  18924. width: number;
  18925. /**
  18926. * Height
  18927. */
  18928. height: number;
  18929. /**
  18930. * Creates a Size object from the given width and height (floats).
  18931. * @param width width of the new size
  18932. * @param height height of the new size
  18933. */
  18934. constructor(width: number, height: number);
  18935. /**
  18936. * Returns a string with the Size width and height
  18937. * @returns a string with the Size width and height
  18938. */
  18939. toString(): string;
  18940. /**
  18941. * "Size"
  18942. * @returns the string "Size"
  18943. */
  18944. getClassName(): string;
  18945. /**
  18946. * Returns the Size hash code.
  18947. * @returns a hash code for a unique width and height
  18948. */
  18949. getHashCode(): number;
  18950. /**
  18951. * Updates the current size from the given one.
  18952. * @param src the given size
  18953. */
  18954. copyFrom(src: Size): void;
  18955. /**
  18956. * Updates in place the current Size from the given floats.
  18957. * @param width width of the new size
  18958. * @param height height of the new size
  18959. * @returns the updated Size.
  18960. */
  18961. copyFromFloats(width: number, height: number): Size;
  18962. /**
  18963. * Updates in place the current Size from the given floats.
  18964. * @param width width to set
  18965. * @param height height to set
  18966. * @returns the updated Size.
  18967. */
  18968. set(width: number, height: number): Size;
  18969. /**
  18970. * Multiplies the width and height by numbers
  18971. * @param w factor to multiple the width by
  18972. * @param h factor to multiple the height by
  18973. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  18974. */
  18975. multiplyByFloats(w: number, h: number): Size;
  18976. /**
  18977. * Clones the size
  18978. * @returns a new Size copied from the given one.
  18979. */
  18980. clone(): Size;
  18981. /**
  18982. * True if the current Size and the given one width and height are strictly equal.
  18983. * @param other the other size to compare against
  18984. * @returns True if the current Size and the given one width and height are strictly equal.
  18985. */
  18986. equals(other: Size): boolean;
  18987. /**
  18988. * The surface of the Size : width * height (float).
  18989. */
  18990. readonly surface: number;
  18991. /**
  18992. * Create a new size of zero
  18993. * @returns a new Size set to (0.0, 0.0)
  18994. */
  18995. static Zero(): Size;
  18996. /**
  18997. * Sums the width and height of two sizes
  18998. * @param otherSize size to add to this size
  18999. * @returns a new Size set as the addition result of the current Size and the given one.
  19000. */
  19001. add(otherSize: Size): Size;
  19002. /**
  19003. * Subtracts the width and height of two
  19004. * @param otherSize size to subtract to this size
  19005. * @returns a new Size set as the subtraction result of the given one from the current Size.
  19006. */
  19007. subtract(otherSize: Size): Size;
  19008. /**
  19009. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  19010. * @param start starting size to lerp between
  19011. * @param end end size to lerp between
  19012. * @param amount amount to lerp between the start and end values
  19013. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  19014. */
  19015. static Lerp(start: Size, end: Size, amount: number): Size;
  19016. }
  19017. /**
  19018. * Class used to store quaternion data
  19019. * @see https://en.wikipedia.org/wiki/Quaternion
  19020. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  19021. */
  19022. class Quaternion {
  19023. /** defines the first component (0 by default) */
  19024. x: number;
  19025. /** defines the second component (0 by default) */
  19026. y: number;
  19027. /** defines the third component (0 by default) */
  19028. z: number;
  19029. /** defines the fourth component (1.0 by default) */
  19030. w: number;
  19031. /**
  19032. * Creates a new Quaternion from the given floats
  19033. * @param x defines the first component (0 by default)
  19034. * @param y defines the second component (0 by default)
  19035. * @param z defines the third component (0 by default)
  19036. * @param w defines the fourth component (1.0 by default)
  19037. */
  19038. constructor(
  19039. /** defines the first component (0 by default) */
  19040. x?: number,
  19041. /** defines the second component (0 by default) */
  19042. y?: number,
  19043. /** defines the third component (0 by default) */
  19044. z?: number,
  19045. /** defines the fourth component (1.0 by default) */
  19046. w?: number);
  19047. /**
  19048. * Gets a string representation for the current quaternion
  19049. * @returns a string with the Quaternion coordinates
  19050. */
  19051. toString(): string;
  19052. /**
  19053. * Gets the class name of the quaternion
  19054. * @returns the string "Quaternion"
  19055. */
  19056. getClassName(): string;
  19057. /**
  19058. * Gets a hash code for this quaternion
  19059. * @returns the quaternion hash code
  19060. */
  19061. getHashCode(): number;
  19062. /**
  19063. * Copy the quaternion to an array
  19064. * @returns a new array populated with 4 elements from the quaternion coordinates
  19065. */
  19066. asArray(): number[];
  19067. /**
  19068. * Check if two quaternions are equals
  19069. * @param otherQuaternion defines the second operand
  19070. * @return true if the current quaternion and the given one coordinates are strictly equals
  19071. */
  19072. equals(otherQuaternion: Quaternion): boolean;
  19073. /**
  19074. * Clone the current quaternion
  19075. * @returns a new quaternion copied from the current one
  19076. */
  19077. clone(): Quaternion;
  19078. /**
  19079. * Copy a quaternion to the current one
  19080. * @param other defines the other quaternion
  19081. * @returns the updated current quaternion
  19082. */
  19083. copyFrom(other: Quaternion): Quaternion;
  19084. /**
  19085. * Updates the current quaternion with the given float coordinates
  19086. * @param x defines the x coordinate
  19087. * @param y defines the y coordinate
  19088. * @param z defines the z coordinate
  19089. * @param w defines the w coordinate
  19090. * @returns the updated current quaternion
  19091. */
  19092. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  19093. /**
  19094. * Updates the current quaternion from the given float coordinates
  19095. * @param x defines the x coordinate
  19096. * @param y defines the y coordinate
  19097. * @param z defines the z coordinate
  19098. * @param w defines the w coordinate
  19099. * @returns the updated current quaternion
  19100. */
  19101. set(x: number, y: number, z: number, w: number): Quaternion;
  19102. /**
  19103. * Adds two quaternions
  19104. * @param other defines the second operand
  19105. * @returns a new quaternion as the addition result of the given one and the current quaternion
  19106. */
  19107. add(other: Quaternion): Quaternion;
  19108. /**
  19109. * Add a quaternion to the current one
  19110. * @param other defines the quaternion to add
  19111. * @returns the current quaternion
  19112. */
  19113. addInPlace(other: Quaternion): Quaternion;
  19114. /**
  19115. * Subtract two quaternions
  19116. * @param other defines the second operand
  19117. * @returns a new quaternion as the subtraction result of the given one from the current one
  19118. */
  19119. subtract(other: Quaternion): Quaternion;
  19120. /**
  19121. * Multiplies the current quaternion by a scale factor
  19122. * @param value defines the scale factor
  19123. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  19124. */
  19125. scale(value: number): Quaternion;
  19126. /**
  19127. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  19128. * @param scale defines the scale factor
  19129. * @param result defines the Quaternion object where to store the result
  19130. * @returns the unmodified current quaternion
  19131. */
  19132. scaleToRef(scale: number, result: Quaternion): Quaternion;
  19133. /**
  19134. * Multiplies in place the current quaternion by a scale factor
  19135. * @param value defines the scale factor
  19136. * @returns the current modified quaternion
  19137. */
  19138. scaleInPlace(value: number): Quaternion;
  19139. /**
  19140. * Scale the current quaternion values by a factor and add the result to a given quaternion
  19141. * @param scale defines the scale factor
  19142. * @param result defines the Quaternion object where to store the result
  19143. * @returns the unmodified current quaternion
  19144. */
  19145. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  19146. /**
  19147. * Multiplies two quaternions
  19148. * @param q1 defines the second operand
  19149. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  19150. */
  19151. multiply(q1: Quaternion): Quaternion;
  19152. /**
  19153. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  19154. * @param q1 defines the second operand
  19155. * @param result defines the target quaternion
  19156. * @returns the current quaternion
  19157. */
  19158. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  19159. /**
  19160. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  19161. * @param q1 defines the second operand
  19162. * @returns the currentupdated quaternion
  19163. */
  19164. multiplyInPlace(q1: Quaternion): Quaternion;
  19165. /**
  19166. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  19167. * @param ref defines the target quaternion
  19168. * @returns the current quaternion
  19169. */
  19170. conjugateToRef(ref: Quaternion): Quaternion;
  19171. /**
  19172. * Conjugates in place (1-q) the current quaternion
  19173. * @returns the current updated quaternion
  19174. */
  19175. conjugateInPlace(): Quaternion;
  19176. /**
  19177. * Conjugates in place (1-q) the current quaternion
  19178. * @returns a new quaternion
  19179. */
  19180. conjugate(): Quaternion;
  19181. /**
  19182. * Gets length of current quaternion
  19183. * @returns the quaternion length (float)
  19184. */
  19185. length(): number;
  19186. /**
  19187. * Normalize in place the current quaternion
  19188. * @returns the current updated quaternion
  19189. */
  19190. normalize(): Quaternion;
  19191. /**
  19192. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  19193. * @param order is a reserved parameter and is ignore for now
  19194. * @returns a new Vector3 containing the Euler angles
  19195. */
  19196. toEulerAngles(order?: string): Vector3;
  19197. /**
  19198. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  19199. * @param result defines the vector which will be filled with the Euler angles
  19200. * @param order is a reserved parameter and is ignore for now
  19201. * @returns the current unchanged quaternion
  19202. */
  19203. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  19204. /**
  19205. * Updates the given rotation matrix with the current quaternion values
  19206. * @param result defines the target matrix
  19207. * @returns the current unchanged quaternion
  19208. */
  19209. toRotationMatrix(result: Matrix): Quaternion;
  19210. /**
  19211. * Updates the current quaternion from the given rotation matrix values
  19212. * @param matrix defines the source matrix
  19213. * @returns the current updated quaternion
  19214. */
  19215. fromRotationMatrix(matrix: Matrix): Quaternion;
  19216. /**
  19217. * Creates a new quaternion from a rotation matrix
  19218. * @param matrix defines the source matrix
  19219. * @returns a new quaternion created from the given rotation matrix values
  19220. */
  19221. static FromRotationMatrix(matrix: Matrix): Quaternion;
  19222. /**
  19223. * Updates the given quaternion with the given rotation matrix values
  19224. * @param matrix defines the source matrix
  19225. * @param result defines the target quaternion
  19226. */
  19227. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  19228. /**
  19229. * Returns the dot product (float) between the quaternions "left" and "right"
  19230. * @param left defines the left operand
  19231. * @param right defines the right operand
  19232. * @returns the dot product
  19233. */
  19234. static Dot(left: Quaternion, right: Quaternion): number;
  19235. /**
  19236. * Checks if the two quaternions are close to each other
  19237. * @param quat0 defines the first quaternion to check
  19238. * @param quat1 defines the second quaternion to check
  19239. * @returns true if the two quaternions are close to each other
  19240. */
  19241. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  19242. /**
  19243. * Creates an empty quaternion
  19244. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  19245. */
  19246. static Zero(): Quaternion;
  19247. /**
  19248. * Inverse a given quaternion
  19249. * @param q defines the source quaternion
  19250. * @returns a new quaternion as the inverted current quaternion
  19251. */
  19252. static Inverse(q: Quaternion): Quaternion;
  19253. /**
  19254. * Creates an identity quaternion
  19255. * @returns the identity quaternion
  19256. */
  19257. static Identity(): Quaternion;
  19258. /**
  19259. * Gets a boolean indicating if the given quaternion is identity
  19260. * @param quaternion defines the quaternion to check
  19261. * @returns true if the quaternion is identity
  19262. */
  19263. static IsIdentity(quaternion: Quaternion): boolean;
  19264. /**
  19265. * Creates a quaternion from a rotation around an axis
  19266. * @param axis defines the axis to use
  19267. * @param angle defines the angle to use
  19268. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  19269. */
  19270. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  19271. /**
  19272. * Creates a rotation around an axis and stores it into the given quaternion
  19273. * @param axis defines the axis to use
  19274. * @param angle defines the angle to use
  19275. * @param result defines the target quaternion
  19276. * @returns the target quaternion
  19277. */
  19278. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  19279. /**
  19280. * Creates a new quaternion from data stored into an array
  19281. * @param array defines the data source
  19282. * @param offset defines the offset in the source array where the data starts
  19283. * @returns a new quaternion
  19284. */
  19285. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  19286. /**
  19287. * Creates a new quaternion from the given Euler float angles (y, x, z)
  19288. * @param yaw defines the rotation around Y axis
  19289. * @param pitch defines the rotation around X axis
  19290. * @param roll defines the rotation around Z axis
  19291. * @returns the new quaternion
  19292. */
  19293. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  19294. /**
  19295. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  19296. * @param yaw defines the rotation around Y axis
  19297. * @param pitch defines the rotation around X axis
  19298. * @param roll defines the rotation around Z axis
  19299. * @param result defines the target quaternion
  19300. */
  19301. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  19302. /**
  19303. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  19304. * @param alpha defines the rotation around first axis
  19305. * @param beta defines the rotation around second axis
  19306. * @param gamma defines the rotation around third axis
  19307. * @returns the new quaternion
  19308. */
  19309. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  19310. /**
  19311. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  19312. * @param alpha defines the rotation around first axis
  19313. * @param beta defines the rotation around second axis
  19314. * @param gamma defines the rotation around third axis
  19315. * @param result defines the target quaternion
  19316. */
  19317. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  19318. /**
  19319. * 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)
  19320. * @param axis1 defines the first axis
  19321. * @param axis2 defines the second axis
  19322. * @param axis3 defines the third axis
  19323. * @returns the new quaternion
  19324. */
  19325. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  19326. /**
  19327. * 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
  19328. * @param axis1 defines the first axis
  19329. * @param axis2 defines the second axis
  19330. * @param axis3 defines the third axis
  19331. * @param ref defines the target quaternion
  19332. */
  19333. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  19334. /**
  19335. * Interpolates between two quaternions
  19336. * @param left defines first quaternion
  19337. * @param right defines second quaternion
  19338. * @param amount defines the gradient to use
  19339. * @returns the new interpolated quaternion
  19340. */
  19341. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  19342. /**
  19343. * Interpolates between two quaternions and stores it into a target quaternion
  19344. * @param left defines first quaternion
  19345. * @param right defines second quaternion
  19346. * @param amount defines the gradient to use
  19347. * @param result defines the target quaternion
  19348. */
  19349. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  19350. /**
  19351. * Interpolate between two quaternions using Hermite interpolation
  19352. * @param value1 defines first quaternion
  19353. * @param tangent1 defines the incoming tangent
  19354. * @param value2 defines second quaternion
  19355. * @param tangent2 defines the outgoing tangent
  19356. * @param amount defines the target quaternion
  19357. * @returns the new interpolated quaternion
  19358. */
  19359. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  19360. }
  19361. /**
  19362. * Class used to store matrix data (4x4)
  19363. */
  19364. class Matrix {
  19365. private static _updateFlagSeed;
  19366. private static _identityReadOnly;
  19367. private _isIdentity;
  19368. private _isIdentityDirty;
  19369. private _isIdentity3x2;
  19370. private _isIdentity3x2Dirty;
  19371. /**
  19372. * Gets the update flag of the matrix which is an unique number for the matrix.
  19373. * It will be incremented every time the matrix data change.
  19374. * You can use it to speed the comparison between two versions of the same matrix.
  19375. */
  19376. updateFlag: number;
  19377. private readonly _m;
  19378. /**
  19379. * Gets the internal data of the matrix
  19380. */
  19381. readonly m: Readonly<Float32Array>;
  19382. /** @hidden */
  19383. _markAsUpdated(): void;
  19384. /** @hidden */
  19385. private _updateIdentityStatus;
  19386. /**
  19387. * Creates an empty matrix (filled with zeros)
  19388. */
  19389. constructor();
  19390. /**
  19391. * Check if the current matrix is identity
  19392. * @returns true is the matrix is the identity matrix
  19393. */
  19394. isIdentity(): boolean;
  19395. /**
  19396. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  19397. * @returns true is the matrix is the identity matrix
  19398. */
  19399. isIdentityAs3x2(): boolean;
  19400. /**
  19401. * Gets the determinant of the matrix
  19402. * @returns the matrix determinant
  19403. */
  19404. determinant(): number;
  19405. /**
  19406. * Returns the matrix as a Float32Array
  19407. * @returns the matrix underlying array
  19408. */
  19409. toArray(): Readonly<Float32Array>;
  19410. /**
  19411. * Returns the matrix as a Float32Array
  19412. * @returns the matrix underlying array.
  19413. */
  19414. asArray(): Readonly<Float32Array>;
  19415. /**
  19416. * Inverts the current matrix in place
  19417. * @returns the current inverted matrix
  19418. */
  19419. invert(): Matrix;
  19420. /**
  19421. * Sets all the matrix elements to zero
  19422. * @returns the current matrix
  19423. */
  19424. reset(): Matrix;
  19425. /**
  19426. * Adds the current matrix with a second one
  19427. * @param other defines the matrix to add
  19428. * @returns a new matrix as the addition of the current matrix and the given one
  19429. */
  19430. add(other: Matrix): Matrix;
  19431. /**
  19432. * Sets the given matrix "result" to the addition of the current matrix and the given one
  19433. * @param other defines the matrix to add
  19434. * @param result defines the target matrix
  19435. * @returns the current matrix
  19436. */
  19437. addToRef(other: Matrix, result: Matrix): Matrix;
  19438. /**
  19439. * Adds in place the given matrix to the current matrix
  19440. * @param other defines the second operand
  19441. * @returns the current updated matrix
  19442. */
  19443. addToSelf(other: Matrix): Matrix;
  19444. /**
  19445. * Sets the given matrix to the current inverted Matrix
  19446. * @param other defines the target matrix
  19447. * @returns the unmodified current matrix
  19448. */
  19449. invertToRef(other: Matrix): Matrix;
  19450. /**
  19451. * add a value at the specified position in the current Matrix
  19452. * @param index the index of the value within the matrix. between 0 and 15.
  19453. * @param value the value to be added
  19454. * @returns the current updated matrix
  19455. */
  19456. addAtIndex(index: number, value: number): Matrix;
  19457. /**
  19458. * mutiply the specified position in the current Matrix by a value
  19459. * @param index the index of the value within the matrix. between 0 and 15.
  19460. * @param value the value to be added
  19461. * @returns the current updated matrix
  19462. */
  19463. multiplyAtIndex(index: number, value: number): Matrix;
  19464. /**
  19465. * Inserts the translation vector (using 3 floats) in the current matrix
  19466. * @param x defines the 1st component of the translation
  19467. * @param y defines the 2nd component of the translation
  19468. * @param z defines the 3rd component of the translation
  19469. * @returns the current updated matrix
  19470. */
  19471. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  19472. /**
  19473. * Inserts the translation vector in the current matrix
  19474. * @param vector3 defines the translation to insert
  19475. * @returns the current updated matrix
  19476. */
  19477. setTranslation(vector3: Vector3): Matrix;
  19478. /**
  19479. * Gets the translation value of the current matrix
  19480. * @returns a new Vector3 as the extracted translation from the matrix
  19481. */
  19482. getTranslation(): Vector3;
  19483. /**
  19484. * Fill a Vector3 with the extracted translation from the matrix
  19485. * @param result defines the Vector3 where to store the translation
  19486. * @returns the current matrix
  19487. */
  19488. getTranslationToRef(result: Vector3): Matrix;
  19489. /**
  19490. * Remove rotation and scaling part from the matrix
  19491. * @returns the updated matrix
  19492. */
  19493. removeRotationAndScaling(): Matrix;
  19494. /**
  19495. * Multiply two matrices
  19496. * @param other defines the second operand
  19497. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  19498. */
  19499. multiply(other: Readonly<Matrix>): Matrix;
  19500. /**
  19501. * Copy the current matrix from the given one
  19502. * @param other defines the source matrix
  19503. * @returns the current updated matrix
  19504. */
  19505. copyFrom(other: Readonly<Matrix>): Matrix;
  19506. /**
  19507. * Populates the given array from the starting index with the current matrix values
  19508. * @param array defines the target array
  19509. * @param offset defines the offset in the target array where to start storing values
  19510. * @returns the current matrix
  19511. */
  19512. copyToArray(array: Float32Array, offset?: number): Matrix;
  19513. /**
  19514. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  19515. * @param other defines the second operand
  19516. * @param result defines the matrix where to store the multiplication
  19517. * @returns the current matrix
  19518. */
  19519. multiplyToRef(other: Readonly<Matrix>, result: Matrix): Matrix;
  19520. /**
  19521. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  19522. * @param other defines the second operand
  19523. * @param result defines the array where to store the multiplication
  19524. * @param offset defines the offset in the target array where to start storing values
  19525. * @returns the current matrix
  19526. */
  19527. multiplyToArray(other: Readonly<Matrix>, result: Float32Array, offset: number): Matrix;
  19528. /**
  19529. * Check equality between this matrix and a second one
  19530. * @param value defines the second matrix to compare
  19531. * @returns true is the current matrix and the given one values are strictly equal
  19532. */
  19533. equals(value: Matrix): boolean;
  19534. /**
  19535. * Clone the current matrix
  19536. * @returns a new matrix from the current matrix
  19537. */
  19538. clone(): Matrix;
  19539. /**
  19540. * Returns the name of the current matrix class
  19541. * @returns the string "Matrix"
  19542. */
  19543. getClassName(): string;
  19544. /**
  19545. * Gets the hash code of the current matrix
  19546. * @returns the hash code
  19547. */
  19548. getHashCode(): number;
  19549. /**
  19550. * Decomposes the current Matrix into a translation, rotation and scaling components
  19551. * @param scale defines the scale vector3 given as a reference to update
  19552. * @param rotation defines the rotation quaternion given as a reference to update
  19553. * @param translation defines the translation vector3 given as a reference to update
  19554. * @returns true if operation was successful
  19555. */
  19556. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  19557. /**
  19558. * Gets specific row of the matrix
  19559. * @param index defines the number of the row to get
  19560. * @returns the index-th row of the current matrix as a new Vector4
  19561. */
  19562. getRow(index: number): Nullable<Vector4>;
  19563. /**
  19564. * Sets the index-th row of the current matrix to the vector4 values
  19565. * @param index defines the number of the row to set
  19566. * @param row defines the target vector4
  19567. * @returns the updated current matrix
  19568. */
  19569. setRow(index: number, row: Vector4): Matrix;
  19570. /**
  19571. * Compute the transpose of the matrix
  19572. * @returns the new transposed matrix
  19573. */
  19574. transpose(): Matrix;
  19575. /**
  19576. * Compute the transpose of the matrix and store it in a given matrix
  19577. * @param result defines the target matrix
  19578. * @returns the current matrix
  19579. */
  19580. transposeToRef(result: Matrix): Matrix;
  19581. /**
  19582. * Sets the index-th row of the current matrix with the given 4 x float values
  19583. * @param index defines the row index
  19584. * @param x defines the x component to set
  19585. * @param y defines the y component to set
  19586. * @param z defines the z component to set
  19587. * @param w defines the w component to set
  19588. * @returns the updated current matrix
  19589. */
  19590. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  19591. /**
  19592. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  19593. * @param scale defines the scale factor
  19594. * @returns a new matrix
  19595. */
  19596. scale(scale: number): Matrix;
  19597. /**
  19598. * Scale the current matrix values by a factor to a given result matrix
  19599. * @param scale defines the scale factor
  19600. * @param result defines the matrix to store the result
  19601. * @returns the current matrix
  19602. */
  19603. scaleToRef(scale: number, result: Matrix): Matrix;
  19604. /**
  19605. * Scale the current matrix values by a factor and add the result to a given matrix
  19606. * @param scale defines the scale factor
  19607. * @param result defines the Matrix to store the result
  19608. * @returns the current matrix
  19609. */
  19610. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  19611. /**
  19612. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  19613. * @param ref matrix to store the result
  19614. */
  19615. toNormalMatrix(ref: Matrix): void;
  19616. /**
  19617. * Gets only rotation part of the current matrix
  19618. * @returns a new matrix sets to the extracted rotation matrix from the current one
  19619. */
  19620. getRotationMatrix(): Matrix;
  19621. /**
  19622. * Extracts the rotation matrix from the current one and sets it as the given "result"
  19623. * @param result defines the target matrix to store data to
  19624. * @returns the current matrix
  19625. */
  19626. getRotationMatrixToRef(result: Matrix): Matrix;
  19627. /**
  19628. * Toggles model matrix from being right handed to left handed in place and vice versa
  19629. */
  19630. toggleModelMatrixHandInPlace(): void;
  19631. /**
  19632. * Toggles projection matrix from being right handed to left handed in place and vice versa
  19633. */
  19634. toggleProjectionMatrixHandInPlace(): void;
  19635. /**
  19636. * Creates a matrix from an array
  19637. * @param array defines the source array
  19638. * @param offset defines an offset in the source array
  19639. * @returns a new Matrix set from the starting index of the given array
  19640. */
  19641. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  19642. /**
  19643. * Copy the content of an array into a given matrix
  19644. * @param array defines the source array
  19645. * @param offset defines an offset in the source array
  19646. * @param result defines the target matrix
  19647. */
  19648. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  19649. /**
  19650. * Stores an array into a matrix after having multiplied each component by a given factor
  19651. * @param array defines the source array
  19652. * @param offset defines the offset in the source array
  19653. * @param scale defines the scaling factor
  19654. * @param result defines the target matrix
  19655. */
  19656. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  19657. /**
  19658. * Gets an identity matrix that must not be updated
  19659. */
  19660. static readonly IdentityReadOnly: Readonly<Matrix>;
  19661. /**
  19662. * Stores a list of values (16) inside a given matrix
  19663. * @param initialM11 defines 1st value of 1st row
  19664. * @param initialM12 defines 2nd value of 1st row
  19665. * @param initialM13 defines 3rd value of 1st row
  19666. * @param initialM14 defines 4th value of 1st row
  19667. * @param initialM21 defines 1st value of 2nd row
  19668. * @param initialM22 defines 2nd value of 2nd row
  19669. * @param initialM23 defines 3rd value of 2nd row
  19670. * @param initialM24 defines 4th value of 2nd row
  19671. * @param initialM31 defines 1st value of 3rd row
  19672. * @param initialM32 defines 2nd value of 3rd row
  19673. * @param initialM33 defines 3rd value of 3rd row
  19674. * @param initialM34 defines 4th value of 3rd row
  19675. * @param initialM41 defines 1st value of 4th row
  19676. * @param initialM42 defines 2nd value of 4th row
  19677. * @param initialM43 defines 3rd value of 4th row
  19678. * @param initialM44 defines 4th value of 4th row
  19679. * @param result defines the target matrix
  19680. */
  19681. 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;
  19682. /**
  19683. * Creates new matrix from a list of values (16)
  19684. * @param initialM11 defines 1st value of 1st row
  19685. * @param initialM12 defines 2nd value of 1st row
  19686. * @param initialM13 defines 3rd value of 1st row
  19687. * @param initialM14 defines 4th value of 1st row
  19688. * @param initialM21 defines 1st value of 2nd row
  19689. * @param initialM22 defines 2nd value of 2nd row
  19690. * @param initialM23 defines 3rd value of 2nd row
  19691. * @param initialM24 defines 4th value of 2nd row
  19692. * @param initialM31 defines 1st value of 3rd row
  19693. * @param initialM32 defines 2nd value of 3rd row
  19694. * @param initialM33 defines 3rd value of 3rd row
  19695. * @param initialM34 defines 4th value of 3rd row
  19696. * @param initialM41 defines 1st value of 4th row
  19697. * @param initialM42 defines 2nd value of 4th row
  19698. * @param initialM43 defines 3rd value of 4th row
  19699. * @param initialM44 defines 4th value of 4th row
  19700. * @returns the new matrix
  19701. */
  19702. 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;
  19703. /**
  19704. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  19705. * @param scale defines the scale vector3
  19706. * @param rotation defines the rotation quaternion
  19707. * @param translation defines the translation vector3
  19708. * @returns a new matrix
  19709. */
  19710. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  19711. /**
  19712. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  19713. * @param scale defines the scale vector3
  19714. * @param rotation defines the rotation quaternion
  19715. * @param translation defines the translation vector3
  19716. * @param result defines the target matrix
  19717. */
  19718. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  19719. /**
  19720. * Creates a new identity matrix
  19721. * @returns a new identity matrix
  19722. */
  19723. static Identity(): Matrix;
  19724. /**
  19725. * Creates a new identity matrix and stores the result in a given matrix
  19726. * @param result defines the target matrix
  19727. */
  19728. static IdentityToRef(result: Matrix): void;
  19729. /**
  19730. * Creates a new zero matrix
  19731. * @returns a new zero matrix
  19732. */
  19733. static Zero(): Matrix;
  19734. /**
  19735. * Creates a new rotation matrix for "angle" radians around the X axis
  19736. * @param angle defines the angle (in radians) to use
  19737. * @return the new matrix
  19738. */
  19739. static RotationX(angle: number): Matrix;
  19740. /**
  19741. * Creates a new matrix as the invert of a given matrix
  19742. * @param source defines the source matrix
  19743. * @returns the new matrix
  19744. */
  19745. static Invert(source: Matrix): Matrix;
  19746. /**
  19747. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  19748. * @param angle defines the angle (in radians) to use
  19749. * @param result defines the target matrix
  19750. */
  19751. static RotationXToRef(angle: number, result: Matrix): void;
  19752. /**
  19753. * Creates a new rotation matrix for "angle" radians around the Y axis
  19754. * @param angle defines the angle (in radians) to use
  19755. * @return the new matrix
  19756. */
  19757. static RotationY(angle: number): Matrix;
  19758. /**
  19759. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  19760. * @param angle defines the angle (in radians) to use
  19761. * @param result defines the target matrix
  19762. */
  19763. static RotationYToRef(angle: number, result: Matrix): void;
  19764. /**
  19765. * Creates a new rotation matrix for "angle" radians around the Z axis
  19766. * @param angle defines the angle (in radians) to use
  19767. * @return the new matrix
  19768. */
  19769. static RotationZ(angle: number): Matrix;
  19770. /**
  19771. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  19772. * @param angle defines the angle (in radians) to use
  19773. * @param result defines the target matrix
  19774. */
  19775. static RotationZToRef(angle: number, result: Matrix): void;
  19776. /**
  19777. * Creates a new rotation matrix for "angle" radians around the given axis
  19778. * @param axis defines the axis to use
  19779. * @param angle defines the angle (in radians) to use
  19780. * @return the new matrix
  19781. */
  19782. static RotationAxis(axis: Vector3, angle: number): Matrix;
  19783. /**
  19784. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  19785. * @param axis defines the axis to use
  19786. * @param angle defines the angle (in radians) to use
  19787. * @param result defines the target matrix
  19788. */
  19789. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  19790. /**
  19791. * Creates a rotation matrix
  19792. * @param yaw defines the yaw angle in radians (Y axis)
  19793. * @param pitch defines the pitch angle in radians (X axis)
  19794. * @param roll defines the roll angle in radians (X axis)
  19795. * @returns the new rotation matrix
  19796. */
  19797. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  19798. /**
  19799. * Creates a rotation matrix and stores it in a given matrix
  19800. * @param yaw defines the yaw angle in radians (Y axis)
  19801. * @param pitch defines the pitch angle in radians (X axis)
  19802. * @param roll defines the roll angle in radians (X axis)
  19803. * @param result defines the target matrix
  19804. */
  19805. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  19806. /**
  19807. * Creates a scaling matrix
  19808. * @param x defines the scale factor on X axis
  19809. * @param y defines the scale factor on Y axis
  19810. * @param z defines the scale factor on Z axis
  19811. * @returns the new matrix
  19812. */
  19813. static Scaling(x: number, y: number, z: number): Matrix;
  19814. /**
  19815. * Creates a scaling matrix and stores it in a given matrix
  19816. * @param x defines the scale factor on X axis
  19817. * @param y defines the scale factor on Y axis
  19818. * @param z defines the scale factor on Z axis
  19819. * @param result defines the target matrix
  19820. */
  19821. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  19822. /**
  19823. * Creates a translation matrix
  19824. * @param x defines the translation on X axis
  19825. * @param y defines the translation on Y axis
  19826. * @param z defines the translationon Z axis
  19827. * @returns the new matrix
  19828. */
  19829. static Translation(x: number, y: number, z: number): Matrix;
  19830. /**
  19831. * Creates a translation matrix and stores it in a given matrix
  19832. * @param x defines the translation on X axis
  19833. * @param y defines the translation on Y axis
  19834. * @param z defines the translationon Z axis
  19835. * @param result defines the target matrix
  19836. */
  19837. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  19838. /**
  19839. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  19840. * @param startValue defines the start value
  19841. * @param endValue defines the end value
  19842. * @param gradient defines the gradient factor
  19843. * @returns the new matrix
  19844. */
  19845. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  19846. /**
  19847. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  19848. * @param startValue defines the start value
  19849. * @param endValue defines the end value
  19850. * @param gradient defines the gradient factor
  19851. * @param result defines the Matrix object where to store data
  19852. */
  19853. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  19854. /**
  19855. * Builds a new matrix whose values are computed by:
  19856. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  19857. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  19858. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  19859. * @param startValue defines the first matrix
  19860. * @param endValue defines the second matrix
  19861. * @param gradient defines the gradient between the two matrices
  19862. * @returns the new matrix
  19863. */
  19864. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  19865. /**
  19866. * Update a matrix to values which are computed by:
  19867. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  19868. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  19869. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  19870. * @param startValue defines the first matrix
  19871. * @param endValue defines the second matrix
  19872. * @param gradient defines the gradient between the two matrices
  19873. * @param result defines the target matrix
  19874. */
  19875. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  19876. /**
  19877. * 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"
  19878. * This function works in left handed mode
  19879. * @param eye defines the final position of the entity
  19880. * @param target defines where the entity should look at
  19881. * @param up defines the up vector for the entity
  19882. * @returns the new matrix
  19883. */
  19884. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  19885. /**
  19886. * 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".
  19887. * This function works in left handed mode
  19888. * @param eye defines the final position of the entity
  19889. * @param target defines where the entity should look at
  19890. * @param up defines the up vector for the entity
  19891. * @param result defines the target matrix
  19892. */
  19893. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  19894. /**
  19895. * 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"
  19896. * This function works in right handed mode
  19897. * @param eye defines the final position of the entity
  19898. * @param target defines where the entity should look at
  19899. * @param up defines the up vector for the entity
  19900. * @returns the new matrix
  19901. */
  19902. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  19903. /**
  19904. * 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".
  19905. * This function works in right handed mode
  19906. * @param eye defines the final position of the entity
  19907. * @param target defines where the entity should look at
  19908. * @param up defines the up vector for the entity
  19909. * @param result defines the target matrix
  19910. */
  19911. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  19912. /**
  19913. * Create a left-handed orthographic projection matrix
  19914. * @param width defines the viewport width
  19915. * @param height defines the viewport height
  19916. * @param znear defines the near clip plane
  19917. * @param zfar defines the far clip plane
  19918. * @returns a new matrix as a left-handed orthographic projection matrix
  19919. */
  19920. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  19921. /**
  19922. * Store a left-handed orthographic projection to a given matrix
  19923. * @param width defines the viewport width
  19924. * @param height defines the viewport height
  19925. * @param znear defines the near clip plane
  19926. * @param zfar defines the far clip plane
  19927. * @param result defines the target matrix
  19928. */
  19929. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  19930. /**
  19931. * Create a left-handed orthographic projection matrix
  19932. * @param left defines the viewport left coordinate
  19933. * @param right defines the viewport right coordinate
  19934. * @param bottom defines the viewport bottom coordinate
  19935. * @param top defines the viewport top coordinate
  19936. * @param znear defines the near clip plane
  19937. * @param zfar defines the far clip plane
  19938. * @returns a new matrix as a left-handed orthographic projection matrix
  19939. */
  19940. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  19941. /**
  19942. * Stores a left-handed orthographic projection into a given matrix
  19943. * @param left defines the viewport left coordinate
  19944. * @param right defines the viewport right coordinate
  19945. * @param bottom defines the viewport bottom coordinate
  19946. * @param top defines the viewport top coordinate
  19947. * @param znear defines the near clip plane
  19948. * @param zfar defines the far clip plane
  19949. * @param result defines the target matrix
  19950. */
  19951. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  19952. /**
  19953. * Creates a right-handed orthographic projection matrix
  19954. * @param left defines the viewport left coordinate
  19955. * @param right defines the viewport right coordinate
  19956. * @param bottom defines the viewport bottom coordinate
  19957. * @param top defines the viewport top coordinate
  19958. * @param znear defines the near clip plane
  19959. * @param zfar defines the far clip plane
  19960. * @returns a new matrix as a right-handed orthographic projection matrix
  19961. */
  19962. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  19963. /**
  19964. * Stores a right-handed orthographic projection into a given matrix
  19965. * @param left defines the viewport left coordinate
  19966. * @param right defines the viewport right coordinate
  19967. * @param bottom defines the viewport bottom coordinate
  19968. * @param top defines the viewport top coordinate
  19969. * @param znear defines the near clip plane
  19970. * @param zfar defines the far clip plane
  19971. * @param result defines the target matrix
  19972. */
  19973. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  19974. /**
  19975. * Creates a left-handed perspective projection matrix
  19976. * @param width defines the viewport width
  19977. * @param height defines the viewport height
  19978. * @param znear defines the near clip plane
  19979. * @param zfar defines the far clip plane
  19980. * @returns a new matrix as a left-handed perspective projection matrix
  19981. */
  19982. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  19983. /**
  19984. * Creates a left-handed perspective projection matrix
  19985. * @param fov defines the horizontal field of view
  19986. * @param aspect defines the aspect ratio
  19987. * @param znear defines the near clip plane
  19988. * @param zfar defines the far clip plane
  19989. * @returns a new matrix as a left-handed perspective projection matrix
  19990. */
  19991. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  19992. /**
  19993. * Stores a left-handed perspective projection into a given matrix
  19994. * @param fov defines the horizontal field of view
  19995. * @param aspect defines the aspect ratio
  19996. * @param znear defines the near clip plane
  19997. * @param zfar defines the far clip plane
  19998. * @param result defines the target matrix
  19999. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  20000. */
  20001. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  20002. /**
  20003. * Creates a right-handed perspective projection matrix
  20004. * @param fov defines the horizontal field of view
  20005. * @param aspect defines the aspect ratio
  20006. * @param znear defines the near clip plane
  20007. * @param zfar defines the far clip plane
  20008. * @returns a new matrix as a right-handed perspective projection matrix
  20009. */
  20010. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  20011. /**
  20012. * Stores a right-handed perspective projection into a given matrix
  20013. * @param fov defines the horizontal field of view
  20014. * @param aspect defines the aspect ratio
  20015. * @param znear defines the near clip plane
  20016. * @param zfar defines the far clip plane
  20017. * @param result defines the target matrix
  20018. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  20019. */
  20020. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  20021. /**
  20022. * Stores a perspective projection for WebVR info a given matrix
  20023. * @param fov defines the field of view
  20024. * @param znear defines the near clip plane
  20025. * @param zfar defines the far clip plane
  20026. * @param result defines the target matrix
  20027. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  20028. */
  20029. static PerspectiveFovWebVRToRef(fov: {
  20030. upDegrees: number;
  20031. downDegrees: number;
  20032. leftDegrees: number;
  20033. rightDegrees: number;
  20034. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  20035. /**
  20036. * Computes a complete transformation matrix
  20037. * @param viewport defines the viewport to use
  20038. * @param world defines the world matrix
  20039. * @param view defines the view matrix
  20040. * @param projection defines the projection matrix
  20041. * @param zmin defines the near clip plane
  20042. * @param zmax defines the far clip plane
  20043. * @returns the transformation matrix
  20044. */
  20045. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  20046. /**
  20047. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  20048. * @param matrix defines the matrix to use
  20049. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  20050. */
  20051. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  20052. /**
  20053. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  20054. * @param matrix defines the matrix to use
  20055. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  20056. */
  20057. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  20058. /**
  20059. * Compute the transpose of a given matrix
  20060. * @param matrix defines the matrix to transpose
  20061. * @returns the new matrix
  20062. */
  20063. static Transpose(matrix: Matrix): Matrix;
  20064. /**
  20065. * Compute the transpose of a matrix and store it in a target matrix
  20066. * @param matrix defines the matrix to transpose
  20067. * @param result defines the target matrix
  20068. */
  20069. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  20070. /**
  20071. * Computes a reflection matrix from a plane
  20072. * @param plane defines the reflection plane
  20073. * @returns a new matrix
  20074. */
  20075. static Reflection(plane: Plane): Matrix;
  20076. /**
  20077. * Computes a reflection matrix from a plane
  20078. * @param plane defines the reflection plane
  20079. * @param result defines the target matrix
  20080. */
  20081. static ReflectionToRef(plane: Plane, result: Matrix): void;
  20082. /**
  20083. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  20084. * @param xaxis defines the value of the 1st axis
  20085. * @param yaxis defines the value of the 2nd axis
  20086. * @param zaxis defines the value of the 3rd axis
  20087. * @param result defines the target matrix
  20088. */
  20089. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  20090. /**
  20091. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  20092. * @param quat defines the quaternion to use
  20093. * @param result defines the target matrix
  20094. */
  20095. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  20096. }
  20097. /**
  20098. * Represens a plane by the equation ax + by + cz + d = 0
  20099. */
  20100. class Plane {
  20101. /**
  20102. * Normal of the plane (a,b,c)
  20103. */
  20104. normal: Vector3;
  20105. /**
  20106. * d component of the plane
  20107. */
  20108. d: number;
  20109. /**
  20110. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  20111. * @param a a component of the plane
  20112. * @param b b component of the plane
  20113. * @param c c component of the plane
  20114. * @param d d component of the plane
  20115. */
  20116. constructor(a: number, b: number, c: number, d: number);
  20117. /**
  20118. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  20119. */
  20120. asArray(): number[];
  20121. /**
  20122. * @returns a new plane copied from the current Plane.
  20123. */
  20124. clone(): Plane;
  20125. /**
  20126. * @returns the string "Plane".
  20127. */
  20128. getClassName(): string;
  20129. /**
  20130. * @returns the Plane hash code.
  20131. */
  20132. getHashCode(): number;
  20133. /**
  20134. * Normalize the current Plane in place.
  20135. * @returns the updated Plane.
  20136. */
  20137. normalize(): Plane;
  20138. /**
  20139. * Applies a transformation the plane and returns the result
  20140. * @param transformation the transformation matrix to be applied to the plane
  20141. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  20142. */
  20143. transform(transformation: Matrix): Plane;
  20144. /**
  20145. * Calcualtte the dot product between the point and the plane normal
  20146. * @param point point to calculate the dot product with
  20147. * @returns the dot product (float) of the point coordinates and the plane normal.
  20148. */
  20149. dotCoordinate(point: Vector3): number;
  20150. /**
  20151. * Updates the current Plane from the plane defined by the three given points.
  20152. * @param point1 one of the points used to contruct the plane
  20153. * @param point2 one of the points used to contruct the plane
  20154. * @param point3 one of the points used to contruct the plane
  20155. * @returns the updated Plane.
  20156. */
  20157. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  20158. /**
  20159. * Checks if the plane is facing a given direction
  20160. * @param direction the direction to check if the plane is facing
  20161. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  20162. * @returns True is the vector "direction" is the same side than the plane normal.
  20163. */
  20164. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  20165. /**
  20166. * Calculates the distance to a point
  20167. * @param point point to calculate distance to
  20168. * @returns the signed distance (float) from the given point to the Plane.
  20169. */
  20170. signedDistanceTo(point: Vector3): number;
  20171. /**
  20172. * Creates a plane from an array
  20173. * @param array the array to create a plane from
  20174. * @returns a new Plane from the given array.
  20175. */
  20176. static FromArray(array: ArrayLike<number>): Plane;
  20177. /**
  20178. * Creates a plane from three points
  20179. * @param point1 point used to create the plane
  20180. * @param point2 point used to create the plane
  20181. * @param point3 point used to create the plane
  20182. * @returns a new Plane defined by the three given points.
  20183. */
  20184. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  20185. /**
  20186. * Creates a plane from an origin point and a normal
  20187. * @param origin origin of the plane to be constructed
  20188. * @param normal normal of the plane to be constructed
  20189. * @returns a new Plane the normal vector to this plane at the given origin point.
  20190. * Note : the vector "normal" is updated because normalized.
  20191. */
  20192. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  20193. /**
  20194. * Calculates the distance from a plane and a point
  20195. * @param origin origin of the plane to be constructed
  20196. * @param normal normal of the plane to be constructed
  20197. * @param point point to calculate distance to
  20198. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  20199. */
  20200. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  20201. }
  20202. /**
  20203. * Class used to represent a viewport on screen
  20204. */
  20205. class Viewport {
  20206. /** viewport left coordinate */
  20207. x: number;
  20208. /** viewport top coordinate */
  20209. y: number;
  20210. /**viewport width */
  20211. width: number;
  20212. /** viewport height */
  20213. height: number;
  20214. /**
  20215. * Creates a Viewport object located at (x, y) and sized (width, height)
  20216. * @param x defines viewport left coordinate
  20217. * @param y defines viewport top coordinate
  20218. * @param width defines the viewport width
  20219. * @param height defines the viewport height
  20220. */
  20221. constructor(
  20222. /** viewport left coordinate */
  20223. x: number,
  20224. /** viewport top coordinate */
  20225. y: number,
  20226. /**viewport width */
  20227. width: number,
  20228. /** viewport height */
  20229. height: number);
  20230. /**
  20231. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  20232. * @param renderWidthOrEngine defines either an engine or the rendering width
  20233. * @param renderHeight defines the rendering height
  20234. * @returns a new Viewport
  20235. */
  20236. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  20237. /**
  20238. * Returns a new Viewport copied from the current one
  20239. * @returns a new Viewport
  20240. */
  20241. clone(): Viewport;
  20242. }
  20243. /**
  20244. * Reprasents a camera frustum
  20245. */
  20246. class Frustum {
  20247. /**
  20248. * Gets the planes representing the frustum
  20249. * @param transform matrix to be applied to the returned planes
  20250. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  20251. */
  20252. static GetPlanes(transform: Matrix): Plane[];
  20253. /**
  20254. * Gets the near frustum plane transformed by the transform matrix
  20255. * @param transform transformation matrix to be applied to the resulting frustum plane
  20256. * @param frustumPlane the resuling frustum plane
  20257. */
  20258. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  20259. /**
  20260. * Gets the far frustum plane transformed by the transform matrix
  20261. * @param transform transformation matrix to be applied to the resulting frustum plane
  20262. * @param frustumPlane the resuling frustum plane
  20263. */
  20264. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  20265. /**
  20266. * Gets the left frustum plane transformed by the transform matrix
  20267. * @param transform transformation matrix to be applied to the resulting frustum plane
  20268. * @param frustumPlane the resuling frustum plane
  20269. */
  20270. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  20271. /**
  20272. * Gets the right frustum plane transformed by the transform matrix
  20273. * @param transform transformation matrix to be applied to the resulting frustum plane
  20274. * @param frustumPlane the resuling frustum plane
  20275. */
  20276. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  20277. /**
  20278. * Gets the top frustum plane transformed by the transform matrix
  20279. * @param transform transformation matrix to be applied to the resulting frustum plane
  20280. * @param frustumPlane the resuling frustum plane
  20281. */
  20282. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  20283. /**
  20284. * Gets the bottom frustum plane transformed by the transform matrix
  20285. * @param transform transformation matrix to be applied to the resulting frustum plane
  20286. * @param frustumPlane the resuling frustum plane
  20287. */
  20288. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  20289. /**
  20290. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  20291. * @param transform transformation matrix to be applied to the resulting frustum planes
  20292. * @param frustumPlanes the resuling frustum planes
  20293. */
  20294. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  20295. }
  20296. /** Defines supported spaces */
  20297. enum Space {
  20298. /** Local (object) space */
  20299. LOCAL = 0,
  20300. /** World space */
  20301. WORLD = 1,
  20302. /** Bone space */
  20303. BONE = 2
  20304. }
  20305. /** Defines the 3 main axes */
  20306. class Axis {
  20307. /** X axis */
  20308. static X: Vector3;
  20309. /** Y axis */
  20310. static Y: Vector3;
  20311. /** Z axis */
  20312. static Z: Vector3;
  20313. }
  20314. /** Class used to represent a Bezier curve */
  20315. class BezierCurve {
  20316. /**
  20317. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  20318. * @param t defines the time
  20319. * @param x1 defines the left coordinate on X axis
  20320. * @param y1 defines the left coordinate on Y axis
  20321. * @param x2 defines the right coordinate on X axis
  20322. * @param y2 defines the right coordinate on Y axis
  20323. * @returns the interpolated value
  20324. */
  20325. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  20326. }
  20327. /**
  20328. * Defines potential orientation for back face culling
  20329. */
  20330. enum Orientation {
  20331. /**
  20332. * Clockwise
  20333. */
  20334. CW = 0,
  20335. /** Counter clockwise */
  20336. CCW = 1
  20337. }
  20338. /**
  20339. * Defines angle representation
  20340. */
  20341. class Angle {
  20342. private _radians;
  20343. /**
  20344. * Creates an Angle object of "radians" radians (float).
  20345. */
  20346. constructor(radians: number);
  20347. /**
  20348. * Get value in degrees
  20349. * @returns the Angle value in degrees (float)
  20350. */
  20351. degrees(): number;
  20352. /**
  20353. * Get value in radians
  20354. * @returns the Angle value in radians (float)
  20355. */
  20356. radians(): number;
  20357. /**
  20358. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  20359. * @param a defines first vector
  20360. * @param b defines second vector
  20361. * @returns a new Angle
  20362. */
  20363. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  20364. /**
  20365. * Gets a new Angle object from the given float in radians
  20366. * @param radians defines the angle value in radians
  20367. * @returns a new Angle
  20368. */
  20369. static FromRadians(radians: number): Angle;
  20370. /**
  20371. * Gets a new Angle object from the given float in degrees
  20372. * @param degrees defines the angle value in degrees
  20373. * @returns a new Angle
  20374. */
  20375. static FromDegrees(degrees: number): Angle;
  20376. }
  20377. /**
  20378. * This represents an arc in a 2d space.
  20379. */
  20380. class Arc2 {
  20381. /** Defines the start point of the arc */
  20382. startPoint: Vector2;
  20383. /** Defines the mid point of the arc */
  20384. midPoint: Vector2;
  20385. /** Defines the end point of the arc */
  20386. endPoint: Vector2;
  20387. /**
  20388. * Defines the center point of the arc.
  20389. */
  20390. centerPoint: Vector2;
  20391. /**
  20392. * Defines the radius of the arc.
  20393. */
  20394. radius: number;
  20395. /**
  20396. * Defines the angle of the arc (from mid point to end point).
  20397. */
  20398. angle: Angle;
  20399. /**
  20400. * Defines the start angle of the arc (from start point to middle point).
  20401. */
  20402. startAngle: Angle;
  20403. /**
  20404. * Defines the orientation of the arc (clock wise/counter clock wise).
  20405. */
  20406. orientation: Orientation;
  20407. /**
  20408. * Creates an Arc object from the three given points : start, middle and end.
  20409. * @param startPoint Defines the start point of the arc
  20410. * @param midPoint Defines the midlle point of the arc
  20411. * @param endPoint Defines the end point of the arc
  20412. */
  20413. constructor(
  20414. /** Defines the start point of the arc */
  20415. startPoint: Vector2,
  20416. /** Defines the mid point of the arc */
  20417. midPoint: Vector2,
  20418. /** Defines the end point of the arc */
  20419. endPoint: Vector2);
  20420. }
  20421. /**
  20422. * Represents a 2D path made up of multiple 2D points
  20423. */
  20424. class Path2 {
  20425. private _points;
  20426. private _length;
  20427. /**
  20428. * If the path start and end point are the same
  20429. */
  20430. closed: boolean;
  20431. /**
  20432. * Creates a Path2 object from the starting 2D coordinates x and y.
  20433. * @param x the starting points x value
  20434. * @param y the starting points y value
  20435. */
  20436. constructor(x: number, y: number);
  20437. /**
  20438. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  20439. * @param x the added points x value
  20440. * @param y the added points y value
  20441. * @returns the updated Path2.
  20442. */
  20443. addLineTo(x: number, y: number): Path2;
  20444. /**
  20445. * 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.
  20446. * @param midX middle point x value
  20447. * @param midY middle point y value
  20448. * @param endX end point x value
  20449. * @param endY end point y value
  20450. * @param numberOfSegments (default: 36)
  20451. * @returns the updated Path2.
  20452. */
  20453. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  20454. /**
  20455. * Closes the Path2.
  20456. * @returns the Path2.
  20457. */
  20458. close(): Path2;
  20459. /**
  20460. * Gets the sum of the distance between each sequential point in the path
  20461. * @returns the Path2 total length (float).
  20462. */
  20463. length(): number;
  20464. /**
  20465. * Gets the points which construct the path
  20466. * @returns the Path2 internal array of points.
  20467. */
  20468. getPoints(): Vector2[];
  20469. /**
  20470. * Retreives the point at the distance aways from the starting point
  20471. * @param normalizedLengthPosition the length along the path to retreive the point from
  20472. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  20473. */
  20474. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  20475. /**
  20476. * Creates a new path starting from an x and y position
  20477. * @param x starting x value
  20478. * @param y starting y value
  20479. * @returns a new Path2 starting at the coordinates (x, y).
  20480. */
  20481. static StartingAt(x: number, y: number): Path2;
  20482. }
  20483. /**
  20484. * Represents a 3D path made up of multiple 3D points
  20485. */
  20486. class Path3D {
  20487. /**
  20488. * an array of Vector3, the curve axis of the Path3D
  20489. */
  20490. path: Vector3[];
  20491. private _curve;
  20492. private _distances;
  20493. private _tangents;
  20494. private _normals;
  20495. private _binormals;
  20496. private _raw;
  20497. /**
  20498. * new Path3D(path, normal, raw)
  20499. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  20500. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  20501. * @param path an array of Vector3, the curve axis of the Path3D
  20502. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  20503. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  20504. */
  20505. constructor(
  20506. /**
  20507. * an array of Vector3, the curve axis of the Path3D
  20508. */
  20509. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  20510. /**
  20511. * Returns the Path3D array of successive Vector3 designing its curve.
  20512. * @returns the Path3D array of successive Vector3 designing its curve.
  20513. */
  20514. getCurve(): Vector3[];
  20515. /**
  20516. * Returns an array populated with tangent vectors on each Path3D curve point.
  20517. * @returns an array populated with tangent vectors on each Path3D curve point.
  20518. */
  20519. getTangents(): Vector3[];
  20520. /**
  20521. * Returns an array populated with normal vectors on each Path3D curve point.
  20522. * @returns an array populated with normal vectors on each Path3D curve point.
  20523. */
  20524. getNormals(): Vector3[];
  20525. /**
  20526. * Returns an array populated with binormal vectors on each Path3D curve point.
  20527. * @returns an array populated with binormal vectors on each Path3D curve point.
  20528. */
  20529. getBinormals(): Vector3[];
  20530. /**
  20531. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  20532. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  20533. */
  20534. getDistances(): number[];
  20535. /**
  20536. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  20537. * @param path path which all values are copied into the curves points
  20538. * @param firstNormal which should be projected onto the curve
  20539. * @returns the same object updated.
  20540. */
  20541. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  20542. private _compute;
  20543. private _getFirstNonNullVector;
  20544. private _getLastNonNullVector;
  20545. private _normalVector;
  20546. }
  20547. /**
  20548. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  20549. * A Curve3 is designed from a series of successive Vector3.
  20550. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  20551. */
  20552. class Curve3 {
  20553. private _points;
  20554. private _length;
  20555. /**
  20556. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  20557. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  20558. * @param v1 (Vector3) the control point
  20559. * @param v2 (Vector3) the end point of the Quadratic Bezier
  20560. * @param nbPoints (integer) the wanted number of points in the curve
  20561. * @returns the created Curve3
  20562. */
  20563. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  20564. /**
  20565. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  20566. * @param v0 (Vector3) the origin point of the Cubic Bezier
  20567. * @param v1 (Vector3) the first control point
  20568. * @param v2 (Vector3) the second control point
  20569. * @param v3 (Vector3) the end point of the Cubic Bezier
  20570. * @param nbPoints (integer) the wanted number of points in the curve
  20571. * @returns the created Curve3
  20572. */
  20573. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  20574. /**
  20575. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  20576. * @param p1 (Vector3) the origin point of the Hermite Spline
  20577. * @param t1 (Vector3) the tangent vector at the origin point
  20578. * @param p2 (Vector3) the end point of the Hermite Spline
  20579. * @param t2 (Vector3) the tangent vector at the end point
  20580. * @param nbPoints (integer) the wanted number of points in the curve
  20581. * @returns the created Curve3
  20582. */
  20583. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  20584. /**
  20585. * Returns a Curve3 object along a CatmullRom Spline curve :
  20586. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  20587. * @param nbPoints (integer) the wanted number of points between each curve control points
  20588. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  20589. * @returns the created Curve3
  20590. */
  20591. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  20592. /**
  20593. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  20594. * A Curve3 is designed from a series of successive Vector3.
  20595. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  20596. * @param points points which make up the curve
  20597. */
  20598. constructor(points: Vector3[]);
  20599. /**
  20600. * @returns the Curve3 stored array of successive Vector3
  20601. */
  20602. getPoints(): Vector3[];
  20603. /**
  20604. * @returns the computed length (float) of the curve.
  20605. */
  20606. length(): number;
  20607. /**
  20608. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  20609. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  20610. * curveA and curveB keep unchanged.
  20611. * @param curve the curve to continue from this curve
  20612. * @returns the newly constructed curve
  20613. */
  20614. continue(curve: Curve3): Curve3;
  20615. private _computeLength;
  20616. }
  20617. /**
  20618. * Contains position and normal vectors for a vertex
  20619. */
  20620. class PositionNormalVertex {
  20621. /** the position of the vertex (defaut: 0,0,0) */
  20622. position: Vector3;
  20623. /** the normal of the vertex (defaut: 0,1,0) */
  20624. normal: Vector3;
  20625. /**
  20626. * Creates a PositionNormalVertex
  20627. * @param position the position of the vertex (defaut: 0,0,0)
  20628. * @param normal the normal of the vertex (defaut: 0,1,0)
  20629. */
  20630. constructor(
  20631. /** the position of the vertex (defaut: 0,0,0) */
  20632. position?: Vector3,
  20633. /** the normal of the vertex (defaut: 0,1,0) */
  20634. normal?: Vector3);
  20635. /**
  20636. * Clones the PositionNormalVertex
  20637. * @returns the cloned PositionNormalVertex
  20638. */
  20639. clone(): PositionNormalVertex;
  20640. }
  20641. /**
  20642. * Contains position, normal and uv vectors for a vertex
  20643. */
  20644. class PositionNormalTextureVertex {
  20645. /** the position of the vertex (defaut: 0,0,0) */
  20646. position: Vector3;
  20647. /** the normal of the vertex (defaut: 0,1,0) */
  20648. normal: Vector3;
  20649. /** the uv of the vertex (default: 0,0) */
  20650. uv: Vector2;
  20651. /**
  20652. * Creates a PositionNormalTextureVertex
  20653. * @param position the position of the vertex (defaut: 0,0,0)
  20654. * @param normal the normal of the vertex (defaut: 0,1,0)
  20655. * @param uv the uv of the vertex (default: 0,0)
  20656. */
  20657. constructor(
  20658. /** the position of the vertex (defaut: 0,0,0) */
  20659. position?: Vector3,
  20660. /** the normal of the vertex (defaut: 0,1,0) */
  20661. normal?: Vector3,
  20662. /** the uv of the vertex (default: 0,0) */
  20663. uv?: Vector2);
  20664. /**
  20665. * Clones the PositionNormalTextureVertex
  20666. * @returns the cloned PositionNormalTextureVertex
  20667. */
  20668. clone(): PositionNormalTextureVertex;
  20669. }
  20670. /**
  20671. * @hidden
  20672. */
  20673. class Tmp {
  20674. static Color3: Color3[];
  20675. static Color4: Color4[];
  20676. static Vector2: Vector2[];
  20677. static Vector3: Vector3[];
  20678. static Vector4: Vector4[];
  20679. static Quaternion: Quaternion[];
  20680. static Matrix: Matrix[];
  20681. }
  20682. }
  20683. declare module BABYLON {
  20684. /**
  20685. * Class representing spherical polynomial coefficients to the 3rd degree
  20686. */
  20687. class SphericalPolynomial {
  20688. /**
  20689. * The x coefficients of the spherical polynomial
  20690. */
  20691. x: Vector3;
  20692. /**
  20693. * The y coefficients of the spherical polynomial
  20694. */
  20695. y: Vector3;
  20696. /**
  20697. * The z coefficients of the spherical polynomial
  20698. */
  20699. z: Vector3;
  20700. /**
  20701. * The xx coefficients of the spherical polynomial
  20702. */
  20703. xx: Vector3;
  20704. /**
  20705. * The yy coefficients of the spherical polynomial
  20706. */
  20707. yy: Vector3;
  20708. /**
  20709. * The zz coefficients of the spherical polynomial
  20710. */
  20711. zz: Vector3;
  20712. /**
  20713. * The xy coefficients of the spherical polynomial
  20714. */
  20715. xy: Vector3;
  20716. /**
  20717. * The yz coefficients of the spherical polynomial
  20718. */
  20719. yz: Vector3;
  20720. /**
  20721. * The zx coefficients of the spherical polynomial
  20722. */
  20723. zx: Vector3;
  20724. /**
  20725. * Adds an ambient color to the spherical polynomial
  20726. * @param color the color to add
  20727. */
  20728. addAmbient(color: Color3): void;
  20729. /**
  20730. * Scales the spherical polynomial by the given amount
  20731. * @param scale the amount to scale
  20732. */
  20733. scale(scale: number): void;
  20734. /**
  20735. * Gets the spherical polynomial from harmonics
  20736. * @param harmonics the spherical harmonics
  20737. * @returns the spherical polynomial
  20738. */
  20739. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  20740. /**
  20741. * Constructs a spherical polynomial from an array.
  20742. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  20743. * @returns the spherical polynomial
  20744. */
  20745. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  20746. }
  20747. /**
  20748. * Class representing spherical harmonics coefficients to the 3rd degree
  20749. */
  20750. class SphericalHarmonics {
  20751. /**
  20752. * The l0,0 coefficients of the spherical harmonics
  20753. */
  20754. l00: Vector3;
  20755. /**
  20756. * The l1,-1 coefficients of the spherical harmonics
  20757. */
  20758. l1_1: Vector3;
  20759. /**
  20760. * The l1,0 coefficients of the spherical harmonics
  20761. */
  20762. l10: Vector3;
  20763. /**
  20764. * The l1,1 coefficients of the spherical harmonics
  20765. */
  20766. l11: Vector3;
  20767. /**
  20768. * The l2,-2 coefficients of the spherical harmonics
  20769. */
  20770. l2_2: Vector3;
  20771. /**
  20772. * The l2,-1 coefficients of the spherical harmonics
  20773. */
  20774. l2_1: Vector3;
  20775. /**
  20776. * The l2,0 coefficients of the spherical harmonics
  20777. */
  20778. l20: Vector3;
  20779. /**
  20780. * The l2,1 coefficients of the spherical harmonics
  20781. */
  20782. l21: Vector3;
  20783. /**
  20784. * The l2,2 coefficients of the spherical harmonics
  20785. */
  20786. lL22: Vector3;
  20787. /**
  20788. * Adds a light to the spherical harmonics
  20789. * @param direction the direction of the light
  20790. * @param color the color of the light
  20791. * @param deltaSolidAngle the delta solid angle of the light
  20792. */
  20793. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20794. /**
  20795. * Scales the spherical harmonics by the given amount
  20796. * @param scale the amount to scale
  20797. */
  20798. scale(scale: number): void;
  20799. /**
  20800. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  20801. *
  20802. * ```
  20803. * E_lm = A_l * L_lm
  20804. * ```
  20805. *
  20806. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  20807. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  20808. * the scaling factors are given in equation 9.
  20809. */
  20810. convertIncidentRadianceToIrradiance(): void;
  20811. /**
  20812. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  20813. *
  20814. * ```
  20815. * L = (1/pi) * E * rho
  20816. * ```
  20817. *
  20818. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  20819. */
  20820. convertIrradianceToLambertianRadiance(): void;
  20821. /**
  20822. * Gets the spherical harmonics from polynomial
  20823. * @param polynomial the spherical polynomial
  20824. * @returns the spherical harmonics
  20825. */
  20826. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  20827. /**
  20828. * Constructs a spherical harmonics from an array.
  20829. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  20830. * @returns the spherical harmonics
  20831. */
  20832. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  20833. }
  20834. }
  20835. declare module BABYLON {
  20836. /**
  20837. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  20838. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  20839. * 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;
  20840. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  20841. */
  20842. class ColorCurves {
  20843. private _dirty;
  20844. private _tempColor;
  20845. private _globalCurve;
  20846. private _highlightsCurve;
  20847. private _midtonesCurve;
  20848. private _shadowsCurve;
  20849. private _positiveCurve;
  20850. private _negativeCurve;
  20851. private _globalHue;
  20852. private _globalDensity;
  20853. private _globalSaturation;
  20854. private _globalExposure;
  20855. /**
  20856. * Gets the global Hue value.
  20857. * 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).
  20858. */
  20859. /**
  20860. * Sets the global Hue value.
  20861. * 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).
  20862. */
  20863. globalHue: number;
  20864. /**
  20865. * Gets the global Density value.
  20866. * 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.
  20867. * Values less than zero provide a filter of opposite hue.
  20868. */
  20869. /**
  20870. * Sets the global Density value.
  20871. * 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.
  20872. * Values less than zero provide a filter of opposite hue.
  20873. */
  20874. globalDensity: number;
  20875. /**
  20876. * Gets the global Saturation value.
  20877. * 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.
  20878. */
  20879. /**
  20880. * Sets the global Saturation value.
  20881. * 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.
  20882. */
  20883. globalSaturation: number;
  20884. /**
  20885. * Gets the global Exposure value.
  20886. * 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.
  20887. */
  20888. /**
  20889. * Sets the global Exposure value.
  20890. * 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.
  20891. */
  20892. globalExposure: number;
  20893. private _highlightsHue;
  20894. private _highlightsDensity;
  20895. private _highlightsSaturation;
  20896. private _highlightsExposure;
  20897. /**
  20898. * Gets the highlights Hue value.
  20899. * 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).
  20900. */
  20901. /**
  20902. * Sets the highlights Hue value.
  20903. * 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).
  20904. */
  20905. highlightsHue: number;
  20906. /**
  20907. * Gets the highlights Density value.
  20908. * 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.
  20909. * Values less than zero provide a filter of opposite hue.
  20910. */
  20911. /**
  20912. * Sets the highlights Density value.
  20913. * 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.
  20914. * Values less than zero provide a filter of opposite hue.
  20915. */
  20916. highlightsDensity: number;
  20917. /**
  20918. * Gets the highlights Saturation value.
  20919. * 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.
  20920. */
  20921. /**
  20922. * Sets the highlights Saturation value.
  20923. * 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.
  20924. */
  20925. highlightsSaturation: number;
  20926. /**
  20927. * Gets the highlights Exposure value.
  20928. * 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.
  20929. */
  20930. /**
  20931. * Sets the highlights Exposure value.
  20932. * 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.
  20933. */
  20934. highlightsExposure: number;
  20935. private _midtonesHue;
  20936. private _midtonesDensity;
  20937. private _midtonesSaturation;
  20938. private _midtonesExposure;
  20939. /**
  20940. * Gets the midtones Hue value.
  20941. * 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).
  20942. */
  20943. /**
  20944. * Sets the midtones Hue value.
  20945. * 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).
  20946. */
  20947. midtonesHue: number;
  20948. /**
  20949. * Gets the midtones Density value.
  20950. * 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.
  20951. * Values less than zero provide a filter of opposite hue.
  20952. */
  20953. /**
  20954. * Sets the midtones Density value.
  20955. * 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.
  20956. * Values less than zero provide a filter of opposite hue.
  20957. */
  20958. midtonesDensity: number;
  20959. /**
  20960. * Gets the midtones Saturation value.
  20961. * 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.
  20962. */
  20963. /**
  20964. * Sets the midtones Saturation value.
  20965. * 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.
  20966. */
  20967. midtonesSaturation: number;
  20968. /**
  20969. * Gets the midtones Exposure value.
  20970. * 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.
  20971. */
  20972. /**
  20973. * Sets the midtones Exposure value.
  20974. * 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.
  20975. */
  20976. midtonesExposure: number;
  20977. private _shadowsHue;
  20978. private _shadowsDensity;
  20979. private _shadowsSaturation;
  20980. private _shadowsExposure;
  20981. /**
  20982. * Gets the shadows Hue value.
  20983. * 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).
  20984. */
  20985. /**
  20986. * Sets the shadows Hue value.
  20987. * 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).
  20988. */
  20989. shadowsHue: number;
  20990. /**
  20991. * Gets the shadows Density value.
  20992. * 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.
  20993. * Values less than zero provide a filter of opposite hue.
  20994. */
  20995. /**
  20996. * Sets the shadows Density value.
  20997. * 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.
  20998. * Values less than zero provide a filter of opposite hue.
  20999. */
  21000. shadowsDensity: number;
  21001. /**
  21002. * Gets the shadows Saturation value.
  21003. * 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.
  21004. */
  21005. /**
  21006. * Sets the shadows Saturation value.
  21007. * 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.
  21008. */
  21009. shadowsSaturation: number;
  21010. /**
  21011. * Gets the shadows Exposure value.
  21012. * 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.
  21013. */
  21014. /**
  21015. * Sets the shadows Exposure value.
  21016. * 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.
  21017. */
  21018. shadowsExposure: number;
  21019. /**
  21020. * Returns the class name
  21021. * @returns The class name
  21022. */
  21023. getClassName(): string;
  21024. /**
  21025. * Binds the color curves to the shader.
  21026. * @param colorCurves The color curve to bind
  21027. * @param effect The effect to bind to
  21028. * @param positiveUniform The positive uniform shader parameter
  21029. * @param neutralUniform The neutral uniform shader parameter
  21030. * @param negativeUniform The negative uniform shader parameter
  21031. */
  21032. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  21033. /**
  21034. * Prepare the list of uniforms associated with the ColorCurves effects.
  21035. * @param uniformsList The list of uniforms used in the effect
  21036. */
  21037. static PrepareUniforms(uniformsList: string[]): void;
  21038. /**
  21039. * Returns color grading data based on a hue, density, saturation and exposure value.
  21040. * @param filterHue The hue of the color filter.
  21041. * @param filterDensity The density of the color filter.
  21042. * @param saturation The saturation.
  21043. * @param exposure The exposure.
  21044. * @param result The result data container.
  21045. */
  21046. private getColorGradingDataToRef;
  21047. /**
  21048. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  21049. * @param value The input slider value in range [-100,100].
  21050. * @returns Adjusted value.
  21051. */
  21052. private static applyColorGradingSliderNonlinear;
  21053. /**
  21054. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  21055. * @param hue The hue (H) input.
  21056. * @param saturation The saturation (S) input.
  21057. * @param brightness The brightness (B) input.
  21058. * @result An RGBA color represented as Vector4.
  21059. */
  21060. private static fromHSBToRef;
  21061. /**
  21062. * Returns a value clamped between min and max
  21063. * @param value The value to clamp
  21064. * @param min The minimum of value
  21065. * @param max The maximum of value
  21066. * @returns The clamped value.
  21067. */
  21068. private static clamp;
  21069. /**
  21070. * Clones the current color curve instance.
  21071. * @return The cloned curves
  21072. */
  21073. clone(): ColorCurves;
  21074. /**
  21075. * Serializes the current color curve instance to a json representation.
  21076. * @return a JSON representation
  21077. */
  21078. serialize(): any;
  21079. /**
  21080. * Parses the color curve from a json representation.
  21081. * @param source the JSON source to parse
  21082. * @return The parsed curves
  21083. */
  21084. static Parse(source: any): ColorCurves;
  21085. }
  21086. }
  21087. declare module BABYLON {
  21088. /**
  21089. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  21090. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  21091. */
  21092. class EffectFallbacks {
  21093. private _defines;
  21094. private _currentRank;
  21095. private _maxRank;
  21096. private _mesh;
  21097. /**
  21098. * Removes the fallback from the bound mesh.
  21099. */
  21100. unBindMesh(): void;
  21101. /**
  21102. * Adds a fallback on the specified property.
  21103. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  21104. * @param define The name of the define in the shader
  21105. */
  21106. addFallback(rank: number, define: string): void;
  21107. /**
  21108. * Sets the mesh to use CPU skinning when needing to fallback.
  21109. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  21110. * @param mesh The mesh to use the fallbacks.
  21111. */
  21112. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  21113. /**
  21114. * Checks to see if more fallbacks are still availible.
  21115. */
  21116. readonly isMoreFallbacks: boolean;
  21117. /**
  21118. * Removes the defines that shoould be removed when falling back.
  21119. * @param currentDefines defines the current define statements for the shader.
  21120. * @param effect defines the current effect we try to compile
  21121. * @returns The resulting defines with defines of the current rank removed.
  21122. */
  21123. reduce(currentDefines: string, effect: Effect): string;
  21124. }
  21125. /**
  21126. * Options to be used when creating an effect.
  21127. */
  21128. class EffectCreationOptions {
  21129. /**
  21130. * Atrributes that will be used in the shader.
  21131. */
  21132. attributes: string[];
  21133. /**
  21134. * Uniform varible names that will be set in the shader.
  21135. */
  21136. uniformsNames: string[];
  21137. /**
  21138. * Uniform buffer varible names that will be set in the shader.
  21139. */
  21140. uniformBuffersNames: string[];
  21141. /**
  21142. * Sampler texture variable names that will be set in the shader.
  21143. */
  21144. samplers: string[];
  21145. /**
  21146. * Define statements that will be set in the shader.
  21147. */
  21148. defines: any;
  21149. /**
  21150. * Possible fallbacks for this effect to improve performance when needed.
  21151. */
  21152. fallbacks: Nullable<EffectFallbacks>;
  21153. /**
  21154. * Callback that will be called when the shader is compiled.
  21155. */
  21156. onCompiled: Nullable<(effect: Effect) => void>;
  21157. /**
  21158. * Callback that will be called if an error occurs during shader compilation.
  21159. */
  21160. onError: Nullable<(effect: Effect, errors: string) => void>;
  21161. /**
  21162. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  21163. */
  21164. indexParameters: any;
  21165. /**
  21166. * Max number of lights that can be used in the shader.
  21167. */
  21168. maxSimultaneousLights: number;
  21169. /**
  21170. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  21171. */
  21172. transformFeedbackVaryings: Nullable<string[]>;
  21173. }
  21174. /**
  21175. * Effect containing vertex and fragment shader that can be executed on an object.
  21176. */
  21177. class Effect {
  21178. /**
  21179. * Name of the effect.
  21180. */
  21181. name: any;
  21182. /**
  21183. * String container all the define statements that should be set on the shader.
  21184. */
  21185. defines: string;
  21186. /**
  21187. * Callback that will be called when the shader is compiled.
  21188. */
  21189. onCompiled: Nullable<(effect: Effect) => void>;
  21190. /**
  21191. * Callback that will be called if an error occurs during shader compilation.
  21192. */
  21193. onError: Nullable<(effect: Effect, errors: string) => void>;
  21194. /**
  21195. * Callback that will be called when effect is bound.
  21196. */
  21197. onBind: Nullable<(effect: Effect) => void>;
  21198. /**
  21199. * Unique ID of the effect.
  21200. */
  21201. uniqueId: number;
  21202. /**
  21203. * Observable that will be called when the shader is compiled.
  21204. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  21205. */
  21206. onCompileObservable: Observable<Effect>;
  21207. /**
  21208. * Observable that will be called if an error occurs during shader compilation.
  21209. */
  21210. onErrorObservable: Observable<Effect>;
  21211. /** @hidden */
  21212. _onBindObservable: Nullable<Observable<Effect>>;
  21213. /**
  21214. * Observable that will be called when effect is bound.
  21215. */
  21216. readonly onBindObservable: Observable<Effect>;
  21217. /** @hidden */
  21218. _bonesComputationForcedToCPU: boolean;
  21219. private static _uniqueIdSeed;
  21220. private _engine;
  21221. private _uniformBuffersNames;
  21222. private _uniformsNames;
  21223. private _samplers;
  21224. private _isReady;
  21225. private _compilationError;
  21226. private _attributesNames;
  21227. private _attributes;
  21228. private _uniforms;
  21229. /**
  21230. * Key for the effect.
  21231. * @hidden
  21232. */
  21233. _key: string;
  21234. private _indexParameters;
  21235. private _fallbacks;
  21236. private _vertexSourceCode;
  21237. private _fragmentSourceCode;
  21238. private _vertexSourceCodeOverride;
  21239. private _fragmentSourceCodeOverride;
  21240. private _transformFeedbackVaryings;
  21241. /**
  21242. * Compiled shader to webGL program.
  21243. * @hidden
  21244. */
  21245. _program: WebGLProgram;
  21246. private _valueCache;
  21247. private static _baseCache;
  21248. /**
  21249. * Instantiates an effect.
  21250. * An effect can be used to create/manage/execute vertex and fragment shaders.
  21251. * @param baseName Name of the effect.
  21252. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  21253. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  21254. * @param samplers List of sampler variables that will be passed to the shader.
  21255. * @param engine Engine to be used to render the effect
  21256. * @param defines Define statements to be added to the shader.
  21257. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  21258. * @param onCompiled Callback that will be called when the shader is compiled.
  21259. * @param onError Callback that will be called if an error occurs during shader compilation.
  21260. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  21261. */
  21262. 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);
  21263. /**
  21264. * Unique key for this effect
  21265. */
  21266. readonly key: string;
  21267. /**
  21268. * If the effect has been compiled and prepared.
  21269. * @returns if the effect is compiled and prepared.
  21270. */
  21271. isReady(): boolean;
  21272. /**
  21273. * The engine the effect was initialized with.
  21274. * @returns the engine.
  21275. */
  21276. getEngine(): Engine;
  21277. /**
  21278. * The compiled webGL program for the effect
  21279. * @returns the webGL program.
  21280. */
  21281. getProgram(): WebGLProgram;
  21282. /**
  21283. * The set of names of attribute variables for the shader.
  21284. * @returns An array of attribute names.
  21285. */
  21286. getAttributesNames(): string[];
  21287. /**
  21288. * Returns the attribute at the given index.
  21289. * @param index The index of the attribute.
  21290. * @returns The location of the attribute.
  21291. */
  21292. getAttributeLocation(index: number): number;
  21293. /**
  21294. * Returns the attribute based on the name of the variable.
  21295. * @param name of the attribute to look up.
  21296. * @returns the attribute location.
  21297. */
  21298. getAttributeLocationByName(name: string): number;
  21299. /**
  21300. * The number of attributes.
  21301. * @returns the numnber of attributes.
  21302. */
  21303. getAttributesCount(): number;
  21304. /**
  21305. * Gets the index of a uniform variable.
  21306. * @param uniformName of the uniform to look up.
  21307. * @returns the index.
  21308. */
  21309. getUniformIndex(uniformName: string): number;
  21310. /**
  21311. * Returns the attribute based on the name of the variable.
  21312. * @param uniformName of the uniform to look up.
  21313. * @returns the location of the uniform.
  21314. */
  21315. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  21316. /**
  21317. * Returns an array of sampler variable names
  21318. * @returns The array of sampler variable neames.
  21319. */
  21320. getSamplers(): string[];
  21321. /**
  21322. * The error from the last compilation.
  21323. * @returns the error string.
  21324. */
  21325. getCompilationError(): string;
  21326. /**
  21327. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  21328. * @param func The callback to be used.
  21329. */
  21330. executeWhenCompiled(func: (effect: Effect) => void): void;
  21331. private _checkIsReady;
  21332. /** @hidden */
  21333. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  21334. /** @hidden */
  21335. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  21336. /** @hidden */
  21337. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  21338. private _processShaderConversion;
  21339. private _processIncludes;
  21340. private _processPrecision;
  21341. /**
  21342. * Recompiles the webGL program
  21343. * @param vertexSourceCode The source code for the vertex shader.
  21344. * @param fragmentSourceCode The source code for the fragment shader.
  21345. * @param onCompiled Callback called when completed.
  21346. * @param onError Callback called on error.
  21347. * @hidden
  21348. */
  21349. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  21350. /**
  21351. * Gets the uniform locations of the the specified variable names
  21352. * @param names THe names of the variables to lookup.
  21353. * @returns Array of locations in the same order as variable names.
  21354. */
  21355. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  21356. /**
  21357. * Prepares the effect
  21358. * @hidden
  21359. */
  21360. _prepareEffect(): void;
  21361. /**
  21362. * Checks if the effect is supported. (Must be called after compilation)
  21363. */
  21364. readonly isSupported: boolean;
  21365. /**
  21366. * Binds a texture to the engine to be used as output of the shader.
  21367. * @param channel Name of the output variable.
  21368. * @param texture Texture to bind.
  21369. * @hidden
  21370. */
  21371. _bindTexture(channel: string, texture: InternalTexture): void;
  21372. /**
  21373. * Sets a texture on the engine to be used in the shader.
  21374. * @param channel Name of the sampler variable.
  21375. * @param texture Texture to set.
  21376. */
  21377. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  21378. /**
  21379. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  21380. * @param channel Name of the sampler variable.
  21381. * @param texture Texture to set.
  21382. */
  21383. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  21384. /**
  21385. * Sets an array of textures on the engine to be used in the shader.
  21386. * @param channel Name of the variable.
  21387. * @param textures Textures to set.
  21388. */
  21389. setTextureArray(channel: string, textures: BaseTexture[]): void;
  21390. /**
  21391. * 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)
  21392. * @param channel Name of the sampler variable.
  21393. * @param postProcess Post process to get the input texture from.
  21394. */
  21395. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  21396. /**
  21397. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  21398. * 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)
  21399. * @param channel Name of the sampler variable.
  21400. * @param postProcess Post process to get the output texture from.
  21401. */
  21402. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  21403. /** @hidden */
  21404. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  21405. /** @hidden */
  21406. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  21407. /** @hidden */
  21408. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  21409. /** @hidden */
  21410. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  21411. /**
  21412. * Binds a buffer to a uniform.
  21413. * @param buffer Buffer to bind.
  21414. * @param name Name of the uniform variable to bind to.
  21415. */
  21416. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  21417. /**
  21418. * Binds block to a uniform.
  21419. * @param blockName Name of the block to bind.
  21420. * @param index Index to bind.
  21421. */
  21422. bindUniformBlock(blockName: string, index: number): void;
  21423. /**
  21424. * Sets an interger value on a uniform variable.
  21425. * @param uniformName Name of the variable.
  21426. * @param value Value to be set.
  21427. * @returns this effect.
  21428. */
  21429. setInt(uniformName: string, value: number): Effect;
  21430. /**
  21431. * Sets an int array on a uniform variable.
  21432. * @param uniformName Name of the variable.
  21433. * @param array array to be set.
  21434. * @returns this effect.
  21435. */
  21436. setIntArray(uniformName: string, array: Int32Array): Effect;
  21437. /**
  21438. * 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)
  21439. * @param uniformName Name of the variable.
  21440. * @param array array to be set.
  21441. * @returns this effect.
  21442. */
  21443. setIntArray2(uniformName: string, array: Int32Array): Effect;
  21444. /**
  21445. * 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)
  21446. * @param uniformName Name of the variable.
  21447. * @param array array to be set.
  21448. * @returns this effect.
  21449. */
  21450. setIntArray3(uniformName: string, array: Int32Array): Effect;
  21451. /**
  21452. * 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)
  21453. * @param uniformName Name of the variable.
  21454. * @param array array to be set.
  21455. * @returns this effect.
  21456. */
  21457. setIntArray4(uniformName: string, array: Int32Array): Effect;
  21458. /**
  21459. * Sets an float array on a uniform variable.
  21460. * @param uniformName Name of the variable.
  21461. * @param array array to be set.
  21462. * @returns this effect.
  21463. */
  21464. setFloatArray(uniformName: string, array: Float32Array): Effect;
  21465. /**
  21466. * 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)
  21467. * @param uniformName Name of the variable.
  21468. * @param array array to be set.
  21469. * @returns this effect.
  21470. */
  21471. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  21472. /**
  21473. * 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)
  21474. * @param uniformName Name of the variable.
  21475. * @param array array to be set.
  21476. * @returns this effect.
  21477. */
  21478. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  21479. /**
  21480. * 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)
  21481. * @param uniformName Name of the variable.
  21482. * @param array array to be set.
  21483. * @returns this effect.
  21484. */
  21485. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  21486. /**
  21487. * Sets an array on a uniform variable.
  21488. * @param uniformName Name of the variable.
  21489. * @param array array to be set.
  21490. * @returns this effect.
  21491. */
  21492. setArray(uniformName: string, array: number[]): Effect;
  21493. /**
  21494. * 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)
  21495. * @param uniformName Name of the variable.
  21496. * @param array array to be set.
  21497. * @returns this effect.
  21498. */
  21499. setArray2(uniformName: string, array: number[]): Effect;
  21500. /**
  21501. * 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)
  21502. * @param uniformName Name of the variable.
  21503. * @param array array to be set.
  21504. * @returns this effect.
  21505. */
  21506. setArray3(uniformName: string, array: number[]): Effect;
  21507. /**
  21508. * 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)
  21509. * @param uniformName Name of the variable.
  21510. * @param array array to be set.
  21511. * @returns this effect.
  21512. */
  21513. setArray4(uniformName: string, array: number[]): Effect;
  21514. /**
  21515. * Sets matrices on a uniform variable.
  21516. * @param uniformName Name of the variable.
  21517. * @param matrices matrices to be set.
  21518. * @returns this effect.
  21519. */
  21520. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  21521. /**
  21522. * Sets matrix on a uniform variable.
  21523. * @param uniformName Name of the variable.
  21524. * @param matrix matrix to be set.
  21525. * @returns this effect.
  21526. */
  21527. setMatrix(uniformName: string, matrix: Matrix): Effect;
  21528. /**
  21529. * 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)
  21530. * @param uniformName Name of the variable.
  21531. * @param matrix matrix to be set.
  21532. * @returns this effect.
  21533. */
  21534. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  21535. /**
  21536. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  21537. * @param uniformName Name of the variable.
  21538. * @param matrix matrix to be set.
  21539. * @returns this effect.
  21540. */
  21541. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  21542. /**
  21543. * Sets a float on a uniform variable.
  21544. * @param uniformName Name of the variable.
  21545. * @param value value to be set.
  21546. * @returns this effect.
  21547. */
  21548. setFloat(uniformName: string, value: number): Effect;
  21549. /**
  21550. * Sets a boolean on a uniform variable.
  21551. * @param uniformName Name of the variable.
  21552. * @param bool value to be set.
  21553. * @returns this effect.
  21554. */
  21555. setBool(uniformName: string, bool: boolean): Effect;
  21556. /**
  21557. * Sets a Vector2 on a uniform variable.
  21558. * @param uniformName Name of the variable.
  21559. * @param vector2 vector2 to be set.
  21560. * @returns this effect.
  21561. */
  21562. setVector2(uniformName: string, vector2: Vector2): Effect;
  21563. /**
  21564. * Sets a float2 on a uniform variable.
  21565. * @param uniformName Name of the variable.
  21566. * @param x First float in float2.
  21567. * @param y Second float in float2.
  21568. * @returns this effect.
  21569. */
  21570. setFloat2(uniformName: string, x: number, y: number): Effect;
  21571. /**
  21572. * Sets a Vector3 on a uniform variable.
  21573. * @param uniformName Name of the variable.
  21574. * @param vector3 Value to be set.
  21575. * @returns this effect.
  21576. */
  21577. setVector3(uniformName: string, vector3: Vector3): Effect;
  21578. /**
  21579. * Sets a float3 on a uniform variable.
  21580. * @param uniformName Name of the variable.
  21581. * @param x First float in float3.
  21582. * @param y Second float in float3.
  21583. * @param z Third float in float3.
  21584. * @returns this effect.
  21585. */
  21586. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  21587. /**
  21588. * Sets a Vector4 on a uniform variable.
  21589. * @param uniformName Name of the variable.
  21590. * @param vector4 Value to be set.
  21591. * @returns this effect.
  21592. */
  21593. setVector4(uniformName: string, vector4: Vector4): Effect;
  21594. /**
  21595. * Sets a float4 on a uniform variable.
  21596. * @param uniformName Name of the variable.
  21597. * @param x First float in float4.
  21598. * @param y Second float in float4.
  21599. * @param z Third float in float4.
  21600. * @param w Fourth float in float4.
  21601. * @returns this effect.
  21602. */
  21603. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  21604. /**
  21605. * Sets a Color3 on a uniform variable.
  21606. * @param uniformName Name of the variable.
  21607. * @param color3 Value to be set.
  21608. * @returns this effect.
  21609. */
  21610. setColor3(uniformName: string, color3: Color3): Effect;
  21611. /**
  21612. * Sets a Color4 on a uniform variable.
  21613. * @param uniformName Name of the variable.
  21614. * @param color3 Value to be set.
  21615. * @param alpha Alpha value to be set.
  21616. * @returns this effect.
  21617. */
  21618. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  21619. /**
  21620. * Sets a Color4 on a uniform variable
  21621. * @param uniformName defines the name of the variable
  21622. * @param color4 defines the value to be set
  21623. * @returns this effect.
  21624. */
  21625. setDirectColor4(uniformName: string, color4: Color4): Effect;
  21626. /**
  21627. * This function will add a new shader to the shader store
  21628. * @param name the name of the shader
  21629. * @param pixelShader optional pixel shader content
  21630. * @param vertexShader optional vertex shader content
  21631. */
  21632. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  21633. /**
  21634. * Store of each shader (The can be looked up using effect.key)
  21635. */
  21636. static ShadersStore: {
  21637. [key: string]: string;
  21638. };
  21639. /**
  21640. * Store of each included file for a shader (The can be looked up using effect.key)
  21641. */
  21642. static IncludesShadersStore: {
  21643. [key: string]: string;
  21644. };
  21645. /**
  21646. * Resets the cache of effects.
  21647. */
  21648. static ResetCache(): void;
  21649. }
  21650. }
  21651. declare module BABYLON {
  21652. /**
  21653. * This represents all the required information to add a fresnel effect on a material:
  21654. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  21655. */
  21656. class FresnelParameters {
  21657. private _isEnabled;
  21658. /**
  21659. * Define if the fresnel effect is enable or not.
  21660. */
  21661. isEnabled: boolean;
  21662. /**
  21663. * Define the color used on edges (grazing angle)
  21664. */
  21665. leftColor: Color3;
  21666. /**
  21667. * Define the color used on center
  21668. */
  21669. rightColor: Color3;
  21670. /**
  21671. * Define bias applied to computed fresnel term
  21672. */
  21673. bias: number;
  21674. /**
  21675. * Defined the power exponent applied to fresnel term
  21676. */
  21677. power: number;
  21678. /**
  21679. * Clones the current fresnel and its valuues
  21680. * @returns a clone fresnel configuration
  21681. */
  21682. clone(): FresnelParameters;
  21683. /**
  21684. * Serializes the current fresnel parameters to a JSON representation.
  21685. * @return the JSON serialization
  21686. */
  21687. serialize(): any;
  21688. /**
  21689. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  21690. * @param parsedFresnelParameters Define the JSON representation
  21691. * @returns the parsed parameters
  21692. */
  21693. static Parse(parsedFresnelParameters: any): FresnelParameters;
  21694. }
  21695. }
  21696. declare module BABYLON {
  21697. /**
  21698. * Interface to follow in your material defines to integrate easily the
  21699. * Image proccessing functions.
  21700. * @hidden
  21701. */
  21702. interface IImageProcessingConfigurationDefines {
  21703. IMAGEPROCESSING: boolean;
  21704. VIGNETTE: boolean;
  21705. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21706. VIGNETTEBLENDMODEOPAQUE: boolean;
  21707. TONEMAPPING: boolean;
  21708. TONEMAPPING_ACES: boolean;
  21709. CONTRAST: boolean;
  21710. EXPOSURE: boolean;
  21711. COLORCURVES: boolean;
  21712. COLORGRADING: boolean;
  21713. COLORGRADING3D: boolean;
  21714. SAMPLER3DGREENDEPTH: boolean;
  21715. SAMPLER3DBGRMAP: boolean;
  21716. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21717. }
  21718. /**
  21719. * @hidden
  21720. */
  21721. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21722. IMAGEPROCESSING: boolean;
  21723. VIGNETTE: boolean;
  21724. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21725. VIGNETTEBLENDMODEOPAQUE: boolean;
  21726. TONEMAPPING: boolean;
  21727. TONEMAPPING_ACES: boolean;
  21728. CONTRAST: boolean;
  21729. COLORCURVES: boolean;
  21730. COLORGRADING: boolean;
  21731. COLORGRADING3D: boolean;
  21732. SAMPLER3DGREENDEPTH: boolean;
  21733. SAMPLER3DBGRMAP: boolean;
  21734. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21735. EXPOSURE: boolean;
  21736. constructor();
  21737. }
  21738. /**
  21739. * This groups together the common properties used for image processing either in direct forward pass
  21740. * or through post processing effect depending on the use of the image processing pipeline in your scene
  21741. * or not.
  21742. */
  21743. class ImageProcessingConfiguration {
  21744. /**
  21745. * Default tone mapping applied in BabylonJS.
  21746. */
  21747. static readonly TONEMAPPING_STANDARD: number;
  21748. /**
  21749. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  21750. * to other engines rendering to increase portability.
  21751. */
  21752. static readonly TONEMAPPING_ACES: number;
  21753. /**
  21754. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  21755. */
  21756. colorCurves: Nullable<ColorCurves>;
  21757. private _colorCurvesEnabled;
  21758. /**
  21759. * Gets wether the color curves effect is enabled.
  21760. */
  21761. /**
  21762. * Sets wether the color curves effect is enabled.
  21763. */
  21764. colorCurvesEnabled: boolean;
  21765. private _colorGradingTexture;
  21766. /**
  21767. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  21768. */
  21769. /**
  21770. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  21771. */
  21772. colorGradingTexture: Nullable<BaseTexture>;
  21773. private _colorGradingEnabled;
  21774. /**
  21775. * Gets wether the color grading effect is enabled.
  21776. */
  21777. /**
  21778. * Sets wether the color grading effect is enabled.
  21779. */
  21780. colorGradingEnabled: boolean;
  21781. private _colorGradingWithGreenDepth;
  21782. /**
  21783. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  21784. */
  21785. /**
  21786. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  21787. */
  21788. colorGradingWithGreenDepth: boolean;
  21789. private _colorGradingBGR;
  21790. /**
  21791. * Gets wether the color grading texture contains BGR values.
  21792. */
  21793. /**
  21794. * Sets wether the color grading texture contains BGR values.
  21795. */
  21796. colorGradingBGR: boolean;
  21797. /** @hidden */
  21798. _exposure: number;
  21799. /**
  21800. * Gets the Exposure used in the effect.
  21801. */
  21802. /**
  21803. * Sets the Exposure used in the effect.
  21804. */
  21805. exposure: number;
  21806. private _toneMappingEnabled;
  21807. /**
  21808. * Gets wether the tone mapping effect is enabled.
  21809. */
  21810. /**
  21811. * Sets wether the tone mapping effect is enabled.
  21812. */
  21813. toneMappingEnabled: boolean;
  21814. private _toneMappingType;
  21815. /**
  21816. * Gets the type of tone mapping effect.
  21817. */
  21818. /**
  21819. * Sets the type of tone mapping effect used in BabylonJS.
  21820. */
  21821. toneMappingType: number;
  21822. protected _contrast: number;
  21823. /**
  21824. * Gets the contrast used in the effect.
  21825. */
  21826. /**
  21827. * Sets the contrast used in the effect.
  21828. */
  21829. contrast: number;
  21830. /**
  21831. * Vignette stretch size.
  21832. */
  21833. vignetteStretch: number;
  21834. /**
  21835. * Vignette centre X Offset.
  21836. */
  21837. vignetteCentreX: number;
  21838. /**
  21839. * Vignette centre Y Offset.
  21840. */
  21841. vignetteCentreY: number;
  21842. /**
  21843. * Vignette weight or intensity of the vignette effect.
  21844. */
  21845. vignetteWeight: number;
  21846. /**
  21847. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  21848. * if vignetteEnabled is set to true.
  21849. */
  21850. vignetteColor: Color4;
  21851. /**
  21852. * Camera field of view used by the Vignette effect.
  21853. */
  21854. vignetteCameraFov: number;
  21855. private _vignetteBlendMode;
  21856. /**
  21857. * Gets the vignette blend mode allowing different kind of effect.
  21858. */
  21859. /**
  21860. * Sets the vignette blend mode allowing different kind of effect.
  21861. */
  21862. vignetteBlendMode: number;
  21863. private _vignetteEnabled;
  21864. /**
  21865. * Gets wether the vignette effect is enabled.
  21866. */
  21867. /**
  21868. * Sets wether the vignette effect is enabled.
  21869. */
  21870. vignetteEnabled: boolean;
  21871. private _applyByPostProcess;
  21872. /**
  21873. * Gets wether the image processing is applied through a post process or not.
  21874. */
  21875. /**
  21876. * Sets wether the image processing is applied through a post process or not.
  21877. */
  21878. applyByPostProcess: boolean;
  21879. private _isEnabled;
  21880. /**
  21881. * Gets wether the image processing is enabled or not.
  21882. */
  21883. /**
  21884. * Sets wether the image processing is enabled or not.
  21885. */
  21886. isEnabled: boolean;
  21887. /**
  21888. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  21889. */
  21890. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  21891. /**
  21892. * Method called each time the image processing information changes requires to recompile the effect.
  21893. */
  21894. protected _updateParameters(): void;
  21895. /**
  21896. * Gets the current class name.
  21897. * @return "ImageProcessingConfiguration"
  21898. */
  21899. getClassName(): string;
  21900. /**
  21901. * Prepare the list of uniforms associated with the Image Processing effects.
  21902. * @param uniforms The list of uniforms used in the effect
  21903. * @param defines the list of defines currently in use
  21904. */
  21905. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  21906. /**
  21907. * Prepare the list of samplers associated with the Image Processing effects.
  21908. * @param samplersList The list of uniforms used in the effect
  21909. * @param defines the list of defines currently in use
  21910. */
  21911. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  21912. /**
  21913. * Prepare the list of defines associated to the shader.
  21914. * @param defines the list of defines to complete
  21915. * @param forPostProcess Define if we are currently in post process mode or not
  21916. */
  21917. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  21918. /**
  21919. * Returns true if all the image processing information are ready.
  21920. * @returns True if ready, otherwise, false
  21921. */
  21922. isReady(): boolean;
  21923. /**
  21924. * Binds the image processing to the shader.
  21925. * @param effect The effect to bind to
  21926. * @param aspectRatio Define the current aspect ratio of the effect
  21927. */
  21928. bind(effect: Effect, aspectRatio?: number): void;
  21929. /**
  21930. * Clones the current image processing instance.
  21931. * @return The cloned image processing
  21932. */
  21933. clone(): ImageProcessingConfiguration;
  21934. /**
  21935. * Serializes the current image processing instance to a json representation.
  21936. * @return a JSON representation
  21937. */
  21938. serialize(): any;
  21939. /**
  21940. * Parses the image processing from a json representation.
  21941. * @param source the JSON source to parse
  21942. * @return The parsed image processing
  21943. */
  21944. static Parse(source: any): ImageProcessingConfiguration;
  21945. private static _VIGNETTEMODE_MULTIPLY;
  21946. private static _VIGNETTEMODE_OPAQUE;
  21947. /**
  21948. * Used to apply the vignette as a mix with the pixel color.
  21949. */
  21950. static readonly VIGNETTEMODE_MULTIPLY: number;
  21951. /**
  21952. * Used to apply the vignette as a replacement of the pixel color.
  21953. */
  21954. static readonly VIGNETTEMODE_OPAQUE: number;
  21955. }
  21956. }
  21957. declare module BABYLON {
  21958. /**
  21959. * Manages the defines for the Material
  21960. */
  21961. class MaterialDefines {
  21962. private _keys;
  21963. private _isDirty;
  21964. /** @hidden */
  21965. _renderId: number;
  21966. /** @hidden */
  21967. _areLightsDirty: boolean;
  21968. /** @hidden */
  21969. _areAttributesDirty: boolean;
  21970. /** @hidden */
  21971. _areTexturesDirty: boolean;
  21972. /** @hidden */
  21973. _areFresnelDirty: boolean;
  21974. /** @hidden */
  21975. _areMiscDirty: boolean;
  21976. /** @hidden */
  21977. _areImageProcessingDirty: boolean;
  21978. /** @hidden */
  21979. _normals: boolean;
  21980. /** @hidden */
  21981. _uvs: boolean;
  21982. /** @hidden */
  21983. _needNormals: boolean;
  21984. /** @hidden */
  21985. _needUVs: boolean;
  21986. /**
  21987. * Specifies if the material needs to be re-calculated
  21988. */
  21989. readonly isDirty: boolean;
  21990. /**
  21991. * Marks the material to indicate that it has been re-calculated
  21992. */
  21993. markAsProcessed(): void;
  21994. /**
  21995. * Marks the material to indicate that it needs to be re-calculated
  21996. */
  21997. markAsUnprocessed(): void;
  21998. /**
  21999. * Marks the material to indicate all of its defines need to be re-calculated
  22000. */
  22001. markAllAsDirty(): void;
  22002. /**
  22003. * Marks the material to indicate that image processing needs to be re-calculated
  22004. */
  22005. markAsImageProcessingDirty(): void;
  22006. /**
  22007. * Marks the material to indicate the lights need to be re-calculated
  22008. */
  22009. markAsLightDirty(): void;
  22010. /**
  22011. * Marks the attribute state as changed
  22012. */
  22013. markAsAttributesDirty(): void;
  22014. /**
  22015. * Marks the texture state as changed
  22016. */
  22017. markAsTexturesDirty(): void;
  22018. /**
  22019. * Marks the fresnel state as changed
  22020. */
  22021. markAsFresnelDirty(): void;
  22022. /**
  22023. * Marks the misc state as changed
  22024. */
  22025. markAsMiscDirty(): void;
  22026. /**
  22027. * Rebuilds the material defines
  22028. */
  22029. rebuild(): void;
  22030. /**
  22031. * Specifies if two material defines are equal
  22032. * @param other - A material define instance to compare to
  22033. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  22034. */
  22035. isEqual(other: MaterialDefines): boolean;
  22036. /**
  22037. * Clones this instance's defines to another instance
  22038. * @param other - material defines to clone values to
  22039. */
  22040. cloneTo(other: MaterialDefines): void;
  22041. /**
  22042. * Resets the material define values
  22043. */
  22044. reset(): void;
  22045. /**
  22046. * Converts the material define values to a string
  22047. * @returns - String of material define information
  22048. */
  22049. toString(): string;
  22050. }
  22051. /**
  22052. * Base class for the main features of a material in Babylon.js
  22053. */
  22054. class Material implements IAnimatable {
  22055. private static _TriangleFillMode;
  22056. private static _WireFrameFillMode;
  22057. private static _PointFillMode;
  22058. private static _PointListDrawMode;
  22059. private static _LineListDrawMode;
  22060. private static _LineLoopDrawMode;
  22061. private static _LineStripDrawMode;
  22062. private static _TriangleStripDrawMode;
  22063. private static _TriangleFanDrawMode;
  22064. /**
  22065. * Returns the triangle fill mode
  22066. */
  22067. static readonly TriangleFillMode: number;
  22068. /**
  22069. * Returns the wireframe mode
  22070. */
  22071. static readonly WireFrameFillMode: number;
  22072. /**
  22073. * Returns the point fill mode
  22074. */
  22075. static readonly PointFillMode: number;
  22076. /**
  22077. * Returns the point list draw mode
  22078. */
  22079. static readonly PointListDrawMode: number;
  22080. /**
  22081. * Returns the line list draw mode
  22082. */
  22083. static readonly LineListDrawMode: number;
  22084. /**
  22085. * Returns the line loop draw mode
  22086. */
  22087. static readonly LineLoopDrawMode: number;
  22088. /**
  22089. * Returns the line strip draw mode
  22090. */
  22091. static readonly LineStripDrawMode: number;
  22092. /**
  22093. * Returns the triangle strip draw mode
  22094. */
  22095. static readonly TriangleStripDrawMode: number;
  22096. /**
  22097. * Returns the triangle fan draw mode
  22098. */
  22099. static readonly TriangleFanDrawMode: number;
  22100. /**
  22101. * Stores the clock-wise side orientation
  22102. */
  22103. private static _ClockWiseSideOrientation;
  22104. /**
  22105. * Stores the counter clock-wise side orientation
  22106. */
  22107. private static _CounterClockWiseSideOrientation;
  22108. /**
  22109. * Returns the clock-wise side orientation
  22110. */
  22111. static readonly ClockWiseSideOrientation: number;
  22112. /**
  22113. * Returns the counter clock-wise side orientation
  22114. */
  22115. static readonly CounterClockWiseSideOrientation: number;
  22116. /**
  22117. * The dirty texture flag value
  22118. */
  22119. static readonly TextureDirtyFlag: number;
  22120. /**
  22121. * The dirty light flag value
  22122. */
  22123. static readonly LightDirtyFlag: number;
  22124. /**
  22125. * The dirty fresnel flag value
  22126. */
  22127. static readonly FresnelDirtyFlag: number;
  22128. /**
  22129. * The dirty attribute flag value
  22130. */
  22131. static readonly AttributesDirtyFlag: number;
  22132. /**
  22133. * The dirty misc flag value
  22134. */
  22135. static readonly MiscDirtyFlag: number;
  22136. /**
  22137. * The all dirty flag value
  22138. */
  22139. static readonly AllDirtyFlag: number;
  22140. /**
  22141. * The ID of the material
  22142. */
  22143. id: string;
  22144. /**
  22145. * Gets or sets the unique id of the material
  22146. */
  22147. uniqueId: number;
  22148. /**
  22149. * The name of the material
  22150. */
  22151. name: string;
  22152. /**
  22153. * Specifies if the ready state should be checked on each call
  22154. */
  22155. checkReadyOnEveryCall: boolean;
  22156. /**
  22157. * Specifies if the ready state should be checked once
  22158. */
  22159. checkReadyOnlyOnce: boolean;
  22160. /**
  22161. * The state of the material
  22162. */
  22163. state: string;
  22164. /**
  22165. * The alpha value of the material
  22166. */
  22167. protected _alpha: number;
  22168. /**
  22169. * Sets the alpha value of the material
  22170. */
  22171. /**
  22172. * Gets the alpha value of the material
  22173. */
  22174. alpha: number;
  22175. /**
  22176. * Specifies if back face culling is enabled
  22177. */
  22178. protected _backFaceCulling: boolean;
  22179. /**
  22180. * Sets the back-face culling state
  22181. */
  22182. /**
  22183. * Gets the back-face culling state
  22184. */
  22185. backFaceCulling: boolean;
  22186. /**
  22187. * Stores the value for side orientation
  22188. */
  22189. sideOrientation: number;
  22190. /**
  22191. * Callback triggered when the material is compiled
  22192. */
  22193. onCompiled: (effect: Effect) => void;
  22194. /**
  22195. * Callback triggered when an error occurs
  22196. */
  22197. onError: (effect: Effect, errors: string) => void;
  22198. /**
  22199. * Callback triggered to get the render target textures
  22200. */
  22201. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  22202. /**
  22203. * Gets a boolean indicating that current material needs to register RTT
  22204. */
  22205. readonly hasRenderTargetTextures: boolean;
  22206. /**
  22207. * Specifies if the material should be serialized
  22208. */
  22209. doNotSerialize: boolean;
  22210. /**
  22211. * @hidden
  22212. */
  22213. _storeEffectOnSubMeshes: boolean;
  22214. /**
  22215. * Stores the animations for the material
  22216. */
  22217. animations: Array<Animation>;
  22218. /**
  22219. * An event triggered when the material is disposed
  22220. */
  22221. onDisposeObservable: Observable<Material>;
  22222. /**
  22223. * An observer which watches for dispose events
  22224. */
  22225. private _onDisposeObserver;
  22226. private _onUnBindObservable;
  22227. /**
  22228. * Called during a dispose event
  22229. */
  22230. onDispose: () => void;
  22231. private _onBindObservable;
  22232. /**
  22233. * An event triggered when the material is bound
  22234. */
  22235. readonly onBindObservable: Observable<AbstractMesh>;
  22236. /**
  22237. * An observer which watches for bind events
  22238. */
  22239. private _onBindObserver;
  22240. /**
  22241. * Called during a bind event
  22242. */
  22243. onBind: (Mesh: AbstractMesh) => void;
  22244. /**
  22245. * An event triggered when the material is unbound
  22246. */
  22247. readonly onUnBindObservable: Observable<Material>;
  22248. /**
  22249. * Stores the value of the alpha mode
  22250. */
  22251. private _alphaMode;
  22252. /**
  22253. * Sets the value of the alpha mode.
  22254. *
  22255. * | Value | Type | Description |
  22256. * | --- | --- | --- |
  22257. * | 0 | ALPHA_DISABLE | |
  22258. * | 1 | ALPHA_ADD | |
  22259. * | 2 | ALPHA_COMBINE | |
  22260. * | 3 | ALPHA_SUBTRACT | |
  22261. * | 4 | ALPHA_MULTIPLY | |
  22262. * | 5 | ALPHA_MAXIMIZED | |
  22263. * | 6 | ALPHA_ONEONE | |
  22264. * | 7 | ALPHA_PREMULTIPLIED | |
  22265. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22266. * | 9 | ALPHA_INTERPOLATE | |
  22267. * | 10 | ALPHA_SCREENMODE | |
  22268. *
  22269. */
  22270. /**
  22271. * Gets the value of the alpha mode
  22272. */
  22273. alphaMode: number;
  22274. /**
  22275. * Stores the state of the need depth pre-pass value
  22276. */
  22277. private _needDepthPrePass;
  22278. /**
  22279. * Sets the need depth pre-pass value
  22280. */
  22281. /**
  22282. * Gets the depth pre-pass value
  22283. */
  22284. needDepthPrePass: boolean;
  22285. /**
  22286. * Specifies if depth writing should be disabled
  22287. */
  22288. disableDepthWrite: boolean;
  22289. /**
  22290. * Specifies if depth writing should be forced
  22291. */
  22292. forceDepthWrite: boolean;
  22293. /**
  22294. * Specifies if there should be a separate pass for culling
  22295. */
  22296. separateCullingPass: boolean;
  22297. /**
  22298. * Stores the state specifing if fog should be enabled
  22299. */
  22300. private _fogEnabled;
  22301. /**
  22302. * Sets the state for enabling fog
  22303. */
  22304. /**
  22305. * Gets the value of the fog enabled state
  22306. */
  22307. fogEnabled: boolean;
  22308. /**
  22309. * Stores the size of points
  22310. */
  22311. pointSize: number;
  22312. /**
  22313. * Stores the z offset value
  22314. */
  22315. zOffset: number;
  22316. /**
  22317. * Gets a value specifying if wireframe mode is enabled
  22318. */
  22319. /**
  22320. * Sets the state of wireframe mode
  22321. */
  22322. wireframe: boolean;
  22323. /**
  22324. * Gets the value specifying if point clouds are enabled
  22325. */
  22326. /**
  22327. * Sets the state of point cloud mode
  22328. */
  22329. pointsCloud: boolean;
  22330. /**
  22331. * Gets the material fill mode
  22332. */
  22333. /**
  22334. * Sets the material fill mode
  22335. */
  22336. fillMode: number;
  22337. /**
  22338. * @hidden
  22339. * Stores the effects for the material
  22340. */
  22341. _effect: Nullable<Effect>;
  22342. /**
  22343. * @hidden
  22344. * Specifies if the material was previously ready
  22345. */
  22346. _wasPreviouslyReady: boolean;
  22347. /**
  22348. * Specifies if uniform buffers should be used
  22349. */
  22350. private _useUBO;
  22351. /**
  22352. * Stores a reference to the scene
  22353. */
  22354. private _scene;
  22355. /**
  22356. * Stores the fill mode state
  22357. */
  22358. private _fillMode;
  22359. /**
  22360. * Specifies if the depth write state should be cached
  22361. */
  22362. private _cachedDepthWriteState;
  22363. /**
  22364. * Stores the uniform buffer
  22365. */
  22366. protected _uniformBuffer: UniformBuffer;
  22367. /** @hidden */
  22368. _indexInSceneMaterialArray: number;
  22369. /** @hidden */
  22370. meshMap: Nullable<{
  22371. [id: string]: AbstractMesh | undefined;
  22372. }>;
  22373. /**
  22374. * Creates a material instance
  22375. * @param name defines the name of the material
  22376. * @param scene defines the scene to reference
  22377. * @param doNotAdd specifies if the material should be added to the scene
  22378. */
  22379. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22380. /**
  22381. * Returns a string representation of the current material
  22382. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22383. * @returns a string with material information
  22384. */
  22385. toString(fullDetails?: boolean): string;
  22386. /**
  22387. * Gets the class name of the material
  22388. * @returns a string with the class name of the material
  22389. */
  22390. getClassName(): string;
  22391. /**
  22392. * Specifies if updates for the material been locked
  22393. */
  22394. readonly isFrozen: boolean;
  22395. /**
  22396. * Locks updates for the material
  22397. */
  22398. freeze(): void;
  22399. /**
  22400. * Unlocks updates for the material
  22401. */
  22402. unfreeze(): void;
  22403. /**
  22404. * Specifies if the material is ready to be used
  22405. * @param mesh defines the mesh to check
  22406. * @param useInstances specifies if instances should be used
  22407. * @returns a boolean indicating if the material is ready to be used
  22408. */
  22409. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22410. /**
  22411. * Specifies that the submesh is ready to be used
  22412. * @param mesh defines the mesh to check
  22413. * @param subMesh defines which submesh to check
  22414. * @param useInstances specifies that instances should be used
  22415. * @returns a boolean indicating that the submesh is ready or not
  22416. */
  22417. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22418. /**
  22419. * Returns the material effect
  22420. * @returns the effect associated with the material
  22421. */
  22422. getEffect(): Nullable<Effect>;
  22423. /**
  22424. * Returns the current scene
  22425. * @returns a Scene
  22426. */
  22427. getScene(): Scene;
  22428. /**
  22429. * Specifies if the material will require alpha blending
  22430. * @returns a boolean specifying if alpha blending is needed
  22431. */
  22432. needAlphaBlending(): boolean;
  22433. /**
  22434. * Specifies if the mesh will require alpha blending
  22435. * @param mesh defines the mesh to check
  22436. * @returns a boolean specifying if alpha blending is needed for the mesh
  22437. */
  22438. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22439. /**
  22440. * Specifies if this material should be rendered in alpha test mode
  22441. * @returns a boolean specifying if an alpha test is needed.
  22442. */
  22443. needAlphaTesting(): boolean;
  22444. /**
  22445. * Gets the texture used for the alpha test
  22446. * @returns the texture to use for alpha testing
  22447. */
  22448. getAlphaTestTexture(): Nullable<BaseTexture>;
  22449. /**
  22450. * Marks the material to indicate that it needs to be re-calculated
  22451. */
  22452. markDirty(): void;
  22453. /** @hidden */
  22454. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22455. /**
  22456. * Binds the material to the mesh
  22457. * @param world defines the world transformation matrix
  22458. * @param mesh defines the mesh to bind the material to
  22459. */
  22460. bind(world: Matrix, mesh?: Mesh): void;
  22461. /**
  22462. * Binds the submesh to the material
  22463. * @param world defines the world transformation matrix
  22464. * @param mesh defines the mesh containing the submesh
  22465. * @param subMesh defines the submesh to bind the material to
  22466. */
  22467. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22468. /**
  22469. * Binds the world matrix to the material
  22470. * @param world defines the world transformation matrix
  22471. */
  22472. bindOnlyWorldMatrix(world: Matrix): void;
  22473. /**
  22474. * Binds the scene's uniform buffer to the effect.
  22475. * @param effect defines the effect to bind to the scene uniform buffer
  22476. * @param sceneUbo defines the uniform buffer storing scene data
  22477. */
  22478. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22479. /**
  22480. * Binds the view matrix to the effect
  22481. * @param effect defines the effect to bind the view matrix to
  22482. */
  22483. bindView(effect: Effect): void;
  22484. /**
  22485. * Binds the view projection matrix to the effect
  22486. * @param effect defines the effect to bind the view projection matrix to
  22487. */
  22488. bindViewProjection(effect: Effect): void;
  22489. /**
  22490. * Specifies if material alpha testing should be turned on for the mesh
  22491. * @param mesh defines the mesh to check
  22492. */
  22493. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22494. /**
  22495. * Processes to execute after binding the material to a mesh
  22496. * @param mesh defines the rendered mesh
  22497. */
  22498. protected _afterBind(mesh?: Mesh): void;
  22499. /**
  22500. * Unbinds the material from the mesh
  22501. */
  22502. unbind(): void;
  22503. /**
  22504. * Gets the active textures from the material
  22505. * @returns an array of textures
  22506. */
  22507. getActiveTextures(): BaseTexture[];
  22508. /**
  22509. * Specifies if the material uses a texture
  22510. * @param texture defines the texture to check against the material
  22511. * @returns a boolean specifying if the material uses the texture
  22512. */
  22513. hasTexture(texture: BaseTexture): boolean;
  22514. /**
  22515. * Makes a duplicate of the material, and gives it a new name
  22516. * @param name defines the new name for the duplicated material
  22517. * @returns the cloned material
  22518. */
  22519. clone(name: string): Nullable<Material>;
  22520. /**
  22521. * Gets the meshes bound to the material
  22522. * @returns an array of meshes bound to the material
  22523. */
  22524. getBindedMeshes(): AbstractMesh[];
  22525. /**
  22526. * Force shader compilation
  22527. * @param mesh defines the mesh associated with this material
  22528. * @param onCompiled defines a function to execute once the material is compiled
  22529. * @param options defines the options to configure the compilation
  22530. */
  22531. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22532. clipPlane: boolean;
  22533. }>): void;
  22534. /**
  22535. * Force shader compilation
  22536. * @param mesh defines the mesh that will use this material
  22537. * @param options defines additional options for compiling the shaders
  22538. * @returns a promise that resolves when the compilation completes
  22539. */
  22540. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22541. clipPlane: boolean;
  22542. }>): Promise<void>;
  22543. /**
  22544. * Marks a define in the material to indicate that it needs to be re-computed
  22545. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22546. */
  22547. markAsDirty(flag: number): void;
  22548. /**
  22549. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22550. * @param func defines a function which checks material defines against the submeshes
  22551. */
  22552. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22553. /**
  22554. * Indicates that image processing needs to be re-calculated for all submeshes
  22555. */
  22556. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22557. /**
  22558. * Indicates that textures need to be re-calculated for all submeshes
  22559. */
  22560. protected _markAllSubMeshesAsTexturesDirty(): void;
  22561. /**
  22562. * Indicates that fresnel needs to be re-calculated for all submeshes
  22563. */
  22564. protected _markAllSubMeshesAsFresnelDirty(): void;
  22565. /**
  22566. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22567. */
  22568. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22569. /**
  22570. * Indicates that lights need to be re-calculated for all submeshes
  22571. */
  22572. protected _markAllSubMeshesAsLightsDirty(): void;
  22573. /**
  22574. * Indicates that attributes need to be re-calculated for all submeshes
  22575. */
  22576. protected _markAllSubMeshesAsAttributesDirty(): void;
  22577. /**
  22578. * Indicates that misc needs to be re-calculated for all submeshes
  22579. */
  22580. protected _markAllSubMeshesAsMiscDirty(): void;
  22581. /**
  22582. * Indicates that textures and misc need to be re-calculated for all submeshes
  22583. */
  22584. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22585. /**
  22586. * Disposes the material
  22587. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22588. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22589. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22590. */
  22591. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22592. /** @hidden */
  22593. private releaseVertexArrayObject;
  22594. /**
  22595. * Serializes this material
  22596. * @returns the serialized material object
  22597. */
  22598. serialize(): any;
  22599. /**
  22600. * Creates a MultiMaterial from parsed MultiMaterial data.
  22601. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22602. * @param scene defines the hosting scene
  22603. * @returns a new MultiMaterial
  22604. */
  22605. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22606. /**
  22607. * Creates a material from parsed material data
  22608. * @param parsedMaterial defines parsed material data
  22609. * @param scene defines the hosting scene
  22610. * @param rootUrl defines the root URL to use to load textures
  22611. * @returns a new material
  22612. */
  22613. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22614. }
  22615. }
  22616. declare module BABYLON {
  22617. /**
  22618. * "Static Class" containing the most commonly used helper while dealing with material for
  22619. * rendering purpose.
  22620. *
  22621. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  22622. *
  22623. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  22624. */
  22625. class MaterialHelper {
  22626. /**
  22627. * Bind the current view position to an effect.
  22628. * @param effect The effect to be bound
  22629. * @param scene The scene the eyes position is used from
  22630. */
  22631. static BindEyePosition(effect: Effect, scene: Scene): void;
  22632. /**
  22633. * Helps preparing the defines values about the UVs in used in the effect.
  22634. * UVs are shared as much as we can accross channels in the shaders.
  22635. * @param texture The texture we are preparing the UVs for
  22636. * @param defines The defines to update
  22637. * @param key The channel key "diffuse", "specular"... used in the shader
  22638. */
  22639. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  22640. /**
  22641. * Binds a texture matrix value to its corrsponding uniform
  22642. * @param texture The texture to bind the matrix for
  22643. * @param uniformBuffer The uniform buffer receivin the data
  22644. * @param key The channel key "diffuse", "specular"... used in the shader
  22645. */
  22646. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  22647. /**
  22648. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  22649. * @param mesh defines the current mesh
  22650. * @param scene defines the current scene
  22651. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  22652. * @param pointsCloud defines if point cloud rendering has to be turned on
  22653. * @param fogEnabled defines if fog has to be turned on
  22654. * @param alphaTest defines if alpha testing has to be turned on
  22655. * @param defines defines the current list of defines
  22656. */
  22657. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  22658. /**
  22659. * Helper used to prepare the list of defines associated with frame values for shader compilation
  22660. * @param scene defines the current scene
  22661. * @param engine defines the current engine
  22662. * @param defines specifies the list of active defines
  22663. * @param useInstances defines if instances have to be turned on
  22664. * @param useClipPlane defines if clip plane have to be turned on
  22665. */
  22666. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  22667. /**
  22668. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  22669. * @param mesh The mesh containing the geometry data we will draw
  22670. * @param defines The defines to update
  22671. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  22672. * @param useBones Precise whether bones should be used or not (override mesh info)
  22673. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  22674. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  22675. * @returns false if defines are considered not dirty and have not been checked
  22676. */
  22677. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  22678. /**
  22679. * Prepares the defines related to the light information passed in parameter
  22680. * @param scene The scene we are intending to draw
  22681. * @param mesh The mesh the effect is compiling for
  22682. * @param defines The defines to update
  22683. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  22684. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  22685. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  22686. * @returns true if normals will be required for the rest of the effect
  22687. */
  22688. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  22689. /**
  22690. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  22691. * that won t be acctive due to defines being turned off.
  22692. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  22693. * @param samplersList The samplers list
  22694. * @param defines The defines helping in the list generation
  22695. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  22696. */
  22697. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  22698. /**
  22699. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  22700. * @param defines The defines to update while falling back
  22701. * @param fallbacks The authorized effect fallbacks
  22702. * @param maxSimultaneousLights The maximum number of lights allowed
  22703. * @param rank the current rank of the Effect
  22704. * @returns The newly affected rank
  22705. */
  22706. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  22707. /**
  22708. * Prepares the list of attributes required for morph targets according to the effect defines.
  22709. * @param attribs The current list of supported attribs
  22710. * @param mesh The mesh to prepare the morph targets attributes for
  22711. * @param defines The current Defines of the effect
  22712. */
  22713. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  22714. /**
  22715. * Prepares the list of attributes required for bones according to the effect defines.
  22716. * @param attribs The current list of supported attribs
  22717. * @param mesh The mesh to prepare the bones attributes for
  22718. * @param defines The current Defines of the effect
  22719. * @param fallbacks The current efffect fallback strategy
  22720. */
  22721. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  22722. /**
  22723. * Prepares the list of attributes required for instances according to the effect defines.
  22724. * @param attribs The current list of supported attribs
  22725. * @param defines The current Defines of the effect
  22726. */
  22727. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  22728. /**
  22729. * Binds the light shadow information to the effect for the given mesh.
  22730. * @param light The light containing the generator
  22731. * @param scene The scene the lights belongs to
  22732. * @param mesh The mesh we are binding the information to render
  22733. * @param lightIndex The light index in the effect used to render the mesh
  22734. * @param effect The effect we are binding the data to
  22735. */
  22736. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  22737. /**
  22738. * Binds the light information to the effect.
  22739. * @param light The light containing the generator
  22740. * @param effect The effect we are binding the data to
  22741. * @param lightIndex The light index in the effect used to render
  22742. */
  22743. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  22744. /**
  22745. * Binds the lights information from the scene to the effect for the given mesh.
  22746. * @param scene The scene the lights belongs to
  22747. * @param mesh The mesh we are binding the information to render
  22748. * @param effect The effect we are binding the data to
  22749. * @param defines The generated defines for the effect
  22750. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  22751. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  22752. */
  22753. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  22754. private static _tempFogColor;
  22755. /**
  22756. * Binds the fog information from the scene to the effect for the given mesh.
  22757. * @param scene The scene the lights belongs to
  22758. * @param mesh The mesh we are binding the information to render
  22759. * @param effect The effect we are binding the data to
  22760. * @param linearSpace Defines if the fog effect is applied in linear space
  22761. */
  22762. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  22763. /**
  22764. * Binds the bones information from the mesh to the effect.
  22765. * @param mesh The mesh we are binding the information to render
  22766. * @param effect The effect we are binding the data to
  22767. */
  22768. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  22769. /**
  22770. * Binds the morph targets information from the mesh to the effect.
  22771. * @param abstractMesh The mesh we are binding the information to render
  22772. * @param effect The effect we are binding the data to
  22773. */
  22774. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  22775. /**
  22776. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  22777. * @param defines The generated defines used in the effect
  22778. * @param effect The effect we are binding the data to
  22779. * @param scene The scene we are willing to render with logarithmic scale for
  22780. */
  22781. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  22782. /**
  22783. * Binds the clip plane information from the scene to the effect.
  22784. * @param scene The scene the clip plane information are extracted from
  22785. * @param effect The effect we are binding the data to
  22786. */
  22787. static BindClipPlane(effect: Effect, scene: Scene): void;
  22788. }
  22789. }
  22790. declare module BABYLON {
  22791. /**
  22792. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22793. * separate meshes. This can be use to improve performances.
  22794. * @see http://doc.babylonjs.com/how_to/multi_materials
  22795. */
  22796. class MultiMaterial extends Material {
  22797. private _subMaterials;
  22798. /**
  22799. * Gets or Sets the list of Materials used within the multi material.
  22800. * They need to be ordered according to the submeshes order in the associated mesh
  22801. */
  22802. subMaterials: Nullable<Material>[];
  22803. /**
  22804. * Instantiates a new Multi Material
  22805. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22806. * separate meshes. This can be use to improve performances.
  22807. * @see http://doc.babylonjs.com/how_to/multi_materials
  22808. * @param name Define the name in the scene
  22809. * @param scene Define the scene the material belongs to
  22810. */
  22811. constructor(name: string, scene: Scene);
  22812. private _hookArray;
  22813. /**
  22814. * Get one of the submaterial by its index in the submaterials array
  22815. * @param index The index to look the sub material at
  22816. * @returns The Material if the index has been defined
  22817. */
  22818. getSubMaterial(index: number): Nullable<Material>;
  22819. /**
  22820. * Get the list of active textures for the whole sub materials list.
  22821. * @returns All the textures that will be used during the rendering
  22822. */
  22823. getActiveTextures(): BaseTexture[];
  22824. /**
  22825. * Gets the current class name of the material e.g. "MultiMaterial"
  22826. * Mainly use in serialization.
  22827. * @returns the class name
  22828. */
  22829. getClassName(): string;
  22830. /**
  22831. * Checks if the material is ready to render the requested sub mesh
  22832. * @param mesh Define the mesh the submesh belongs to
  22833. * @param subMesh Define the sub mesh to look readyness for
  22834. * @param useInstances Define whether or not the material is used with instances
  22835. * @returns true if ready, otherwise false
  22836. */
  22837. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22838. /**
  22839. * Clones the current material and its related sub materials
  22840. * @param name Define the name of the newly cloned material
  22841. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22842. * @returns the cloned material
  22843. */
  22844. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22845. /**
  22846. * Serializes the materials into a JSON representation.
  22847. * @returns the JSON representation
  22848. */
  22849. serialize(): any;
  22850. /**
  22851. * Dispose the material and release its associated resources
  22852. * @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)
  22853. * @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)
  22854. */
  22855. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22856. }
  22857. }
  22858. declare module BABYLON {
  22859. /**
  22860. * Base class of materials working in push mode in babylon JS
  22861. * @hidden
  22862. */
  22863. class PushMaterial extends Material {
  22864. protected _activeEffect: Effect;
  22865. protected _normalMatrix: Matrix;
  22866. /**
  22867. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  22868. * This means that the material can keep using a previous shader while a new one is being compiled.
  22869. * This is mostly used when shader parallel compilation is supported (true by default)
  22870. */
  22871. allowShaderHotSwapping: boolean;
  22872. constructor(name: string, scene: Scene);
  22873. getEffect(): Effect;
  22874. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22875. /**
  22876. * Binds the given world matrix to the active effect
  22877. *
  22878. * @param world the matrix to bind
  22879. */
  22880. bindOnlyWorldMatrix(world: Matrix): void;
  22881. /**
  22882. * Binds the given normal matrix to the active effect
  22883. *
  22884. * @param normalMatrix the matrix to bind
  22885. */
  22886. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22887. bind(world: Matrix, mesh?: Mesh): void;
  22888. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22889. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22890. }
  22891. }
  22892. declare module BABYLON {
  22893. /**
  22894. * Defines the options associated with the creation of a shader material.
  22895. */
  22896. interface IShaderMaterialOptions {
  22897. /**
  22898. * Does the material work in alpha blend mode
  22899. */
  22900. needAlphaBlending: boolean;
  22901. /**
  22902. * Does the material work in alpha test mode
  22903. */
  22904. needAlphaTesting: boolean;
  22905. /**
  22906. * The list of attribute names used in the shader
  22907. */
  22908. attributes: string[];
  22909. /**
  22910. * The list of unifrom names used in the shader
  22911. */
  22912. uniforms: string[];
  22913. /**
  22914. * The list of UBO names used in the shader
  22915. */
  22916. uniformBuffers: string[];
  22917. /**
  22918. * The list of sampler names used in the shader
  22919. */
  22920. samplers: string[];
  22921. /**
  22922. * The list of defines used in the shader
  22923. */
  22924. defines: string[];
  22925. }
  22926. /**
  22927. * 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.
  22928. *
  22929. * This returned material effects how the mesh will look based on the code in the shaders.
  22930. *
  22931. * @see http://doc.babylonjs.com/how_to/shader_material
  22932. */
  22933. class ShaderMaterial extends Material {
  22934. private _shaderPath;
  22935. private _options;
  22936. private _textures;
  22937. private _textureArrays;
  22938. private _floats;
  22939. private _ints;
  22940. private _floatsArrays;
  22941. private _colors3;
  22942. private _colors3Arrays;
  22943. private _colors4;
  22944. private _vectors2;
  22945. private _vectors3;
  22946. private _vectors4;
  22947. private _matrices;
  22948. private _matrices3x3;
  22949. private _matrices2x2;
  22950. private _vectors2Arrays;
  22951. private _vectors3Arrays;
  22952. private _cachedWorldViewMatrix;
  22953. private _renderId;
  22954. /**
  22955. * Instantiate a new shader material.
  22956. * 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.
  22957. * This returned material effects how the mesh will look based on the code in the shaders.
  22958. * @see http://doc.babylonjs.com/how_to/shader_material
  22959. * @param name Define the name of the material in the scene
  22960. * @param scene Define the scene the material belongs to
  22961. * @param shaderPath Defines the route to the shader code in one of three ways:
  22962. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  22963. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  22964. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  22965. * @param options Define the options used to create the shader
  22966. */
  22967. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  22968. /**
  22969. * Gets the current class name of the material e.g. "ShaderMaterial"
  22970. * Mainly use in serialization.
  22971. * @returns the class name
  22972. */
  22973. getClassName(): string;
  22974. /**
  22975. * Specifies if the material will require alpha blending
  22976. * @returns a boolean specifying if alpha blending is needed
  22977. */
  22978. needAlphaBlending(): boolean;
  22979. /**
  22980. * Specifies if this material should be rendered in alpha test mode
  22981. * @returns a boolean specifying if an alpha test is needed.
  22982. */
  22983. needAlphaTesting(): boolean;
  22984. private _checkUniform;
  22985. /**
  22986. * Set a texture in the shader.
  22987. * @param name Define the name of the uniform samplers as defined in the shader
  22988. * @param texture Define the texture to bind to this sampler
  22989. * @return the material itself allowing "fluent" like uniform updates
  22990. */
  22991. setTexture(name: string, texture: Texture): ShaderMaterial;
  22992. /**
  22993. * Set a texture array in the shader.
  22994. * @param name Define the name of the uniform sampler array as defined in the shader
  22995. * @param textures Define the list of textures to bind to this sampler
  22996. * @return the material itself allowing "fluent" like uniform updates
  22997. */
  22998. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  22999. /**
  23000. * Set a float in the shader.
  23001. * @param name Define the name of the uniform as defined in the shader
  23002. * @param value Define the value to give to the uniform
  23003. * @return the material itself allowing "fluent" like uniform updates
  23004. */
  23005. setFloat(name: string, value: number): ShaderMaterial;
  23006. /**
  23007. * Set a int in the shader.
  23008. * @param name Define the name of the uniform as defined in the shader
  23009. * @param value Define the value to give to the uniform
  23010. * @return the material itself allowing "fluent" like uniform updates
  23011. */
  23012. setInt(name: string, value: number): ShaderMaterial;
  23013. /**
  23014. * Set an array of floats in the shader.
  23015. * @param name Define the name of the uniform as defined in the shader
  23016. * @param value Define the value to give to the uniform
  23017. * @return the material itself allowing "fluent" like uniform updates
  23018. */
  23019. setFloats(name: string, value: number[]): ShaderMaterial;
  23020. /**
  23021. * Set a vec3 in the shader from a Color3.
  23022. * @param name Define the name of the uniform as defined in the shader
  23023. * @param value Define the value to give to the uniform
  23024. * @return the material itself allowing "fluent" like uniform updates
  23025. */
  23026. setColor3(name: string, value: Color3): ShaderMaterial;
  23027. /**
  23028. * Set a vec3 array in the shader from a Color3 array.
  23029. * @param name Define the name of the uniform as defined in the shader
  23030. * @param value Define the value to give to the uniform
  23031. * @return the material itself allowing "fluent" like uniform updates
  23032. */
  23033. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  23034. /**
  23035. * Set a vec4 in the shader from a Color4.
  23036. * @param name Define the name of the uniform as defined in the shader
  23037. * @param value Define the value to give to the uniform
  23038. * @return the material itself allowing "fluent" like uniform updates
  23039. */
  23040. setColor4(name: string, value: Color4): ShaderMaterial;
  23041. /**
  23042. * Set a vec2 in the shader from a Vector2.
  23043. * @param name Define the name of the uniform as defined in the shader
  23044. * @param value Define the value to give to the uniform
  23045. * @return the material itself allowing "fluent" like uniform updates
  23046. */
  23047. setVector2(name: string, value: Vector2): ShaderMaterial;
  23048. /**
  23049. * Set a vec3 in the shader from a Vector3.
  23050. * @param name Define the name of the uniform as defined in the shader
  23051. * @param value Define the value to give to the uniform
  23052. * @return the material itself allowing "fluent" like uniform updates
  23053. */
  23054. setVector3(name: string, value: Vector3): ShaderMaterial;
  23055. /**
  23056. * Set a vec4 in the shader from a Vector4.
  23057. * @param name Define the name of the uniform as defined in the shader
  23058. * @param value Define the value to give to the uniform
  23059. * @return the material itself allowing "fluent" like uniform updates
  23060. */
  23061. setVector4(name: string, value: Vector4): ShaderMaterial;
  23062. /**
  23063. * Set a mat4 in the shader from a Matrix.
  23064. * @param name Define the name of the uniform as defined in the shader
  23065. * @param value Define the value to give to the uniform
  23066. * @return the material itself allowing "fluent" like uniform updates
  23067. */
  23068. setMatrix(name: string, value: Matrix): ShaderMaterial;
  23069. /**
  23070. * Set a mat3 in the shader from a Float32Array.
  23071. * @param name Define the name of the uniform as defined in the shader
  23072. * @param value Define the value to give to the uniform
  23073. * @return the material itself allowing "fluent" like uniform updates
  23074. */
  23075. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  23076. /**
  23077. * Set a mat2 in the shader from a Float32Array.
  23078. * @param name Define the name of the uniform as defined in the shader
  23079. * @param value Define the value to give to the uniform
  23080. * @return the material itself allowing "fluent" like uniform updates
  23081. */
  23082. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  23083. /**
  23084. * Set a vec2 array in the shader from a number array.
  23085. * @param name Define the name of the uniform as defined in the shader
  23086. * @param value Define the value to give to the uniform
  23087. * @return the material itself allowing "fluent" like uniform updates
  23088. */
  23089. setArray2(name: string, value: number[]): ShaderMaterial;
  23090. /**
  23091. * Set a vec3 array in the shader from a number array.
  23092. * @param name Define the name of the uniform as defined in the shader
  23093. * @param value Define the value to give to the uniform
  23094. * @return the material itself allowing "fluent" like uniform updates
  23095. */
  23096. setArray3(name: string, value: number[]): ShaderMaterial;
  23097. private _checkCache;
  23098. /**
  23099. * Checks if the material is ready to render the requested mesh
  23100. * @param mesh Define the mesh to render
  23101. * @param useInstances Define whether or not the material is used with instances
  23102. * @returns true if ready, otherwise false
  23103. */
  23104. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23105. /**
  23106. * Binds the world matrix to the material
  23107. * @param world defines the world transformation matrix
  23108. */
  23109. bindOnlyWorldMatrix(world: Matrix): void;
  23110. /**
  23111. * Binds the material to the mesh
  23112. * @param world defines the world transformation matrix
  23113. * @param mesh defines the mesh to bind the material to
  23114. */
  23115. bind(world: Matrix, mesh?: Mesh): void;
  23116. /**
  23117. * Gets the active textures from the material
  23118. * @returns an array of textures
  23119. */
  23120. getActiveTextures(): BaseTexture[];
  23121. /**
  23122. * Specifies if the material uses a texture
  23123. * @param texture defines the texture to check against the material
  23124. * @returns a boolean specifying if the material uses the texture
  23125. */
  23126. hasTexture(texture: BaseTexture): boolean;
  23127. /**
  23128. * Makes a duplicate of the material, and gives it a new name
  23129. * @param name defines the new name for the duplicated material
  23130. * @returns the cloned material
  23131. */
  23132. clone(name: string): ShaderMaterial;
  23133. /**
  23134. * Disposes the material
  23135. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23136. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23137. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23138. */
  23139. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23140. /**
  23141. * Serializes this material in a JSON representation
  23142. * @returns the serialized material object
  23143. */
  23144. serialize(): any;
  23145. /**
  23146. * Creates a shader material from parsed shader material data
  23147. * @param source defines the JSON represnetation of the material
  23148. * @param scene defines the hosting scene
  23149. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23150. * @returns a new material
  23151. */
  23152. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  23153. }
  23154. }
  23155. declare module BABYLON {
  23156. /** @hidden */
  23157. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23158. MAINUV1: boolean;
  23159. MAINUV2: boolean;
  23160. DIFFUSE: boolean;
  23161. DIFFUSEDIRECTUV: number;
  23162. AMBIENT: boolean;
  23163. AMBIENTDIRECTUV: number;
  23164. OPACITY: boolean;
  23165. OPACITYDIRECTUV: number;
  23166. OPACITYRGB: boolean;
  23167. REFLECTION: boolean;
  23168. EMISSIVE: boolean;
  23169. EMISSIVEDIRECTUV: number;
  23170. SPECULAR: boolean;
  23171. SPECULARDIRECTUV: number;
  23172. BUMP: boolean;
  23173. BUMPDIRECTUV: number;
  23174. PARALLAX: boolean;
  23175. PARALLAXOCCLUSION: boolean;
  23176. SPECULAROVERALPHA: boolean;
  23177. CLIPPLANE: boolean;
  23178. CLIPPLANE2: boolean;
  23179. CLIPPLANE3: boolean;
  23180. CLIPPLANE4: boolean;
  23181. ALPHATEST: boolean;
  23182. DEPTHPREPASS: boolean;
  23183. ALPHAFROMDIFFUSE: boolean;
  23184. POINTSIZE: boolean;
  23185. FOG: boolean;
  23186. SPECULARTERM: boolean;
  23187. DIFFUSEFRESNEL: boolean;
  23188. OPACITYFRESNEL: boolean;
  23189. REFLECTIONFRESNEL: boolean;
  23190. REFRACTIONFRESNEL: boolean;
  23191. EMISSIVEFRESNEL: boolean;
  23192. FRESNEL: boolean;
  23193. NORMAL: boolean;
  23194. UV1: boolean;
  23195. UV2: boolean;
  23196. VERTEXCOLOR: boolean;
  23197. VERTEXALPHA: boolean;
  23198. NUM_BONE_INFLUENCERS: number;
  23199. BonesPerMesh: number;
  23200. BONETEXTURE: boolean;
  23201. INSTANCES: boolean;
  23202. GLOSSINESS: boolean;
  23203. ROUGHNESS: boolean;
  23204. EMISSIVEASILLUMINATION: boolean;
  23205. LINKEMISSIVEWITHDIFFUSE: boolean;
  23206. REFLECTIONFRESNELFROMSPECULAR: boolean;
  23207. LIGHTMAP: boolean;
  23208. LIGHTMAPDIRECTUV: number;
  23209. OBJECTSPACE_NORMALMAP: boolean;
  23210. USELIGHTMAPASSHADOWMAP: boolean;
  23211. REFLECTIONMAP_3D: boolean;
  23212. REFLECTIONMAP_SPHERICAL: boolean;
  23213. REFLECTIONMAP_PLANAR: boolean;
  23214. REFLECTIONMAP_CUBIC: boolean;
  23215. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  23216. REFLECTIONMAP_PROJECTION: boolean;
  23217. REFLECTIONMAP_SKYBOX: boolean;
  23218. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  23219. REFLECTIONMAP_EXPLICIT: boolean;
  23220. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  23221. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  23222. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  23223. INVERTCUBICMAP: boolean;
  23224. LOGARITHMICDEPTH: boolean;
  23225. REFRACTION: boolean;
  23226. REFRACTIONMAP_3D: boolean;
  23227. REFLECTIONOVERALPHA: boolean;
  23228. TWOSIDEDLIGHTING: boolean;
  23229. SHADOWFLOAT: boolean;
  23230. MORPHTARGETS: boolean;
  23231. MORPHTARGETS_NORMAL: boolean;
  23232. MORPHTARGETS_TANGENT: boolean;
  23233. NUM_MORPH_INFLUENCERS: number;
  23234. NONUNIFORMSCALING: boolean;
  23235. PREMULTIPLYALPHA: boolean;
  23236. IMAGEPROCESSING: boolean;
  23237. VIGNETTE: boolean;
  23238. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23239. VIGNETTEBLENDMODEOPAQUE: boolean;
  23240. TONEMAPPING: boolean;
  23241. TONEMAPPING_ACES: boolean;
  23242. CONTRAST: boolean;
  23243. COLORCURVES: boolean;
  23244. COLORGRADING: boolean;
  23245. COLORGRADING3D: boolean;
  23246. SAMPLER3DGREENDEPTH: boolean;
  23247. SAMPLER3DBGRMAP: boolean;
  23248. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23249. /**
  23250. * If the reflection texture on this material is in linear color space
  23251. * @hidden
  23252. */
  23253. IS_REFLECTION_LINEAR: boolean;
  23254. /**
  23255. * If the refraction texture on this material is in linear color space
  23256. * @hidden
  23257. */
  23258. IS_REFRACTION_LINEAR: boolean;
  23259. EXPOSURE: boolean;
  23260. constructor();
  23261. setReflectionMode(modeToEnable: string): void;
  23262. }
  23263. /**
  23264. * This is the default material used in Babylon. It is the best trade off between quality
  23265. * and performances.
  23266. * @see http://doc.babylonjs.com/babylon101/materials
  23267. */
  23268. class StandardMaterial extends PushMaterial {
  23269. private _diffuseTexture;
  23270. /**
  23271. * The basic texture of the material as viewed under a light.
  23272. */
  23273. diffuseTexture: Nullable<BaseTexture>;
  23274. private _ambientTexture;
  23275. /**
  23276. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  23277. */
  23278. ambientTexture: Nullable<BaseTexture>;
  23279. private _opacityTexture;
  23280. /**
  23281. * Define the transparency of the material from a texture.
  23282. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  23283. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  23284. */
  23285. opacityTexture: Nullable<BaseTexture>;
  23286. private _reflectionTexture;
  23287. /**
  23288. * Define the texture used to display the reflection.
  23289. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23290. */
  23291. reflectionTexture: Nullable<BaseTexture>;
  23292. private _emissiveTexture;
  23293. /**
  23294. * Define texture of the material as if self lit.
  23295. * This will be mixed in the final result even in the absence of light.
  23296. */
  23297. emissiveTexture: Nullable<BaseTexture>;
  23298. private _specularTexture;
  23299. /**
  23300. * Define how the color and intensity of the highlight given by the light in the material.
  23301. */
  23302. specularTexture: Nullable<BaseTexture>;
  23303. private _bumpTexture;
  23304. /**
  23305. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  23306. * 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.
  23307. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  23308. */
  23309. bumpTexture: Nullable<BaseTexture>;
  23310. private _lightmapTexture;
  23311. /**
  23312. * Complex lighting can be computationally expensive to compute at runtime.
  23313. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  23314. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  23315. */
  23316. lightmapTexture: Nullable<BaseTexture>;
  23317. private _refractionTexture;
  23318. /**
  23319. * Define the texture used to display the refraction.
  23320. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23321. */
  23322. refractionTexture: Nullable<BaseTexture>;
  23323. /**
  23324. * The color of the material lit by the environmental background lighting.
  23325. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  23326. */
  23327. ambientColor: Color3;
  23328. /**
  23329. * The basic color of the material as viewed under a light.
  23330. */
  23331. diffuseColor: Color3;
  23332. /**
  23333. * Define how the color and intensity of the highlight given by the light in the material.
  23334. */
  23335. specularColor: Color3;
  23336. /**
  23337. * Define the color of the material as if self lit.
  23338. * This will be mixed in the final result even in the absence of light.
  23339. */
  23340. emissiveColor: Color3;
  23341. /**
  23342. * Defines how sharp are the highlights in the material.
  23343. * The bigger the value the sharper giving a more glossy feeling to the result.
  23344. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  23345. */
  23346. specularPower: number;
  23347. private _useAlphaFromDiffuseTexture;
  23348. /**
  23349. * Does the transparency come from the diffuse texture alpha channel.
  23350. */
  23351. useAlphaFromDiffuseTexture: boolean;
  23352. private _useEmissiveAsIllumination;
  23353. /**
  23354. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  23355. */
  23356. useEmissiveAsIllumination: boolean;
  23357. private _linkEmissiveWithDiffuse;
  23358. /**
  23359. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  23360. * the emissive level when the final color is close to one.
  23361. */
  23362. linkEmissiveWithDiffuse: boolean;
  23363. private _useSpecularOverAlpha;
  23364. /**
  23365. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  23366. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  23367. */
  23368. useSpecularOverAlpha: boolean;
  23369. private _useReflectionOverAlpha;
  23370. /**
  23371. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  23372. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  23373. */
  23374. useReflectionOverAlpha: boolean;
  23375. private _disableLighting;
  23376. /**
  23377. * Does lights from the scene impacts this material.
  23378. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  23379. */
  23380. disableLighting: boolean;
  23381. private _useObjectSpaceNormalMap;
  23382. /**
  23383. * Allows using an object space normal map (instead of tangent space).
  23384. */
  23385. useObjectSpaceNormalMap: boolean;
  23386. private _useParallax;
  23387. /**
  23388. * Is parallax enabled or not.
  23389. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  23390. */
  23391. useParallax: boolean;
  23392. private _useParallaxOcclusion;
  23393. /**
  23394. * Is parallax occlusion enabled or not.
  23395. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  23396. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  23397. */
  23398. useParallaxOcclusion: boolean;
  23399. /**
  23400. * 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.
  23401. */
  23402. parallaxScaleBias: number;
  23403. private _roughness;
  23404. /**
  23405. * Helps to define how blurry the reflections should appears in the material.
  23406. */
  23407. roughness: number;
  23408. /**
  23409. * In case of refraction, define the value of the indice of refraction.
  23410. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23411. */
  23412. indexOfRefraction: number;
  23413. /**
  23414. * Invert the refraction texture alongside the y axis.
  23415. * It can be usefull with procedural textures or probe for instance.
  23416. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23417. */
  23418. invertRefractionY: boolean;
  23419. /**
  23420. * Defines the alpha limits in alpha test mode.
  23421. */
  23422. alphaCutOff: number;
  23423. private _useLightmapAsShadowmap;
  23424. /**
  23425. * In case of light mapping, define whether the map contains light or shadow informations.
  23426. */
  23427. useLightmapAsShadowmap: boolean;
  23428. private _diffuseFresnelParameters;
  23429. /**
  23430. * Define the diffuse fresnel parameters of the material.
  23431. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23432. */
  23433. diffuseFresnelParameters: FresnelParameters;
  23434. private _opacityFresnelParameters;
  23435. /**
  23436. * Define the opacity fresnel parameters of the material.
  23437. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23438. */
  23439. opacityFresnelParameters: FresnelParameters;
  23440. private _reflectionFresnelParameters;
  23441. /**
  23442. * Define the reflection fresnel parameters of the material.
  23443. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23444. */
  23445. reflectionFresnelParameters: FresnelParameters;
  23446. private _refractionFresnelParameters;
  23447. /**
  23448. * Define the refraction fresnel parameters of the material.
  23449. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23450. */
  23451. refractionFresnelParameters: FresnelParameters;
  23452. private _emissiveFresnelParameters;
  23453. /**
  23454. * Define the emissive fresnel parameters of the material.
  23455. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23456. */
  23457. emissiveFresnelParameters: FresnelParameters;
  23458. private _useReflectionFresnelFromSpecular;
  23459. /**
  23460. * If true automatically deducts the fresnels values from the material specularity.
  23461. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23462. */
  23463. useReflectionFresnelFromSpecular: boolean;
  23464. private _useGlossinessFromSpecularMapAlpha;
  23465. /**
  23466. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  23467. */
  23468. useGlossinessFromSpecularMapAlpha: boolean;
  23469. private _maxSimultaneousLights;
  23470. /**
  23471. * Defines the maximum number of lights that can be used in the material
  23472. */
  23473. maxSimultaneousLights: number;
  23474. private _invertNormalMapX;
  23475. /**
  23476. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  23477. */
  23478. invertNormalMapX: boolean;
  23479. private _invertNormalMapY;
  23480. /**
  23481. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  23482. */
  23483. invertNormalMapY: boolean;
  23484. private _twoSidedLighting;
  23485. /**
  23486. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  23487. */
  23488. twoSidedLighting: boolean;
  23489. /**
  23490. * Default configuration related to image processing available in the standard Material.
  23491. */
  23492. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23493. /**
  23494. * Gets the image processing configuration used either in this material.
  23495. */
  23496. /**
  23497. * Sets the Default image processing configuration used either in the this material.
  23498. *
  23499. * If sets to null, the scene one is in use.
  23500. */
  23501. imageProcessingConfiguration: ImageProcessingConfiguration;
  23502. /**
  23503. * Keep track of the image processing observer to allow dispose and replace.
  23504. */
  23505. private _imageProcessingObserver;
  23506. /**
  23507. * Attaches a new image processing configuration to the Standard Material.
  23508. * @param configuration
  23509. */
  23510. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23511. /**
  23512. * Gets wether the color curves effect is enabled.
  23513. */
  23514. /**
  23515. * Sets wether the color curves effect is enabled.
  23516. */
  23517. cameraColorCurvesEnabled: boolean;
  23518. /**
  23519. * Gets wether the color grading effect is enabled.
  23520. */
  23521. /**
  23522. * Gets wether the color grading effect is enabled.
  23523. */
  23524. cameraColorGradingEnabled: boolean;
  23525. /**
  23526. * Gets wether tonemapping is enabled or not.
  23527. */
  23528. /**
  23529. * Sets wether tonemapping is enabled or not
  23530. */
  23531. cameraToneMappingEnabled: boolean;
  23532. /**
  23533. * The camera exposure used on this material.
  23534. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23535. * This corresponds to a photographic exposure.
  23536. */
  23537. /**
  23538. * The camera exposure used on this material.
  23539. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23540. * This corresponds to a photographic exposure.
  23541. */
  23542. cameraExposure: number;
  23543. /**
  23544. * Gets The camera contrast used on this material.
  23545. */
  23546. /**
  23547. * Sets The camera contrast used on this material.
  23548. */
  23549. cameraContrast: number;
  23550. /**
  23551. * Gets the Color Grading 2D Lookup Texture.
  23552. */
  23553. /**
  23554. * Sets the Color Grading 2D Lookup Texture.
  23555. */
  23556. cameraColorGradingTexture: Nullable<BaseTexture>;
  23557. /**
  23558. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23559. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23560. * 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;
  23561. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23562. */
  23563. /**
  23564. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23565. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23566. * 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;
  23567. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23568. */
  23569. cameraColorCurves: Nullable<ColorCurves>;
  23570. /**
  23571. * Custom callback helping to override the default shader used in the material.
  23572. */
  23573. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  23574. protected _renderTargets: SmartArray<RenderTargetTexture>;
  23575. protected _worldViewProjectionMatrix: Matrix;
  23576. protected _globalAmbientColor: Color3;
  23577. protected _useLogarithmicDepth: boolean;
  23578. /**
  23579. * Instantiates a new standard material.
  23580. * This is the default material used in Babylon. It is the best trade off between quality
  23581. * and performances.
  23582. * @see http://doc.babylonjs.com/babylon101/materials
  23583. * @param name Define the name of the material in the scene
  23584. * @param scene Define the scene the material belong to
  23585. */
  23586. constructor(name: string, scene: Scene);
  23587. /**
  23588. * Gets a boolean indicating that current material needs to register RTT
  23589. */
  23590. readonly hasRenderTargetTextures: boolean;
  23591. /**
  23592. * Gets the current class name of the material e.g. "StandardMaterial"
  23593. * Mainly use in serialization.
  23594. * @returns the class name
  23595. */
  23596. getClassName(): string;
  23597. /**
  23598. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  23599. * You can try switching to logarithmic depth.
  23600. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  23601. */
  23602. useLogarithmicDepth: boolean;
  23603. /**
  23604. * Specifies if the material will require alpha blending
  23605. * @returns a boolean specifying if alpha blending is needed
  23606. */
  23607. needAlphaBlending(): boolean;
  23608. /**
  23609. * Specifies if this material should be rendered in alpha test mode
  23610. * @returns a boolean specifying if an alpha test is needed.
  23611. */
  23612. needAlphaTesting(): boolean;
  23613. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  23614. /**
  23615. * Get the texture used for alpha test purpose.
  23616. * @returns the diffuse texture in case of the standard material.
  23617. */
  23618. getAlphaTestTexture(): Nullable<BaseTexture>;
  23619. /**
  23620. * Get if the submesh is ready to be used and all its information available.
  23621. * Child classes can use it to update shaders
  23622. * @param mesh defines the mesh to check
  23623. * @param subMesh defines which submesh to check
  23624. * @param useInstances specifies that instances should be used
  23625. * @returns a boolean indicating that the submesh is ready or not
  23626. */
  23627. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23628. /**
  23629. * Builds the material UBO layouts.
  23630. * Used internally during the effect preparation.
  23631. */
  23632. buildUniformLayout(): void;
  23633. /**
  23634. * Unbinds the material from the mesh
  23635. */
  23636. unbind(): void;
  23637. /**
  23638. * Binds the submesh to this material by preparing the effect and shader to draw
  23639. * @param world defines the world transformation matrix
  23640. * @param mesh defines the mesh containing the submesh
  23641. * @param subMesh defines the submesh to bind the material to
  23642. */
  23643. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23644. /**
  23645. * Get the list of animatables in the material.
  23646. * @returns the list of animatables object used in the material
  23647. */
  23648. getAnimatables(): IAnimatable[];
  23649. /**
  23650. * Gets the active textures from the material
  23651. * @returns an array of textures
  23652. */
  23653. getActiveTextures(): BaseTexture[];
  23654. /**
  23655. * Specifies if the material uses a texture
  23656. * @param texture defines the texture to check against the material
  23657. * @returns a boolean specifying if the material uses the texture
  23658. */
  23659. hasTexture(texture: BaseTexture): boolean;
  23660. /**
  23661. * Disposes the material
  23662. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23663. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23664. */
  23665. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  23666. /**
  23667. * Makes a duplicate of the material, and gives it a new name
  23668. * @param name defines the new name for the duplicated material
  23669. * @returns the cloned material
  23670. */
  23671. clone(name: string): StandardMaterial;
  23672. /**
  23673. * Serializes this material in a JSON representation
  23674. * @returns the serialized material object
  23675. */
  23676. serialize(): any;
  23677. /**
  23678. * Creates a standard material from parsed material data
  23679. * @param source defines the JSON represnetation of the material
  23680. * @param scene defines the hosting scene
  23681. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23682. * @returns a new material
  23683. */
  23684. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  23685. private static _DiffuseTextureEnabled;
  23686. /**
  23687. * Are diffuse textures enabled in the application.
  23688. */
  23689. static DiffuseTextureEnabled: boolean;
  23690. private static _AmbientTextureEnabled;
  23691. /**
  23692. * Are ambient textures enabled in the application.
  23693. */
  23694. static AmbientTextureEnabled: boolean;
  23695. private static _OpacityTextureEnabled;
  23696. /**
  23697. * Are opacity textures enabled in the application.
  23698. */
  23699. static OpacityTextureEnabled: boolean;
  23700. private static _ReflectionTextureEnabled;
  23701. /**
  23702. * Are reflection textures enabled in the application.
  23703. */
  23704. static ReflectionTextureEnabled: boolean;
  23705. private static _EmissiveTextureEnabled;
  23706. /**
  23707. * Are emissive textures enabled in the application.
  23708. */
  23709. static EmissiveTextureEnabled: boolean;
  23710. private static _SpecularTextureEnabled;
  23711. /**
  23712. * Are specular textures enabled in the application.
  23713. */
  23714. static SpecularTextureEnabled: boolean;
  23715. private static _BumpTextureEnabled;
  23716. /**
  23717. * Are bump textures enabled in the application.
  23718. */
  23719. static BumpTextureEnabled: boolean;
  23720. private static _LightmapTextureEnabled;
  23721. /**
  23722. * Are lightmap textures enabled in the application.
  23723. */
  23724. static LightmapTextureEnabled: boolean;
  23725. private static _RefractionTextureEnabled;
  23726. /**
  23727. * Are refraction textures enabled in the application.
  23728. */
  23729. static RefractionTextureEnabled: boolean;
  23730. private static _ColorGradingTextureEnabled;
  23731. /**
  23732. * Are color grading textures enabled in the application.
  23733. */
  23734. static ColorGradingTextureEnabled: boolean;
  23735. private static _FresnelEnabled;
  23736. /**
  23737. * Are fresnels enabled in the application.
  23738. */
  23739. static FresnelEnabled: boolean;
  23740. }
  23741. }
  23742. declare module BABYLON {
  23743. /**
  23744. * Uniform buffer objects.
  23745. *
  23746. * Handles blocks of uniform on the GPU.
  23747. *
  23748. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  23749. *
  23750. * For more information, please refer to :
  23751. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  23752. */
  23753. class UniformBuffer {
  23754. private _engine;
  23755. private _buffer;
  23756. private _data;
  23757. private _bufferData;
  23758. private _dynamic?;
  23759. private _uniformLocations;
  23760. private _uniformSizes;
  23761. private _uniformLocationPointer;
  23762. private _needSync;
  23763. private _noUBO;
  23764. private _currentEffect;
  23765. private static _MAX_UNIFORM_SIZE;
  23766. private static _tempBuffer;
  23767. /**
  23768. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  23769. * This is dynamic to allow compat with webgl 1 and 2.
  23770. * You will need to pass the name of the uniform as well as the value.
  23771. */
  23772. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  23773. /**
  23774. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  23775. * This is dynamic to allow compat with webgl 1 and 2.
  23776. * You will need to pass the name of the uniform as well as the value.
  23777. */
  23778. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  23779. /**
  23780. * Lambda to Update a single float in a uniform buffer.
  23781. * This is dynamic to allow compat with webgl 1 and 2.
  23782. * You will need to pass the name of the uniform as well as the value.
  23783. */
  23784. updateFloat: (name: string, x: number) => void;
  23785. /**
  23786. * Lambda to Update a vec2 of float in a uniform buffer.
  23787. * This is dynamic to allow compat with webgl 1 and 2.
  23788. * You will need to pass the name of the uniform as well as the value.
  23789. */
  23790. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  23791. /**
  23792. * Lambda to Update a vec3 of float in a uniform buffer.
  23793. * This is dynamic to allow compat with webgl 1 and 2.
  23794. * You will need to pass the name of the uniform as well as the value.
  23795. */
  23796. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  23797. /**
  23798. * Lambda to Update a vec4 of float in a uniform buffer.
  23799. * This is dynamic to allow compat with webgl 1 and 2.
  23800. * You will need to pass the name of the uniform as well as the value.
  23801. */
  23802. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  23803. /**
  23804. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  23805. * This is dynamic to allow compat with webgl 1 and 2.
  23806. * You will need to pass the name of the uniform as well as the value.
  23807. */
  23808. updateMatrix: (name: string, mat: Matrix) => void;
  23809. /**
  23810. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  23811. * This is dynamic to allow compat with webgl 1 and 2.
  23812. * You will need to pass the name of the uniform as well as the value.
  23813. */
  23814. updateVector3: (name: string, vector: Vector3) => void;
  23815. /**
  23816. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  23817. * This is dynamic to allow compat with webgl 1 and 2.
  23818. * You will need to pass the name of the uniform as well as the value.
  23819. */
  23820. updateVector4: (name: string, vector: Vector4) => void;
  23821. /**
  23822. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  23823. * This is dynamic to allow compat with webgl 1 and 2.
  23824. * You will need to pass the name of the uniform as well as the value.
  23825. */
  23826. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  23827. /**
  23828. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  23829. * This is dynamic to allow compat with webgl 1 and 2.
  23830. * You will need to pass the name of the uniform as well as the value.
  23831. */
  23832. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  23833. /**
  23834. * Instantiates a new Uniform buffer objects.
  23835. *
  23836. * Handles blocks of uniform on the GPU.
  23837. *
  23838. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  23839. *
  23840. * For more information, please refer to :
  23841. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  23842. * @param engine Define the engine the buffer is associated with
  23843. * @param data Define the data contained in the buffer
  23844. * @param dynamic Define if the buffer is updatable
  23845. */
  23846. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  23847. /**
  23848. * Indicates if the buffer is using the WebGL2 UBO implementation,
  23849. * or just falling back on setUniformXXX calls.
  23850. */
  23851. readonly useUbo: boolean;
  23852. /**
  23853. * Indicates if the WebGL underlying uniform buffer is in sync
  23854. * with the javascript cache data.
  23855. */
  23856. readonly isSync: boolean;
  23857. /**
  23858. * Indicates if the WebGL underlying uniform buffer is dynamic.
  23859. * Also, a dynamic UniformBuffer will disable cache verification and always
  23860. * update the underlying WebGL uniform buffer to the GPU.
  23861. * @returns if Dynamic, otherwise false
  23862. */
  23863. isDynamic(): boolean;
  23864. /**
  23865. * The data cache on JS side.
  23866. * @returns the underlying data as a float array
  23867. */
  23868. getData(): Float32Array;
  23869. /**
  23870. * The underlying WebGL Uniform buffer.
  23871. * @returns the webgl buffer
  23872. */
  23873. getBuffer(): Nullable<WebGLBuffer>;
  23874. /**
  23875. * std140 layout specifies how to align data within an UBO structure.
  23876. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  23877. * for specs.
  23878. */
  23879. private _fillAlignment;
  23880. /**
  23881. * Adds an uniform in the buffer.
  23882. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  23883. * for the layout to be correct !
  23884. * @param name Name of the uniform, as used in the uniform block in the shader.
  23885. * @param size Data size, or data directly.
  23886. */
  23887. addUniform(name: string, size: number | number[]): void;
  23888. /**
  23889. * Adds a Matrix 4x4 to the uniform buffer.
  23890. * @param name Name of the uniform, as used in the uniform block in the shader.
  23891. * @param mat A 4x4 matrix.
  23892. */
  23893. addMatrix(name: string, mat: Matrix): void;
  23894. /**
  23895. * Adds a vec2 to the uniform buffer.
  23896. * @param name Name of the uniform, as used in the uniform block in the shader.
  23897. * @param x Define the x component value of the vec2
  23898. * @param y Define the y component value of the vec2
  23899. */
  23900. addFloat2(name: string, x: number, y: number): void;
  23901. /**
  23902. * Adds a vec3 to the uniform buffer.
  23903. * @param name Name of the uniform, as used in the uniform block in the shader.
  23904. * @param x Define the x component value of the vec3
  23905. * @param y Define the y component value of the vec3
  23906. * @param z Define the z component value of the vec3
  23907. */
  23908. addFloat3(name: string, x: number, y: number, z: number): void;
  23909. /**
  23910. * Adds a vec3 to the uniform buffer.
  23911. * @param name Name of the uniform, as used in the uniform block in the shader.
  23912. * @param color Define the vec3 from a Color
  23913. */
  23914. addColor3(name: string, color: Color3): void;
  23915. /**
  23916. * Adds a vec4 to the uniform buffer.
  23917. * @param name Name of the uniform, as used in the uniform block in the shader.
  23918. * @param color Define the rgb components from a Color
  23919. * @param alpha Define the a component of the vec4
  23920. */
  23921. addColor4(name: string, color: Color3, alpha: number): void;
  23922. /**
  23923. * Adds a vec3 to the uniform buffer.
  23924. * @param name Name of the uniform, as used in the uniform block in the shader.
  23925. * @param vector Define the vec3 components from a Vector
  23926. */
  23927. addVector3(name: string, vector: Vector3): void;
  23928. /**
  23929. * Adds a Matrix 3x3 to the uniform buffer.
  23930. * @param name Name of the uniform, as used in the uniform block in the shader.
  23931. */
  23932. addMatrix3x3(name: string): void;
  23933. /**
  23934. * Adds a Matrix 2x2 to the uniform buffer.
  23935. * @param name Name of the uniform, as used in the uniform block in the shader.
  23936. */
  23937. addMatrix2x2(name: string): void;
  23938. /**
  23939. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  23940. */
  23941. create(): void;
  23942. /** @hidden */
  23943. _rebuild(): void;
  23944. /**
  23945. * Updates the WebGL Uniform Buffer on the GPU.
  23946. * If the `dynamic` flag is set to true, no cache comparison is done.
  23947. * Otherwise, the buffer will be updated only if the cache differs.
  23948. */
  23949. update(): void;
  23950. /**
  23951. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  23952. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  23953. * @param data Define the flattened data
  23954. * @param size Define the size of the data.
  23955. */
  23956. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  23957. private _updateMatrix3x3ForUniform;
  23958. private _updateMatrix3x3ForEffect;
  23959. private _updateMatrix2x2ForEffect;
  23960. private _updateMatrix2x2ForUniform;
  23961. private _updateFloatForEffect;
  23962. private _updateFloatForUniform;
  23963. private _updateFloat2ForEffect;
  23964. private _updateFloat2ForUniform;
  23965. private _updateFloat3ForEffect;
  23966. private _updateFloat3ForUniform;
  23967. private _updateFloat4ForEffect;
  23968. private _updateFloat4ForUniform;
  23969. private _updateMatrixForEffect;
  23970. private _updateMatrixForUniform;
  23971. private _updateVector3ForEffect;
  23972. private _updateVector3ForUniform;
  23973. private _updateVector4ForEffect;
  23974. private _updateVector4ForUniform;
  23975. private _updateColor3ForEffect;
  23976. private _updateColor3ForUniform;
  23977. private _updateColor4ForEffect;
  23978. private _updateColor4ForUniform;
  23979. /**
  23980. * Sets a sampler uniform on the effect.
  23981. * @param name Define the name of the sampler.
  23982. * @param texture Define the texture to set in the sampler
  23983. */
  23984. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  23985. /**
  23986. * Directly updates the value of the uniform in the cache AND on the GPU.
  23987. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  23988. * @param data Define the flattened data
  23989. */
  23990. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  23991. /**
  23992. * Binds this uniform buffer to an effect.
  23993. * @param effect Define the effect to bind the buffer to
  23994. * @param name Name of the uniform block in the shader.
  23995. */
  23996. bindToEffect(effect: Effect, name: string): void;
  23997. /**
  23998. * Disposes the uniform buffer.
  23999. */
  24000. dispose(): void;
  24001. }
  24002. }
  24003. declare module BABYLON {
  24004. /**
  24005. * Class used to store all common mesh properties
  24006. */
  24007. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24008. /** No occlusion */
  24009. static OCCLUSION_TYPE_NONE: number;
  24010. /** Occlusion set to optimisitic */
  24011. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24012. /** Occlusion set to strict */
  24013. static OCCLUSION_TYPE_STRICT: number;
  24014. /** Use an accurante occlusion algorithm */
  24015. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24016. /** Use a conservative occlusion algorithm */
  24017. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24018. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  24019. static readonly CULLINGSTRATEGY_STANDARD: number;
  24020. /** Culling strategy with bounding sphere only and then frustum culling */
  24021. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24022. /**
  24023. * No billboard
  24024. */
  24025. static readonly BILLBOARDMODE_NONE: number;
  24026. /** Billboard on X axis */
  24027. static readonly BILLBOARDMODE_X: number;
  24028. /** Billboard on Y axis */
  24029. static readonly BILLBOARDMODE_Y: number;
  24030. /** Billboard on Z axis */
  24031. static readonly BILLBOARDMODE_Z: number;
  24032. /** Billboard on all axes */
  24033. static readonly BILLBOARDMODE_ALL: number;
  24034. private _facetData;
  24035. /** Gets ot sets the culling strategy to use to find visible meshes */
  24036. cullingStrategy: number;
  24037. /**
  24038. * Gets the number of facets in the mesh
  24039. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24040. */
  24041. readonly facetNb: number;
  24042. /**
  24043. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24044. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24045. */
  24046. partitioningSubdivisions: number;
  24047. /**
  24048. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24049. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24050. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24051. */
  24052. partitioningBBoxRatio: number;
  24053. /**
  24054. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24055. * Works only for updatable meshes.
  24056. * Doesn't work with multi-materials
  24057. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24058. */
  24059. mustDepthSortFacets: boolean;
  24060. /**
  24061. * The location (Vector3) where the facet depth sort must be computed from.
  24062. * By default, the active camera position.
  24063. * Used only when facet depth sort is enabled
  24064. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24065. */
  24066. facetDepthSortFrom: Vector3;
  24067. /**
  24068. * gets a boolean indicating if facetData is enabled
  24069. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24070. */
  24071. readonly isFacetDataEnabled: boolean;
  24072. /** @hidden */
  24073. _updateNonUniformScalingState(value: boolean): boolean;
  24074. /**
  24075. * An event triggered when this mesh collides with another one
  24076. */
  24077. onCollideObservable: Observable<AbstractMesh>;
  24078. private _onCollideObserver;
  24079. /** Set a function to call when this mesh collides with another one */
  24080. onCollide: () => void;
  24081. /**
  24082. * An event triggered when the collision's position changes
  24083. */
  24084. onCollisionPositionChangeObservable: Observable<Vector3>;
  24085. private _onCollisionPositionChangeObserver;
  24086. /** Set a function to call when the collision's position changes */
  24087. onCollisionPositionChange: () => void;
  24088. /**
  24089. * An event triggered when material is changed
  24090. */
  24091. onMaterialChangedObservable: Observable<AbstractMesh>;
  24092. /**
  24093. * Gets or sets the orientation for POV movement & rotation
  24094. */
  24095. definedFacingForward: boolean;
  24096. /** @hidden */
  24097. _occlusionQuery: Nullable<WebGLQuery>;
  24098. private _visibility;
  24099. /**
  24100. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24101. */
  24102. /**
  24103. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24104. */
  24105. visibility: number;
  24106. /** Gets or sets the alpha index used to sort transparent meshes
  24107. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24108. */
  24109. alphaIndex: number;
  24110. /**
  24111. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24112. */
  24113. isVisible: boolean;
  24114. /**
  24115. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24116. */
  24117. isPickable: boolean;
  24118. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24119. showSubMeshesBoundingBox: boolean;
  24120. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24121. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24122. */
  24123. isBlocker: boolean;
  24124. /**
  24125. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24126. */
  24127. enablePointerMoveEvents: boolean;
  24128. /**
  24129. * Specifies the rendering group id for this mesh (0 by default)
  24130. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24131. */
  24132. renderingGroupId: number;
  24133. private _material;
  24134. /** Gets or sets current material */
  24135. material: Nullable<Material>;
  24136. private _receiveShadows;
  24137. /**
  24138. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24139. * @see http://doc.babylonjs.com/babylon101/shadows
  24140. */
  24141. receiveShadows: boolean;
  24142. /** Defines color to use when rendering outline */
  24143. outlineColor: Color3;
  24144. /** Define width to use when rendering outline */
  24145. outlineWidth: number;
  24146. /** Defines color to use when rendering overlay */
  24147. overlayColor: Color3;
  24148. /** Defines alpha to use when rendering overlay */
  24149. overlayAlpha: number;
  24150. private _hasVertexAlpha;
  24151. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24152. hasVertexAlpha: boolean;
  24153. private _useVertexColors;
  24154. /** 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) */
  24155. useVertexColors: boolean;
  24156. private _computeBonesUsingShaders;
  24157. /**
  24158. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24159. */
  24160. computeBonesUsingShaders: boolean;
  24161. private _numBoneInfluencers;
  24162. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24163. numBoneInfluencers: number;
  24164. private _applyFog;
  24165. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24166. applyFog: boolean;
  24167. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24168. useOctreeForRenderingSelection: boolean;
  24169. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24170. useOctreeForPicking: boolean;
  24171. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24172. useOctreeForCollisions: boolean;
  24173. private _layerMask;
  24174. /**
  24175. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24176. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24177. */
  24178. layerMask: number;
  24179. /**
  24180. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24181. */
  24182. alwaysSelectAsActiveMesh: boolean;
  24183. /**
  24184. * Gets or sets the current action manager
  24185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24186. */
  24187. actionManager: Nullable<ActionManager>;
  24188. private _checkCollisions;
  24189. private _collisionMask;
  24190. private _collisionGroup;
  24191. /**
  24192. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24193. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24194. */
  24195. ellipsoid: Vector3;
  24196. /**
  24197. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24198. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24199. */
  24200. ellipsoidOffset: Vector3;
  24201. private _collider;
  24202. private _oldPositionForCollisions;
  24203. private _diffPositionForCollisions;
  24204. /**
  24205. * Gets or sets a collision mask used to mask collisions (default is -1).
  24206. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24207. */
  24208. collisionMask: number;
  24209. /**
  24210. * Gets or sets the current collision group mask (-1 by default).
  24211. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24212. */
  24213. collisionGroup: number;
  24214. /**
  24215. * Defines edge width used when edgesRenderer is enabled
  24216. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24217. */
  24218. edgesWidth: number;
  24219. /**
  24220. * Defines edge color used when edgesRenderer is enabled
  24221. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24222. */
  24223. edgesColor: Color4;
  24224. /** @hidden */
  24225. _edgesRenderer: Nullable<IEdgesRenderer>;
  24226. /** @hidden */
  24227. _masterMesh: Nullable<AbstractMesh>;
  24228. /** @hidden */
  24229. _boundingInfo: Nullable<BoundingInfo>;
  24230. /** @hidden */
  24231. _renderId: number;
  24232. /**
  24233. * Gets or sets the list of subMeshes
  24234. * @see http://doc.babylonjs.com/how_to/multi_materials
  24235. */
  24236. subMeshes: SubMesh[];
  24237. /** @hidden */
  24238. _intersectionsInProgress: AbstractMesh[];
  24239. /** @hidden */
  24240. _unIndexed: boolean;
  24241. /** @hidden */
  24242. _lightSources: Light[];
  24243. /** @hidden */
  24244. readonly _positions: Nullable<Vector3[]>;
  24245. /** @hidden */
  24246. _waitingActions: any;
  24247. /** @hidden */
  24248. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24249. private _skeleton;
  24250. /** @hidden */
  24251. _bonesTransformMatrices: Nullable<Float32Array>;
  24252. /**
  24253. * Gets or sets a skeleton to apply skining transformations
  24254. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24255. */
  24256. skeleton: Nullable<Skeleton>;
  24257. /**
  24258. * An event triggered when the mesh is rebuilt.
  24259. */
  24260. onRebuildObservable: Observable<AbstractMesh>;
  24261. /**
  24262. * Creates a new AbstractMesh
  24263. * @param name defines the name of the mesh
  24264. * @param scene defines the hosting scene
  24265. */
  24266. constructor(name: string, scene?: Nullable<Scene>);
  24267. /**
  24268. * Returns the string "AbstractMesh"
  24269. * @returns "AbstractMesh"
  24270. */
  24271. getClassName(): string;
  24272. /**
  24273. * Gets a string representation of the current mesh
  24274. * @param fullDetails defines a boolean indicating if full details must be included
  24275. * @returns a string representation of the current mesh
  24276. */
  24277. toString(fullDetails?: boolean): string;
  24278. /** @hidden */
  24279. _rebuild(): void;
  24280. /** @hidden */
  24281. _resyncLightSources(): void;
  24282. /** @hidden */
  24283. _resyncLighSource(light: Light): void;
  24284. /** @hidden */
  24285. _unBindEffect(): void;
  24286. /** @hidden */
  24287. _removeLightSource(light: Light): void;
  24288. private _markSubMeshesAsDirty;
  24289. /** @hidden */
  24290. _markSubMeshesAsLightDirty(): void;
  24291. /** @hidden */
  24292. _markSubMeshesAsAttributesDirty(): void;
  24293. /** @hidden */
  24294. _markSubMeshesAsMiscDirty(): void;
  24295. /**
  24296. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24297. */
  24298. scaling: Vector3;
  24299. /**
  24300. * Returns true if the mesh is blocked. Implemented by child classes
  24301. */
  24302. readonly isBlocked: boolean;
  24303. /**
  24304. * Returns the mesh itself by default. Implemented by child classes
  24305. * @param camera defines the camera to use to pick the right LOD level
  24306. * @returns the currentAbstractMesh
  24307. */
  24308. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24309. /**
  24310. * Returns 0 by default. Implemented by child classes
  24311. * @returns an integer
  24312. */
  24313. getTotalVertices(): number;
  24314. /**
  24315. * Returns null by default. Implemented by child classes
  24316. * @returns null
  24317. */
  24318. getIndices(): Nullable<IndicesArray>;
  24319. /**
  24320. * Returns the array of the requested vertex data kind. Implemented by child classes
  24321. * @param kind defines the vertex data kind to use
  24322. * @returns null
  24323. */
  24324. getVerticesData(kind: string): Nullable<FloatArray>;
  24325. /**
  24326. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24327. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24328. * Note that a new underlying VertexBuffer object is created each call.
  24329. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24330. * @param kind defines vertex data kind:
  24331. * * BABYLON.VertexBuffer.PositionKind
  24332. * * BABYLON.VertexBuffer.UVKind
  24333. * * BABYLON.VertexBuffer.UV2Kind
  24334. * * BABYLON.VertexBuffer.UV3Kind
  24335. * * BABYLON.VertexBuffer.UV4Kind
  24336. * * BABYLON.VertexBuffer.UV5Kind
  24337. * * BABYLON.VertexBuffer.UV6Kind
  24338. * * BABYLON.VertexBuffer.ColorKind
  24339. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24340. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24341. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24342. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24343. * @param data defines the data source
  24344. * @param updatable defines if the data must be flagged as updatable (or static)
  24345. * @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
  24346. * @returns the current mesh
  24347. */
  24348. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24349. /**
  24350. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24351. * If the mesh has no geometry, it is simply returned as it is.
  24352. * @param kind defines vertex data kind:
  24353. * * BABYLON.VertexBuffer.PositionKind
  24354. * * BABYLON.VertexBuffer.UVKind
  24355. * * BABYLON.VertexBuffer.UV2Kind
  24356. * * BABYLON.VertexBuffer.UV3Kind
  24357. * * BABYLON.VertexBuffer.UV4Kind
  24358. * * BABYLON.VertexBuffer.UV5Kind
  24359. * * BABYLON.VertexBuffer.UV6Kind
  24360. * * BABYLON.VertexBuffer.ColorKind
  24361. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24362. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24363. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24364. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24365. * @param data defines the data source
  24366. * @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
  24367. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24368. * @returns the current mesh
  24369. */
  24370. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24371. /**
  24372. * Sets the mesh indices,
  24373. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24374. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24375. * @param totalVertices Defines the total number of vertices
  24376. * @returns the current mesh
  24377. */
  24378. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24379. /**
  24380. * Gets a boolean indicating if specific vertex data is present
  24381. * @param kind defines the vertex data kind to use
  24382. * @returns true is data kind is present
  24383. */
  24384. isVerticesDataPresent(kind: string): boolean;
  24385. /**
  24386. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24387. * @returns a BoundingInfo
  24388. */
  24389. getBoundingInfo(): BoundingInfo;
  24390. /**
  24391. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24392. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24393. * @returns the current mesh
  24394. */
  24395. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24396. /**
  24397. * Overwrite the current bounding info
  24398. * @param boundingInfo defines the new bounding info
  24399. * @returns the current mesh
  24400. */
  24401. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24402. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24403. readonly useBones: boolean;
  24404. /** @hidden */
  24405. _preActivate(): void;
  24406. /** @hidden */
  24407. _preActivateForIntermediateRendering(renderId: number): void;
  24408. /** @hidden */
  24409. _activate(renderId: number): void;
  24410. /**
  24411. * Gets the current world matrix
  24412. * @returns a Matrix
  24413. */
  24414. getWorldMatrix(): Matrix;
  24415. /** @hidden */
  24416. _getWorldMatrixDeterminant(): number;
  24417. /**
  24418. * Perform relative position change from the point of view of behind the front of the mesh.
  24419. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24420. * Supports definition of mesh facing forward or backward
  24421. * @param amountRight defines the distance on the right axis
  24422. * @param amountUp defines the distance on the up axis
  24423. * @param amountForward defines the distance on the forward axis
  24424. * @returns the current mesh
  24425. */
  24426. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24427. /**
  24428. * Calculate relative position change from the point of view of behind the front of the mesh.
  24429. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24430. * Supports definition of mesh facing forward or backward
  24431. * @param amountRight defines the distance on the right axis
  24432. * @param amountUp defines the distance on the up axis
  24433. * @param amountForward defines the distance on the forward axis
  24434. * @returns the new displacement vector
  24435. */
  24436. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24437. /**
  24438. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24439. * Supports definition of mesh facing forward or backward
  24440. * @param flipBack defines the flip
  24441. * @param twirlClockwise defines the twirl
  24442. * @param tiltRight defines the tilt
  24443. * @returns the current mesh
  24444. */
  24445. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24446. /**
  24447. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24448. * Supports definition of mesh facing forward or backward.
  24449. * @param flipBack defines the flip
  24450. * @param twirlClockwise defines the twirl
  24451. * @param tiltRight defines the tilt
  24452. * @returns the new rotation vector
  24453. */
  24454. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24455. /**
  24456. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24457. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24458. * @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
  24459. * @returns the new bounding vectors
  24460. */
  24461. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24462. min: Vector3;
  24463. max: Vector3;
  24464. };
  24465. /** @hidden */
  24466. _updateBoundingInfo(): AbstractMesh;
  24467. /** @hidden */
  24468. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  24469. /** @hidden */
  24470. protected _afterComputeWorldMatrix(): void;
  24471. /**
  24472. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24473. * A mesh is in the frustum if its bounding box intersects the frustum
  24474. * @param frustumPlanes defines the frustum to test
  24475. * @returns true if the mesh is in the frustum planes
  24476. */
  24477. isInFrustum(frustumPlanes: Plane[]): boolean;
  24478. /**
  24479. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24480. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24481. * @param frustumPlanes defines the frustum to test
  24482. * @returns true if the mesh is completely in the frustum planes
  24483. */
  24484. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24485. /**
  24486. * True if the mesh intersects another mesh or a SolidParticle object
  24487. * @param mesh defines a target mesh or SolidParticle to test
  24488. * @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)
  24489. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24490. * @returns true if there is an intersection
  24491. */
  24492. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24493. /**
  24494. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24495. * @param point defines the point to test
  24496. * @returns true if there is an intersection
  24497. */
  24498. intersectsPoint(point: Vector3): boolean;
  24499. /**
  24500. * Gets the position of the current mesh in camera space
  24501. * @param camera defines the camera to use
  24502. * @returns a position
  24503. */
  24504. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  24505. /**
  24506. * Returns the distance from the mesh to the active camera
  24507. * @param camera defines the camera to use
  24508. * @returns the distance
  24509. */
  24510. getDistanceToCamera(camera?: Nullable<Camera>): number;
  24511. /**
  24512. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24513. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24514. */
  24515. checkCollisions: boolean;
  24516. /**
  24517. * Gets Collider object used to compute collisions (not physics)
  24518. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24519. */
  24520. readonly collider: Collider;
  24521. /**
  24522. * Move the mesh using collision engine
  24523. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24524. * @param displacement defines the requested displacement vector
  24525. * @returns the current mesh
  24526. */
  24527. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24528. private _onCollisionPositionChange;
  24529. /** @hidden */
  24530. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24531. /** @hidden */
  24532. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24533. /** @hidden */
  24534. _checkCollision(collider: Collider): AbstractMesh;
  24535. /** @hidden */
  24536. _generatePointsArray(): boolean;
  24537. /**
  24538. * Checks if the passed Ray intersects with the mesh
  24539. * @param ray defines the ray to use
  24540. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24541. * @returns the picking info
  24542. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24543. */
  24544. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24545. /**
  24546. * Clones the current mesh
  24547. * @param name defines the mesh name
  24548. * @param newParent defines the new mesh parent
  24549. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24550. * @returns the new mesh
  24551. */
  24552. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24553. /**
  24554. * Disposes all the submeshes of the current meshnp
  24555. * @returns the current mesh
  24556. */
  24557. releaseSubMeshes(): AbstractMesh;
  24558. /**
  24559. * Releases resources associated with this abstract mesh.
  24560. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24561. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24562. */
  24563. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24564. /**
  24565. * Adds the passed mesh as a child to the current mesh
  24566. * @param mesh defines the child mesh
  24567. * @returns the current mesh
  24568. */
  24569. addChild(mesh: AbstractMesh): AbstractMesh;
  24570. /**
  24571. * Removes the passed mesh from the current mesh children list
  24572. * @param mesh defines the child mesh
  24573. * @returns the current mesh
  24574. */
  24575. removeChild(mesh: AbstractMesh): AbstractMesh;
  24576. /** @hidden */
  24577. private _initFacetData;
  24578. /**
  24579. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24580. * This method can be called within the render loop.
  24581. * 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
  24582. * @returns the current mesh
  24583. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24584. */
  24585. updateFacetData(): AbstractMesh;
  24586. /**
  24587. * Returns the facetLocalNormals array.
  24588. * The normals are expressed in the mesh local spac
  24589. * @returns an array of Vector3
  24590. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24591. */
  24592. getFacetLocalNormals(): Vector3[];
  24593. /**
  24594. * Returns the facetLocalPositions array.
  24595. * The facet positions are expressed in the mesh local space
  24596. * @returns an array of Vector3
  24597. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24598. */
  24599. getFacetLocalPositions(): Vector3[];
  24600. /**
  24601. * Returns the facetLocalPartioning array
  24602. * @returns an array of array of numbers
  24603. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24604. */
  24605. getFacetLocalPartitioning(): number[][];
  24606. /**
  24607. * Returns the i-th facet position in the world system.
  24608. * This method allocates a new Vector3 per call
  24609. * @param i defines the facet index
  24610. * @returns a new Vector3
  24611. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24612. */
  24613. getFacetPosition(i: number): Vector3;
  24614. /**
  24615. * Sets the reference Vector3 with the i-th facet position in the world system
  24616. * @param i defines the facet index
  24617. * @param ref defines the target vector
  24618. * @returns the current mesh
  24619. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24620. */
  24621. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24622. /**
  24623. * Returns the i-th facet normal in the world system.
  24624. * This method allocates a new Vector3 per call
  24625. * @param i defines the facet index
  24626. * @returns a new Vector3
  24627. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24628. */
  24629. getFacetNormal(i: number): Vector3;
  24630. /**
  24631. * Sets the reference Vector3 with the i-th facet normal in the world system
  24632. * @param i defines the facet index
  24633. * @param ref defines the target vector
  24634. * @returns the current mesh
  24635. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24636. */
  24637. getFacetNormalToRef(i: number, ref: Vector3): this;
  24638. /**
  24639. * 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)
  24640. * @param x defines x coordinate
  24641. * @param y defines y coordinate
  24642. * @param z defines z coordinate
  24643. * @returns the array of facet indexes
  24644. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24645. */
  24646. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24647. /**
  24648. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24649. * @param projected sets as the (x,y,z) world projection on the facet
  24650. * @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
  24651. * @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
  24652. * @param x defines x coordinate
  24653. * @param y defines y coordinate
  24654. * @param z defines z coordinate
  24655. * @returns the face index if found (or null instead)
  24656. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24657. */
  24658. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24659. /**
  24660. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24661. * @param projected sets as the (x,y,z) local projection on the facet
  24662. * @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
  24663. * @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
  24664. * @param x defines x coordinate
  24665. * @param y defines y coordinate
  24666. * @param z defines z coordinate
  24667. * @returns the face index if found (or null instead)
  24668. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24669. */
  24670. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24671. /**
  24672. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24673. * @returns the parameters
  24674. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24675. */
  24676. getFacetDataParameters(): any;
  24677. /**
  24678. * Disables the feature FacetData and frees the related memory
  24679. * @returns the current mesh
  24680. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24681. */
  24682. disableFacetData(): AbstractMesh;
  24683. /**
  24684. * Updates the AbstractMesh indices array
  24685. * @param indices defines the data source
  24686. * @returns the current mesh
  24687. */
  24688. updateIndices(indices: IndicesArray): AbstractMesh;
  24689. /**
  24690. * Creates new normals data for the mesh
  24691. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24692. * @returns the current mesh
  24693. */
  24694. createNormals(updatable: boolean): AbstractMesh;
  24695. /**
  24696. * Align the mesh with a normal
  24697. * @param normal defines the normal to use
  24698. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24699. * @returns the current mesh
  24700. */
  24701. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24702. /** @hidden */
  24703. _checkOcclusionQuery(): boolean;
  24704. }
  24705. }
  24706. declare module BABYLON {
  24707. /**
  24708. * Class used to store data that will be store in GPU memory
  24709. */
  24710. class Buffer {
  24711. private _engine;
  24712. private _buffer;
  24713. /** @hidden */
  24714. _data: Nullable<DataArray>;
  24715. private _updatable;
  24716. private _instanced;
  24717. /**
  24718. * Gets the byte stride.
  24719. */
  24720. readonly byteStride: number;
  24721. /**
  24722. * Constructor
  24723. * @param engine the engine
  24724. * @param data the data to use for this buffer
  24725. * @param updatable whether the data is updatable
  24726. * @param stride the stride (optional)
  24727. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24728. * @param instanced whether the buffer is instanced (optional)
  24729. * @param useBytes set to true if the stride in in bytes (optional)
  24730. */
  24731. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  24732. /**
  24733. * Create a new VertexBuffer based on the current buffer
  24734. * @param kind defines the vertex buffer kind (position, normal, etc.)
  24735. * @param offset defines offset in the buffer (0 by default)
  24736. * @param size defines the size in floats of attributes (position is 3 for instance)
  24737. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  24738. * @param instanced defines if the vertex buffer contains indexed data
  24739. * @param useBytes defines if the offset and stride are in bytes
  24740. * @returns the new vertex buffer
  24741. */
  24742. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  24743. /**
  24744. * Gets a boolean indicating if the Buffer is updatable?
  24745. * @returns true if the buffer is updatable
  24746. */
  24747. isUpdatable(): boolean;
  24748. /**
  24749. * Gets current buffer's data
  24750. * @returns a DataArray or null
  24751. */
  24752. getData(): Nullable<DataArray>;
  24753. /**
  24754. * Gets underlying native buffer
  24755. * @returns underlying native buffer
  24756. */
  24757. getBuffer(): Nullable<WebGLBuffer>;
  24758. /**
  24759. * Gets the stride in float32 units (i.e. byte stride / 4).
  24760. * May not be an integer if the byte stride is not divisible by 4.
  24761. * DEPRECATED. Use byteStride instead.
  24762. * @returns the stride in float32 units
  24763. */
  24764. getStrideSize(): number;
  24765. /**
  24766. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  24767. * @param data defines the data to store
  24768. */
  24769. create(data?: Nullable<DataArray>): void;
  24770. /** @hidden */
  24771. _rebuild(): void;
  24772. /**
  24773. * Update current buffer data
  24774. * @param data defines the data to store
  24775. */
  24776. update(data: DataArray): void;
  24777. /**
  24778. * Updates the data directly.
  24779. * @param data the new data
  24780. * @param offset the new offset
  24781. * @param vertexCount the vertex count (optional)
  24782. * @param useBytes set to true if the offset is in bytes
  24783. */
  24784. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  24785. /**
  24786. * Release all resources
  24787. */
  24788. dispose(): void;
  24789. }
  24790. }
  24791. declare module BABYLON {
  24792. /**
  24793. * Class for building Constructive Solid Geometry
  24794. */
  24795. class CSG {
  24796. private polygons;
  24797. /**
  24798. * The world matrix
  24799. */
  24800. matrix: Matrix;
  24801. /**
  24802. * Stores the position
  24803. */
  24804. position: Vector3;
  24805. /**
  24806. * Stores the rotation
  24807. */
  24808. rotation: Vector3;
  24809. /**
  24810. * Stores the rotation quaternion
  24811. */
  24812. rotationQuaternion: Nullable<Quaternion>;
  24813. /**
  24814. * Stores the scaling vector
  24815. */
  24816. scaling: Vector3;
  24817. /**
  24818. * Convert the BABYLON.Mesh to BABYLON.CSG
  24819. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  24820. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  24821. */
  24822. static FromMesh(mesh: Mesh): CSG;
  24823. /**
  24824. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  24825. * @param polygons Polygons used to construct a BABYLON.CSG solid
  24826. */
  24827. private static FromPolygons;
  24828. /**
  24829. * Clones, or makes a deep copy, of the BABYLON.CSG
  24830. * @returns A new BABYLON.CSG
  24831. */
  24832. clone(): CSG;
  24833. /**
  24834. * Unions this CSG with another CSG
  24835. * @param csg The CSG to union against this CSG
  24836. * @returns The unioned CSG
  24837. */
  24838. union(csg: CSG): CSG;
  24839. /**
  24840. * Unions this CSG with another CSG in place
  24841. * @param csg The CSG to union against this CSG
  24842. */
  24843. unionInPlace(csg: CSG): void;
  24844. /**
  24845. * Subtracts this CSG with another CSG
  24846. * @param csg The CSG to subtract against this CSG
  24847. * @returns A new BABYLON.CSG
  24848. */
  24849. subtract(csg: CSG): CSG;
  24850. /**
  24851. * Subtracts this CSG with another CSG in place
  24852. * @param csg The CSG to subtact against this CSG
  24853. */
  24854. subtractInPlace(csg: CSG): void;
  24855. /**
  24856. * Intersect this CSG with another CSG
  24857. * @param csg The CSG to intersect against this CSG
  24858. * @returns A new BABYLON.CSG
  24859. */
  24860. intersect(csg: CSG): CSG;
  24861. /**
  24862. * Intersects this CSG with another CSG in place
  24863. * @param csg The CSG to intersect against this CSG
  24864. */
  24865. intersectInPlace(csg: CSG): void;
  24866. /**
  24867. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  24868. * not modified.
  24869. * @returns A new BABYLON.CSG solid with solid and empty space switched
  24870. */
  24871. inverse(): CSG;
  24872. /**
  24873. * Inverses the BABYLON.CSG in place
  24874. */
  24875. inverseInPlace(): void;
  24876. /**
  24877. * This is used to keep meshes transformations so they can be restored
  24878. * when we build back a Babylon Mesh
  24879. * NB : All CSG operations are performed in world coordinates
  24880. * @param csg The BABYLON.CSG to copy the transform attributes from
  24881. * @returns This BABYLON.CSG
  24882. */
  24883. copyTransformAttributes(csg: CSG): CSG;
  24884. /**
  24885. * Build Raw mesh from CSG
  24886. * Coordinates here are in world space
  24887. * @param name The name of the mesh geometry
  24888. * @param scene The BABYLON.Scene
  24889. * @param keepSubMeshes Specifies if the submeshes should be kept
  24890. * @returns A new BABYLON.Mesh
  24891. */
  24892. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  24893. /**
  24894. * Build Mesh from CSG taking material and transforms into account
  24895. * @param name The name of the BABYLON.Mesh
  24896. * @param material The material of the BABYLON.Mesh
  24897. * @param scene The BABYLON.Scene
  24898. * @param keepSubMeshes Specifies if submeshes should be kept
  24899. * @returns The new BABYLON.Mesh
  24900. */
  24901. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  24902. }
  24903. }
  24904. declare module BABYLON {
  24905. /**
  24906. * Class used to store geometry data (vertex buffers + index buffer)
  24907. */
  24908. class Geometry implements IGetSetVerticesData {
  24909. /**
  24910. * Gets or sets the unique ID of the geometry
  24911. */
  24912. id: string;
  24913. /**
  24914. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24915. */
  24916. delayLoadState: number;
  24917. /**
  24918. * Gets the file containing the data to load when running in delay load state
  24919. */
  24920. delayLoadingFile: Nullable<string>;
  24921. /**
  24922. * Callback called when the geometry is updated
  24923. */
  24924. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24925. private _scene;
  24926. private _engine;
  24927. private _meshes;
  24928. private _totalVertices;
  24929. /** @hidden */
  24930. _indices: IndicesArray;
  24931. /** @hidden */
  24932. _vertexBuffers: {
  24933. [key: string]: VertexBuffer;
  24934. };
  24935. private _isDisposed;
  24936. private _extend;
  24937. private _boundingBias;
  24938. /** @hidden */
  24939. _delayInfo: Array<string>;
  24940. private _indexBuffer;
  24941. private _indexBufferIsUpdatable;
  24942. /** @hidden */
  24943. _boundingInfo: Nullable<BoundingInfo>;
  24944. /** @hidden */
  24945. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24946. /** @hidden */
  24947. _softwareSkinningFrameId: number;
  24948. private _vertexArrayObjects;
  24949. private _updatable;
  24950. /** @hidden */
  24951. _positions: Nullable<Vector3[]>;
  24952. /**
  24953. * 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
  24954. */
  24955. /**
  24956. * 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
  24957. */
  24958. boundingBias: Vector2;
  24959. /**
  24960. * Static function used to attach a new empty geometry to a mesh
  24961. * @param mesh defines the mesh to attach the geometry to
  24962. * @returns the new Geometry
  24963. */
  24964. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24965. /**
  24966. * Creates a new geometry
  24967. * @param id defines the unique ID
  24968. * @param scene defines the hosting scene
  24969. * @param vertexData defines the VertexData used to get geometry data
  24970. * @param updatable defines if geometry must be updatable (false by default)
  24971. * @param mesh defines the mesh that will be associated with the geometry
  24972. */
  24973. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24974. /**
  24975. * Gets the current extend of the geometry
  24976. */
  24977. readonly extend: {
  24978. minimum: Vector3;
  24979. maximum: Vector3;
  24980. };
  24981. /**
  24982. * Gets the hosting scene
  24983. * @returns the hosting Scene
  24984. */
  24985. getScene(): Scene;
  24986. /**
  24987. * Gets the hosting engine
  24988. * @returns the hosting Engine
  24989. */
  24990. getEngine(): Engine;
  24991. /**
  24992. * Defines if the geometry is ready to use
  24993. * @returns true if the geometry is ready to be used
  24994. */
  24995. isReady(): boolean;
  24996. /**
  24997. * Gets a value indicating that the geometry should not be serialized
  24998. */
  24999. readonly doNotSerialize: boolean;
  25000. /** @hidden */
  25001. _rebuild(): void;
  25002. /**
  25003. * Affects all geometry data in one call
  25004. * @param vertexData defines the geometry data
  25005. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25006. */
  25007. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25008. /**
  25009. * Set specific vertex data
  25010. * @param kind defines the data kind (Position, normal, etc...)
  25011. * @param data defines the vertex data to use
  25012. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25013. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25014. */
  25015. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25016. /**
  25017. * Removes a specific vertex data
  25018. * @param kind defines the data kind (Position, normal, etc...)
  25019. */
  25020. removeVerticesData(kind: string): void;
  25021. /**
  25022. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25023. * @param buffer defines the vertex buffer to use
  25024. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25025. */
  25026. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25027. /**
  25028. * Update a specific vertex buffer
  25029. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25030. * It will do nothing if the buffer is not updatable
  25031. * @param kind defines the data kind (Position, normal, etc...)
  25032. * @param data defines the data to use
  25033. * @param offset defines the offset in the target buffer where to store the data
  25034. * @param useBytes set to true if the offset is in bytes
  25035. */
  25036. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25037. /**
  25038. * Update a specific vertex buffer
  25039. * This function will create a new buffer if the current one is not updatable
  25040. * @param kind defines the data kind (Position, normal, etc...)
  25041. * @param data defines the data to use
  25042. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25043. */
  25044. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25045. private _updateBoundingInfo;
  25046. /** @hidden */
  25047. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25048. /**
  25049. * Gets total number of vertices
  25050. * @returns the total number of vertices
  25051. */
  25052. getTotalVertices(): number;
  25053. /**
  25054. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25055. * @param kind defines the data kind (Position, normal, etc...)
  25056. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25057. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25058. * @returns a float array containing vertex data
  25059. */
  25060. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25061. /**
  25062. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25063. * @param kind defines the data kind (Position, normal, etc...)
  25064. * @returns true if the vertex buffer with the specified kind is updatable
  25065. */
  25066. isVertexBufferUpdatable(kind: string): boolean;
  25067. /**
  25068. * Gets a specific vertex buffer
  25069. * @param kind defines the data kind (Position, normal, etc...)
  25070. * @returns a VertexBuffer
  25071. */
  25072. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25073. /**
  25074. * Returns all vertex buffers
  25075. * @return an object holding all vertex buffers indexed by kind
  25076. */
  25077. getVertexBuffers(): Nullable<{
  25078. [key: string]: VertexBuffer;
  25079. }>;
  25080. /**
  25081. * Gets a boolean indicating if specific vertex buffer is present
  25082. * @param kind defines the data kind (Position, normal, etc...)
  25083. * @returns true if data is present
  25084. */
  25085. isVerticesDataPresent(kind: string): boolean;
  25086. /**
  25087. * Gets a list of all attached data kinds (Position, normal, etc...)
  25088. * @returns a list of string containing all kinds
  25089. */
  25090. getVerticesDataKinds(): string[];
  25091. /**
  25092. * Update index buffer
  25093. * @param indices defines the indices to store in the index buffer
  25094. * @param offset defines the offset in the target buffer where to store the data
  25095. */
  25096. updateIndices(indices: IndicesArray, offset?: number): void;
  25097. /**
  25098. * Creates a new index buffer
  25099. * @param indices defines the indices to store in the index buffer
  25100. * @param totalVertices defines the total number of vertices (could be null)
  25101. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25102. */
  25103. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25104. /**
  25105. * Return the total number of indices
  25106. * @returns the total number of indices
  25107. */
  25108. getTotalIndices(): number;
  25109. /**
  25110. * Gets the index buffer array
  25111. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25112. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25113. * @returns the index buffer array
  25114. */
  25115. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25116. /**
  25117. * Gets the index buffer
  25118. * @return the index buffer
  25119. */
  25120. getIndexBuffer(): Nullable<WebGLBuffer>;
  25121. /** @hidden */
  25122. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25123. /**
  25124. * Release the associated resources for a specific mesh
  25125. * @param mesh defines the source mesh
  25126. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25127. */
  25128. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25129. /**
  25130. * Apply current geometry to a given mesh
  25131. * @param mesh defines the mesh to apply geometry to
  25132. */
  25133. applyToMesh(mesh: Mesh): void;
  25134. private _updateExtend;
  25135. private _applyToMesh;
  25136. private notifyUpdate;
  25137. /**
  25138. * Load the geometry if it was flagged as delay loaded
  25139. * @param scene defines the hosting scene
  25140. * @param onLoaded defines a callback called when the geometry is loaded
  25141. */
  25142. load(scene: Scene, onLoaded?: () => void): void;
  25143. private _queueLoad;
  25144. /**
  25145. * Invert the geometry to move from a right handed system to a left handed one.
  25146. */
  25147. toLeftHanded(): void;
  25148. /** @hidden */
  25149. _resetPointsArrayCache(): void;
  25150. /** @hidden */
  25151. _generatePointsArray(): boolean;
  25152. /**
  25153. * Gets a value indicating if the geometry is disposed
  25154. * @returns true if the geometry was disposed
  25155. */
  25156. isDisposed(): boolean;
  25157. private _disposeVertexArrayObjects;
  25158. /**
  25159. * Free all associated resources
  25160. */
  25161. dispose(): void;
  25162. /**
  25163. * Clone the current geometry into a new geometry
  25164. * @param id defines the unique ID of the new geometry
  25165. * @returns a new geometry object
  25166. */
  25167. copy(id: string): Geometry;
  25168. /**
  25169. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25170. * @return a JSON representation of the current geometry data (without the vertices data)
  25171. */
  25172. serialize(): any;
  25173. private toNumberArray;
  25174. /**
  25175. * Serialize all vertices data into a JSON oject
  25176. * @returns a JSON representation of the current geometry data
  25177. */
  25178. serializeVerticeData(): any;
  25179. /**
  25180. * Extracts a clone of a mesh geometry
  25181. * @param mesh defines the source mesh
  25182. * @param id defines the unique ID of the new geometry object
  25183. * @returns the new geometry object
  25184. */
  25185. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25186. /**
  25187. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25188. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25189. * Be aware Math.random() could cause collisions, but:
  25190. * "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"
  25191. * @returns a string containing a new GUID
  25192. */
  25193. static RandomId(): string;
  25194. /** @hidden */
  25195. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25196. private static _CleanMatricesWeights;
  25197. /**
  25198. * Create a new geometry from persisted data (Using .babylon file format)
  25199. * @param parsedVertexData defines the persisted data
  25200. * @param scene defines the hosting scene
  25201. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25202. * @returns the new geometry object
  25203. */
  25204. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25205. }
  25206. /**
  25207. * Abstract class used to provide common services for all typed geometries
  25208. * @hidden
  25209. */
  25210. class _PrimitiveGeometry extends Geometry {
  25211. private _canBeRegenerated;
  25212. private _beingRegenerated;
  25213. /**
  25214. * Creates a new typed geometry
  25215. * @param id defines the unique ID of the geometry
  25216. * @param scene defines the hosting scene
  25217. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25218. * @param mesh defines the hosting mesh (can be null)
  25219. */
  25220. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25221. /**
  25222. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25223. * @returns true if the geometry can be regenerated
  25224. */
  25225. canBeRegenerated(): boolean;
  25226. /**
  25227. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25228. */
  25229. regenerate(): void;
  25230. /**
  25231. * Clone the geometry
  25232. * @param id defines the unique ID of the new geometry
  25233. * @returns the new geometry
  25234. */
  25235. asNewGeometry(id: string): Geometry;
  25236. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25237. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25238. /** @hidden */
  25239. _regenerateVertexData(): VertexData;
  25240. copy(id: string): Geometry;
  25241. serialize(): any;
  25242. }
  25243. /**
  25244. * Creates a ribbon geometry
  25245. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25246. */
  25247. class RibbonGeometry extends _PrimitiveGeometry {
  25248. /**
  25249. * Defines the array of paths to use
  25250. */
  25251. pathArray: Vector3[][];
  25252. /**
  25253. * Defines if the last and first points of each path in your pathArray must be joined
  25254. */
  25255. closeArray: boolean;
  25256. /**
  25257. * Defines if the last and first points of each path in your pathArray must be joined
  25258. */
  25259. closePath: boolean;
  25260. /**
  25261. * Defines the offset between points
  25262. */
  25263. offset: number;
  25264. /**
  25265. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25266. */
  25267. side: number;
  25268. /**
  25269. * Creates a ribbon geometry
  25270. * @param id defines the unique ID of the geometry
  25271. * @param scene defines the hosting scene
  25272. * @param pathArray defines the array of paths to use
  25273. * @param closeArray defines if the last path and the first path must be joined
  25274. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25275. * @param offset defines the offset between points
  25276. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25277. * @param mesh defines the hosting mesh (can be null)
  25278. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25279. */
  25280. constructor(id: string, scene: Scene,
  25281. /**
  25282. * Defines the array of paths to use
  25283. */
  25284. pathArray: Vector3[][],
  25285. /**
  25286. * Defines if the last and first points of each path in your pathArray must be joined
  25287. */
  25288. closeArray: boolean,
  25289. /**
  25290. * Defines if the last and first points of each path in your pathArray must be joined
  25291. */
  25292. closePath: boolean,
  25293. /**
  25294. * Defines the offset between points
  25295. */
  25296. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25297. /**
  25298. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25299. */
  25300. side?: number);
  25301. /** @hidden */
  25302. _regenerateVertexData(): VertexData;
  25303. copy(id: string): Geometry;
  25304. }
  25305. /**
  25306. * Creates a box geometry
  25307. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25308. */
  25309. class BoxGeometry extends _PrimitiveGeometry {
  25310. /**
  25311. * Defines the zise of the box (width, height and depth are the same)
  25312. */
  25313. size: number;
  25314. /**
  25315. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25316. */
  25317. side: number;
  25318. /**
  25319. * Creates a box geometry
  25320. * @param id defines the unique ID of the geometry
  25321. * @param scene defines the hosting scene
  25322. * @param size defines the zise of the box (width, height and depth are the same)
  25323. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25324. * @param mesh defines the hosting mesh (can be null)
  25325. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25326. */
  25327. constructor(id: string, scene: Scene,
  25328. /**
  25329. * Defines the zise of the box (width, height and depth are the same)
  25330. */
  25331. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25332. /**
  25333. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25334. */
  25335. side?: number);
  25336. /** @hidden */
  25337. _regenerateVertexData(): VertexData;
  25338. copy(id: string): Geometry;
  25339. serialize(): any;
  25340. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25341. }
  25342. /**
  25343. * Creates a sphere geometry
  25344. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25345. */
  25346. class SphereGeometry extends _PrimitiveGeometry {
  25347. /**
  25348. * Defines the number of segments to use to create the sphere
  25349. */
  25350. segments: number;
  25351. /**
  25352. * Defines the diameter of the sphere
  25353. */
  25354. diameter: number;
  25355. /**
  25356. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25357. */
  25358. side: number;
  25359. /**
  25360. * Create a new sphere geometry
  25361. * @param id defines the unique ID of the geometry
  25362. * @param scene defines the hosting scene
  25363. * @param segments defines the number of segments to use to create the sphere
  25364. * @param diameter defines the diameter of the sphere
  25365. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25366. * @param mesh defines the hosting mesh (can be null)
  25367. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25368. */
  25369. constructor(id: string, scene: Scene,
  25370. /**
  25371. * Defines the number of segments to use to create the sphere
  25372. */
  25373. segments: number,
  25374. /**
  25375. * Defines the diameter of the sphere
  25376. */
  25377. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25378. /**
  25379. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25380. */
  25381. side?: number);
  25382. /** @hidden */
  25383. _regenerateVertexData(): VertexData;
  25384. copy(id: string): Geometry;
  25385. serialize(): any;
  25386. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  25387. }
  25388. /**
  25389. * Creates a disc geometry
  25390. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25391. */
  25392. class DiscGeometry extends _PrimitiveGeometry {
  25393. /**
  25394. * Defines the radius of the disc
  25395. */
  25396. radius: number;
  25397. /**
  25398. * Defines the tesselation factor to apply to the disc
  25399. */
  25400. tessellation: number;
  25401. /**
  25402. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25403. */
  25404. side: number;
  25405. /**
  25406. * Creates a new disc geometry
  25407. * @param id defines the unique ID of the geometry
  25408. * @param scene defines the hosting scene
  25409. * @param radius defines the radius of the disc
  25410. * @param tessellation defines the tesselation factor to apply to the disc
  25411. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25412. * @param mesh defines the hosting mesh (can be null)
  25413. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25414. */
  25415. constructor(id: string, scene: Scene,
  25416. /**
  25417. * Defines the radius of the disc
  25418. */
  25419. radius: number,
  25420. /**
  25421. * Defines the tesselation factor to apply to the disc
  25422. */
  25423. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25424. /**
  25425. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25426. */
  25427. side?: number);
  25428. /** @hidden */
  25429. _regenerateVertexData(): VertexData;
  25430. copy(id: string): Geometry;
  25431. }
  25432. /**
  25433. * Creates a new cylinder geometry
  25434. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  25435. */
  25436. class CylinderGeometry extends _PrimitiveGeometry {
  25437. /**
  25438. * Defines the height of the cylinder
  25439. */
  25440. height: number;
  25441. /**
  25442. * Defines the diameter of the cylinder's top cap
  25443. */
  25444. diameterTop: number;
  25445. /**
  25446. * Defines the diameter of the cylinder's bottom cap
  25447. */
  25448. diameterBottom: number;
  25449. /**
  25450. * Defines the tessellation factor to apply to the cylinder
  25451. */
  25452. tessellation: number;
  25453. /**
  25454. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25455. */
  25456. subdivisions: number;
  25457. /**
  25458. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25459. */
  25460. side: number;
  25461. /**
  25462. * Creates a new cylinder geometry
  25463. * @param id defines the unique ID of the geometry
  25464. * @param scene defines the hosting scene
  25465. * @param height defines the height of the cylinder
  25466. * @param diameterTop defines the diameter of the cylinder's top cap
  25467. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  25468. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  25469. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  25470. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25471. * @param mesh defines the hosting mesh (can be null)
  25472. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25473. */
  25474. constructor(id: string, scene: Scene,
  25475. /**
  25476. * Defines the height of the cylinder
  25477. */
  25478. height: number,
  25479. /**
  25480. * Defines the diameter of the cylinder's top cap
  25481. */
  25482. diameterTop: number,
  25483. /**
  25484. * Defines the diameter of the cylinder's bottom cap
  25485. */
  25486. diameterBottom: number,
  25487. /**
  25488. * Defines the tessellation factor to apply to the cylinder
  25489. */
  25490. tessellation: number,
  25491. /**
  25492. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25493. */
  25494. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25495. /**
  25496. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25497. */
  25498. side?: number);
  25499. /** @hidden */
  25500. _regenerateVertexData(): VertexData;
  25501. copy(id: string): Geometry;
  25502. serialize(): any;
  25503. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25504. }
  25505. /**
  25506. * Creates a new torus geometry
  25507. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25508. */
  25509. class TorusGeometry extends _PrimitiveGeometry {
  25510. /**
  25511. * Defines the diameter of the torus
  25512. */
  25513. diameter: number;
  25514. /**
  25515. * Defines the thickness of the torus (ie. internal diameter)
  25516. */
  25517. thickness: number;
  25518. /**
  25519. * Defines the tesselation factor to apply to the torus
  25520. */
  25521. tessellation: number;
  25522. /**
  25523. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25524. */
  25525. side: number;
  25526. /**
  25527. * Creates a new torus geometry
  25528. * @param id defines the unique ID of the geometry
  25529. * @param scene defines the hosting scene
  25530. * @param diameter defines the diameter of the torus
  25531. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25532. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25533. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25534. * @param mesh defines the hosting mesh (can be null)
  25535. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25536. */
  25537. constructor(id: string, scene: Scene,
  25538. /**
  25539. * Defines the diameter of the torus
  25540. */
  25541. diameter: number,
  25542. /**
  25543. * Defines the thickness of the torus (ie. internal diameter)
  25544. */
  25545. thickness: number,
  25546. /**
  25547. * Defines the tesselation factor to apply to the torus
  25548. */
  25549. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25550. /**
  25551. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25552. */
  25553. side?: number);
  25554. /** @hidden */
  25555. _regenerateVertexData(): VertexData;
  25556. copy(id: string): Geometry;
  25557. serialize(): any;
  25558. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25559. }
  25560. /**
  25561. * Creates a new ground geometry
  25562. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25563. */
  25564. class GroundGeometry extends _PrimitiveGeometry {
  25565. /**
  25566. * Defines the width of the ground
  25567. */
  25568. width: number;
  25569. /**
  25570. * Defines the height of the ground
  25571. */
  25572. height: number;
  25573. /**
  25574. * Defines the subdivisions to apply to the ground
  25575. */
  25576. subdivisions: number;
  25577. /**
  25578. * Creates a new ground geometry
  25579. * @param id defines the unique ID of the geometry
  25580. * @param scene defines the hosting scene
  25581. * @param width defines the width of the ground
  25582. * @param height defines the height of the ground
  25583. * @param subdivisions defines the subdivisions to apply to the ground
  25584. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25585. * @param mesh defines the hosting mesh (can be null)
  25586. */
  25587. constructor(id: string, scene: Scene,
  25588. /**
  25589. * Defines the width of the ground
  25590. */
  25591. width: number,
  25592. /**
  25593. * Defines the height of the ground
  25594. */
  25595. height: number,
  25596. /**
  25597. * Defines the subdivisions to apply to the ground
  25598. */
  25599. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25600. /** @hidden */
  25601. _regenerateVertexData(): VertexData;
  25602. copy(id: string): Geometry;
  25603. serialize(): any;
  25604. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  25605. }
  25606. /**
  25607. * Creates a tiled ground geometry
  25608. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  25609. */
  25610. class TiledGroundGeometry extends _PrimitiveGeometry {
  25611. /**
  25612. * Defines the minimum value on X axis
  25613. */
  25614. xmin: number;
  25615. /**
  25616. * Defines the minimum value on Z axis
  25617. */
  25618. zmin: number;
  25619. /**
  25620. * Defines the maximum value on X axis
  25621. */
  25622. xmax: number;
  25623. /**
  25624. * Defines the maximum value on Z axis
  25625. */
  25626. zmax: number;
  25627. /**
  25628. * Defines the subdivisions to apply to the ground
  25629. */
  25630. subdivisions: {
  25631. w: number;
  25632. h: number;
  25633. };
  25634. /**
  25635. * Defines the precision to use when computing the tiles
  25636. */
  25637. precision: {
  25638. w: number;
  25639. h: number;
  25640. };
  25641. /**
  25642. * Creates a tiled ground geometry
  25643. * @param id defines the unique ID of the geometry
  25644. * @param scene defines the hosting scene
  25645. * @param xmin defines the minimum value on X axis
  25646. * @param zmin defines the minimum value on Z axis
  25647. * @param xmax defines the maximum value on X axis
  25648. * @param zmax defines the maximum value on Z axis
  25649. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  25650. * @param precision defines the precision to use when computing the tiles
  25651. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25652. * @param mesh defines the hosting mesh (can be null)
  25653. */
  25654. constructor(id: string, scene: Scene,
  25655. /**
  25656. * Defines the minimum value on X axis
  25657. */
  25658. xmin: number,
  25659. /**
  25660. * Defines the minimum value on Z axis
  25661. */
  25662. zmin: number,
  25663. /**
  25664. * Defines the maximum value on X axis
  25665. */
  25666. xmax: number,
  25667. /**
  25668. * Defines the maximum value on Z axis
  25669. */
  25670. zmax: number,
  25671. /**
  25672. * Defines the subdivisions to apply to the ground
  25673. */
  25674. subdivisions: {
  25675. w: number;
  25676. h: number;
  25677. },
  25678. /**
  25679. * Defines the precision to use when computing the tiles
  25680. */
  25681. precision: {
  25682. w: number;
  25683. h: number;
  25684. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25685. /** @hidden */
  25686. _regenerateVertexData(): VertexData;
  25687. copy(id: string): Geometry;
  25688. }
  25689. /**
  25690. * Creates a plane geometry
  25691. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  25692. */
  25693. class PlaneGeometry extends _PrimitiveGeometry {
  25694. /**
  25695. * Defines the size of the plane (width === height)
  25696. */
  25697. size: number;
  25698. /**
  25699. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25700. */
  25701. side: number;
  25702. /**
  25703. * Creates a plane geometry
  25704. * @param id defines the unique ID of the geometry
  25705. * @param scene defines the hosting scene
  25706. * @param size defines the size of the plane (width === height)
  25707. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25708. * @param mesh defines the hosting mesh (can be null)
  25709. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25710. */
  25711. constructor(id: string, scene: Scene,
  25712. /**
  25713. * Defines the size of the plane (width === height)
  25714. */
  25715. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25716. /**
  25717. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25718. */
  25719. side?: number);
  25720. /** @hidden */
  25721. _regenerateVertexData(): VertexData;
  25722. copy(id: string): Geometry;
  25723. serialize(): any;
  25724. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  25725. }
  25726. /**
  25727. * Creates a torus knot geometry
  25728. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  25729. */
  25730. class TorusKnotGeometry extends _PrimitiveGeometry {
  25731. /**
  25732. * Defines the radius of the torus knot
  25733. */
  25734. radius: number;
  25735. /**
  25736. * Defines the thickness of the torus knot tube
  25737. */
  25738. tube: number;
  25739. /**
  25740. * Defines the number of radial segments
  25741. */
  25742. radialSegments: number;
  25743. /**
  25744. * Defines the number of tubular segments
  25745. */
  25746. tubularSegments: number;
  25747. /**
  25748. * Defines the first number of windings
  25749. */
  25750. p: number;
  25751. /**
  25752. * Defines the second number of windings
  25753. */
  25754. q: number;
  25755. /**
  25756. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25757. */
  25758. side: number;
  25759. /**
  25760. * Creates a torus knot geometry
  25761. * @param id defines the unique ID of the geometry
  25762. * @param scene defines the hosting scene
  25763. * @param radius defines the radius of the torus knot
  25764. * @param tube defines the thickness of the torus knot tube
  25765. * @param radialSegments defines the number of radial segments
  25766. * @param tubularSegments defines the number of tubular segments
  25767. * @param p defines the first number of windings
  25768. * @param q defines the second number of windings
  25769. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25770. * @param mesh defines the hosting mesh (can be null)
  25771. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25772. */
  25773. constructor(id: string, scene: Scene,
  25774. /**
  25775. * Defines the radius of the torus knot
  25776. */
  25777. radius: number,
  25778. /**
  25779. * Defines the thickness of the torus knot tube
  25780. */
  25781. tube: number,
  25782. /**
  25783. * Defines the number of radial segments
  25784. */
  25785. radialSegments: number,
  25786. /**
  25787. * Defines the number of tubular segments
  25788. */
  25789. tubularSegments: number,
  25790. /**
  25791. * Defines the first number of windings
  25792. */
  25793. p: number,
  25794. /**
  25795. * Defines the second number of windings
  25796. */
  25797. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25798. /**
  25799. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25800. */
  25801. side?: number);
  25802. /** @hidden */
  25803. _regenerateVertexData(): VertexData;
  25804. copy(id: string): Geometry;
  25805. serialize(): any;
  25806. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  25807. }
  25808. }
  25809. declare module BABYLON {
  25810. /**
  25811. * Mesh representing the gorund
  25812. */
  25813. class GroundMesh extends Mesh {
  25814. /** If octree should be generated */
  25815. generateOctree: boolean;
  25816. private _heightQuads;
  25817. /** @hidden */
  25818. _subdivisionsX: number;
  25819. /** @hidden */
  25820. _subdivisionsY: number;
  25821. /** @hidden */
  25822. _width: number;
  25823. /** @hidden */
  25824. _height: number;
  25825. /** @hidden */
  25826. _minX: number;
  25827. /** @hidden */
  25828. _maxX: number;
  25829. /** @hidden */
  25830. _minZ: number;
  25831. /** @hidden */
  25832. _maxZ: number;
  25833. constructor(name: string, scene: Scene);
  25834. /**
  25835. * "GroundMesh"
  25836. * @returns "GroundMesh"
  25837. */
  25838. getClassName(): string;
  25839. /**
  25840. * The minimum of x and y subdivisions
  25841. */
  25842. readonly subdivisions: number;
  25843. /**
  25844. * X subdivisions
  25845. */
  25846. readonly subdivisionsX: number;
  25847. /**
  25848. * Y subdivisions
  25849. */
  25850. readonly subdivisionsY: number;
  25851. /**
  25852. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25853. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25854. * @param chunksCount the number of subdivisions for x and y
  25855. * @param octreeBlocksSize (Default: 32)
  25856. */
  25857. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25858. /**
  25859. * Returns a height (y) value in the Worl system :
  25860. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25861. * @param x x coordinate
  25862. * @param z z coordinate
  25863. * @returns the ground y position if (x, z) are outside the ground surface.
  25864. */
  25865. getHeightAtCoordinates(x: number, z: number): number;
  25866. /**
  25867. * Returns a normalized vector (Vector3) orthogonal to the ground
  25868. * at the ground coordinates (x, z) expressed in the World system.
  25869. * @param x x coordinate
  25870. * @param z z coordinate
  25871. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25872. */
  25873. getNormalAtCoordinates(x: number, z: number): Vector3;
  25874. /**
  25875. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25876. * at the ground coordinates (x, z) expressed in the World system.
  25877. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25878. * @param x x coordinate
  25879. * @param z z coordinate
  25880. * @param ref vector to store the result
  25881. * @returns the GroundMesh.
  25882. */
  25883. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25884. /**
  25885. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25886. * if the ground has been updated.
  25887. * This can be used in the render loop.
  25888. * @returns the GroundMesh.
  25889. */
  25890. updateCoordinateHeights(): GroundMesh;
  25891. private _getFacetAt;
  25892. private _initHeightQuads;
  25893. private _computeHeightQuads;
  25894. /**
  25895. * Serializes this ground mesh
  25896. * @param serializationObject object to write serialization to
  25897. */
  25898. serialize(serializationObject: any): void;
  25899. /**
  25900. * Parses a serialized ground mesh
  25901. * @param parsedMesh the serialized mesh
  25902. * @param scene the scene to create the ground mesh in
  25903. * @returns the created ground mesh
  25904. */
  25905. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25906. }
  25907. }
  25908. declare module BABYLON {
  25909. /**
  25910. * Creates an instance based on a source mesh.
  25911. */
  25912. class InstancedMesh extends AbstractMesh {
  25913. private _sourceMesh;
  25914. private _currentLOD;
  25915. /** @hidden */
  25916. _indexInSourceMeshInstanceArray: number;
  25917. constructor(name: string, source: Mesh);
  25918. /**
  25919. * Returns the string "InstancedMesh".
  25920. */
  25921. getClassName(): string;
  25922. /**
  25923. * If the source mesh receives shadows
  25924. */
  25925. readonly receiveShadows: boolean;
  25926. /**
  25927. * The material of the source mesh
  25928. */
  25929. readonly material: Nullable<Material>;
  25930. /**
  25931. * Visibility of the source mesh
  25932. */
  25933. readonly visibility: number;
  25934. /**
  25935. * Skeleton of the source mesh
  25936. */
  25937. readonly skeleton: Nullable<Skeleton>;
  25938. /**
  25939. * Rendering ground id of the source mesh
  25940. */
  25941. renderingGroupId: number;
  25942. /**
  25943. * Returns the total number of vertices (integer).
  25944. */
  25945. getTotalVertices(): number;
  25946. /**
  25947. * The source mesh of the instance
  25948. */
  25949. readonly sourceMesh: Mesh;
  25950. /**
  25951. * Is this node ready to be used/rendered
  25952. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25953. * @return {boolean} is it ready
  25954. */
  25955. isReady(completeCheck?: boolean): boolean;
  25956. /**
  25957. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25958. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  25959. * @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.
  25960. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  25961. */
  25962. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  25963. /**
  25964. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25965. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25966. * The `data` are either a numeric array either a Float32Array.
  25967. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  25968. * 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).
  25969. * Note that a new underlying VertexBuffer object is created each call.
  25970. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25971. *
  25972. * Possible `kind` values :
  25973. * - BABYLON.VertexBuffer.PositionKind
  25974. * - BABYLON.VertexBuffer.UVKind
  25975. * - BABYLON.VertexBuffer.UV2Kind
  25976. * - BABYLON.VertexBuffer.UV3Kind
  25977. * - BABYLON.VertexBuffer.UV4Kind
  25978. * - BABYLON.VertexBuffer.UV5Kind
  25979. * - BABYLON.VertexBuffer.UV6Kind
  25980. * - BABYLON.VertexBuffer.ColorKind
  25981. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25982. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25983. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25984. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25985. *
  25986. * Returns the Mesh.
  25987. */
  25988. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  25989. /**
  25990. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25991. * If the mesh has no geometry, it is simply returned as it is.
  25992. * The `data` are either a numeric array either a Float32Array.
  25993. * No new underlying VertexBuffer object is created.
  25994. * 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.
  25995. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  25996. *
  25997. * Possible `kind` values :
  25998. * - BABYLON.VertexBuffer.PositionKind
  25999. * - BABYLON.VertexBuffer.UVKind
  26000. * - BABYLON.VertexBuffer.UV2Kind
  26001. * - BABYLON.VertexBuffer.UV3Kind
  26002. * - BABYLON.VertexBuffer.UV4Kind
  26003. * - BABYLON.VertexBuffer.UV5Kind
  26004. * - BABYLON.VertexBuffer.UV6Kind
  26005. * - BABYLON.VertexBuffer.ColorKind
  26006. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26007. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26008. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26009. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26010. *
  26011. * Returns the Mesh.
  26012. */
  26013. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26014. /**
  26015. * Sets the mesh indices.
  26016. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26017. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26018. * This method creates a new index buffer each call.
  26019. * Returns the Mesh.
  26020. */
  26021. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26022. /**
  26023. * Boolean : True if the mesh owns the requested kind of data.
  26024. */
  26025. isVerticesDataPresent(kind: string): boolean;
  26026. /**
  26027. * Returns an array of indices (IndicesArray).
  26028. */
  26029. getIndices(): Nullable<IndicesArray>;
  26030. readonly _positions: Nullable<Vector3[]>;
  26031. /**
  26032. * reconstructs and updates the BoundingInfo of the mesh.
  26033. * @returns the mesh.
  26034. */
  26035. refreshBoundingInfo(): InstancedMesh;
  26036. /** @hidden */
  26037. _preActivate(): InstancedMesh;
  26038. /** @hidden */
  26039. _activate(renderId: number): InstancedMesh;
  26040. /**
  26041. * Returns the current associated LOD AbstractMesh.
  26042. */
  26043. getLOD(camera: Camera): AbstractMesh;
  26044. /** @hidden */
  26045. _syncSubMeshes(): InstancedMesh;
  26046. /** @hidden */
  26047. _generatePointsArray(): boolean;
  26048. /**
  26049. * Creates a new InstancedMesh from the current mesh.
  26050. * - name (string) : the cloned mesh name
  26051. * - newParent (optional Node) : the optional Node to parent the clone to.
  26052. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26053. *
  26054. * Returns the clone.
  26055. */
  26056. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26057. /**
  26058. * Disposes the InstancedMesh.
  26059. * Returns nothing.
  26060. */
  26061. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26062. }
  26063. }
  26064. declare module BABYLON {
  26065. /**
  26066. * Line mesh
  26067. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26068. */
  26069. class LinesMesh extends Mesh {
  26070. /**
  26071. * If vertex color should be applied to the mesh
  26072. */
  26073. useVertexColor?: boolean | undefined;
  26074. /**
  26075. * If vertex alpha should be applied to the mesh
  26076. */
  26077. useVertexAlpha?: boolean | undefined;
  26078. /**
  26079. * Color of the line (Default: White)
  26080. */
  26081. color: Color3;
  26082. /**
  26083. * Alpha of the line (Default: 1)
  26084. */
  26085. alpha: number;
  26086. /**
  26087. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26088. * This margin is expressed in world space coordinates, so its value may vary.
  26089. * Default value is 0.1
  26090. * @returns the intersection Threshold value.
  26091. */
  26092. /**
  26093. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26094. * This margin is expressed in world space coordinates, so its value may vary.
  26095. */
  26096. intersectionThreshold: number;
  26097. private _intersectionThreshold;
  26098. private _colorShader;
  26099. /**
  26100. * Creates a new LinesMesh
  26101. * @param name defines the name
  26102. * @param scene defines the hosting scene
  26103. * @param parent defines the parent mesh if any
  26104. * @param source defines the optional source LinesMesh used to clone data from
  26105. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26106. * When false, achieved by calling a clone(), also passing False.
  26107. * This will make creation of children, recursive.
  26108. * @param useVertexColor defines if this LinesMesh supports vertex color
  26109. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26110. */
  26111. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26112. /**
  26113. * If vertex color should be applied to the mesh
  26114. */
  26115. useVertexColor?: boolean | undefined,
  26116. /**
  26117. * If vertex alpha should be applied to the mesh
  26118. */
  26119. useVertexAlpha?: boolean | undefined);
  26120. /**
  26121. * Returns the string "LineMesh"
  26122. */
  26123. getClassName(): string;
  26124. /**
  26125. * @hidden
  26126. */
  26127. /**
  26128. * @hidden
  26129. */
  26130. material: Material;
  26131. /**
  26132. * @hidden
  26133. */
  26134. readonly checkCollisions: boolean;
  26135. /** @hidden */
  26136. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26137. /** @hidden */
  26138. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26139. /**
  26140. * Disposes of the line mesh
  26141. * @param doNotRecurse If children should be disposed
  26142. */
  26143. dispose(doNotRecurse?: boolean): void;
  26144. /**
  26145. * Returns a new LineMesh object cloned from the current one.
  26146. */
  26147. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26148. }
  26149. }
  26150. declare module BABYLON {
  26151. /**
  26152. * @hidden
  26153. **/
  26154. class _CreationDataStorage {
  26155. closePath?: boolean;
  26156. closeArray?: boolean;
  26157. idx: number[];
  26158. dashSize: number;
  26159. gapSize: number;
  26160. path3D: Path3D;
  26161. pathArray: Vector3[][];
  26162. arc: number;
  26163. radius: number;
  26164. cap: number;
  26165. tessellation: number;
  26166. }
  26167. /**
  26168. * @hidden
  26169. **/
  26170. class _InstanceDataStorage {
  26171. visibleInstances: any;
  26172. renderIdForInstances: number[];
  26173. batchCache: _InstancesBatch;
  26174. instancesBufferSize: number;
  26175. instancesBuffer: Nullable<Buffer>;
  26176. instancesData: Float32Array;
  26177. overridenInstanceCount: number;
  26178. }
  26179. /**
  26180. * @hidden
  26181. **/
  26182. class _InstancesBatch {
  26183. mustReturn: boolean;
  26184. visibleInstances: Nullable<InstancedMesh[]>[];
  26185. renderSelf: boolean[];
  26186. }
  26187. /**
  26188. * Class used to represent renderable models
  26189. */
  26190. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26191. /**
  26192. * Mesh side orientation : usually the external or front surface
  26193. */
  26194. static readonly FRONTSIDE: number;
  26195. /**
  26196. * Mesh side orientation : usually the internal or back surface
  26197. */
  26198. static readonly BACKSIDE: number;
  26199. /**
  26200. * Mesh side orientation : both internal and external or front and back surfaces
  26201. */
  26202. static readonly DOUBLESIDE: number;
  26203. /**
  26204. * Mesh side orientation : by default, `FRONTSIDE`
  26205. */
  26206. static readonly DEFAULTSIDE: number;
  26207. /**
  26208. * Mesh cap setting : no cap
  26209. */
  26210. static readonly NO_CAP: number;
  26211. /**
  26212. * Mesh cap setting : one cap at the beginning of the mesh
  26213. */
  26214. static readonly CAP_START: number;
  26215. /**
  26216. * Mesh cap setting : one cap at the end of the mesh
  26217. */
  26218. static readonly CAP_END: number;
  26219. /**
  26220. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26221. */
  26222. static readonly CAP_ALL: number;
  26223. private _onBeforeRenderObservable;
  26224. private _onAfterRenderObservable;
  26225. private _onBeforeDrawObservable;
  26226. /**
  26227. * An event triggered before rendering the mesh
  26228. */
  26229. readonly onBeforeRenderObservable: Observable<Mesh>;
  26230. /**
  26231. * An event triggered after rendering the mesh
  26232. */
  26233. readonly onAfterRenderObservable: Observable<Mesh>;
  26234. /**
  26235. * An event triggered before drawing the mesh
  26236. */
  26237. readonly onBeforeDrawObservable: Observable<Mesh>;
  26238. private _onBeforeDrawObserver;
  26239. /**
  26240. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26241. */
  26242. onBeforeDraw: () => void;
  26243. /**
  26244. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26245. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26246. */
  26247. delayLoadState: number;
  26248. /**
  26249. * Gets the list of instances created from this mesh
  26250. * it is not supposed to be modified manually.
  26251. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26252. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26253. */
  26254. instances: InstancedMesh[];
  26255. /**
  26256. * Gets the file containing delay loading data for this mesh
  26257. */
  26258. delayLoadingFile: string;
  26259. /** @hidden */
  26260. _binaryInfo: any;
  26261. private _LODLevels;
  26262. /**
  26263. * User defined function used to change how LOD level selection is done
  26264. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26265. */
  26266. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26267. private _morphTargetManager;
  26268. /**
  26269. * Gets or sets the morph target manager
  26270. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26271. */
  26272. morphTargetManager: Nullable<MorphTargetManager>;
  26273. /** @hidden */
  26274. _creationDataStorage: Nullable<_CreationDataStorage>;
  26275. /** @hidden */
  26276. _geometry: Nullable<Geometry>;
  26277. /** @hidden */
  26278. _delayInfo: Array<string>;
  26279. /** @hidden */
  26280. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26281. /** @hidden */
  26282. _instanceDataStorage: _InstanceDataStorage;
  26283. private _effectiveMaterial;
  26284. /** @hidden */
  26285. _shouldGenerateFlatShading: boolean;
  26286. private _preActivateId;
  26287. /** @hidden */
  26288. _originalBuilderSideOrientation: number;
  26289. /**
  26290. * Use this property to change the original side orientation defined at construction time
  26291. */
  26292. overrideMaterialSideOrientation: Nullable<number>;
  26293. private _areNormalsFrozen;
  26294. private _sourcePositions;
  26295. private _sourceNormals;
  26296. private _source;
  26297. private meshMap;
  26298. /**
  26299. * Gets the source mesh (the one used to clone this one from)
  26300. */
  26301. readonly source: Nullable<Mesh>;
  26302. /**
  26303. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26304. */
  26305. isUnIndexed: boolean;
  26306. /**
  26307. * @constructor
  26308. * @param name The value used by scene.getMeshByName() to do a lookup.
  26309. * @param scene The scene to add this mesh to.
  26310. * @param parent The parent of this mesh, if it has one
  26311. * @param source An optional Mesh from which geometry is shared, cloned.
  26312. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26313. * When false, achieved by calling a clone(), also passing False.
  26314. * This will make creation of children, recursive.
  26315. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26316. */
  26317. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26318. /**
  26319. * Gets the class name
  26320. * @returns the string "Mesh".
  26321. */
  26322. getClassName(): string;
  26323. /**
  26324. * Returns a description of this mesh
  26325. * @param fullDetails define if full details about this mesh must be used
  26326. * @returns a descriptive string representing this mesh
  26327. */
  26328. toString(fullDetails?: boolean): string;
  26329. /** @hidden */
  26330. _unBindEffect(): void;
  26331. /**
  26332. * Gets a boolean indicating if this mesh has LOD
  26333. */
  26334. readonly hasLODLevels: boolean;
  26335. /**
  26336. * Gets the list of MeshLODLevel associated with the current mesh
  26337. * @returns an array of MeshLODLevel
  26338. */
  26339. getLODLevels(): MeshLODLevel[];
  26340. private _sortLODLevels;
  26341. /**
  26342. * Add a mesh as LOD level triggered at the given distance.
  26343. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26344. * @param distance The distance from the center of the object to show this level
  26345. * @param mesh The mesh to be added as LOD level (can be null)
  26346. * @return This mesh (for chaining)
  26347. */
  26348. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26349. /**
  26350. * Returns the LOD level mesh at the passed distance or null if not found.
  26351. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26352. * @param distance The distance from the center of the object to show this level
  26353. * @returns a Mesh or `null`
  26354. */
  26355. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  26356. /**
  26357. * Remove a mesh from the LOD array
  26358. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26359. * @param mesh defines the mesh to be removed
  26360. * @return This mesh (for chaining)
  26361. */
  26362. removeLODLevel(mesh: Mesh): Mesh;
  26363. /**
  26364. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  26365. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26366. * @param camera defines the camera to use to compute distance
  26367. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  26368. * @return This mesh (for chaining)
  26369. */
  26370. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  26371. /**
  26372. * Gets the mesh internal Geometry object
  26373. */
  26374. readonly geometry: Nullable<Geometry>;
  26375. /**
  26376. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  26377. * @returns the total number of vertices
  26378. */
  26379. getTotalVertices(): number;
  26380. /**
  26381. * Returns the content of an associated vertex buffer
  26382. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26383. * - BABYLON.VertexBuffer.PositionKind
  26384. * - BABYLON.VertexBuffer.UVKind
  26385. * - BABYLON.VertexBuffer.UV2Kind
  26386. * - BABYLON.VertexBuffer.UV3Kind
  26387. * - BABYLON.VertexBuffer.UV4Kind
  26388. * - BABYLON.VertexBuffer.UV5Kind
  26389. * - BABYLON.VertexBuffer.UV6Kind
  26390. * - BABYLON.VertexBuffer.ColorKind
  26391. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26392. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26393. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26394. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26395. * @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
  26396. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  26397. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  26398. */
  26399. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26400. /**
  26401. * Returns the mesh VertexBuffer object from the requested `kind`
  26402. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26403. * - BABYLON.VertexBuffer.PositionKind
  26404. * - BABYLON.VertexBuffer.UVKind
  26405. * - BABYLON.VertexBuffer.UV2Kind
  26406. * - BABYLON.VertexBuffer.UV3Kind
  26407. * - BABYLON.VertexBuffer.UV4Kind
  26408. * - BABYLON.VertexBuffer.UV5Kind
  26409. * - BABYLON.VertexBuffer.UV6Kind
  26410. * - BABYLON.VertexBuffer.ColorKind
  26411. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26412. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26413. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26414. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26415. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  26416. */
  26417. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26418. /**
  26419. * Tests if a specific vertex buffer is associated with this mesh
  26420. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26421. * - BABYLON.VertexBuffer.PositionKind
  26422. * - BABYLON.VertexBuffer.UVKind
  26423. * - BABYLON.VertexBuffer.UV2Kind
  26424. * - BABYLON.VertexBuffer.UV3Kind
  26425. * - BABYLON.VertexBuffer.UV4Kind
  26426. * - BABYLON.VertexBuffer.UV5Kind
  26427. * - BABYLON.VertexBuffer.UV6Kind
  26428. * - BABYLON.VertexBuffer.ColorKind
  26429. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26430. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26431. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26432. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26433. * @returns a boolean
  26434. */
  26435. isVerticesDataPresent(kind: string): boolean;
  26436. /**
  26437. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  26438. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26439. * - BABYLON.VertexBuffer.PositionKind
  26440. * - BABYLON.VertexBuffer.UVKind
  26441. * - BABYLON.VertexBuffer.UV2Kind
  26442. * - BABYLON.VertexBuffer.UV3Kind
  26443. * - BABYLON.VertexBuffer.UV4Kind
  26444. * - BABYLON.VertexBuffer.UV5Kind
  26445. * - BABYLON.VertexBuffer.UV6Kind
  26446. * - BABYLON.VertexBuffer.ColorKind
  26447. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26448. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26449. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26450. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26451. * @returns a boolean
  26452. */
  26453. isVertexBufferUpdatable(kind: string): boolean;
  26454. /**
  26455. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26456. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26457. * - BABYLON.VertexBuffer.PositionKind
  26458. * - BABYLON.VertexBuffer.UVKind
  26459. * - BABYLON.VertexBuffer.UV2Kind
  26460. * - BABYLON.VertexBuffer.UV3Kind
  26461. * - BABYLON.VertexBuffer.UV4Kind
  26462. * - BABYLON.VertexBuffer.UV5Kind
  26463. * - BABYLON.VertexBuffer.UV6Kind
  26464. * - BABYLON.VertexBuffer.ColorKind
  26465. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26466. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26467. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26468. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26469. * @returns an array of strings
  26470. */
  26471. getVerticesDataKinds(): string[];
  26472. /**
  26473. * Returns a positive integer : the total number of indices in this mesh geometry.
  26474. * @returns the numner of indices or zero if the mesh has no geometry.
  26475. */
  26476. getTotalIndices(): number;
  26477. /**
  26478. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26479. * @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.
  26480. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26481. * @returns the indices array or an empty array if the mesh has no geometry
  26482. */
  26483. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26484. readonly isBlocked: boolean;
  26485. /**
  26486. * Determine if the current mesh is ready to be rendered
  26487. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26488. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26489. * @returns true if all associated assets are ready (material, textures, shaders)
  26490. */
  26491. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26492. /**
  26493. * 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.
  26494. */
  26495. readonly areNormalsFrozen: boolean;
  26496. /**
  26497. * 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.
  26498. * @returns the current mesh
  26499. */
  26500. freezeNormals(): Mesh;
  26501. /**
  26502. * 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
  26503. * @returns the current mesh
  26504. */
  26505. unfreezeNormals(): Mesh;
  26506. /**
  26507. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26508. */
  26509. overridenInstanceCount: number;
  26510. /** @hidden */
  26511. _preActivate(): Mesh;
  26512. /** @hidden */
  26513. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26514. /** @hidden */
  26515. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26516. /**
  26517. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26518. * This means the mesh underlying bounding box and sphere are recomputed.
  26519. * @returns the current mesh
  26520. */
  26521. refreshBoundingInfo(): Mesh;
  26522. /** @hidden */
  26523. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  26524. private _getPositionData;
  26525. /** @hidden */
  26526. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26527. /**
  26528. * This function will subdivide the mesh into multiple submeshes
  26529. * @param count defines the expected number of submeshes
  26530. */
  26531. subdivide(count: number): void;
  26532. /**
  26533. * Copy a FloatArray into a specific associated vertex buffer
  26534. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26535. * - BABYLON.VertexBuffer.PositionKind
  26536. * - BABYLON.VertexBuffer.UVKind
  26537. * - BABYLON.VertexBuffer.UV2Kind
  26538. * - BABYLON.VertexBuffer.UV3Kind
  26539. * - BABYLON.VertexBuffer.UV4Kind
  26540. * - BABYLON.VertexBuffer.UV5Kind
  26541. * - BABYLON.VertexBuffer.UV6Kind
  26542. * - BABYLON.VertexBuffer.ColorKind
  26543. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26544. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26545. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26546. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26547. * @param data defines the data source
  26548. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26549. * @param stride defines the data stride size (can be null)
  26550. * @returns the current mesh
  26551. */
  26552. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26553. /**
  26554. * Flags an associated vertex buffer as updatable
  26555. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  26556. * - BABYLON.VertexBuffer.PositionKind
  26557. * - BABYLON.VertexBuffer.UVKind
  26558. * - BABYLON.VertexBuffer.UV2Kind
  26559. * - BABYLON.VertexBuffer.UV3Kind
  26560. * - BABYLON.VertexBuffer.UV4Kind
  26561. * - BABYLON.VertexBuffer.UV5Kind
  26562. * - BABYLON.VertexBuffer.UV6Kind
  26563. * - BABYLON.VertexBuffer.ColorKind
  26564. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26565. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26566. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26567. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26568. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26569. */
  26570. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  26571. /**
  26572. * Sets the mesh global Vertex Buffer
  26573. * @param buffer defines the buffer to use
  26574. * @returns the current mesh
  26575. */
  26576. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  26577. /**
  26578. * Update a specific associated vertex buffer
  26579. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26580. * - BABYLON.VertexBuffer.PositionKind
  26581. * - BABYLON.VertexBuffer.UVKind
  26582. * - BABYLON.VertexBuffer.UV2Kind
  26583. * - BABYLON.VertexBuffer.UV3Kind
  26584. * - BABYLON.VertexBuffer.UV4Kind
  26585. * - BABYLON.VertexBuffer.UV5Kind
  26586. * - BABYLON.VertexBuffer.UV6Kind
  26587. * - BABYLON.VertexBuffer.ColorKind
  26588. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26589. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26590. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26591. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26592. * @param data defines the data source
  26593. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26594. * @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)
  26595. * @returns the current mesh
  26596. */
  26597. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26598. /**
  26599. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  26600. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  26601. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  26602. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  26603. * @returns the current mesh
  26604. */
  26605. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  26606. /**
  26607. * Creates a un-shared specific occurence of the geometry for the mesh.
  26608. * @returns the current mesh
  26609. */
  26610. makeGeometryUnique(): Mesh;
  26611. /**
  26612. * Set the index buffer of this mesh
  26613. * @param indices defines the source data
  26614. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  26615. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  26616. * @returns the current mesh
  26617. */
  26618. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  26619. /**
  26620. * Update the current index buffer
  26621. * @param indices defines the source data
  26622. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26623. * @returns the current mesh
  26624. */
  26625. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  26626. /**
  26627. * Invert the geometry to move from a right handed system to a left handed one.
  26628. * @returns the current mesh
  26629. */
  26630. toLeftHanded(): Mesh;
  26631. /** @hidden */
  26632. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  26633. /** @hidden */
  26634. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  26635. /**
  26636. * Registers for this mesh a javascript function called just before the rendering process
  26637. * @param func defines the function to call before rendering this mesh
  26638. * @returns the current mesh
  26639. */
  26640. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26641. /**
  26642. * Disposes a previously registered javascript function called before the rendering
  26643. * @param func defines the function to remove
  26644. * @returns the current mesh
  26645. */
  26646. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26647. /**
  26648. * Registers for this mesh a javascript function called just after the rendering is complete
  26649. * @param func defines the function to call after rendering this mesh
  26650. * @returns the current mesh
  26651. */
  26652. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26653. /**
  26654. * Disposes a previously registered javascript function called after the rendering.
  26655. * @param func defines the function to remove
  26656. * @returns the current mesh
  26657. */
  26658. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26659. /** @hidden */
  26660. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  26661. /** @hidden */
  26662. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  26663. /** @hidden */
  26664. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  26665. /**
  26666. * 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
  26667. * @param subMesh defines the subMesh to render
  26668. * @param enableAlphaMode defines if alpha mode can be changed
  26669. * @returns the current mesh
  26670. */
  26671. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  26672. private _onBeforeDraw;
  26673. /**
  26674. * Renormalize the mesh and patch it up if there are no weights
  26675. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  26676. * However in the case of zero weights then we set just a single influence to 1.
  26677. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  26678. */
  26679. cleanMatrixWeights(): void;
  26680. private normalizeSkinFourWeights;
  26681. private normalizeSkinWeightsAndExtra;
  26682. /**
  26683. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  26684. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  26685. * the user know there was an issue with importing the mesh
  26686. * @returns a validation object with skinned, valid and report string
  26687. */
  26688. validateSkinning(): {
  26689. skinned: boolean;
  26690. valid: boolean;
  26691. report: string;
  26692. };
  26693. /** @hidden */
  26694. _checkDelayState(): Mesh;
  26695. private _queueLoad;
  26696. /**
  26697. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26698. * A mesh is in the frustum if its bounding box intersects the frustum
  26699. * @param frustumPlanes defines the frustum to test
  26700. * @returns true if the mesh is in the frustum planes
  26701. */
  26702. isInFrustum(frustumPlanes: Plane[]): boolean;
  26703. /**
  26704. * Sets the mesh material by the material or multiMaterial `id` property
  26705. * @param id is a string identifying the material or the multiMaterial
  26706. * @returns the current mesh
  26707. */
  26708. setMaterialByID(id: string): Mesh;
  26709. /**
  26710. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  26711. * @returns an array of IAnimatable
  26712. */
  26713. getAnimatables(): IAnimatable[];
  26714. /**
  26715. * Modifies the mesh geometry according to the passed transformation matrix.
  26716. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26717. * The mesh normals are modified using the same transformation.
  26718. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26719. * @param transform defines the transform matrix to use
  26720. * @see http://doc.babylonjs.com/resources/baking_transformations
  26721. * @returns the current mesh
  26722. */
  26723. bakeTransformIntoVertices(transform: Matrix): Mesh;
  26724. /**
  26725. * Modifies the mesh geometry according to its own current World Matrix.
  26726. * The mesh World Matrix is then reset.
  26727. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  26728. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26729. * @see http://doc.babylonjs.com/resources/baking_transformations
  26730. * @returns the current mesh
  26731. */
  26732. bakeCurrentTransformIntoVertices(): Mesh;
  26733. /** @hidden */
  26734. readonly _positions: Nullable<Vector3[]>;
  26735. /** @hidden */
  26736. _resetPointsArrayCache(): Mesh;
  26737. /** @hidden */
  26738. _generatePointsArray(): boolean;
  26739. /**
  26740. * Returns a new Mesh object generated from the current mesh properties.
  26741. * This method must not get confused with createInstance()
  26742. * @param name is a string, the name given to the new mesh
  26743. * @param newParent can be any Node object (default `null`)
  26744. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  26745. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  26746. * @returns a new mesh
  26747. */
  26748. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  26749. /**
  26750. * Releases resources associated with this mesh.
  26751. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26752. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26753. */
  26754. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26755. /**
  26756. * Modifies the mesh geometry according to a displacement map.
  26757. * 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.
  26758. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26759. * @param url is a string, the URL from the image file is to be downloaded.
  26760. * @param minHeight is the lower limit of the displacement.
  26761. * @param maxHeight is the upper limit of the displacement.
  26762. * @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.
  26763. * @param uvOffset is an optional vector2 used to offset UV.
  26764. * @param uvScale is an optional vector2 used to scale UV.
  26765. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  26766. * @returns the Mesh.
  26767. */
  26768. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26769. /**
  26770. * Modifies the mesh geometry according to a displacementMap buffer.
  26771. * 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.
  26772. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26773. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  26774. * @param heightMapWidth is the width of the buffer image.
  26775. * @param heightMapHeight is the height of the buffer image.
  26776. * @param minHeight is the lower limit of the displacement.
  26777. * @param maxHeight is the upper limit of the displacement.
  26778. * @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.
  26779. * @param uvOffset is an optional vector2 used to offset UV.
  26780. * @param uvScale is an optional vector2 used to scale UV.
  26781. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  26782. * @returns the Mesh.
  26783. */
  26784. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26785. /**
  26786. * Modify the mesh to get a flat shading rendering.
  26787. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  26788. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  26789. * @returns current mesh
  26790. */
  26791. convertToFlatShadedMesh(): Mesh;
  26792. /**
  26793. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  26794. * In other words, more vertices, no more indices and a single bigger VBO.
  26795. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  26796. * @returns current mesh
  26797. */
  26798. convertToUnIndexedMesh(): Mesh;
  26799. /**
  26800. * Inverses facet orientations.
  26801. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26802. * @param flipNormals will also inverts the normals
  26803. * @returns current mesh
  26804. */
  26805. flipFaces(flipNormals?: boolean): Mesh;
  26806. /**
  26807. * Creates a new InstancedMesh object from the mesh model.
  26808. * Warning : this method is not supported for Line mesh and LineSystem
  26809. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26810. * @param name defines the name of the new instance
  26811. * @returns a new InstancedMesh
  26812. */
  26813. createInstance(name: string): InstancedMesh;
  26814. /**
  26815. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  26816. * After this call, all the mesh instances have the same submeshes than the current mesh.
  26817. * @returns the current mesh
  26818. */
  26819. synchronizeInstances(): Mesh;
  26820. /**
  26821. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  26822. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  26823. * This should be used together with the simplification to avoid disappearing triangles.
  26824. * @param successCallback an optional success callback to be called after the optimization finished.
  26825. * @returns the current mesh
  26826. */
  26827. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  26828. /**
  26829. * Serialize current mesh
  26830. * @param serializationObject defines the object which will receive the serialization data
  26831. */
  26832. serialize(serializationObject: any): void;
  26833. /** @hidden */
  26834. _syncGeometryWithMorphTargetManager(): void;
  26835. /**
  26836. * Returns a new Mesh object parsed from the source provided.
  26837. * @param parsedMesh is the source
  26838. * @param scene defines the hosting scene
  26839. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  26840. * @returns a new Mesh
  26841. */
  26842. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  26843. /**
  26844. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  26845. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26846. * @param name defines the name of the mesh to create
  26847. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  26848. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  26849. * @param closePath creates a seam between the first and the last points of each path of the path array
  26850. * @param offset is taken in account only if the `pathArray` is containing a single path
  26851. * @param scene defines the hosting scene
  26852. * @param updatable defines if the mesh must be flagged as updatable
  26853. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26854. * @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)
  26855. * @returns a new Mesh
  26856. */
  26857. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26858. /**
  26859. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  26860. * @param name defines the name of the mesh to create
  26861. * @param radius sets the radius size (float) of the polygon (default 0.5)
  26862. * @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
  26863. * @param scene defines the hosting scene
  26864. * @param updatable defines if the mesh must be flagged as updatable
  26865. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26866. * @returns a new Mesh
  26867. */
  26868. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26869. /**
  26870. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  26871. * @param name defines the name of the mesh to create
  26872. * @param size sets the size (float) of each box side (default 1)
  26873. * @param scene defines the hosting scene
  26874. * @param updatable defines if the mesh must be flagged as updatable
  26875. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26876. * @returns a new Mesh
  26877. */
  26878. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26879. /**
  26880. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  26881. * @param name defines the name of the mesh to create
  26882. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26883. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26884. * @param scene defines the hosting scene
  26885. * @param updatable defines if the mesh must be flagged as updatable
  26886. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26887. * @returns a new Mesh
  26888. */
  26889. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26890. /**
  26891. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26892. * @param name defines the name of the mesh to create
  26893. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26894. * @param diameterTop set the top cap diameter (floats, default 1)
  26895. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26896. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26897. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26898. * @param scene defines the hosting scene
  26899. * @param updatable defines if the mesh must be flagged as updatable
  26900. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26901. * @returns a new Mesh
  26902. */
  26903. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26904. /**
  26905. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26906. * @param name defines the name of the mesh to create
  26907. * @param diameter sets the diameter size (float) of the torus (default 1)
  26908. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26909. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26910. * @param scene defines the hosting scene
  26911. * @param updatable defines if the mesh must be flagged as updatable
  26912. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26913. * @returns a new Mesh
  26914. */
  26915. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26916. /**
  26917. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  26918. * @param name defines the name of the mesh to create
  26919. * @param radius sets the global radius size (float) of the torus knot (default 2)
  26920. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26921. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26922. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26923. * @param p the number of windings on X axis (positive integers, default 2)
  26924. * @param q the number of windings on Y axis (positive integers, default 3)
  26925. * @param scene defines the hosting scene
  26926. * @param updatable defines if the mesh must be flagged as updatable
  26927. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26928. * @returns a new Mesh
  26929. */
  26930. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26931. /**
  26932. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26933. * @param name defines the name of the mesh to create
  26934. * @param points is an array successive Vector3
  26935. * @param scene defines the hosting scene
  26936. * @param updatable defines if the mesh must be flagged as updatable
  26937. * @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).
  26938. * @returns a new Mesh
  26939. */
  26940. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  26941. /**
  26942. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26943. * @param name defines the name of the mesh to create
  26944. * @param points is an array successive Vector3
  26945. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  26946. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  26947. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  26948. * @param scene defines the hosting scene
  26949. * @param updatable defines if the mesh must be flagged as updatable
  26950. * @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)
  26951. * @returns a new Mesh
  26952. */
  26953. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  26954. /**
  26955. * Creates a polygon mesh.
  26956. * Please consider using the same method from the MeshBuilder class instead.
  26957. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  26958. * 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.
  26959. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26960. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26961. * Remember you can only change the shape positions, not their number when updating a polygon.
  26962. */
  26963. /**
  26964. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  26965. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  26966. * @param name defines the name of the mesh to create
  26967. * @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
  26968. * @param scene defines the hosting scene
  26969. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26970. * @param updatable defines if the mesh must be flagged as updatable
  26971. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26972. * @returns a new Mesh
  26973. */
  26974. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  26975. /**
  26976. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  26977. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  26978. * @param name defines the name of the mesh to create
  26979. * @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
  26980. * @param depth defines the height of extrusion
  26981. * @param scene defines the hosting scene
  26982. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26983. * @param updatable defines if the mesh must be flagged as updatable
  26984. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26985. * @returns a new Mesh
  26986. */
  26987. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  26988. /**
  26989. * Creates an extruded shape mesh.
  26990. * 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
  26991. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26992. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26993. * @param name defines the name of the mesh to create
  26994. * @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
  26995. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26996. * @param scale is the value to scale the shape
  26997. * @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
  26998. * @param 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
  26999. * @param scene defines the hosting scene
  27000. * @param updatable defines if the mesh must be flagged as updatable
  27001. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27002. * @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)
  27003. * @returns a new Mesh
  27004. */
  27005. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27006. /**
  27007. * Creates an custom extruded shape mesh.
  27008. * The custom extrusion is a parametric shape.
  27009. * It has no predefined shape. Its final shape will depend on the input parameters.
  27010. * Please consider using the same method from the MeshBuilder class instead
  27011. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27012. * @param name defines the name of the mesh to create
  27013. * @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
  27014. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27015. * @param scaleFunction is a custom Javascript function called on each path point
  27016. * @param rotationFunction is a custom Javascript function called on each path point
  27017. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27018. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27019. * @param 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
  27020. * @param scene defines the hosting scene
  27021. * @param updatable defines if the mesh must be flagged as updatable
  27022. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27023. * @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)
  27024. * @returns a new Mesh
  27025. */
  27026. 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;
  27027. /**
  27028. * Creates lathe mesh.
  27029. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27030. * Please consider using the same method from the MeshBuilder class instead
  27031. * @param name defines the name of the mesh to create
  27032. * @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
  27033. * @param radius is the radius value of the lathe
  27034. * @param tessellation is the side number of the lathe.
  27035. * @param scene defines the hosting scene
  27036. * @param updatable defines if the mesh must be flagged as updatable
  27037. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27038. * @returns a new Mesh
  27039. */
  27040. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27041. /**
  27042. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27043. * @param name defines the name of the mesh to create
  27044. * @param size sets the size (float) of both sides of the plane at once (default 1)
  27045. * @param scene defines the hosting scene
  27046. * @param updatable defines if the mesh must be flagged as updatable
  27047. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27048. * @returns a new Mesh
  27049. */
  27050. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27051. /**
  27052. * Creates a ground mesh.
  27053. * Please consider using the same method from the MeshBuilder class instead
  27054. * @param name defines the name of the mesh to create
  27055. * @param width set the width of the ground
  27056. * @param height set the height of the ground
  27057. * @param subdivisions sets the number of subdivisions per side
  27058. * @param scene defines the hosting scene
  27059. * @param updatable defines if the mesh must be flagged as updatable
  27060. * @returns a new Mesh
  27061. */
  27062. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27063. /**
  27064. * Creates a tiled ground mesh.
  27065. * Please consider using the same method from the MeshBuilder class instead
  27066. * @param name defines the name of the mesh to create
  27067. * @param xmin set the ground minimum X coordinate
  27068. * @param zmin set the ground minimum Y coordinate
  27069. * @param xmax set the ground maximum X coordinate
  27070. * @param zmax set the ground maximum Z coordinate
  27071. * @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
  27072. * @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
  27073. * @param scene defines the hosting scene
  27074. * @param updatable defines if the mesh must be flagged as updatable
  27075. * @returns a new Mesh
  27076. */
  27077. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27078. w: number;
  27079. h: number;
  27080. }, precision: {
  27081. w: number;
  27082. h: number;
  27083. }, scene: Scene, updatable?: boolean): Mesh;
  27084. /**
  27085. * Creates a ground mesh from a height map.
  27086. * Please consider using the same method from the MeshBuilder class instead
  27087. * @see http://doc.babylonjs.com/babylon101/height_map
  27088. * @param name defines the name of the mesh to create
  27089. * @param url sets the URL of the height map image resource
  27090. * @param width set the ground width size
  27091. * @param height set the ground height size
  27092. * @param subdivisions sets the number of subdivision per side
  27093. * @param minHeight is the minimum altitude on the ground
  27094. * @param maxHeight is the maximum altitude on the ground
  27095. * @param scene defines the hosting scene
  27096. * @param updatable defines if the mesh must be flagged as updatable
  27097. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27098. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27099. * @returns a new Mesh
  27100. */
  27101. 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;
  27102. /**
  27103. * Creates a tube mesh.
  27104. * The tube is a parametric shape.
  27105. * It has no predefined shape. Its final shape will depend on the input parameters.
  27106. * Please consider using the same method from the MeshBuilder class instead
  27107. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27108. * @param name defines the name of the mesh to create
  27109. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27110. * @param radius sets the tube radius size
  27111. * @param tessellation is the number of sides on the tubular surface
  27112. * @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
  27113. * @param 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
  27114. * @param scene defines the hosting scene
  27115. * @param updatable defines if the mesh must be flagged as updatable
  27116. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27117. * @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)
  27118. * @returns a new Mesh
  27119. */
  27120. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27121. (i: number, distance: number): number;
  27122. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27123. /**
  27124. * Creates a polyhedron mesh.
  27125. * Please consider using the same method from the MeshBuilder class instead.
  27126. * * 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
  27127. * * The parameter `size` (positive float, default 1) sets the polygon size
  27128. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27129. * * 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`
  27130. * * 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
  27131. * * 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)`)
  27132. * * 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 : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  27133. * * 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
  27134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27135. * * 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
  27136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27137. * @param name defines the name of the mesh to create
  27138. * @param options defines the options used to create the mesh
  27139. * @param scene defines the hosting scene
  27140. * @returns a new Mesh
  27141. */
  27142. static CreatePolyhedron(name: string, options: {
  27143. type?: number;
  27144. size?: number;
  27145. sizeX?: number;
  27146. sizeY?: number;
  27147. sizeZ?: number;
  27148. custom?: any;
  27149. faceUV?: Vector4[];
  27150. faceColors?: Color4[];
  27151. updatable?: boolean;
  27152. sideOrientation?: number;
  27153. }, scene: Scene): Mesh;
  27154. /**
  27155. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27156. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27157. * * 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`)
  27158. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27159. * * 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
  27160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27161. * * 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
  27162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27163. * @param name defines the name of the mesh
  27164. * @param options defines the options used to create the mesh
  27165. * @param scene defines the hosting scene
  27166. * @returns a new Mesh
  27167. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27168. */
  27169. static CreateIcoSphere(name: string, options: {
  27170. radius?: number;
  27171. flat?: boolean;
  27172. subdivisions?: number;
  27173. sideOrientation?: number;
  27174. updatable?: boolean;
  27175. }, scene: Scene): Mesh;
  27176. /**
  27177. * Creates a decal mesh.
  27178. * Please consider using the same method from the MeshBuilder class instead.
  27179. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27180. * @param name defines the name of the mesh
  27181. * @param sourceMesh defines the mesh receiving the decal
  27182. * @param position sets the position of the decal in world coordinates
  27183. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27184. * @param size sets the decal scaling
  27185. * @param angle sets the angle to rotate the decal
  27186. * @returns a new Mesh
  27187. */
  27188. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27189. /**
  27190. * Prepare internal position array for software CPU skinning
  27191. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27192. */
  27193. setPositionsForCPUSkinning(): Float32Array;
  27194. /**
  27195. * Prepare internal normal array for software CPU skinning
  27196. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27197. */
  27198. setNormalsForCPUSkinning(): Float32Array;
  27199. /**
  27200. * Updates the vertex buffer by applying transformation from the bones
  27201. * @param skeleton defines the skeleton to apply to current mesh
  27202. * @returns the current mesh
  27203. */
  27204. applySkeleton(skeleton: Skeleton): Mesh;
  27205. /**
  27206. * 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
  27207. * @param meshes defines the list of meshes to scan
  27208. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27209. */
  27210. static MinMax(meshes: AbstractMesh[]): {
  27211. min: Vector3;
  27212. max: Vector3;
  27213. };
  27214. /**
  27215. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27216. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27217. * @returns a vector3
  27218. */
  27219. static Center(meshesOrMinMaxVector: {
  27220. min: Vector3;
  27221. max: Vector3;
  27222. } | AbstractMesh[]): Vector3;
  27223. /**
  27224. * Merge the array of meshes into a single mesh for performance reasons.
  27225. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27226. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27227. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27228. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27229. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27230. * @returns a new mesh
  27231. */
  27232. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27233. /** @hidden */
  27234. addInstance(instance: InstancedMesh): void;
  27235. /** @hidden */
  27236. removeInstance(instance: InstancedMesh): void;
  27237. }
  27238. }
  27239. declare module BABYLON {
  27240. /**
  27241. * Define an interface for all classes that will get and set the data on vertices
  27242. */
  27243. interface IGetSetVerticesData {
  27244. /**
  27245. * Gets a boolean indicating if specific vertex data is present
  27246. * @param kind defines the vertex data kind to use
  27247. * @returns true is data kind is present
  27248. */
  27249. isVerticesDataPresent(kind: string): boolean;
  27250. /**
  27251. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27252. * @param kind defines the data kind (Position, normal, etc...)
  27253. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27254. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27255. * @returns a float array containing vertex data
  27256. */
  27257. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27258. /**
  27259. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27260. * @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.
  27261. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27262. * @returns the indices array or an empty array if the mesh has no geometry
  27263. */
  27264. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27265. /**
  27266. * Set specific vertex data
  27267. * @param kind defines the data kind (Position, normal, etc...)
  27268. * @param data defines the vertex data to use
  27269. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27270. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27271. */
  27272. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27273. /**
  27274. * Update a specific associated vertex buffer
  27275. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27276. * - BABYLON.VertexBuffer.PositionKind
  27277. * - BABYLON.VertexBuffer.UVKind
  27278. * - BABYLON.VertexBuffer.UV2Kind
  27279. * - BABYLON.VertexBuffer.UV3Kind
  27280. * - BABYLON.VertexBuffer.UV4Kind
  27281. * - BABYLON.VertexBuffer.UV5Kind
  27282. * - BABYLON.VertexBuffer.UV6Kind
  27283. * - BABYLON.VertexBuffer.ColorKind
  27284. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27285. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27286. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27287. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27288. * @param data defines the data source
  27289. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27290. * @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)
  27291. */
  27292. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27293. /**
  27294. * Creates a new index buffer
  27295. * @param indices defines the indices to store in the index buffer
  27296. * @param totalVertices defines the total number of vertices (could be null)
  27297. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27298. */
  27299. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27300. }
  27301. /**
  27302. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27303. */
  27304. class VertexData {
  27305. /**
  27306. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27307. */
  27308. positions: Nullable<FloatArray>;
  27309. /**
  27310. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27311. */
  27312. normals: Nullable<FloatArray>;
  27313. /**
  27314. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27315. */
  27316. tangents: Nullable<FloatArray>;
  27317. /**
  27318. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27319. */
  27320. uvs: Nullable<FloatArray>;
  27321. /**
  27322. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27323. */
  27324. uvs2: Nullable<FloatArray>;
  27325. /**
  27326. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27327. */
  27328. uvs3: Nullable<FloatArray>;
  27329. /**
  27330. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27331. */
  27332. uvs4: Nullable<FloatArray>;
  27333. /**
  27334. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27335. */
  27336. uvs5: Nullable<FloatArray>;
  27337. /**
  27338. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27339. */
  27340. uvs6: Nullable<FloatArray>;
  27341. /**
  27342. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27343. */
  27344. colors: Nullable<FloatArray>;
  27345. /**
  27346. * 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).
  27347. */
  27348. matricesIndices: Nullable<FloatArray>;
  27349. /**
  27350. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27351. */
  27352. matricesWeights: Nullable<FloatArray>;
  27353. /**
  27354. * An array extending the number of possible indices
  27355. */
  27356. matricesIndicesExtra: Nullable<FloatArray>;
  27357. /**
  27358. * An array extending the number of possible weights when the number of indices is extended
  27359. */
  27360. matricesWeightsExtra: Nullable<FloatArray>;
  27361. /**
  27362. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27363. */
  27364. indices: Nullable<IndicesArray>;
  27365. /**
  27366. * Uses the passed data array to set the set the values for the specified kind of data
  27367. * @param data a linear array of floating numbers
  27368. * @param kind the type of data that is being set, eg positions, colors etc
  27369. */
  27370. set(data: FloatArray, kind: string): void;
  27371. /**
  27372. * Associates the vertexData to the passed Mesh.
  27373. * Sets it as updatable or not (default `false`)
  27374. * @param mesh the mesh the vertexData is applied to
  27375. * @param updatable when used and having the value true allows new data to update the vertexData
  27376. * @returns the VertexData
  27377. */
  27378. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27379. /**
  27380. * Associates the vertexData to the passed Geometry.
  27381. * Sets it as updatable or not (default `false`)
  27382. * @param geometry the geometry the vertexData is applied to
  27383. * @param updatable when used and having the value true allows new data to update the vertexData
  27384. * @returns VertexData
  27385. */
  27386. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27387. /**
  27388. * Updates the associated mesh
  27389. * @param mesh the mesh to be updated
  27390. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27391. * @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
  27392. * @returns VertexData
  27393. */
  27394. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27395. /**
  27396. * Updates the associated geometry
  27397. * @param geometry the geometry to be updated
  27398. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27399. * @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
  27400. * @returns VertexData.
  27401. */
  27402. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27403. private _applyTo;
  27404. private _update;
  27405. /**
  27406. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27407. * @param matrix the transforming matrix
  27408. * @returns the VertexData
  27409. */
  27410. transform(matrix: Matrix): VertexData;
  27411. /**
  27412. * Merges the passed VertexData into the current one
  27413. * @param other the VertexData to be merged into the current one
  27414. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27415. * @returns the modified VertexData
  27416. */
  27417. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27418. private _mergeElement;
  27419. private _validate;
  27420. /**
  27421. * Serializes the VertexData
  27422. * @returns a serialized object
  27423. */
  27424. serialize(): any;
  27425. /**
  27426. * Extracts the vertexData from a mesh
  27427. * @param mesh the mesh from which to extract the VertexData
  27428. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27429. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27430. * @returns the object VertexData associated to the passed mesh
  27431. */
  27432. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27433. /**
  27434. * Extracts the vertexData from the geometry
  27435. * @param geometry the geometry from which to extract the VertexData
  27436. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27437. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27438. * @returns the object VertexData associated to the passed mesh
  27439. */
  27440. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27441. private static _ExtractFrom;
  27442. /**
  27443. * Creates the VertexData for a Ribbon
  27444. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27445. * * pathArray array of paths, each of which an array of successive Vector3
  27446. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27447. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27448. * * 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
  27449. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27450. * * 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)
  27451. * * 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)
  27452. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27453. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27454. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27455. * @returns the VertexData of the ribbon
  27456. */
  27457. static CreateRibbon(options: {
  27458. pathArray: Vector3[][];
  27459. closeArray?: boolean;
  27460. closePath?: boolean;
  27461. offset?: number;
  27462. sideOrientation?: number;
  27463. frontUVs?: Vector4;
  27464. backUVs?: Vector4;
  27465. invertUV?: boolean;
  27466. uvs?: Vector2[];
  27467. colors?: Color4[];
  27468. }): VertexData;
  27469. /**
  27470. * Creates the VertexData for a box
  27471. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27472. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27473. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27474. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27475. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27476. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27477. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27478. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27479. * * 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)
  27480. * * 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)
  27481. * @returns the VertexData of the box
  27482. */
  27483. static CreateBox(options: {
  27484. size?: number;
  27485. width?: number;
  27486. height?: number;
  27487. depth?: number;
  27488. faceUV?: Vector4[];
  27489. faceColors?: Color4[];
  27490. sideOrientation?: number;
  27491. frontUVs?: Vector4;
  27492. backUVs?: Vector4;
  27493. }): VertexData;
  27494. /**
  27495. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27496. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27497. * * segments sets the number of horizontal strips optional, default 32
  27498. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27499. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27500. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27501. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27502. * * 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
  27503. * * 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
  27504. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27505. * * 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)
  27506. * * 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)
  27507. * @returns the VertexData of the ellipsoid
  27508. */
  27509. static CreateSphere(options: {
  27510. segments?: number;
  27511. diameter?: number;
  27512. diameterX?: number;
  27513. diameterY?: number;
  27514. diameterZ?: number;
  27515. arc?: number;
  27516. slice?: number;
  27517. sideOrientation?: number;
  27518. frontUVs?: Vector4;
  27519. backUVs?: Vector4;
  27520. }): VertexData;
  27521. /**
  27522. * Creates the VertexData for a cylinder, cone or prism
  27523. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27524. * * height sets the height (y direction) of the cylinder, optional, default 2
  27525. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27526. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27527. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27528. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27529. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27530. * * 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
  27531. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27532. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27533. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27534. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27535. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27536. * * 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)
  27537. * * 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)
  27538. * @returns the VertexData of the cylinder, cone or prism
  27539. */
  27540. static CreateCylinder(options: {
  27541. height?: number;
  27542. diameterTop?: number;
  27543. diameterBottom?: number;
  27544. diameter?: number;
  27545. tessellation?: number;
  27546. subdivisions?: number;
  27547. arc?: number;
  27548. faceColors?: Color4[];
  27549. faceUV?: Vector4[];
  27550. hasRings?: boolean;
  27551. enclose?: boolean;
  27552. sideOrientation?: number;
  27553. frontUVs?: Vector4;
  27554. backUVs?: Vector4;
  27555. }): VertexData;
  27556. /**
  27557. * Creates the VertexData for a torus
  27558. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27559. * * diameter the diameter of the torus, optional default 1
  27560. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27561. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27562. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27563. * * 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)
  27564. * * 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)
  27565. * @returns the VertexData of the torus
  27566. */
  27567. static CreateTorus(options: {
  27568. diameter?: number;
  27569. thickness?: number;
  27570. tessellation?: number;
  27571. sideOrientation?: number;
  27572. frontUVs?: Vector4;
  27573. backUVs?: Vector4;
  27574. }): VertexData;
  27575. /**
  27576. * Creates the VertexData of the LineSystem
  27577. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27578. * - lines an array of lines, each line being an array of successive Vector3
  27579. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27580. * @returns the VertexData of the LineSystem
  27581. */
  27582. static CreateLineSystem(options: {
  27583. lines: Vector3[][];
  27584. colors?: Nullable<Color4[][]>;
  27585. }): VertexData;
  27586. /**
  27587. * Create the VertexData for a DashedLines
  27588. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27589. * - points an array successive Vector3
  27590. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27591. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27592. * - dashNb the intended total number of dashes, optional, default 200
  27593. * @returns the VertexData for the DashedLines
  27594. */
  27595. static CreateDashedLines(options: {
  27596. points: Vector3[];
  27597. dashSize?: number;
  27598. gapSize?: number;
  27599. dashNb?: number;
  27600. }): VertexData;
  27601. /**
  27602. * Creates the VertexData for a Ground
  27603. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27604. * - width the width (x direction) of the ground, optional, default 1
  27605. * - height the height (z direction) of the ground, optional, default 1
  27606. * - subdivisions the number of subdivisions per side, optional, default 1
  27607. * @returns the VertexData of the Ground
  27608. */
  27609. static CreateGround(options: {
  27610. width?: number;
  27611. height?: number;
  27612. subdivisions?: number;
  27613. subdivisionsX?: number;
  27614. subdivisionsY?: number;
  27615. }): VertexData;
  27616. /**
  27617. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27618. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27619. * * xmin the ground minimum X coordinate, optional, default -1
  27620. * * zmin the ground minimum Z coordinate, optional, default -1
  27621. * * xmax the ground maximum X coordinate, optional, default 1
  27622. * * zmax the ground maximum Z coordinate, optional, default 1
  27623. * * 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}
  27624. * * 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}
  27625. * @returns the VertexData of the TiledGround
  27626. */
  27627. static CreateTiledGround(options: {
  27628. xmin: number;
  27629. zmin: number;
  27630. xmax: number;
  27631. zmax: number;
  27632. subdivisions?: {
  27633. w: number;
  27634. h: number;
  27635. };
  27636. precision?: {
  27637. w: number;
  27638. h: number;
  27639. };
  27640. }): VertexData;
  27641. /**
  27642. * Creates the VertexData of the Ground designed from a heightmap
  27643. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27644. * * width the width (x direction) of the ground
  27645. * * height the height (z direction) of the ground
  27646. * * subdivisions the number of subdivisions per side
  27647. * * minHeight the minimum altitude on the ground, optional, default 0
  27648. * * maxHeight the maximum altitude on the ground, optional default 1
  27649. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27650. * * buffer the array holding the image color data
  27651. * * bufferWidth the width of image
  27652. * * bufferHeight the height of image
  27653. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27654. * @returns the VertexData of the Ground designed from a heightmap
  27655. */
  27656. static CreateGroundFromHeightMap(options: {
  27657. width: number;
  27658. height: number;
  27659. subdivisions: number;
  27660. minHeight: number;
  27661. maxHeight: number;
  27662. colorFilter: Color3;
  27663. buffer: Uint8Array;
  27664. bufferWidth: number;
  27665. bufferHeight: number;
  27666. alphaFilter: number;
  27667. }): VertexData;
  27668. /**
  27669. * Creates the VertexData for a Plane
  27670. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27671. * * size sets the width and height of the plane to the value of size, optional default 1
  27672. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27673. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27674. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27675. * * 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)
  27676. * * 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)
  27677. * @returns the VertexData of the box
  27678. */
  27679. static CreatePlane(options: {
  27680. size?: number;
  27681. width?: number;
  27682. height?: number;
  27683. sideOrientation?: number;
  27684. frontUVs?: Vector4;
  27685. backUVs?: Vector4;
  27686. }): VertexData;
  27687. /**
  27688. * Creates the VertexData of the Disc or regular Polygon
  27689. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27690. * * radius the radius of the disc, optional default 0.5
  27691. * * tessellation the number of polygon sides, optional, default 64
  27692. * * 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
  27693. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27694. * * 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)
  27695. * * 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)
  27696. * @returns the VertexData of the box
  27697. */
  27698. static CreateDisc(options: {
  27699. radius?: number;
  27700. tessellation?: number;
  27701. arc?: number;
  27702. sideOrientation?: number;
  27703. frontUVs?: Vector4;
  27704. backUVs?: Vector4;
  27705. }): VertexData;
  27706. /**
  27707. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27708. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27709. * @param polygon a mesh built from polygonTriangulation.build()
  27710. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27711. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27712. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27713. * @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)
  27714. * @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)
  27715. * @returns the VertexData of the Polygon
  27716. */
  27717. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  27718. /**
  27719. * Creates the VertexData of the IcoSphere
  27720. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27721. * * radius the radius of the IcoSphere, optional default 1
  27722. * * radiusX allows stretching in the x direction, optional, default radius
  27723. * * radiusY allows stretching in the y direction, optional, default radius
  27724. * * radiusZ allows stretching in the z direction, optional, default radius
  27725. * * flat when true creates a flat shaded mesh, optional, default true
  27726. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27727. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27728. * * 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)
  27729. * * 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)
  27730. * @returns the VertexData of the IcoSphere
  27731. */
  27732. static CreateIcoSphere(options: {
  27733. radius?: number;
  27734. radiusX?: number;
  27735. radiusY?: number;
  27736. radiusZ?: number;
  27737. flat?: boolean;
  27738. subdivisions?: number;
  27739. sideOrientation?: number;
  27740. frontUVs?: Vector4;
  27741. backUVs?: Vector4;
  27742. }): VertexData;
  27743. /**
  27744. * Creates the VertexData for a Polyhedron
  27745. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27746. * * type provided types are:
  27747. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27748. * * 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)
  27749. * * size the size of the IcoSphere, optional default 1
  27750. * * sizeX allows stretching in the x direction, optional, default size
  27751. * * sizeY allows stretching in the y direction, optional, default size
  27752. * * sizeZ allows stretching in the z direction, optional, default size
  27753. * * 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
  27754. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27755. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27756. * * flat when true creates a flat shaded mesh, optional, default true
  27757. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27758. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27759. * * 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)
  27760. * * 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)
  27761. * @returns the VertexData of the Polyhedron
  27762. */
  27763. static CreatePolyhedron(options: {
  27764. type?: number;
  27765. size?: number;
  27766. sizeX?: number;
  27767. sizeY?: number;
  27768. sizeZ?: number;
  27769. custom?: any;
  27770. faceUV?: Vector4[];
  27771. faceColors?: Color4[];
  27772. flat?: boolean;
  27773. sideOrientation?: number;
  27774. frontUVs?: Vector4;
  27775. backUVs?: Vector4;
  27776. }): VertexData;
  27777. /**
  27778. * Creates the VertexData for a TorusKnot
  27779. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27780. * * radius the radius of the torus knot, optional, default 2
  27781. * * tube the thickness of the tube, optional, default 0.5
  27782. * * radialSegments the number of sides on each tube segments, optional, default 32
  27783. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27784. * * p the number of windings around the z axis, optional, default 2
  27785. * * q the number of windings around the x axis, optional, default 3
  27786. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27787. * * 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)
  27788. * * 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)
  27789. * @returns the VertexData of the Torus Knot
  27790. */
  27791. static CreateTorusKnot(options: {
  27792. radius?: number;
  27793. tube?: number;
  27794. radialSegments?: number;
  27795. tubularSegments?: number;
  27796. p?: number;
  27797. q?: number;
  27798. sideOrientation?: number;
  27799. frontUVs?: Vector4;
  27800. backUVs?: Vector4;
  27801. }): VertexData;
  27802. /**
  27803. * Compute normals for given positions and indices
  27804. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27805. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27806. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27807. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27808. * * facetNormals : optional array of facet normals (vector3)
  27809. * * facetPositions : optional array of facet positions (vector3)
  27810. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27811. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27812. * * bInfo : optional bounding info, required for facetPartitioning computation
  27813. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27814. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27815. * * useRightHandedSystem: optional boolean to for right handed system computation
  27816. * * depthSort : optional boolean to enable the facet depth sort computation
  27817. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27818. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27819. */
  27820. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27821. facetNormals?: any;
  27822. facetPositions?: any;
  27823. facetPartitioning?: any;
  27824. ratio?: number;
  27825. bInfo?: any;
  27826. bbSize?: Vector3;
  27827. subDiv?: any;
  27828. useRightHandedSystem?: boolean;
  27829. depthSort?: boolean;
  27830. distanceTo?: Vector3;
  27831. depthSortedFacets?: any;
  27832. }): void;
  27833. private static _ComputeSides;
  27834. /**
  27835. * Applies VertexData created from the imported parameters to the geometry
  27836. * @param parsedVertexData the parsed data from an imported file
  27837. * @param geometry the geometry to apply the VertexData to
  27838. */
  27839. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27840. }
  27841. }
  27842. declare module BABYLON {
  27843. /**
  27844. * Class containing static functions to help procedurally build meshes
  27845. */
  27846. class MeshBuilder {
  27847. private static updateSideOrientation;
  27848. /**
  27849. * Creates a box mesh
  27850. * * The parameter `size` sets the size (float) of each box side (default 1)
  27851. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  27852. * * 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)
  27853. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  27854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27855. * * 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
  27856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27857. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  27858. * @param name defines the name of the mesh
  27859. * @param options defines the options used to create the mesh
  27860. * @param scene defines the hosting scene
  27861. * @returns the box mesh
  27862. */
  27863. static CreateBox(name: string, options: {
  27864. size?: number;
  27865. width?: number;
  27866. height?: number;
  27867. depth?: number;
  27868. faceUV?: Vector4[];
  27869. faceColors?: Color4[];
  27870. sideOrientation?: number;
  27871. frontUVs?: Vector4;
  27872. backUVs?: Vector4;
  27873. updatable?: boolean;
  27874. }, scene?: Nullable<Scene>): Mesh;
  27875. /**
  27876. * Creates a sphere mesh
  27877. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  27878. * * 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`)
  27879. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  27880. * * 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
  27881. * * 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)
  27882. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27883. * * 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
  27884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27885. * @param name defines the name of the mesh
  27886. * @param options defines the options used to create the mesh
  27887. * @param scene defines the hosting scene
  27888. * @returns the sphere mesh
  27889. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  27890. */
  27891. static CreateSphere(name: string, options: {
  27892. segments?: number;
  27893. diameter?: number;
  27894. diameterX?: number;
  27895. diameterY?: number;
  27896. diameterZ?: number;
  27897. arc?: number;
  27898. slice?: number;
  27899. sideOrientation?: number;
  27900. frontUVs?: Vector4;
  27901. backUVs?: Vector4;
  27902. updatable?: boolean;
  27903. }, scene: any): Mesh;
  27904. /**
  27905. * Creates a plane polygonal mesh. By default, this is a disc
  27906. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  27907. * * 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
  27908. * * 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
  27909. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27910. * * 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
  27911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27912. * @param name defines the name of the mesh
  27913. * @param options defines the options used to create the mesh
  27914. * @param scene defines the hosting scene
  27915. * @returns the plane polygonal mesh
  27916. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  27917. */
  27918. static CreateDisc(name: string, options: {
  27919. radius?: number;
  27920. tessellation?: number;
  27921. arc?: number;
  27922. updatable?: boolean;
  27923. sideOrientation?: number;
  27924. frontUVs?: Vector4;
  27925. backUVs?: Vector4;
  27926. }, scene?: Nullable<Scene>): Mesh;
  27927. /**
  27928. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27929. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27930. * * 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`)
  27931. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27932. * * 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
  27933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27934. * * 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
  27935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27936. * @param name defines the name of the mesh
  27937. * @param options defines the options used to create the mesh
  27938. * @param scene defines the hosting scene
  27939. * @returns the icosahedron mesh
  27940. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27941. */
  27942. static CreateIcoSphere(name: string, options: {
  27943. radius?: number;
  27944. radiusX?: number;
  27945. radiusY?: number;
  27946. radiusZ?: number;
  27947. flat?: boolean;
  27948. subdivisions?: number;
  27949. sideOrientation?: number;
  27950. frontUVs?: Vector4;
  27951. backUVs?: Vector4;
  27952. updatable?: boolean;
  27953. }, scene: Scene): Mesh;
  27954. /**
  27955. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  27956. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  27957. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  27958. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  27959. * * 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
  27960. * * 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
  27961. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#ribbon
  27962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27963. * * 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
  27964. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  27965. * * 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
  27966. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  27967. * * 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
  27968. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  27969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27970. * @param name defines the name of the mesh
  27971. * @param options defines the options used to create the mesh
  27972. * @param scene defines the hosting scene
  27973. * @returns the ribbon mesh
  27974. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  27975. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  27976. */
  27977. static CreateRibbon(name: string, options: {
  27978. pathArray: Vector3[][];
  27979. closeArray?: boolean;
  27980. closePath?: boolean;
  27981. offset?: number;
  27982. updatable?: boolean;
  27983. sideOrientation?: number;
  27984. frontUVs?: Vector4;
  27985. backUVs?: Vector4;
  27986. instance?: Mesh;
  27987. invertUV?: boolean;
  27988. uvs?: Vector2[];
  27989. colors?: Color4[];
  27990. }, scene?: Nullable<Scene>): Mesh;
  27991. /**
  27992. * Creates a cylinder or a cone mesh
  27993. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  27994. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  27995. * * 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.
  27996. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  27997. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  27998. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  27999. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  28000. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  28001. * * 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).
  28002. * * 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
  28003. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  28004. * * 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
  28005. * * 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.
  28006. * * If `enclose` is false, a ring surface is one element.
  28007. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  28008. * * Example how to set colors and textures on a sliced cylinder : http://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  28009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28010. * * 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
  28011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28012. * @param name defines the name of the mesh
  28013. * @param options defines the options used to create the mesh
  28014. * @param scene defines the hosting scene
  28015. * @returns the cylinder mesh
  28016. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  28017. */
  28018. static CreateCylinder(name: string, options: {
  28019. height?: number;
  28020. diameterTop?: number;
  28021. diameterBottom?: number;
  28022. diameter?: number;
  28023. tessellation?: number;
  28024. subdivisions?: number;
  28025. arc?: number;
  28026. faceColors?: Color4[];
  28027. faceUV?: Vector4[];
  28028. updatable?: boolean;
  28029. hasRings?: boolean;
  28030. enclose?: boolean;
  28031. sideOrientation?: number;
  28032. frontUVs?: Vector4;
  28033. backUVs?: Vector4;
  28034. }, scene: any): Mesh;
  28035. /**
  28036. * Creates a torus mesh
  28037. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28038. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28039. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28041. * * 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
  28042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28043. * @param name defines the name of the mesh
  28044. * @param options defines the options used to create the mesh
  28045. * @param scene defines the hosting scene
  28046. * @returns the torus mesh
  28047. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  28048. */
  28049. static CreateTorus(name: string, options: {
  28050. diameter?: number;
  28051. thickness?: number;
  28052. tessellation?: number;
  28053. updatable?: boolean;
  28054. sideOrientation?: number;
  28055. frontUVs?: Vector4;
  28056. backUVs?: Vector4;
  28057. }, scene: any): Mesh;
  28058. /**
  28059. * Creates a torus knot mesh
  28060. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28061. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28062. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28063. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28064. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28065. * * 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
  28066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28067. * @param name defines the name of the mesh
  28068. * @param options defines the options used to create the mesh
  28069. * @param scene defines the hosting scene
  28070. * @returns the torus knot mesh
  28071. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  28072. */
  28073. static CreateTorusKnot(name: string, options: {
  28074. radius?: number;
  28075. tube?: number;
  28076. radialSegments?: number;
  28077. tubularSegments?: number;
  28078. p?: number;
  28079. q?: number;
  28080. updatable?: boolean;
  28081. sideOrientation?: number;
  28082. frontUVs?: Vector4;
  28083. backUVs?: Vector4;
  28084. }, scene: any): Mesh;
  28085. /**
  28086. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28087. * * 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
  28088. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28089. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28090. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28091. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28092. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28093. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  28094. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28096. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28097. * @param name defines the name of the new line system
  28098. * @param options defines the options used to create the line system
  28099. * @param scene defines the hosting scene
  28100. * @returns a new line system mesh
  28101. */
  28102. static CreateLineSystem(name: string, options: {
  28103. lines: Vector3[][];
  28104. updatable?: boolean;
  28105. instance?: Nullable<LinesMesh>;
  28106. colors?: Nullable<Color4[][]>;
  28107. useVertexAlpha?: boolean;
  28108. }, scene: Nullable<Scene>): LinesMesh;
  28109. /**
  28110. * Creates a line mesh
  28111. * 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
  28112. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28113. * * The parameter `points` is an array successive Vector3
  28114. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  28115. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28116. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28117. * * When updating an instance, remember that only point positions can change, not the number of points
  28118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28119. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  28120. * @param name defines the name of the new line system
  28121. * @param options defines the options used to create the line system
  28122. * @param scene defines the hosting scene
  28123. * @returns a new line mesh
  28124. */
  28125. static CreateLines(name: string, options: {
  28126. points: Vector3[];
  28127. updatable?: boolean;
  28128. instance?: Nullable<LinesMesh>;
  28129. colors?: Color4[];
  28130. useVertexAlpha?: boolean;
  28131. }, scene?: Nullable<Scene>): LinesMesh;
  28132. /**
  28133. * Creates a dashed line mesh
  28134. * * 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
  28135. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28136. * * The parameter `points` is an array successive Vector3
  28137. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28138. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28139. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28140. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  28141. * * When updating an instance, remember that only point positions can change, not the number of points
  28142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28143. * @param name defines the name of the mesh
  28144. * @param options defines the options used to create the mesh
  28145. * @param scene defines the hosting scene
  28146. * @returns the dashed line mesh
  28147. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28148. */
  28149. static CreateDashedLines(name: string, options: {
  28150. points: Vector3[];
  28151. dashSize?: number;
  28152. gapSize?: number;
  28153. dashNb?: number;
  28154. updatable?: boolean;
  28155. instance?: LinesMesh;
  28156. }, scene?: Nullable<Scene>): LinesMesh;
  28157. /**
  28158. * 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.
  28159. * * 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.
  28160. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28161. * * 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.
  28162. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28163. * * 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
  28164. * * The optional parameter `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/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  28165. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28167. * * 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
  28168. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28170. * @param name defines the name of the mesh
  28171. * @param options defines the options used to create the mesh
  28172. * @param scene defines the hosting scene
  28173. * @returns the extruded shape mesh
  28174. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28175. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28176. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28177. */
  28178. static ExtrudeShape(name: string, options: {
  28179. shape: Vector3[];
  28180. path: Vector3[];
  28181. scale?: number;
  28182. rotation?: number;
  28183. cap?: number;
  28184. updatable?: boolean;
  28185. sideOrientation?: number;
  28186. frontUVs?: Vector4;
  28187. backUVs?: Vector4;
  28188. instance?: Mesh;
  28189. invertUV?: boolean;
  28190. }, scene?: Nullable<Scene>): Mesh;
  28191. /**
  28192. * Creates an custom extruded shape mesh.
  28193. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28194. * * 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.
  28195. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28196. * * 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
  28197. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28198. * * 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
  28199. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28200. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28201. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28202. * * 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
  28203. * * The optional parameter `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/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  28204. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28206. * * 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
  28207. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28209. * @param name defines the name of the mesh
  28210. * @param options defines the options used to create the mesh
  28211. * @param scene defines the hosting scene
  28212. * @returns the custom extruded shape mesh
  28213. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28214. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28215. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28216. */
  28217. static ExtrudeShapeCustom(name: string, options: {
  28218. shape: Vector3[];
  28219. path: Vector3[];
  28220. scaleFunction?: any;
  28221. rotationFunction?: any;
  28222. ribbonCloseArray?: boolean;
  28223. ribbonClosePath?: boolean;
  28224. cap?: number;
  28225. updatable?: boolean;
  28226. sideOrientation?: number;
  28227. frontUVs?: Vector4;
  28228. backUVs?: Vector4;
  28229. instance?: Mesh;
  28230. invertUV?: boolean;
  28231. }, scene: Scene): Mesh;
  28232. /**
  28233. * Creates lathe mesh.
  28234. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28235. * * 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
  28236. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28237. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28238. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28239. * * 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
  28240. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28241. * * 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
  28242. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28243. * * 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
  28244. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28246. * @param name defines the name of the mesh
  28247. * @param options defines the options used to create the mesh
  28248. * @param scene defines the hosting scene
  28249. * @returns the lathe mesh
  28250. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28251. */
  28252. static CreateLathe(name: string, options: {
  28253. shape: Vector3[];
  28254. radius?: number;
  28255. tessellation?: number;
  28256. clip?: number;
  28257. arc?: number;
  28258. closed?: boolean;
  28259. updatable?: boolean;
  28260. sideOrientation?: number;
  28261. frontUVs?: Vector4;
  28262. backUVs?: Vector4;
  28263. cap?: number;
  28264. invertUV?: boolean;
  28265. }, scene: Scene): Mesh;
  28266. /**
  28267. * Creates a plane mesh
  28268. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28269. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28270. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28272. * * 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
  28273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28274. * @param name defines the name of the mesh
  28275. * @param options defines the options used to create the mesh
  28276. * @param scene defines the hosting scene
  28277. * @returns the plane mesh
  28278. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  28279. */
  28280. static CreatePlane(name: string, options: {
  28281. size?: number;
  28282. width?: number;
  28283. height?: number;
  28284. sideOrientation?: number;
  28285. frontUVs?: Vector4;
  28286. backUVs?: Vector4;
  28287. updatable?: boolean;
  28288. sourcePlane?: Plane;
  28289. }, scene: Scene): Mesh;
  28290. /**
  28291. * Creates a ground mesh
  28292. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28293. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28295. * @param name defines the name of the mesh
  28296. * @param options defines the options used to create the mesh
  28297. * @param scene defines the hosting scene
  28298. * @returns the ground mesh
  28299. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  28300. */
  28301. static CreateGround(name: string, options: {
  28302. width?: number;
  28303. height?: number;
  28304. subdivisions?: number;
  28305. subdivisionsX?: number;
  28306. subdivisionsY?: number;
  28307. updatable?: boolean;
  28308. }, scene: any): Mesh;
  28309. /**
  28310. * Creates a tiled ground mesh
  28311. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28312. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28313. * * 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
  28314. * * 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
  28315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28316. * @param name defines the name of the mesh
  28317. * @param options defines the options used to create the mesh
  28318. * @param scene defines the hosting scene
  28319. * @returns the tiled ground mesh
  28320. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  28321. */
  28322. static CreateTiledGround(name: string, options: {
  28323. xmin: number;
  28324. zmin: number;
  28325. xmax: number;
  28326. zmax: number;
  28327. subdivisions?: {
  28328. w: number;
  28329. h: number;
  28330. };
  28331. precision?: {
  28332. w: number;
  28333. h: number;
  28334. };
  28335. updatable?: boolean;
  28336. }, scene: Scene): Mesh;
  28337. /**
  28338. * Creates a ground mesh from a height map
  28339. * * The parameter `url` sets the URL of the height map image resource.
  28340. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28341. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28342. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28343. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28344. * * 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.
  28345. * * 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).
  28346. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28348. * @param name defines the name of the mesh
  28349. * @param url defines the url to the height map
  28350. * @param options defines the options used to create the mesh
  28351. * @param scene defines the hosting scene
  28352. * @returns the ground mesh
  28353. * @see http://doc.babylonjs.com/babylon101/height_map
  28354. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  28355. */
  28356. static CreateGroundFromHeightMap(name: string, url: string, options: {
  28357. width?: number;
  28358. height?: number;
  28359. subdivisions?: number;
  28360. minHeight?: number;
  28361. maxHeight?: number;
  28362. colorFilter?: Color3;
  28363. alphaFilter?: number;
  28364. updatable?: boolean;
  28365. onReady?: (mesh: GroundMesh) => void;
  28366. }, scene: Scene): GroundMesh;
  28367. /**
  28368. * Creates a polygon mesh
  28369. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  28370. * * 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
  28371. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28373. * * 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)
  28374. * * Remember you can only change the shape positions, not their number when updating a polygon
  28375. * @param name defines the name of the mesh
  28376. * @param options defines the options used to create the mesh
  28377. * @param scene defines the hosting scene
  28378. * @returns the polygon mesh
  28379. */
  28380. static CreatePolygon(name: string, options: {
  28381. shape: Vector3[];
  28382. holes?: Vector3[][];
  28383. depth?: number;
  28384. faceUV?: Vector4[];
  28385. faceColors?: Color4[];
  28386. updatable?: boolean;
  28387. sideOrientation?: number;
  28388. frontUVs?: Vector4;
  28389. backUVs?: Vector4;
  28390. }, scene: Scene): Mesh;
  28391. /**
  28392. * Creates an extruded polygon mesh, with depth in the Y direction.
  28393. * * 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)
  28394. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  28395. * @param name defines the name of the mesh
  28396. * @param options defines the options used to create the mesh
  28397. * @param scene defines the hosting scene
  28398. * @returns the polygon mesh
  28399. */
  28400. static ExtrudePolygon(name: string, options: {
  28401. shape: Vector3[];
  28402. holes?: Vector3[][];
  28403. depth?: number;
  28404. faceUV?: Vector4[];
  28405. faceColors?: Color4[];
  28406. updatable?: boolean;
  28407. sideOrientation?: number;
  28408. frontUVs?: Vector4;
  28409. backUVs?: Vector4;
  28410. }, scene: Scene): Mesh;
  28411. /**
  28412. * Creates a tube mesh.
  28413. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28414. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  28415. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  28416. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  28417. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  28418. * * 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)
  28419. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  28420. * * 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
  28421. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#tube
  28422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28423. * * 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
  28424. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28426. * @param name defines the name of the mesh
  28427. * @param options defines the options used to create the mesh
  28428. * @param scene defines the hosting scene
  28429. * @returns the tube mesh
  28430. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28431. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  28432. */
  28433. static CreateTube(name: string, options: {
  28434. path: Vector3[];
  28435. radius?: number;
  28436. tessellation?: number;
  28437. radiusFunction?: {
  28438. (i: number, distance: number): number;
  28439. };
  28440. cap?: number;
  28441. arc?: number;
  28442. updatable?: boolean;
  28443. sideOrientation?: number;
  28444. frontUVs?: Vector4;
  28445. backUVs?: Vector4;
  28446. instance?: Mesh;
  28447. invertUV?: boolean;
  28448. }, scene: Scene): Mesh;
  28449. /**
  28450. * Creates a polyhedron mesh
  28451. * * 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
  28452. * * The parameter `size` (positive float, default 1) sets the polygon size
  28453. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28454. * * 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`
  28455. * * 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
  28456. * * 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)`)
  28457. * * 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 : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  28458. * * 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
  28459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28460. * * 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
  28461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28462. * @param name defines the name of the mesh
  28463. * @param options defines the options used to create the mesh
  28464. * @param scene defines the hosting scene
  28465. * @returns the polyhedron mesh
  28466. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  28467. */
  28468. static CreatePolyhedron(name: string, options: {
  28469. type?: number;
  28470. size?: number;
  28471. sizeX?: number;
  28472. sizeY?: number;
  28473. sizeZ?: number;
  28474. custom?: any;
  28475. faceUV?: Vector4[];
  28476. faceColors?: Color4[];
  28477. flat?: boolean;
  28478. updatable?: boolean;
  28479. sideOrientation?: number;
  28480. frontUVs?: Vector4;
  28481. backUVs?: Vector4;
  28482. }, scene: Scene): Mesh;
  28483. /**
  28484. * Creates a decal mesh.
  28485. * 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
  28486. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  28487. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  28488. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  28489. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  28490. * @param name defines the name of the mesh
  28491. * @param sourceMesh defines the mesh where the decal must be applied
  28492. * @param options defines the options used to create the mesh
  28493. * @param scene defines the hosting scene
  28494. * @returns the decal mesh
  28495. * @see http://doc.babylonjs.com/how_to/decals
  28496. */
  28497. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28498. position?: Vector3;
  28499. normal?: Vector3;
  28500. size?: Vector3;
  28501. angle?: number;
  28502. }): Mesh;
  28503. private static _ExtrudeShapeGeneric;
  28504. }
  28505. }
  28506. declare module BABYLON {
  28507. /**
  28508. * Class used to represent a specific level of detail of a mesh
  28509. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28510. */
  28511. class MeshLODLevel {
  28512. /** Defines the distance where this level should star being displayed */
  28513. distance: number;
  28514. /** Defines the mesh to use to render this level */
  28515. mesh: Nullable<Mesh>;
  28516. /**
  28517. * Creates a new LOD level
  28518. * @param distance defines the distance where this level should star being displayed
  28519. * @param mesh defines the mesh to use to render this level
  28520. */
  28521. constructor(
  28522. /** Defines the distance where this level should star being displayed */
  28523. distance: number,
  28524. /** Defines the mesh to use to render this level */
  28525. mesh: Nullable<Mesh>);
  28526. }
  28527. }
  28528. declare module BABYLON {
  28529. /**
  28530. * A simplifier interface for future simplification implementations
  28531. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28532. */
  28533. interface ISimplifier {
  28534. /**
  28535. * Simplification of a given mesh according to the given settings.
  28536. * Since this requires computation, it is assumed that the function runs async.
  28537. * @param settings The settings of the simplification, including quality and distance
  28538. * @param successCallback A callback that will be called after the mesh was simplified.
  28539. * @param errorCallback in case of an error, this callback will be called. optional.
  28540. */
  28541. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28542. }
  28543. /**
  28544. * Expected simplification settings.
  28545. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28546. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28547. */
  28548. interface ISimplificationSettings {
  28549. /**
  28550. * Gets or sets the expected quality
  28551. */
  28552. quality: number;
  28553. /**
  28554. * Gets or sets the distance when this optimized version should be used
  28555. */
  28556. distance: number;
  28557. /**
  28558. * Gets an already optimized mesh
  28559. */
  28560. optimizeMesh?: boolean;
  28561. }
  28562. /**
  28563. * Class used to specify simplification options
  28564. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28565. */
  28566. class SimplificationSettings implements ISimplificationSettings {
  28567. /** expected quality */
  28568. quality: number;
  28569. /** distance when this optimized version should be used */
  28570. distance: number;
  28571. /** already optimized mesh */
  28572. optimizeMesh?: boolean | undefined;
  28573. /**
  28574. * Creates a SimplificationSettings
  28575. * @param quality expected quality
  28576. * @param distance distance when this optimized version should be used
  28577. * @param optimizeMesh already optimized mesh
  28578. */
  28579. constructor(
  28580. /** expected quality */
  28581. quality: number,
  28582. /** distance when this optimized version should be used */
  28583. distance: number,
  28584. /** already optimized mesh */
  28585. optimizeMesh?: boolean | undefined);
  28586. }
  28587. /**
  28588. * Interface used to define a simplification task
  28589. */
  28590. interface ISimplificationTask {
  28591. /**
  28592. * Array of settings
  28593. */
  28594. settings: Array<ISimplificationSettings>;
  28595. /**
  28596. * Simplification type
  28597. */
  28598. simplificationType: SimplificationType;
  28599. /**
  28600. * Mesh to simplify
  28601. */
  28602. mesh: Mesh;
  28603. /**
  28604. * Callback called on success
  28605. */
  28606. successCallback?: () => void;
  28607. /**
  28608. * Defines if parallel processing can be used
  28609. */
  28610. parallelProcessing: boolean;
  28611. }
  28612. /**
  28613. * Queue used to order the simplification tasks
  28614. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28615. */
  28616. class SimplificationQueue {
  28617. private _simplificationArray;
  28618. /**
  28619. * Gets a boolean indicating that the process is still running
  28620. */
  28621. running: boolean;
  28622. /**
  28623. * Creates a new queue
  28624. */
  28625. constructor();
  28626. /**
  28627. * Adds a new simplification task
  28628. * @param task defines a task to add
  28629. */
  28630. addTask(task: ISimplificationTask): void;
  28631. /**
  28632. * Execute next task
  28633. */
  28634. executeNext(): void;
  28635. /**
  28636. * Execute a simplification task
  28637. * @param task defines the task to run
  28638. */
  28639. runSimplification(task: ISimplificationTask): void;
  28640. private getSimplifier;
  28641. }
  28642. /**
  28643. * The implemented types of simplification
  28644. * At the moment only Quadratic Error Decimation is implemented
  28645. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28646. */
  28647. enum SimplificationType {
  28648. /** Quadratic error decimation */
  28649. QUADRATIC = 0
  28650. }
  28651. }
  28652. declare module BABYLON {
  28653. interface Scene {
  28654. /** @hidden (Backing field) */
  28655. _simplificationQueue: SimplificationQueue;
  28656. /**
  28657. * Gets or sets the simplification queue attached to the scene
  28658. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28659. */
  28660. simplificationQueue: SimplificationQueue;
  28661. }
  28662. interface Mesh {
  28663. /**
  28664. * Simplify the mesh according to the given array of settings.
  28665. * Function will return immediately and will simplify async
  28666. * @param settings a collection of simplification settings
  28667. * @param parallelProcessing should all levels calculate parallel or one after the other
  28668. * @param simplificationType the type of simplification to run
  28669. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  28670. * @returns the current mesh
  28671. */
  28672. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  28673. }
  28674. /**
  28675. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  28676. * created in a scene
  28677. */
  28678. class SimplicationQueueSceneComponent implements ISceneComponent {
  28679. /**
  28680. * The component name helpfull to identify the component in the list of scene components.
  28681. */
  28682. readonly name: string;
  28683. /**
  28684. * The scene the component belongs to.
  28685. */
  28686. scene: Scene;
  28687. /**
  28688. * Creates a new instance of the component for the given scene
  28689. * @param scene Defines the scene to register the component in
  28690. */
  28691. constructor(scene: Scene);
  28692. /**
  28693. * Registers the component in a given scene
  28694. */
  28695. register(): void;
  28696. /**
  28697. * Rebuilds the elements related to this component in case of
  28698. * context lost for instance.
  28699. */
  28700. rebuild(): void;
  28701. /**
  28702. * Disposes the component and the associated ressources
  28703. */
  28704. dispose(): void;
  28705. private _beforeCameraUpdate;
  28706. }
  28707. }
  28708. declare module BABYLON {
  28709. /**
  28710. * Polygon
  28711. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28712. */
  28713. class Polygon {
  28714. /**
  28715. * Creates a rectangle
  28716. * @param xmin bottom X coord
  28717. * @param ymin bottom Y coord
  28718. * @param xmax top X coord
  28719. * @param ymax top Y coord
  28720. * @returns points that make the resulting rectation
  28721. */
  28722. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  28723. /**
  28724. * Creates a circle
  28725. * @param radius radius of circle
  28726. * @param cx scale in x
  28727. * @param cy scale in y
  28728. * @param numberOfSides number of sides that make up the circle
  28729. * @returns points that make the resulting circle
  28730. */
  28731. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  28732. /**
  28733. * Creates a polygon from input string
  28734. * @param input Input polygon data
  28735. * @returns the parsed points
  28736. */
  28737. static Parse(input: string): Vector2[];
  28738. /**
  28739. * Starts building a polygon from x and y coordinates
  28740. * @param x x coordinate
  28741. * @param y y coordinate
  28742. * @returns the started path2
  28743. */
  28744. static StartingAt(x: number, y: number): Path2;
  28745. }
  28746. /**
  28747. * Builds a polygon
  28748. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  28749. */
  28750. class PolygonMeshBuilder {
  28751. private _points;
  28752. private _outlinepoints;
  28753. private _holes;
  28754. private _name;
  28755. private _scene;
  28756. private _epoints;
  28757. private _eholes;
  28758. private _addToepoint;
  28759. /**
  28760. * Creates a PolygonMeshBuilder
  28761. * @param name name of the builder
  28762. * @param contours Path of the polygon
  28763. * @param scene scene to add to
  28764. */
  28765. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  28766. /**
  28767. * Adds a whole within the polygon
  28768. * @param hole Array of points defining the hole
  28769. * @returns this
  28770. */
  28771. addHole(hole: Vector2[]): PolygonMeshBuilder;
  28772. /**
  28773. * Creates the polygon
  28774. * @param updatable If the mesh should be updatable
  28775. * @param depth The depth of the mesh created
  28776. * @returns the created mesh
  28777. */
  28778. build(updatable?: boolean, depth?: number): Mesh;
  28779. /**
  28780. * Adds a side to the polygon
  28781. * @param positions points that make the polygon
  28782. * @param normals normals of the polygon
  28783. * @param uvs uvs of the polygon
  28784. * @param indices indices of the polygon
  28785. * @param bounds bounds of the polygon
  28786. * @param points points of the polygon
  28787. * @param depth depth of the polygon
  28788. * @param flip flip of the polygon
  28789. */
  28790. private addSide;
  28791. }
  28792. }
  28793. declare module BABYLON {
  28794. /**
  28795. * Base class for submeshes
  28796. */
  28797. class BaseSubMesh {
  28798. /** @hidden */
  28799. _materialDefines: Nullable<MaterialDefines>;
  28800. /** @hidden */
  28801. _materialEffect: Nullable<Effect>;
  28802. /**
  28803. * Gets associated effect
  28804. */
  28805. readonly effect: Nullable<Effect>;
  28806. /**
  28807. * Sets associated effect (effect used to render this submesh)
  28808. * @param effect defines the effect to associate with
  28809. * @param defines defines the set of defines used to compile this effect
  28810. */
  28811. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  28812. }
  28813. /**
  28814. * Defines a subdivision inside a mesh
  28815. */
  28816. class SubMesh extends BaseSubMesh implements ICullable {
  28817. /** the material index to use */
  28818. materialIndex: number;
  28819. /** vertex index start */
  28820. verticesStart: number;
  28821. /** vertices count */
  28822. verticesCount: number;
  28823. /** index start */
  28824. indexStart: number;
  28825. /** indices count */
  28826. indexCount: number;
  28827. /** @hidden */
  28828. _linesIndexCount: number;
  28829. private _mesh;
  28830. private _renderingMesh;
  28831. private _boundingInfo;
  28832. private _linesIndexBuffer;
  28833. /** @hidden */
  28834. _lastColliderWorldVertices: Nullable<Vector3[]>;
  28835. /** @hidden */
  28836. _trianglePlanes: Plane[];
  28837. /** @hidden */
  28838. _lastColliderTransformMatrix: Matrix;
  28839. /** @hidden */
  28840. _renderId: number;
  28841. /** @hidden */
  28842. _alphaIndex: number;
  28843. /** @hidden */
  28844. _distanceToCamera: number;
  28845. /** @hidden */
  28846. _id: number;
  28847. private _currentMaterial;
  28848. /**
  28849. * Add a new submesh to a mesh
  28850. * @param materialIndex defines the material index to use
  28851. * @param verticesStart defines vertex index start
  28852. * @param verticesCount defines vertices count
  28853. * @param indexStart defines index start
  28854. * @param indexCount defines indices count
  28855. * @param mesh defines the parent mesh
  28856. * @param renderingMesh defines an optional rendering mesh
  28857. * @param createBoundingBox defines if bounding box should be created for this submesh
  28858. * @returns the new submesh
  28859. */
  28860. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  28861. /**
  28862. * Creates a new submesh
  28863. * @param materialIndex defines the material index to use
  28864. * @param verticesStart defines vertex index start
  28865. * @param verticesCount defines vertices count
  28866. * @param indexStart defines index start
  28867. * @param indexCount defines indices count
  28868. * @param mesh defines the parent mesh
  28869. * @param renderingMesh defines an optional rendering mesh
  28870. * @param createBoundingBox defines if bounding box should be created for this submesh
  28871. */
  28872. constructor(
  28873. /** the material index to use */
  28874. materialIndex: number,
  28875. /** vertex index start */
  28876. verticesStart: number,
  28877. /** vertices count */
  28878. verticesCount: number,
  28879. /** index start */
  28880. indexStart: number,
  28881. /** indices count */
  28882. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  28883. /**
  28884. * Returns true if this submesh covers the entire parent mesh
  28885. * @ignorenaming
  28886. */
  28887. readonly IsGlobal: boolean;
  28888. /**
  28889. * Returns the submesh BoudingInfo object
  28890. * @returns current bounding info (or mesh's one if the submesh is global)
  28891. */
  28892. getBoundingInfo(): BoundingInfo;
  28893. /**
  28894. * Sets the submesh BoundingInfo
  28895. * @param boundingInfo defines the new bounding info to use
  28896. * @returns the SubMesh
  28897. */
  28898. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  28899. /**
  28900. * Returns the mesh of the current submesh
  28901. * @return the parent mesh
  28902. */
  28903. getMesh(): AbstractMesh;
  28904. /**
  28905. * Returns the rendering mesh of the submesh
  28906. * @returns the rendering mesh (could be different from parent mesh)
  28907. */
  28908. getRenderingMesh(): Mesh;
  28909. /**
  28910. * Returns the submesh material
  28911. * @returns null or the current material
  28912. */
  28913. getMaterial(): Nullable<Material>;
  28914. /**
  28915. * Sets a new updated BoundingInfo object to the submesh
  28916. * @returns the SubMesh
  28917. */
  28918. refreshBoundingInfo(): SubMesh;
  28919. /** @hidden */
  28920. _checkCollision(collider: Collider): boolean;
  28921. /**
  28922. * Updates the submesh BoundingInfo
  28923. * @param world defines the world matrix to use to update the bounding info
  28924. * @returns the submesh
  28925. */
  28926. updateBoundingInfo(world: Matrix): SubMesh;
  28927. /**
  28928. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  28929. * @param frustumPlanes defines the frustum planes
  28930. * @returns true if the submesh is intersecting with the frustum
  28931. */
  28932. isInFrustum(frustumPlanes: Plane[]): boolean;
  28933. /**
  28934. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  28935. * @param frustumPlanes defines the frustum planes
  28936. * @returns true if the submesh is inside the frustum
  28937. */
  28938. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28939. /**
  28940. * Renders the submesh
  28941. * @param enableAlphaMode defines if alpha needs to be used
  28942. * @returns the submesh
  28943. */
  28944. render(enableAlphaMode: boolean): SubMesh;
  28945. /**
  28946. * @hidden
  28947. */
  28948. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  28949. /**
  28950. * Checks if the submesh intersects with a ray
  28951. * @param ray defines the ray to test
  28952. * @returns true is the passed ray intersects the submesh bounding box
  28953. */
  28954. canIntersects(ray: Ray): boolean;
  28955. /**
  28956. * Intersects current submesh with a ray
  28957. * @param ray defines the ray to test
  28958. * @param positions defines mesh's positions array
  28959. * @param indices defines mesh's indices array
  28960. * @param fastCheck defines if only bounding info should be used
  28961. * @returns intersection info or null if no intersection
  28962. */
  28963. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  28964. /** @hidden */
  28965. private _intersectLines;
  28966. /** @hidden */
  28967. private _intersectTriangles;
  28968. /** @hidden */
  28969. _rebuild(): void;
  28970. /**
  28971. * Creates a new submesh from the passed mesh
  28972. * @param newMesh defines the new hosting mesh
  28973. * @param newRenderingMesh defines an optional rendering mesh
  28974. * @returns the new submesh
  28975. */
  28976. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  28977. /**
  28978. * Release associated resources
  28979. */
  28980. dispose(): void;
  28981. /**
  28982. * Creates a new submesh from indices data
  28983. * @param materialIndex the index of the main mesh material
  28984. * @param startIndex the index where to start the copy in the mesh indices array
  28985. * @param indexCount the number of indices to copy then from the startIndex
  28986. * @param mesh the main mesh to create the submesh from
  28987. * @param renderingMesh the optional rendering mesh
  28988. * @returns a new submesh
  28989. */
  28990. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  28991. }
  28992. }
  28993. declare module BABYLON {
  28994. /**
  28995. * 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.
  28996. * @see https://doc.babylonjs.com/how_to/transformnode
  28997. */
  28998. class TransformNode extends Node {
  28999. /**
  29000. * Object will not rotate to face the camera
  29001. */
  29002. static BILLBOARDMODE_NONE: number;
  29003. /**
  29004. * Object will rotate to face the camera but only on the x axis
  29005. */
  29006. static BILLBOARDMODE_X: number;
  29007. /**
  29008. * Object will rotate to face the camera but only on the y axis
  29009. */
  29010. static BILLBOARDMODE_Y: number;
  29011. /**
  29012. * Object will rotate to face the camera but only on the z axis
  29013. */
  29014. static BILLBOARDMODE_Z: number;
  29015. /**
  29016. * Object will rotate to face the camera
  29017. */
  29018. static BILLBOARDMODE_ALL: number;
  29019. private _forward;
  29020. private _forwardInverted;
  29021. private _up;
  29022. private _right;
  29023. private _rightInverted;
  29024. private _position;
  29025. private _rotation;
  29026. private _rotationQuaternion;
  29027. protected _scaling: Vector3;
  29028. protected _isDirty: boolean;
  29029. private _transformToBoneReferal;
  29030. /**
  29031. * Set the billboard mode. Default is 0.
  29032. *
  29033. * | Value | Type | Description |
  29034. * | --- | --- | --- |
  29035. * | 0 | BILLBOARDMODE_NONE | |
  29036. * | 1 | BILLBOARDMODE_X | |
  29037. * | 2 | BILLBOARDMODE_Y | |
  29038. * | 4 | BILLBOARDMODE_Z | |
  29039. * | 7 | BILLBOARDMODE_ALL | |
  29040. *
  29041. */
  29042. billboardMode: number;
  29043. /**
  29044. * 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
  29045. */
  29046. scalingDeterminant: number;
  29047. /**
  29048. * Sets the distance of the object to max, often used by skybox
  29049. */
  29050. infiniteDistance: boolean;
  29051. /**
  29052. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29053. * By default the system will update normals to compensate
  29054. */
  29055. ignoreNonUniformScaling: boolean;
  29056. /** @hidden */
  29057. _poseMatrix: Matrix;
  29058. private _localWorld;
  29059. private _absolutePosition;
  29060. private _pivotMatrix;
  29061. private _pivotMatrixInverse;
  29062. private _postMultiplyPivotMatrix;
  29063. protected _isWorldMatrixFrozen: boolean;
  29064. /** @hidden */
  29065. _indexInSceneTransformNodesArray: number;
  29066. /**
  29067. * An event triggered after the world matrix is updated
  29068. */
  29069. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29070. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29071. /**
  29072. * Gets a string identifying the name of the class
  29073. * @returns "TransformNode" string
  29074. */
  29075. getClassName(): string;
  29076. /**
  29077. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29078. */
  29079. position: Vector3;
  29080. /**
  29081. * 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)).
  29082. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29083. */
  29084. rotation: Vector3;
  29085. /**
  29086. * 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)).
  29087. */
  29088. scaling: Vector3;
  29089. /**
  29090. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  29091. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29092. */
  29093. rotationQuaternion: Nullable<Quaternion>;
  29094. /**
  29095. * The forward direction of that transform in world space.
  29096. */
  29097. readonly forward: Vector3;
  29098. /**
  29099. * The up direction of that transform in world space.
  29100. */
  29101. readonly up: Vector3;
  29102. /**
  29103. * The right direction of that transform in world space.
  29104. */
  29105. readonly right: Vector3;
  29106. /**
  29107. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29108. * @param matrix the matrix to copy the pose from
  29109. * @returns this TransformNode.
  29110. */
  29111. updatePoseMatrix(matrix: Matrix): TransformNode;
  29112. /**
  29113. * Returns the mesh Pose matrix.
  29114. * @returns the pose matrix
  29115. */
  29116. getPoseMatrix(): Matrix;
  29117. /** @hidden */
  29118. _isSynchronized(): boolean;
  29119. /** @hidden */
  29120. _initCache(): void;
  29121. /**
  29122. * Flag the transform node as dirty (Forcing it to update everything)
  29123. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29124. * @returns this transform node
  29125. */
  29126. markAsDirty(property: string): TransformNode;
  29127. /**
  29128. * Returns the current mesh absolute position.
  29129. * Returns a Vector3.
  29130. */
  29131. readonly absolutePosition: Vector3;
  29132. /**
  29133. * Sets a new matrix to apply before all other transformation
  29134. * @param matrix defines the transform matrix
  29135. * @returns the current TransformNode
  29136. */
  29137. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29138. /**
  29139. * Sets a new pivot matrix to the current node
  29140. * @param matrix defines the new pivot matrix to use
  29141. * @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
  29142. * @returns the current TransformNode
  29143. */
  29144. setPivotMatrix(matrix: Readonly<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  29145. /**
  29146. * Returns the mesh pivot matrix.
  29147. * Default : Identity.
  29148. * @returns the matrix
  29149. */
  29150. getPivotMatrix(): Matrix;
  29151. /**
  29152. * Prevents the World matrix to be computed any longer.
  29153. * @returns the TransformNode.
  29154. */
  29155. freezeWorldMatrix(): TransformNode;
  29156. /**
  29157. * Allows back the World matrix computation.
  29158. * @returns the TransformNode.
  29159. */
  29160. unfreezeWorldMatrix(): this;
  29161. /**
  29162. * True if the World matrix has been frozen.
  29163. */
  29164. readonly isWorldMatrixFrozen: boolean;
  29165. /**
  29166. * Retuns the mesh absolute position in the World.
  29167. * @returns a Vector3.
  29168. */
  29169. getAbsolutePosition(): Vector3;
  29170. /**
  29171. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29172. * @param absolutePosition the absolute position to set
  29173. * @returns the TransformNode.
  29174. */
  29175. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29176. /**
  29177. * Sets the mesh position in its local space.
  29178. * @param vector3 the position to set in localspace
  29179. * @returns the TransformNode.
  29180. */
  29181. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29182. /**
  29183. * Returns the mesh position in the local space from the current World matrix values.
  29184. * @returns a new Vector3.
  29185. */
  29186. getPositionExpressedInLocalSpace(): Vector3;
  29187. /**
  29188. * Translates the mesh along the passed Vector3 in its local space.
  29189. * @param vector3 the distance to translate in localspace
  29190. * @returns the TransformNode.
  29191. */
  29192. locallyTranslate(vector3: Vector3): TransformNode;
  29193. private static _lookAtVectorCache;
  29194. /**
  29195. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29196. * @param targetPoint the position (must be in same space as current mesh) to look at
  29197. * @param yawCor optional yaw (y-axis) correction in radians
  29198. * @param pitchCor optional pitch (x-axis) correction in radians
  29199. * @param rollCor optional roll (z-axis) correction in radians
  29200. * @param space the choosen space of the target
  29201. * @returns the TransformNode.
  29202. */
  29203. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29204. /**
  29205. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29206. * This Vector3 is expressed in the World space.
  29207. * @param localAxis axis to rotate
  29208. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29209. */
  29210. getDirection(localAxis: Vector3): Vector3;
  29211. /**
  29212. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29213. * localAxis is expressed in the mesh local space.
  29214. * result is computed in the Wordl space from the mesh World matrix.
  29215. * @param localAxis axis to rotate
  29216. * @param result the resulting transformnode
  29217. * @returns this TransformNode.
  29218. */
  29219. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29220. /**
  29221. * Sets a new pivot point to the current node
  29222. * @param point defines the new pivot point to use
  29223. * @param space defines if the point is in world or local space (local by default)
  29224. * @returns the current TransformNode
  29225. */
  29226. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29227. /**
  29228. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29229. * @returns the pivot point
  29230. */
  29231. getPivotPoint(): Vector3;
  29232. /**
  29233. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29234. * @param result the vector3 to store the result
  29235. * @returns this TransformNode.
  29236. */
  29237. getPivotPointToRef(result: Vector3): TransformNode;
  29238. /**
  29239. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29240. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29241. */
  29242. getAbsolutePivotPoint(): Vector3;
  29243. /**
  29244. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29245. * @param result vector3 to store the result
  29246. * @returns this TransformNode.
  29247. */
  29248. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29249. /**
  29250. * Defines the passed node as the parent of the current node.
  29251. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29252. * @param node the node ot set as the parent
  29253. * @returns this TransformNode.
  29254. */
  29255. setParent(node: Nullable<Node>): TransformNode;
  29256. private _nonUniformScaling;
  29257. /**
  29258. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29259. */
  29260. readonly nonUniformScaling: boolean;
  29261. /** @hidden */
  29262. _updateNonUniformScalingState(value: boolean): boolean;
  29263. /**
  29264. * Attach the current TransformNode to another TransformNode associated with a bone
  29265. * @param bone Bone affecting the TransformNode
  29266. * @param affectedTransformNode TransformNode associated with the bone
  29267. * @returns this object
  29268. */
  29269. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29270. /**
  29271. * Detach the transform node if its associated with a bone
  29272. * @returns this object
  29273. */
  29274. detachFromBone(): TransformNode;
  29275. private static _rotationAxisCache;
  29276. /**
  29277. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29278. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29279. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29280. * The passed axis is also normalized.
  29281. * @param axis the axis to rotate around
  29282. * @param amount the amount to rotate in radians
  29283. * @param space Space to rotate in (Default: local)
  29284. * @returns the TransformNode.
  29285. */
  29286. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29287. /**
  29288. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29289. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29290. * The passed axis is also normalized. .
  29291. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29292. * @param point the point to rotate around
  29293. * @param axis the axis to rotate around
  29294. * @param amount the amount to rotate in radians
  29295. * @returns the TransformNode
  29296. */
  29297. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29298. /**
  29299. * Translates the mesh along the axis vector for the passed distance in the given space.
  29300. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29301. * @param axis the axis to translate in
  29302. * @param distance the distance to translate
  29303. * @param space Space to rotate in (Default: local)
  29304. * @returns the TransformNode.
  29305. */
  29306. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29307. /**
  29308. * Adds a rotation step to the mesh current rotation.
  29309. * x, y, z are Euler angles expressed in radians.
  29310. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29311. * This means this rotation is made in the mesh local space only.
  29312. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29313. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29314. * ```javascript
  29315. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29316. * ```
  29317. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29318. * 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.
  29319. * @param x Rotation to add
  29320. * @param y Rotation to add
  29321. * @param z Rotation to add
  29322. * @returns the TransformNode.
  29323. */
  29324. addRotation(x: number, y: number, z: number): TransformNode;
  29325. /**
  29326. * Computes the world matrix of the node
  29327. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29328. * @returns the world matrix
  29329. */
  29330. computeWorldMatrix(force?: boolean): Matrix;
  29331. protected _afterComputeWorldMatrix(): void;
  29332. /**
  29333. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29334. * @param func callback function to add
  29335. *
  29336. * @returns the TransformNode.
  29337. */
  29338. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29339. /**
  29340. * Removes a registered callback function.
  29341. * @param func callback function to remove
  29342. * @returns the TransformNode.
  29343. */
  29344. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29345. /**
  29346. * Clone the current transform node
  29347. * @param name Name of the new clone
  29348. * @param newParent New parent for the clone
  29349. * @param doNotCloneChildren Do not clone children hierarchy
  29350. * @returns the new transform node
  29351. */
  29352. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  29353. /**
  29354. * Serializes the objects information.
  29355. * @param currentSerializationObject defines the object to serialize in
  29356. * @returns the serialized object
  29357. */
  29358. serialize(currentSerializationObject?: any): any;
  29359. /**
  29360. * Returns a new TransformNode object parsed from the source provided.
  29361. * @param parsedTransformNode is the source.
  29362. * @param scene the scne the object belongs to
  29363. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  29364. * @returns a new TransformNode object parsed from the source provided.
  29365. */
  29366. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  29367. /**
  29368. * Releases resources associated with this transform node.
  29369. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29370. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29371. */
  29372. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29373. }
  29374. }
  29375. declare module BABYLON {
  29376. /**
  29377. * Specialized buffer used to store vertex data
  29378. */
  29379. class VertexBuffer {
  29380. /** @hidden */
  29381. _buffer: Buffer;
  29382. private _kind;
  29383. private _size;
  29384. private _ownsBuffer;
  29385. private _instanced;
  29386. private _instanceDivisor;
  29387. /**
  29388. * The byte type.
  29389. */
  29390. static readonly BYTE: number;
  29391. /**
  29392. * The unsigned byte type.
  29393. */
  29394. static readonly UNSIGNED_BYTE: number;
  29395. /**
  29396. * The short type.
  29397. */
  29398. static readonly SHORT: number;
  29399. /**
  29400. * The unsigned short type.
  29401. */
  29402. static readonly UNSIGNED_SHORT: number;
  29403. /**
  29404. * The integer type.
  29405. */
  29406. static readonly INT: number;
  29407. /**
  29408. * The unsigned integer type.
  29409. */
  29410. static readonly UNSIGNED_INT: number;
  29411. /**
  29412. * The float type.
  29413. */
  29414. static readonly FLOAT: number;
  29415. /**
  29416. * Gets or sets the instance divisor when in instanced mode
  29417. */
  29418. instanceDivisor: number;
  29419. /**
  29420. * Gets the byte stride.
  29421. */
  29422. readonly byteStride: number;
  29423. /**
  29424. * Gets the byte offset.
  29425. */
  29426. readonly byteOffset: number;
  29427. /**
  29428. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  29429. */
  29430. readonly normalized: boolean;
  29431. /**
  29432. * Gets the data type of each component in the array.
  29433. */
  29434. readonly type: number;
  29435. /**
  29436. * Constructor
  29437. * @param engine the engine
  29438. * @param data the data to use for this vertex buffer
  29439. * @param kind the vertex buffer kind
  29440. * @param updatable whether the data is updatable
  29441. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  29442. * @param stride the stride (optional)
  29443. * @param instanced whether the buffer is instanced (optional)
  29444. * @param offset the offset of the data (optional)
  29445. * @param size the number of components (optional)
  29446. * @param type the type of the component (optional)
  29447. * @param normalized whether the data contains normalized data (optional)
  29448. * @param useBytes set to true if stride and offset are in bytes (optional)
  29449. */
  29450. 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);
  29451. /** @hidden */
  29452. _rebuild(): void;
  29453. /**
  29454. * Returns the kind of the VertexBuffer (string)
  29455. * @returns a string
  29456. */
  29457. getKind(): string;
  29458. /**
  29459. * Gets a boolean indicating if the VertexBuffer is updatable?
  29460. * @returns true if the buffer is updatable
  29461. */
  29462. isUpdatable(): boolean;
  29463. /**
  29464. * Gets current buffer's data
  29465. * @returns a DataArray or null
  29466. */
  29467. getData(): Nullable<DataArray>;
  29468. /**
  29469. * Gets underlying native buffer
  29470. * @returns underlying native buffer
  29471. */
  29472. getBuffer(): Nullable<WebGLBuffer>;
  29473. /**
  29474. * Gets the stride in float32 units (i.e. byte stride / 4).
  29475. * May not be an integer if the byte stride is not divisible by 4.
  29476. * DEPRECATED. Use byteStride instead.
  29477. * @returns the stride in float32 units
  29478. */
  29479. getStrideSize(): number;
  29480. /**
  29481. * Returns the offset as a multiple of the type byte length.
  29482. * DEPRECATED. Use byteOffset instead.
  29483. * @returns the offset in bytes
  29484. */
  29485. getOffset(): number;
  29486. /**
  29487. * Returns the number of components per vertex attribute (integer)
  29488. * @returns the size in float
  29489. */
  29490. getSize(): number;
  29491. /**
  29492. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  29493. * @returns true if this buffer is instanced
  29494. */
  29495. getIsInstanced(): boolean;
  29496. /**
  29497. * Returns the instancing divisor, zero for non-instanced (integer).
  29498. * @returns a number
  29499. */
  29500. getInstanceDivisor(): number;
  29501. /**
  29502. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29503. * @param data defines the data to store
  29504. */
  29505. create(data?: DataArray): void;
  29506. /**
  29507. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29508. * This function will create a new buffer if the current one is not updatable
  29509. * @param data defines the data to store
  29510. */
  29511. update(data: DataArray): void;
  29512. /**
  29513. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29514. * Returns the directly updated WebGLBuffer.
  29515. * @param data the new data
  29516. * @param offset the new offset
  29517. * @param useBytes set to true if the offset is in bytes
  29518. */
  29519. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29520. /**
  29521. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29522. */
  29523. dispose(): void;
  29524. /**
  29525. * Enumerates each value of this vertex buffer as numbers.
  29526. * @param count the number of values to enumerate
  29527. * @param callback the callback function called for each value
  29528. */
  29529. forEach(count: number, callback: (value: number, index: number) => void): void;
  29530. /**
  29531. * Positions
  29532. */
  29533. static readonly PositionKind: string;
  29534. /**
  29535. * Normals
  29536. */
  29537. static readonly NormalKind: string;
  29538. /**
  29539. * Tangents
  29540. */
  29541. static readonly TangentKind: string;
  29542. /**
  29543. * Texture coordinates
  29544. */
  29545. static readonly UVKind: string;
  29546. /**
  29547. * Texture coordinates 2
  29548. */
  29549. static readonly UV2Kind: string;
  29550. /**
  29551. * Texture coordinates 3
  29552. */
  29553. static readonly UV3Kind: string;
  29554. /**
  29555. * Texture coordinates 4
  29556. */
  29557. static readonly UV4Kind: string;
  29558. /**
  29559. * Texture coordinates 5
  29560. */
  29561. static readonly UV5Kind: string;
  29562. /**
  29563. * Texture coordinates 6
  29564. */
  29565. static readonly UV6Kind: string;
  29566. /**
  29567. * Colors
  29568. */
  29569. static readonly ColorKind: string;
  29570. /**
  29571. * Matrix indices (for bones)
  29572. */
  29573. static readonly MatricesIndicesKind: string;
  29574. /**
  29575. * Matrix weights (for bones)
  29576. */
  29577. static readonly MatricesWeightsKind: string;
  29578. /**
  29579. * Additional matrix indices (for bones)
  29580. */
  29581. static readonly MatricesIndicesExtraKind: string;
  29582. /**
  29583. * Additional matrix weights (for bones)
  29584. */
  29585. static readonly MatricesWeightsExtraKind: string;
  29586. /**
  29587. * Deduces the stride given a kind.
  29588. * @param kind The kind string to deduce
  29589. * @returns The deduced stride
  29590. */
  29591. static DeduceStride(kind: string): number;
  29592. /**
  29593. * Gets the byte length of the given type.
  29594. * @param type the type
  29595. * @returns the number of bytes
  29596. */
  29597. static GetTypeByteLength(type: number): number;
  29598. /**
  29599. * Enumerates each value of the given parameters as numbers.
  29600. * @param data the data to enumerate
  29601. * @param byteOffset the byte offset of the data
  29602. * @param byteStride the byte stride of the data
  29603. * @param componentCount the number of components per element
  29604. * @param componentType the type of the component
  29605. * @param count the total number of components
  29606. * @param normalized whether the data is normalized
  29607. * @param callback the callback function called for each value
  29608. */
  29609. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  29610. private static _GetFloatValue;
  29611. }
  29612. }
  29613. declare module BABYLON {
  29614. /**
  29615. * Class used to enable access to IndexedDB
  29616. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  29617. */
  29618. class Database implements IOfflineProvider {
  29619. private _callbackManifestChecked;
  29620. private _currentSceneUrl;
  29621. private _db;
  29622. private _enableSceneOffline;
  29623. private _enableTexturesOffline;
  29624. private _manifestVersionFound;
  29625. private _mustUpdateRessources;
  29626. private _hasReachedQuota;
  29627. private _isSupported;
  29628. private _idbFactory;
  29629. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  29630. private static IsUASupportingBlobStorage;
  29631. /**
  29632. * Gets a boolean indicating if Database storate is enabled (off by default)
  29633. */
  29634. static IDBStorageEnabled: boolean;
  29635. /**
  29636. * Gets a boolean indicating if scene must be saved in the database
  29637. */
  29638. readonly enableSceneOffline: boolean;
  29639. /**
  29640. * Gets a boolean indicating if textures must be saved in the database
  29641. */
  29642. readonly enableTexturesOffline: boolean;
  29643. /**
  29644. * Creates a new Database
  29645. * @param urlToScene defines the url to load the scene
  29646. * @param callbackManifestChecked defines the callback to use when manifest is checked
  29647. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  29648. */
  29649. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  29650. private static _ParseURL;
  29651. private static _ReturnFullUrlLocation;
  29652. private _checkManifestFile;
  29653. /**
  29654. * Open the database and make it available
  29655. * @param successCallback defines the callback to call on success
  29656. * @param errorCallback defines the callback to call on error
  29657. */
  29658. open(successCallback: () => void, errorCallback: () => void): void;
  29659. /**
  29660. * Loads an image from the database
  29661. * @param url defines the url to load from
  29662. * @param image defines the target DOM image
  29663. */
  29664. loadImage(url: string, image: HTMLImageElement): void;
  29665. private _loadImageFromDBAsync;
  29666. private _saveImageIntoDBAsync;
  29667. private _checkVersionFromDB;
  29668. private _loadVersionFromDBAsync;
  29669. private _saveVersionIntoDBAsync;
  29670. /**
  29671. * Loads a file from database
  29672. * @param url defines the URL to load from
  29673. * @param sceneLoaded defines a callback to call on success
  29674. * @param progressCallBack defines a callback to call when progress changed
  29675. * @param errorCallback defines a callback to call on error
  29676. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  29677. */
  29678. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  29679. private _loadFileAsync;
  29680. private _saveFileAsync;
  29681. }
  29682. }
  29683. declare module BABYLON {
  29684. /**
  29685. * Class used to enable access to offline support
  29686. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  29687. */
  29688. interface IOfflineProvider {
  29689. /**
  29690. * Gets a boolean indicating if scene must be saved in the database
  29691. */
  29692. enableSceneOffline: boolean;
  29693. /**
  29694. * Gets a boolean indicating if textures must be saved in the database
  29695. */
  29696. enableTexturesOffline: boolean;
  29697. /**
  29698. * Open the offline support and make it available
  29699. * @param successCallback defines the callback to call on success
  29700. * @param errorCallback defines the callback to call on error
  29701. */
  29702. open(successCallback: () => void, errorCallback: () => void): void;
  29703. /**
  29704. * Loads an image from the offline support
  29705. * @param url defines the url to load from
  29706. * @param image defines the target DOM image
  29707. */
  29708. loadImage(url: string, image: HTMLImageElement): void;
  29709. /**
  29710. * Loads a file from offline support
  29711. * @param url defines the URL to load from
  29712. * @param sceneLoaded defines a callback to call on success
  29713. * @param progressCallBack defines a callback to call when progress changed
  29714. * @param errorCallback defines a callback to call on error
  29715. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  29716. */
  29717. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  29718. }
  29719. }
  29720. declare module BABYLON {
  29721. /**
  29722. * Defines a target to use with MorphTargetManager
  29723. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29724. */
  29725. class MorphTarget implements IAnimatable {
  29726. /** defines the name of the target */
  29727. name: string;
  29728. /**
  29729. * Gets or sets the list of animations
  29730. */
  29731. animations: Animation[];
  29732. private _scene;
  29733. private _positions;
  29734. private _normals;
  29735. private _tangents;
  29736. private _influence;
  29737. /**
  29738. * Observable raised when the influence changes
  29739. */
  29740. onInfluenceChanged: Observable<boolean>;
  29741. /** @hidden */
  29742. _onDataLayoutChanged: Observable<void>;
  29743. /**
  29744. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  29745. */
  29746. influence: number;
  29747. private _animationPropertiesOverride;
  29748. /**
  29749. * Gets or sets the animation properties override
  29750. */
  29751. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  29752. /**
  29753. * Creates a new MorphTarget
  29754. * @param name defines the name of the target
  29755. * @param influence defines the influence to use
  29756. */
  29757. constructor(
  29758. /** defines the name of the target */
  29759. name: string, influence?: number, scene?: Nullable<Scene>);
  29760. /**
  29761. * Gets a boolean defining if the target contains position data
  29762. */
  29763. readonly hasPositions: boolean;
  29764. /**
  29765. * Gets a boolean defining if the target contains normal data
  29766. */
  29767. readonly hasNormals: boolean;
  29768. /**
  29769. * Gets a boolean defining if the target contains tangent data
  29770. */
  29771. readonly hasTangents: boolean;
  29772. /**
  29773. * Affects position data to this target
  29774. * @param data defines the position data to use
  29775. */
  29776. setPositions(data: Nullable<FloatArray>): void;
  29777. /**
  29778. * Gets the position data stored in this target
  29779. * @returns a FloatArray containing the position data (or null if not present)
  29780. */
  29781. getPositions(): Nullable<FloatArray>;
  29782. /**
  29783. * Affects normal data to this target
  29784. * @param data defines the normal data to use
  29785. */
  29786. setNormals(data: Nullable<FloatArray>): void;
  29787. /**
  29788. * Gets the normal data stored in this target
  29789. * @returns a FloatArray containing the normal data (or null if not present)
  29790. */
  29791. getNormals(): Nullable<FloatArray>;
  29792. /**
  29793. * Affects tangent data to this target
  29794. * @param data defines the tangent data to use
  29795. */
  29796. setTangents(data: Nullable<FloatArray>): void;
  29797. /**
  29798. * Gets the tangent data stored in this target
  29799. * @returns a FloatArray containing the tangent data (or null if not present)
  29800. */
  29801. getTangents(): Nullable<FloatArray>;
  29802. /**
  29803. * Serializes the current target into a Serialization object
  29804. * @returns the serialized object
  29805. */
  29806. serialize(): any;
  29807. /**
  29808. * Creates a new target from serialized data
  29809. * @param serializationObject defines the serialized data to use
  29810. * @returns a new MorphTarget
  29811. */
  29812. static Parse(serializationObject: any): MorphTarget;
  29813. /**
  29814. * Creates a MorphTarget from mesh data
  29815. * @param mesh defines the source mesh
  29816. * @param name defines the name to use for the new target
  29817. * @param influence defines the influence to attach to the target
  29818. * @returns a new MorphTarget
  29819. */
  29820. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  29821. }
  29822. }
  29823. declare module BABYLON {
  29824. /**
  29825. * This class is used to deform meshes using morphing between different targets
  29826. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29827. */
  29828. class MorphTargetManager {
  29829. private _targets;
  29830. private _targetInfluenceChangedObservers;
  29831. private _targetDataLayoutChangedObservers;
  29832. private _activeTargets;
  29833. private _scene;
  29834. private _influences;
  29835. private _supportsNormals;
  29836. private _supportsTangents;
  29837. private _vertexCount;
  29838. private _uniqueId;
  29839. private _tempInfluences;
  29840. /**
  29841. * Creates a new MorphTargetManager
  29842. * @param scene defines the current scene
  29843. */
  29844. constructor(scene?: Nullable<Scene>);
  29845. /**
  29846. * Gets the unique ID of this manager
  29847. */
  29848. readonly uniqueId: number;
  29849. /**
  29850. * Gets the number of vertices handled by this manager
  29851. */
  29852. readonly vertexCount: number;
  29853. /**
  29854. * Gets a boolean indicating if this manager supports morphing of normals
  29855. */
  29856. readonly supportsNormals: boolean;
  29857. /**
  29858. * Gets a boolean indicating if this manager supports morphing of tangents
  29859. */
  29860. readonly supportsTangents: boolean;
  29861. /**
  29862. * Gets the number of targets stored in this manager
  29863. */
  29864. readonly numTargets: number;
  29865. /**
  29866. * Gets the number of influencers (ie. the number of targets with influences > 0)
  29867. */
  29868. readonly numInfluencers: number;
  29869. /**
  29870. * Gets the list of influences (one per target)
  29871. */
  29872. readonly influences: Float32Array;
  29873. /**
  29874. * Gets the active target at specified index. An active target is a target with an influence > 0
  29875. * @param index defines the index to check
  29876. * @returns the requested target
  29877. */
  29878. getActiveTarget(index: number): MorphTarget;
  29879. /**
  29880. * Gets the target at specified index
  29881. * @param index defines the index to check
  29882. * @returns the requested target
  29883. */
  29884. getTarget(index: number): MorphTarget;
  29885. /**
  29886. * Add a new target to this manager
  29887. * @param target defines the target to add
  29888. */
  29889. addTarget(target: MorphTarget): void;
  29890. /**
  29891. * Removes a target from the manager
  29892. * @param target defines the target to remove
  29893. */
  29894. removeTarget(target: MorphTarget): void;
  29895. /**
  29896. * Serializes the current manager into a Serialization object
  29897. * @returns the serialized object
  29898. */
  29899. serialize(): any;
  29900. private _syncActiveTargets;
  29901. /**
  29902. * Syncrhonize the targets with all the meshes using this morph target manager
  29903. */
  29904. synchronize(): void;
  29905. /**
  29906. * Creates a new MorphTargetManager from serialized data
  29907. * @param serializationObject defines the serialized data
  29908. * @param scene defines the hosting scene
  29909. * @returns the new MorphTargetManager
  29910. */
  29911. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  29912. }
  29913. }
  29914. declare module BABYLON {
  29915. /**
  29916. * Interface used to describe a physics joint
  29917. */
  29918. interface PhysicsImpostorJoint {
  29919. /** Defines the main impostor to which the joint is linked */
  29920. mainImpostor: PhysicsImpostor;
  29921. /** Defines the impostor that is connected to the main impostor using this joint */
  29922. connectedImpostor: PhysicsImpostor;
  29923. /** Defines the joint itself */
  29924. joint: PhysicsJoint;
  29925. }
  29926. /** @hidden */
  29927. interface IPhysicsEnginePlugin {
  29928. world: any;
  29929. name: string;
  29930. setGravity(gravity: Vector3): void;
  29931. setTimeStep(timeStep: number): void;
  29932. getTimeStep(): number;
  29933. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  29934. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  29935. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  29936. generatePhysicsBody(impostor: PhysicsImpostor): void;
  29937. removePhysicsBody(impostor: PhysicsImpostor): void;
  29938. generateJoint(joint: PhysicsImpostorJoint): void;
  29939. removeJoint(joint: PhysicsImpostorJoint): void;
  29940. isSupported(): boolean;
  29941. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  29942. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  29943. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  29944. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  29945. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  29946. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  29947. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  29948. getBodyMass(impostor: PhysicsImpostor): number;
  29949. getBodyFriction(impostor: PhysicsImpostor): number;
  29950. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  29951. getBodyRestitution(impostor: PhysicsImpostor): number;
  29952. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  29953. sleepBody(impostor: PhysicsImpostor): void;
  29954. wakeUpBody(impostor: PhysicsImpostor): void;
  29955. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  29956. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  29957. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  29958. getRadius(impostor: PhysicsImpostor): number;
  29959. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  29960. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  29961. dispose(): void;
  29962. }
  29963. /**
  29964. * Interface used to define a physics engine
  29965. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  29966. */
  29967. interface IPhysicsEngine {
  29968. /**
  29969. * Gets the gravity vector used by the simulation
  29970. */
  29971. gravity: Vector3;
  29972. /**
  29973. * Sets the gravity vector used by the simulation
  29974. * @param gravity defines the gravity vector to use
  29975. */
  29976. setGravity(gravity: Vector3): void;
  29977. /**
  29978. * Set the time step of the physics engine.
  29979. * Default is 1/60.
  29980. * To slow it down, enter 1/600 for example.
  29981. * To speed it up, 1/30
  29982. * @param newTimeStep the new timestep to apply to this world.
  29983. */
  29984. setTimeStep(newTimeStep: number): void;
  29985. /**
  29986. * Get the time step of the physics engine.
  29987. * @returns the current time step
  29988. */
  29989. getTimeStep(): number;
  29990. /**
  29991. * Release all resources
  29992. */
  29993. dispose(): void;
  29994. /**
  29995. * Gets the name of the current physics plugin
  29996. * @returns the name of the plugin
  29997. */
  29998. getPhysicsPluginName(): string;
  29999. /**
  30000. * Adding a new impostor for the impostor tracking.
  30001. * This will be done by the impostor itself.
  30002. * @param impostor the impostor to add
  30003. */
  30004. addImpostor(impostor: PhysicsImpostor): void;
  30005. /**
  30006. * Remove an impostor from the engine.
  30007. * This impostor and its mesh will not longer be updated by the physics engine.
  30008. * @param impostor the impostor to remove
  30009. */
  30010. removeImpostor(impostor: PhysicsImpostor): void;
  30011. /**
  30012. * Add a joint to the physics engine
  30013. * @param mainImpostor defines the main impostor to which the joint is added.
  30014. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  30015. * @param joint defines the joint that will connect both impostors.
  30016. */
  30017. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30018. /**
  30019. * Removes a joint from the simulation
  30020. * @param mainImpostor defines the impostor used with the joint
  30021. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  30022. * @param joint defines the joint to remove
  30023. */
  30024. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30025. /**
  30026. * Gets the current plugin used to run the simulation
  30027. * @returns current plugin
  30028. */
  30029. getPhysicsPlugin(): IPhysicsEnginePlugin;
  30030. /**
  30031. * Gets the list of physic impostors
  30032. * @returns an array of PhysicsImpostor
  30033. */
  30034. getImpostors(): Array<PhysicsImpostor>;
  30035. /**
  30036. * Gets the impostor for a physics enabled object
  30037. * @param object defines the object impersonated by the impostor
  30038. * @returns the PhysicsImpostor or null if not found
  30039. */
  30040. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  30041. /**
  30042. * Gets the impostor for a physics body object
  30043. * @param body defines physics body used by the impostor
  30044. * @returns the PhysicsImpostor or null if not found
  30045. */
  30046. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  30047. /**
  30048. * Called by the scene. No need to call it.
  30049. * @param delta defines the timespam between frames
  30050. */
  30051. _step(delta: number): void;
  30052. }
  30053. }
  30054. declare module BABYLON {
  30055. /**
  30056. * Class used to control physics engine
  30057. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  30058. */
  30059. class PhysicsEngine implements IPhysicsEngine {
  30060. private _physicsPlugin;
  30061. /**
  30062. * Global value used to control the smallest number supported by the simulation
  30063. */
  30064. static Epsilon: number;
  30065. private _impostors;
  30066. private _joints;
  30067. /**
  30068. * Gets the gravity vector used by the simulation
  30069. */
  30070. gravity: Vector3;
  30071. /**
  30072. * Creates a new Physics Engine
  30073. * @param gravity defines the gravity vector used by the simulation
  30074. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  30075. */
  30076. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  30077. /**
  30078. * Sets the gravity vector used by the simulation
  30079. * @param gravity defines the gravity vector to use
  30080. */
  30081. setGravity(gravity: Vector3): void;
  30082. /**
  30083. * Set the time step of the physics engine.
  30084. * Default is 1/60.
  30085. * To slow it down, enter 1/600 for example.
  30086. * To speed it up, 1/30
  30087. * @param newTimeStep defines the new timestep to apply to this world.
  30088. */
  30089. setTimeStep(newTimeStep?: number): void;
  30090. /**
  30091. * Get the time step of the physics engine.
  30092. * @returns the current time step
  30093. */
  30094. getTimeStep(): number;
  30095. /**
  30096. * Release all resources
  30097. */
  30098. dispose(): void;
  30099. /**
  30100. * Gets the name of the current physics plugin
  30101. * @returns the name of the plugin
  30102. */
  30103. getPhysicsPluginName(): string;
  30104. /**
  30105. * Adding a new impostor for the impostor tracking.
  30106. * This will be done by the impostor itself.
  30107. * @param impostor the impostor to add
  30108. */
  30109. addImpostor(impostor: PhysicsImpostor): void;
  30110. /**
  30111. * Remove an impostor from the engine.
  30112. * This impostor and its mesh will not longer be updated by the physics engine.
  30113. * @param impostor the impostor to remove
  30114. */
  30115. removeImpostor(impostor: PhysicsImpostor): void;
  30116. /**
  30117. * Add a joint to the physics engine
  30118. * @param mainImpostor defines the main impostor to which the joint is added.
  30119. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  30120. * @param joint defines the joint that will connect both impostors.
  30121. */
  30122. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30123. /**
  30124. * Removes a joint from the simulation
  30125. * @param mainImpostor defines the impostor used with the joint
  30126. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  30127. * @param joint defines the joint to remove
  30128. */
  30129. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30130. /**
  30131. * Called by the scene. No need to call it.
  30132. * @param delta defines the timespam between frames
  30133. */
  30134. _step(delta: number): void;
  30135. /**
  30136. * Gets the current plugin used to run the simulation
  30137. * @returns current plugin
  30138. */
  30139. getPhysicsPlugin(): IPhysicsEnginePlugin;
  30140. /**
  30141. * Gets the list of physic impostors
  30142. * @returns an array of PhysicsImpostor
  30143. */
  30144. getImpostors(): Array<PhysicsImpostor>;
  30145. /**
  30146. * Gets the impostor for a physics enabled object
  30147. * @param object defines the object impersonated by the impostor
  30148. * @returns the PhysicsImpostor or null if not found
  30149. */
  30150. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  30151. /**
  30152. * Gets the impostor for a physics body object
  30153. * @param body defines physics body used by the impostor
  30154. * @returns the PhysicsImpostor or null if not found
  30155. */
  30156. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  30157. }
  30158. }
  30159. declare module BABYLON {
  30160. interface Scene {
  30161. /** @hidden (Backing field) */
  30162. _physicsEngine: Nullable<IPhysicsEngine>;
  30163. /**
  30164. * Gets the current physics engine
  30165. * @returns a IPhysicsEngine or null if none attached
  30166. */
  30167. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  30168. /**
  30169. * Enables physics to the current scene
  30170. * @param gravity defines the scene's gravity for the physics engine
  30171. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  30172. * @return a boolean indicating if the physics engine was initialized
  30173. */
  30174. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  30175. /**
  30176. * Disables and disposes the physics engine associated with the scene
  30177. */
  30178. disablePhysicsEngine(): void;
  30179. /**
  30180. * Gets a boolean indicating if there is an active physics engine
  30181. * @returns a boolean indicating if there is an active physics engine
  30182. */
  30183. isPhysicsEnabled(): boolean;
  30184. /**
  30185. * Deletes a physics compound impostor
  30186. * @param compound defines the compound to delete
  30187. */
  30188. deleteCompoundImpostor(compound: any): void;
  30189. /**
  30190. * An event triggered when physic simulation is about to be run
  30191. */
  30192. onBeforePhysicsObservable: Observable<Scene>;
  30193. /**
  30194. * An event triggered when physic simulation has been done
  30195. */
  30196. onAfterPhysicsObservable: Observable<Scene>;
  30197. }
  30198. interface AbstractMesh {
  30199. /** @hidden */
  30200. _physicsImpostor: Nullable<PhysicsImpostor>;
  30201. /**
  30202. * Gets or sets impostor used for physic simulation
  30203. * @see http://doc.babylonjs.com/features/physics_engine
  30204. */
  30205. physicsImpostor: Nullable<PhysicsImpostor>;
  30206. /**
  30207. * Gets the current physics impostor
  30208. * @see http://doc.babylonjs.com/features/physics_engine
  30209. * @returns a physics impostor or null
  30210. */
  30211. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  30212. /** Apply a physic impulse to the mesh
  30213. * @param force defines the force to apply
  30214. * @param contactPoint defines where to apply the force
  30215. * @returns the current mesh
  30216. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  30217. */
  30218. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  30219. /**
  30220. * Creates a physic joint between two meshes
  30221. * @param otherMesh defines the other mesh to use
  30222. * @param pivot1 defines the pivot to use on this mesh
  30223. * @param pivot2 defines the pivot to use on the other mesh
  30224. * @param options defines additional options (can be plugin dependent)
  30225. * @returns the current mesh
  30226. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  30227. */
  30228. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  30229. /** @hidden */
  30230. _disposePhysicsObserver: Nullable<Observer<Node>>;
  30231. }
  30232. /**
  30233. * Defines the physics engine scene component responsible to manage a physics engine
  30234. */
  30235. class PhysicsEngineSceneComponent implements ISceneComponent {
  30236. /**
  30237. * The component name helpful to identify the component in the list of scene components.
  30238. */
  30239. readonly name: string;
  30240. /**
  30241. * The scene the component belongs to.
  30242. */
  30243. scene: Scene;
  30244. /**
  30245. * Creates a new instance of the component for the given scene
  30246. * @param scene Defines the scene to register the component in
  30247. */
  30248. constructor(scene: Scene);
  30249. /**
  30250. * Registers the component in a given scene
  30251. */
  30252. register(): void;
  30253. /**
  30254. * Rebuilds the elements related to this component in case of
  30255. * context lost for instance.
  30256. */
  30257. rebuild(): void;
  30258. /**
  30259. * Disposes the component and the associated ressources
  30260. */
  30261. dispose(): void;
  30262. }
  30263. }
  30264. declare module BABYLON {
  30265. /**
  30266. * A helper for physics simulations
  30267. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30268. */
  30269. class PhysicsHelper {
  30270. private _scene;
  30271. private _physicsEngine;
  30272. /**
  30273. * Initializes the Physics helper
  30274. * @param scene Babylon.js scene
  30275. */
  30276. constructor(scene: Scene);
  30277. /**
  30278. * Applies a radial explosion impulse
  30279. * @param origin the origin of the explosion
  30280. * @param radius the explosion radius
  30281. * @param strength the explosion strength
  30282. * @param falloff possible options: Constant & Linear. Defaults to Constant
  30283. * @returns A physics radial explosion event, or null
  30284. */
  30285. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  30286. /**
  30287. * Applies a radial explosion force
  30288. * @param origin the origin of the explosion
  30289. * @param radius the explosion radius
  30290. * @param strength the explosion strength
  30291. * @param falloff possible options: Constant & Linear. Defaults to Constant
  30292. * @returns A physics radial explosion event, or null
  30293. */
  30294. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  30295. /**
  30296. * Creates a gravitational field
  30297. * @param origin the origin of the explosion
  30298. * @param radius the explosion radius
  30299. * @param strength the explosion strength
  30300. * @param falloff possible options: Constant & Linear. Defaults to Constant
  30301. * @returns A physics gravitational field event, or null
  30302. */
  30303. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  30304. /**
  30305. * Creates a physics updraft event
  30306. * @param origin the origin of the updraft
  30307. * @param radius the radius of the updraft
  30308. * @param strength the strength of the updraft
  30309. * @param height the height of the updraft
  30310. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  30311. * @returns A physics updraft event, or null
  30312. */
  30313. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  30314. /**
  30315. * Creates a physics vortex event
  30316. * @param origin the of the vortex
  30317. * @param radius the radius of the vortex
  30318. * @param strength the strength of the vortex
  30319. * @param height the height of the vortex
  30320. * @returns a Physics vortex event, or null
  30321. * A physics vortex event or null
  30322. */
  30323. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  30324. }
  30325. /**
  30326. * Represents a physics radial explosion event
  30327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30328. */
  30329. class PhysicsRadialExplosionEvent {
  30330. private _scene;
  30331. private _sphere;
  30332. private _sphereOptions;
  30333. private _rays;
  30334. private _dataFetched;
  30335. /**
  30336. * Initializes a radial explosioin event
  30337. * @param scene BabylonJS scene
  30338. */
  30339. constructor(scene: Scene);
  30340. /**
  30341. * Returns the data related to the radial explosion event (sphere & rays).
  30342. * @returns The radial explosion event data
  30343. */
  30344. getData(): PhysicsRadialExplosionEventData;
  30345. /**
  30346. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  30347. * @param impostor A physics imposter
  30348. * @param origin the origin of the explosion
  30349. * @param radius the explosion radius
  30350. * @param strength the explosion strength
  30351. * @param falloff possible options: Constant & Linear
  30352. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  30353. */
  30354. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  30355. /**
  30356. * Disposes the sphere.
  30357. * @param force Specifies if the sphere should be disposed by force
  30358. */
  30359. dispose(force?: boolean): void;
  30360. /*** Helpers ***/
  30361. private _prepareSphere;
  30362. private _intersectsWithSphere;
  30363. }
  30364. /**
  30365. * Represents a gravitational field event
  30366. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30367. */
  30368. class PhysicsGravitationalFieldEvent {
  30369. private _physicsHelper;
  30370. private _scene;
  30371. private _origin;
  30372. private _radius;
  30373. private _strength;
  30374. private _falloff;
  30375. private _tickCallback;
  30376. private _sphere;
  30377. private _dataFetched;
  30378. /**
  30379. * Initializes the physics gravitational field event
  30380. * @param physicsHelper A physics helper
  30381. * @param scene BabylonJS scene
  30382. * @param origin The origin position of the gravitational field event
  30383. * @param radius The radius of the gravitational field event
  30384. * @param strength The strength of the gravitational field event
  30385. * @param falloff The falloff for the gravitational field event
  30386. */
  30387. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  30388. /**
  30389. * Returns the data related to the gravitational field event (sphere).
  30390. * @returns A gravitational field event
  30391. */
  30392. getData(): PhysicsGravitationalFieldEventData;
  30393. /**
  30394. * Enables the gravitational field.
  30395. */
  30396. enable(): void;
  30397. /**
  30398. * Disables the gravitational field.
  30399. */
  30400. disable(): void;
  30401. /**
  30402. * Disposes the sphere.
  30403. * @param force The force to dispose from the gravitational field event
  30404. */
  30405. dispose(force?: boolean): void;
  30406. private _tick;
  30407. }
  30408. /**
  30409. * Represents a physics updraft event
  30410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30411. */
  30412. class PhysicsUpdraftEvent {
  30413. private _scene;
  30414. private _origin;
  30415. private _radius;
  30416. private _strength;
  30417. private _height;
  30418. private _updraftMode;
  30419. private _physicsEngine;
  30420. private _originTop;
  30421. private _originDirection;
  30422. private _tickCallback;
  30423. private _cylinder;
  30424. private _cylinderPosition;
  30425. private _dataFetched;
  30426. /**
  30427. * Initializes the physics updraft event
  30428. * @param _scene BabylonJS scene
  30429. * @param _origin The origin position of the updraft
  30430. * @param _radius The radius of the updraft
  30431. * @param _strength The strength of the updraft
  30432. * @param _height The height of the updraft
  30433. * @param _updraftMode The mode of the updraft
  30434. */
  30435. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  30436. /**
  30437. * Returns the data related to the updraft event (cylinder).
  30438. * @returns A physics updraft event
  30439. */
  30440. getData(): PhysicsUpdraftEventData;
  30441. /**
  30442. * Enables the updraft.
  30443. */
  30444. enable(): void;
  30445. /**
  30446. * Disables the cortex.
  30447. */
  30448. disable(): void;
  30449. /**
  30450. * Disposes the sphere.
  30451. * @param force Specifies if the updraft should be disposed by force
  30452. */
  30453. dispose(force?: boolean): void;
  30454. private getImpostorForceAndContactPoint;
  30455. private _tick;
  30456. /*** Helpers ***/
  30457. private _prepareCylinder;
  30458. private _intersectsWithCylinder;
  30459. }
  30460. /**
  30461. * Represents a physics vortex event
  30462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30463. */
  30464. class PhysicsVortexEvent {
  30465. private _scene;
  30466. private _origin;
  30467. private _radius;
  30468. private _strength;
  30469. private _height;
  30470. private _physicsEngine;
  30471. private _originTop;
  30472. private _centripetalForceThreshold;
  30473. private _updraftMultiplier;
  30474. private _tickCallback;
  30475. private _cylinder;
  30476. private _cylinderPosition;
  30477. private _dataFetched;
  30478. /**
  30479. * Initializes the physics vortex event
  30480. * @param _scene The BabylonJS scene
  30481. * @param _origin The origin position of the vortex
  30482. * @param _radius The radius of the vortex
  30483. * @param _strength The strength of the vortex
  30484. * @param _height The height of the vortex
  30485. */
  30486. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  30487. /**
  30488. * Returns the data related to the vortex event (cylinder).
  30489. * @returns The physics vortex event data
  30490. */
  30491. getData(): PhysicsVortexEventData;
  30492. /**
  30493. * Enables the vortex.
  30494. */
  30495. enable(): void;
  30496. /**
  30497. * Disables the cortex.
  30498. */
  30499. disable(): void;
  30500. /**
  30501. * Disposes the sphere.
  30502. * @param force
  30503. */
  30504. dispose(force?: boolean): void;
  30505. private getImpostorForceAndContactPoint;
  30506. private _tick;
  30507. /*** Helpers ***/
  30508. private _prepareCylinder;
  30509. private _intersectsWithCylinder;
  30510. }
  30511. /**
  30512. * The strenght of the force in correspondence to the distance of the affected object
  30513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30514. */
  30515. enum PhysicsRadialImpulseFalloff {
  30516. /** Defines that impulse is constant in strength across it's whole radius */
  30517. Constant = 0,
  30518. /** DEfines that impulse gets weaker if it's further from the origin */
  30519. Linear = 1
  30520. }
  30521. /**
  30522. * The strength of the force in correspondence to the distance of the affected object
  30523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30524. */
  30525. enum PhysicsUpdraftMode {
  30526. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  30527. Center = 0,
  30528. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  30529. Perpendicular = 1
  30530. }
  30531. /**
  30532. * Interface for a physics force and contact point
  30533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30534. */
  30535. interface PhysicsForceAndContactPoint {
  30536. /**
  30537. * The force applied at the contact point
  30538. */
  30539. force: Vector3;
  30540. /**
  30541. * The contact point
  30542. */
  30543. contactPoint: Vector3;
  30544. }
  30545. /**
  30546. * Interface for radial explosion event data
  30547. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30548. */
  30549. interface PhysicsRadialExplosionEventData {
  30550. /**
  30551. * A sphere used for the radial explosion event
  30552. */
  30553. sphere: Mesh;
  30554. /**
  30555. * An array of rays for the radial explosion event
  30556. */
  30557. rays: Array<Ray>;
  30558. }
  30559. /**
  30560. * Interface for gravitational field event data
  30561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30562. */
  30563. interface PhysicsGravitationalFieldEventData {
  30564. /**
  30565. * A sphere mesh used for the gravitational field event
  30566. */
  30567. sphere: Mesh;
  30568. }
  30569. /**
  30570. * Interface for updraft event data
  30571. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30572. */
  30573. interface PhysicsUpdraftEventData {
  30574. /**
  30575. * A cylinder used for the updraft event
  30576. */
  30577. cylinder: Mesh;
  30578. }
  30579. /**
  30580. * Interface for vortex event data
  30581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30582. */
  30583. interface PhysicsVortexEventData {
  30584. /**
  30585. * A cylinder used for the vortex event
  30586. */
  30587. cylinder: Mesh;
  30588. }
  30589. }
  30590. declare module BABYLON {
  30591. /**
  30592. * The interface for the physics imposter parameters
  30593. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30594. */
  30595. interface PhysicsImpostorParameters {
  30596. /**
  30597. * The mass of the physics imposter
  30598. */
  30599. mass: number;
  30600. /**
  30601. * The friction of the physics imposter
  30602. */
  30603. friction?: number;
  30604. /**
  30605. * The coefficient of restitution of the physics imposter
  30606. */
  30607. restitution?: number;
  30608. /**
  30609. * The native options of the physics imposter
  30610. */
  30611. nativeOptions?: any;
  30612. /**
  30613. * Specifies if the parent should be ignored
  30614. */
  30615. ignoreParent?: boolean;
  30616. /**
  30617. * Specifies if bi-directional transformations should be disabled
  30618. */
  30619. disableBidirectionalTransformation?: boolean;
  30620. }
  30621. /**
  30622. * Interface for a physics-enabled object
  30623. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30624. */
  30625. interface IPhysicsEnabledObject {
  30626. /**
  30627. * The position of the physics-enabled object
  30628. */
  30629. position: Vector3;
  30630. /**
  30631. * The rotation of the physics-enabled object
  30632. */
  30633. rotationQuaternion: Nullable<Quaternion>;
  30634. /**
  30635. * The scale of the physics-enabled object
  30636. */
  30637. scaling: Vector3;
  30638. /**
  30639. * The rotation of the physics-enabled object
  30640. */
  30641. rotation?: Vector3;
  30642. /**
  30643. * The parent of the physics-enabled object
  30644. */
  30645. parent?: any;
  30646. /**
  30647. * The bounding info of the physics-enabled object
  30648. * @returns The bounding info of the physics-enabled object
  30649. */
  30650. getBoundingInfo(): BoundingInfo;
  30651. /**
  30652. * Computes the world matrix
  30653. * @param force Specifies if the world matrix should be computed by force
  30654. * @returns A world matrix
  30655. */
  30656. computeWorldMatrix(force: boolean): Matrix;
  30657. /**
  30658. * Gets the world matrix
  30659. * @returns A world matrix
  30660. */
  30661. getWorldMatrix?(): Matrix;
  30662. /**
  30663. * Gets the child meshes
  30664. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  30665. * @returns An array of abstract meshes
  30666. */
  30667. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  30668. /**
  30669. * Gets the vertex data
  30670. * @param kind The type of vertex data
  30671. * @returns A nullable array of numbers, or a float32 array
  30672. */
  30673. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  30674. /**
  30675. * Gets the indices from the mesh
  30676. * @returns A nullable array of index arrays
  30677. */
  30678. getIndices?(): Nullable<IndicesArray>;
  30679. /**
  30680. * Gets the scene from the mesh
  30681. * @returns the indices array or null
  30682. */
  30683. getScene?(): Scene;
  30684. /**
  30685. * Gets the absolute position from the mesh
  30686. * @returns the absolute position
  30687. */
  30688. getAbsolutePosition(): Vector3;
  30689. /**
  30690. * Gets the absolute pivot point from the mesh
  30691. * @returns the absolute pivot point
  30692. */
  30693. getAbsolutePivotPoint(): Vector3;
  30694. /**
  30695. * Rotates the mesh
  30696. * @param axis The axis of rotation
  30697. * @param amount The amount of rotation
  30698. * @param space The space of the rotation
  30699. * @returns The rotation transform node
  30700. */
  30701. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  30702. /**
  30703. * Translates the mesh
  30704. * @param axis The axis of translation
  30705. * @param distance The distance of translation
  30706. * @param space The space of the translation
  30707. * @returns The transform node
  30708. */
  30709. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  30710. /**
  30711. * Sets the absolute position of the mesh
  30712. * @param absolutePosition The absolute position of the mesh
  30713. * @returns The transform node
  30714. */
  30715. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  30716. /**
  30717. * Gets the class name of the mesh
  30718. * @returns The class name
  30719. */
  30720. getClassName(): string;
  30721. }
  30722. /**
  30723. * Represents a physics imposter
  30724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30725. */
  30726. class PhysicsImpostor {
  30727. /**
  30728. * The physics-enabled object used as the physics imposter
  30729. */
  30730. object: IPhysicsEnabledObject;
  30731. /**
  30732. * The type of the physics imposter
  30733. */
  30734. type: number;
  30735. private _options;
  30736. private _scene?;
  30737. /**
  30738. * The default object size of the imposter
  30739. */
  30740. static DEFAULT_OBJECT_SIZE: Vector3;
  30741. /**
  30742. * The identity quaternion of the imposter
  30743. */
  30744. static IDENTITY_QUATERNION: Quaternion;
  30745. private _physicsEngine;
  30746. private _physicsBody;
  30747. private _bodyUpdateRequired;
  30748. private _onBeforePhysicsStepCallbacks;
  30749. private _onAfterPhysicsStepCallbacks;
  30750. private _onPhysicsCollideCallbacks;
  30751. private _deltaPosition;
  30752. private _deltaRotation;
  30753. private _deltaRotationConjugated;
  30754. private _parent;
  30755. private _isDisposed;
  30756. private static _tmpVecs;
  30757. private static _tmpQuat;
  30758. /**
  30759. * Specifies if the physics imposter is disposed
  30760. */
  30761. readonly isDisposed: boolean;
  30762. /**
  30763. * Gets the mass of the physics imposter
  30764. */
  30765. mass: number;
  30766. /**
  30767. * Gets the coefficient of friction
  30768. */
  30769. /**
  30770. * Sets the coefficient of friction
  30771. */
  30772. friction: number;
  30773. /**
  30774. * Gets the coefficient of restitution
  30775. */
  30776. /**
  30777. * Sets the coefficient of restitution
  30778. */
  30779. restitution: number;
  30780. /**
  30781. * The unique id of the physics imposter
  30782. * set by the physics engine when adding this impostor to the array
  30783. */
  30784. uniqueId: number;
  30785. private _joints;
  30786. /**
  30787. * Initializes the physics imposter
  30788. * @param object The physics-enabled object used as the physics imposter
  30789. * @param type The type of the physics imposter
  30790. * @param _options The options for the physics imposter
  30791. * @param _scene The Babylon scene
  30792. */
  30793. constructor(
  30794. /**
  30795. * The physics-enabled object used as the physics imposter
  30796. */
  30797. object: IPhysicsEnabledObject,
  30798. /**
  30799. * The type of the physics imposter
  30800. */
  30801. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  30802. /**
  30803. * This function will completly initialize this impostor.
  30804. * It will create a new body - but only if this mesh has no parent.
  30805. * If it has, this impostor will not be used other than to define the impostor
  30806. * of the child mesh.
  30807. * @hidden
  30808. */
  30809. _init(): void;
  30810. private _getPhysicsParent;
  30811. /**
  30812. * Should a new body be generated.
  30813. * @returns boolean specifying if body initialization is required
  30814. */
  30815. isBodyInitRequired(): boolean;
  30816. /**
  30817. * Sets the updated scaling
  30818. * @param updated Specifies if the scaling is updated
  30819. */
  30820. setScalingUpdated(updated: boolean): void;
  30821. /**
  30822. * Force a regeneration of this or the parent's impostor's body.
  30823. * Use under cautious - This will remove all joints already implemented.
  30824. */
  30825. forceUpdate(): void;
  30826. /**
  30827. * Gets the body that holds this impostor. Either its own, or its parent.
  30828. */
  30829. /**
  30830. * Set the physics body. Used mainly by the physics engine/plugin
  30831. */
  30832. physicsBody: any;
  30833. /**
  30834. * Get the parent of the physics imposter
  30835. * @returns Physics imposter or null
  30836. */
  30837. /**
  30838. * Sets the parent of the physics imposter
  30839. */
  30840. parent: Nullable<PhysicsImpostor>;
  30841. /**
  30842. * Resets the update flags
  30843. */
  30844. resetUpdateFlags(): void;
  30845. /**
  30846. * Gets the object extend size
  30847. * @returns the object extend size
  30848. */
  30849. getObjectExtendSize(): Vector3;
  30850. /**
  30851. * Gets the object center
  30852. * @returns The object center
  30853. */
  30854. getObjectCenter(): Vector3;
  30855. /**
  30856. * Get a specific parametes from the options parameter
  30857. * @param paramName The object parameter name
  30858. * @returns The object parameter
  30859. */
  30860. getParam(paramName: string): any;
  30861. /**
  30862. * Sets a specific parameter in the options given to the physics plugin
  30863. * @param paramName The parameter name
  30864. * @param value The value of the parameter
  30865. */
  30866. setParam(paramName: string, value: number): void;
  30867. /**
  30868. * Specifically change the body's mass option. Won't recreate the physics body object
  30869. * @param mass The mass of the physics imposter
  30870. */
  30871. setMass(mass: number): void;
  30872. /**
  30873. * Gets the linear velocity
  30874. * @returns linear velocity or null
  30875. */
  30876. getLinearVelocity(): Nullable<Vector3>;
  30877. /**
  30878. * Sets the linear velocity
  30879. * @param velocity linear velocity or null
  30880. */
  30881. setLinearVelocity(velocity: Nullable<Vector3>): void;
  30882. /**
  30883. * Gets the angular velocity
  30884. * @returns angular velocity or null
  30885. */
  30886. getAngularVelocity(): Nullable<Vector3>;
  30887. /**
  30888. * Sets the angular velocity
  30889. * @param velocity The velocity or null
  30890. */
  30891. setAngularVelocity(velocity: Nullable<Vector3>): void;
  30892. /**
  30893. * Execute a function with the physics plugin native code
  30894. * Provide a function the will have two variables - the world object and the physics body object
  30895. * @param func The function to execute with the physics plugin native code
  30896. */
  30897. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  30898. /**
  30899. * Register a function that will be executed before the physics world is stepping forward
  30900. * @param func The function to execute before the physics world is stepped forward
  30901. */
  30902. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30903. /**
  30904. * Unregister a function that will be executed before the physics world is stepping forward
  30905. * @param func The function to execute before the physics world is stepped forward
  30906. */
  30907. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30908. /**
  30909. * Register a function that will be executed after the physics step
  30910. * @param func The function to execute after physics step
  30911. */
  30912. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30913. /**
  30914. * Unregisters a function that will be executed after the physics step
  30915. * @param func The function to execute after physics step
  30916. */
  30917. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30918. /**
  30919. * register a function that will be executed when this impostor collides against a different body
  30920. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  30921. * @param func Callback that is executed on collision
  30922. */
  30923. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  30924. /**
  30925. * Unregisters the physics imposter on contact
  30926. * @param collideAgainst The physics object to collide against
  30927. * @param func Callback to execute on collision
  30928. */
  30929. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  30930. private _tmpQuat;
  30931. private _tmpQuat2;
  30932. /**
  30933. * Get the parent rotation
  30934. * @returns The parent rotation
  30935. */
  30936. getParentsRotation(): Quaternion;
  30937. /**
  30938. * this function is executed by the physics engine.
  30939. */
  30940. beforeStep: () => void;
  30941. /**
  30942. * this function is executed by the physics engine
  30943. */
  30944. afterStep: () => void;
  30945. /**
  30946. * Legacy collision detection event support
  30947. */
  30948. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  30949. /**
  30950. * event and body object due to cannon's event-based architecture.
  30951. */
  30952. onCollide: (e: {
  30953. body: any;
  30954. }) => void;
  30955. /**
  30956. * Apply a force
  30957. * @param force The force to apply
  30958. * @param contactPoint The contact point for the force
  30959. * @returns The physics imposter
  30960. */
  30961. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  30962. /**
  30963. * Apply an impulse
  30964. * @param force The impulse force
  30965. * @param contactPoint The contact point for the impulse force
  30966. * @returns The physics imposter
  30967. */
  30968. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  30969. /**
  30970. * A help function to create a joint
  30971. * @param otherImpostor A physics imposter used to create a joint
  30972. * @param jointType The type of joint
  30973. * @param jointData The data for the joint
  30974. * @returns The physics imposter
  30975. */
  30976. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  30977. /**
  30978. * Add a joint to this impostor with a different impostor
  30979. * @param otherImpostor A physics imposter used to add a joint
  30980. * @param joint The joint to add
  30981. * @returns The physics imposter
  30982. */
  30983. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  30984. /**
  30985. * Will keep this body still, in a sleep mode.
  30986. * @returns the physics imposter
  30987. */
  30988. sleep(): PhysicsImpostor;
  30989. /**
  30990. * Wake the body up.
  30991. * @returns The physics imposter
  30992. */
  30993. wakeUp(): PhysicsImpostor;
  30994. /**
  30995. * Clones the physics imposter
  30996. * @param newObject The physics imposter clones to this physics-enabled object
  30997. * @returns A nullable physics imposter
  30998. */
  30999. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31000. /**
  31001. * Disposes the physics imposter
  31002. */
  31003. dispose(): void;
  31004. /**
  31005. * Sets the delta position
  31006. * @param position The delta position amount
  31007. */
  31008. setDeltaPosition(position: Vector3): void;
  31009. /**
  31010. * Sets the delta rotation
  31011. * @param rotation The delta rotation amount
  31012. */
  31013. setDeltaRotation(rotation: Quaternion): void;
  31014. /**
  31015. * Gets the box size of the physics imposter and stores the result in the input parameter
  31016. * @param result Stores the box size
  31017. * @returns The physics imposter
  31018. */
  31019. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  31020. /**
  31021. * Gets the radius of the physics imposter
  31022. * @returns Radius of the physics imposter
  31023. */
  31024. getRadius(): number;
  31025. /**
  31026. * Sync a bone with this impostor
  31027. * @param bone The bone to sync to the impostor.
  31028. * @param boneMesh The mesh that the bone is influencing.
  31029. * @param jointPivot The pivot of the joint / bone in local space.
  31030. * @param distToJoint Optional distance from the impostor to the joint.
  31031. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  31032. */
  31033. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  31034. /**
  31035. * Sync impostor to a bone
  31036. * @param bone The bone that the impostor will be synced to.
  31037. * @param boneMesh The mesh that the bone is influencing.
  31038. * @param jointPivot The pivot of the joint / bone in local space.
  31039. * @param distToJoint Optional distance from the impostor to the joint.
  31040. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  31041. * @param boneAxis Optional vector3 axis the bone is aligned with
  31042. */
  31043. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  31044. /**
  31045. * No-Imposter type
  31046. */
  31047. static NoImpostor: number;
  31048. /**
  31049. * Sphere-Imposter type
  31050. */
  31051. static SphereImpostor: number;
  31052. /**
  31053. * Box-Imposter type
  31054. */
  31055. static BoxImpostor: number;
  31056. /**
  31057. * Plane-Imposter type
  31058. */
  31059. static PlaneImpostor: number;
  31060. /**
  31061. * Mesh-imposter type
  31062. */
  31063. static MeshImpostor: number;
  31064. /**
  31065. * Cylinder-Imposter type
  31066. */
  31067. static CylinderImpostor: number;
  31068. /**
  31069. * Particle-Imposter type
  31070. */
  31071. static ParticleImpostor: number;
  31072. /**
  31073. * Heightmap-Imposter type
  31074. */
  31075. static HeightmapImpostor: number;
  31076. }
  31077. }
  31078. declare module BABYLON {
  31079. /**
  31080. * Interface for Physics-Joint data
  31081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31082. */
  31083. interface PhysicsJointData {
  31084. /**
  31085. * The main pivot of the joint
  31086. */
  31087. mainPivot?: Vector3;
  31088. /**
  31089. * The connected pivot of the joint
  31090. */
  31091. connectedPivot?: Vector3;
  31092. /**
  31093. * The main axis of the joint
  31094. */
  31095. mainAxis?: Vector3;
  31096. /**
  31097. * The connected axis of the joint
  31098. */
  31099. connectedAxis?: Vector3;
  31100. /**
  31101. * The collision of the joint
  31102. */
  31103. collision?: boolean;
  31104. /**
  31105. * Native Oimo/Cannon/Energy data
  31106. */
  31107. nativeParams?: any;
  31108. }
  31109. /**
  31110. * This is a holder class for the physics joint created by the physics plugin
  31111. * It holds a set of functions to control the underlying joint
  31112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31113. */
  31114. class PhysicsJoint {
  31115. /**
  31116. * The type of the physics joint
  31117. */
  31118. type: number;
  31119. /**
  31120. * The data for the physics joint
  31121. */
  31122. jointData: PhysicsJointData;
  31123. private _physicsJoint;
  31124. protected _physicsPlugin: IPhysicsEnginePlugin;
  31125. /**
  31126. * Initializes the physics joint
  31127. * @param type The type of the physics joint
  31128. * @param jointData The data for the physics joint
  31129. */
  31130. constructor(
  31131. /**
  31132. * The type of the physics joint
  31133. */
  31134. type: number,
  31135. /**
  31136. * The data for the physics joint
  31137. */
  31138. jointData: PhysicsJointData);
  31139. /**
  31140. * Gets the physics joint
  31141. */
  31142. /**
  31143. * Sets the physics joint
  31144. */
  31145. physicsJoint: any;
  31146. /**
  31147. * Sets the physics plugin
  31148. */
  31149. physicsPlugin: IPhysicsEnginePlugin;
  31150. /**
  31151. * Execute a function that is physics-plugin specific.
  31152. * @param {Function} func the function that will be executed.
  31153. * It accepts two parameters: the physics world and the physics joint
  31154. */
  31155. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31156. /**
  31157. * Distance-Joint type
  31158. */
  31159. static DistanceJoint: number;
  31160. /**
  31161. * Hinge-Joint type
  31162. */
  31163. static HingeJoint: number;
  31164. /**
  31165. * Ball-and-Socket joint type
  31166. */
  31167. static BallAndSocketJoint: number;
  31168. /**
  31169. * Wheel-Joint type
  31170. */
  31171. static WheelJoint: number;
  31172. /**
  31173. * Slider-Joint type
  31174. */
  31175. static SliderJoint: number;
  31176. /**
  31177. * Prismatic-Joint type
  31178. */
  31179. static PrismaticJoint: number;
  31180. /**
  31181. * Universal-Joint type
  31182. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31183. */
  31184. static UniversalJoint: number;
  31185. /**
  31186. * Hinge-Joint 2 type
  31187. */
  31188. static Hinge2Joint: number;
  31189. /**
  31190. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31191. */
  31192. static PointToPointJoint: number;
  31193. /**
  31194. * Spring-Joint type
  31195. */
  31196. static SpringJoint: number;
  31197. /**
  31198. * Lock-Joint type
  31199. */
  31200. static LockJoint: number;
  31201. }
  31202. /**
  31203. * A class representing a physics distance joint
  31204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31205. */
  31206. class DistanceJoint extends PhysicsJoint {
  31207. /**
  31208. *
  31209. * @param jointData The data for the Distance-Joint
  31210. */
  31211. constructor(jointData: DistanceJointData);
  31212. /**
  31213. * Update the predefined distance.
  31214. * @param maxDistance The maximum preferred distance
  31215. * @param minDistance The minimum preferred distance
  31216. */
  31217. updateDistance(maxDistance: number, minDistance?: number): void;
  31218. }
  31219. /**
  31220. * Represents a Motor-Enabled Joint
  31221. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31222. */
  31223. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31224. /**
  31225. * Initializes the Motor-Enabled Joint
  31226. * @param type The type of the joint
  31227. * @param jointData The physica joint data for the joint
  31228. */
  31229. constructor(type: number, jointData: PhysicsJointData);
  31230. /**
  31231. * Set the motor values.
  31232. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31233. * @param force the force to apply
  31234. * @param maxForce max force for this motor.
  31235. */
  31236. setMotor(force?: number, maxForce?: number): void;
  31237. /**
  31238. * Set the motor's limits.
  31239. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31240. * @param upperLimit The upper limit of the motor
  31241. * @param lowerLimit The lower limit of the motor
  31242. */
  31243. setLimit(upperLimit: number, lowerLimit?: number): void;
  31244. }
  31245. /**
  31246. * This class represents a single physics Hinge-Joint
  31247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31248. */
  31249. class HingeJoint extends MotorEnabledJoint {
  31250. /**
  31251. * Initializes the Hinge-Joint
  31252. * @param jointData The joint data for the Hinge-Joint
  31253. */
  31254. constructor(jointData: PhysicsJointData);
  31255. /**
  31256. * Set the motor values.
  31257. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31258. * @param {number} force the force to apply
  31259. * @param {number} maxForce max force for this motor.
  31260. */
  31261. setMotor(force?: number, maxForce?: number): void;
  31262. /**
  31263. * Set the motor's limits.
  31264. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31265. * @param upperLimit The upper limit of the motor
  31266. * @param lowerLimit The lower limit of the motor
  31267. */
  31268. setLimit(upperLimit: number, lowerLimit?: number): void;
  31269. }
  31270. /**
  31271. * This class represents a dual hinge physics joint (same as wheel joint)
  31272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31273. */
  31274. class Hinge2Joint extends MotorEnabledJoint {
  31275. /**
  31276. * Initializes the Hinge2-Joint
  31277. * @param jointData The joint data for the Hinge2-Joint
  31278. */
  31279. constructor(jointData: PhysicsJointData);
  31280. /**
  31281. * Set the motor values.
  31282. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31283. * @param {number} force the force to apply
  31284. * @param {number} maxForce max force for this motor.
  31285. * @param {motorIndex} the motor's index, 0 or 1.
  31286. */
  31287. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31288. /**
  31289. * Set the motor limits.
  31290. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31291. * @param {number} upperLimit the upper limit
  31292. * @param {number} lowerLimit lower limit
  31293. * @param {motorIndex} the motor's index, 0 or 1.
  31294. */
  31295. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31296. }
  31297. /**
  31298. * Interface for a motor enabled joint
  31299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31300. */
  31301. interface IMotorEnabledJoint {
  31302. /**
  31303. * Physics joint
  31304. */
  31305. physicsJoint: any;
  31306. /**
  31307. * Sets the motor of the motor-enabled joint
  31308. * @param force The force of the motor
  31309. * @param maxForce The maximum force of the motor
  31310. * @param motorIndex The index of the motor
  31311. */
  31312. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31313. /**
  31314. * Sets the limit of the motor
  31315. * @param upperLimit The upper limit of the motor
  31316. * @param lowerLimit The lower limit of the motor
  31317. * @param motorIndex The index of the motor
  31318. */
  31319. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31320. }
  31321. /**
  31322. * Joint data for a Distance-Joint
  31323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31324. */
  31325. interface DistanceJointData extends PhysicsJointData {
  31326. /**
  31327. * Max distance the 2 joint objects can be apart
  31328. */
  31329. maxDistance: number;
  31330. }
  31331. /**
  31332. * Joint data from a spring joint
  31333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31334. */
  31335. interface SpringJointData extends PhysicsJointData {
  31336. /**
  31337. * Length of the spring
  31338. */
  31339. length: number;
  31340. /**
  31341. * Stiffness of the spring
  31342. */
  31343. stiffness: number;
  31344. /**
  31345. * Damping of the spring
  31346. */
  31347. damping: number;
  31348. /** this callback will be called when applying the force to the impostors. */
  31349. forceApplicationCallback: () => void;
  31350. }
  31351. }
  31352. declare module BABYLON {
  31353. /**
  31354. * This represents the base class for particle system in Babylon.
  31355. * 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.
  31356. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31357. * @example https://doc.babylonjs.com/babylon101/particles
  31358. */
  31359. class BaseParticleSystem {
  31360. /**
  31361. * Source color is added to the destination color without alpha affecting the result
  31362. */
  31363. static BLENDMODE_ONEONE: number;
  31364. /**
  31365. * Blend current color and particle color using particle’s alpha
  31366. */
  31367. static BLENDMODE_STANDARD: number;
  31368. /**
  31369. * Add current color and particle color multiplied by particle’s alpha
  31370. */
  31371. static BLENDMODE_ADD: number;
  31372. /**
  31373. * Multiply current color with particle color
  31374. */
  31375. static BLENDMODE_MULTIPLY: number;
  31376. /**
  31377. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  31378. */
  31379. static BLENDMODE_MULTIPLYADD: number;
  31380. /**
  31381. * List of animations used by the particle system.
  31382. */
  31383. animations: Animation[];
  31384. /**
  31385. * The id of the Particle system.
  31386. */
  31387. id: string;
  31388. /**
  31389. * The friendly name of the Particle system.
  31390. */
  31391. name: string;
  31392. /**
  31393. * The rendering group used by the Particle system to chose when to render.
  31394. */
  31395. renderingGroupId: number;
  31396. /**
  31397. * The emitter represents the Mesh or position we are attaching the particle system to.
  31398. */
  31399. emitter: Nullable<AbstractMesh | Vector3>;
  31400. /**
  31401. * The maximum number of particles to emit per frame
  31402. */
  31403. emitRate: number;
  31404. /**
  31405. * If you want to launch only a few particles at once, that can be done, as well.
  31406. */
  31407. manualEmitCount: number;
  31408. /**
  31409. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  31410. */
  31411. updateSpeed: number;
  31412. /**
  31413. * The amount of time the particle system is running (depends of the overall update speed).
  31414. */
  31415. targetStopDuration: number;
  31416. /**
  31417. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  31418. */
  31419. disposeOnStop: boolean;
  31420. /**
  31421. * Minimum power of emitting particles.
  31422. */
  31423. minEmitPower: number;
  31424. /**
  31425. * Maximum power of emitting particles.
  31426. */
  31427. maxEmitPower: number;
  31428. /**
  31429. * Minimum life time of emitting particles.
  31430. */
  31431. minLifeTime: number;
  31432. /**
  31433. * Maximum life time of emitting particles.
  31434. */
  31435. maxLifeTime: number;
  31436. /**
  31437. * Minimum Size of emitting particles.
  31438. */
  31439. minSize: number;
  31440. /**
  31441. * Maximum Size of emitting particles.
  31442. */
  31443. maxSize: number;
  31444. /**
  31445. * Minimum scale of emitting particles on X axis.
  31446. */
  31447. minScaleX: number;
  31448. /**
  31449. * Maximum scale of emitting particles on X axis.
  31450. */
  31451. maxScaleX: number;
  31452. /**
  31453. * Minimum scale of emitting particles on Y axis.
  31454. */
  31455. minScaleY: number;
  31456. /**
  31457. * Maximum scale of emitting particles on Y axis.
  31458. */
  31459. maxScaleY: number;
  31460. /**
  31461. * Gets or sets the minimal initial rotation in radians.
  31462. */
  31463. minInitialRotation: number;
  31464. /**
  31465. * Gets or sets the maximal initial rotation in radians.
  31466. */
  31467. maxInitialRotation: number;
  31468. /**
  31469. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  31470. */
  31471. minAngularSpeed: number;
  31472. /**
  31473. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  31474. */
  31475. maxAngularSpeed: number;
  31476. /**
  31477. * The texture used to render each particle. (this can be a spritesheet)
  31478. */
  31479. particleTexture: Nullable<Texture>;
  31480. /**
  31481. * The layer mask we are rendering the particles through.
  31482. */
  31483. layerMask: number;
  31484. /**
  31485. * This can help using your own shader to render the particle system.
  31486. * The according effect will be created
  31487. */
  31488. customShader: any;
  31489. /**
  31490. * By default particle system starts as soon as they are created. This prevents the
  31491. * automatic start to happen and let you decide when to start emitting particles.
  31492. */
  31493. preventAutoStart: boolean;
  31494. /**
  31495. * Gets or sets a texture used to add random noise to particle positions
  31496. */
  31497. noiseTexture: Nullable<ProceduralTexture>;
  31498. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  31499. noiseStrength: Vector3;
  31500. /**
  31501. * Callback triggered when the particle animation is ending.
  31502. */
  31503. onAnimationEnd: Nullable<() => void>;
  31504. /**
  31505. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  31506. */
  31507. blendMode: number;
  31508. /**
  31509. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  31510. * to override the particles.
  31511. */
  31512. forceDepthWrite: boolean;
  31513. /** 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 */
  31514. preWarmCycles: number;
  31515. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  31516. preWarmStepOffset: number;
  31517. /**
  31518. * 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)
  31519. */
  31520. spriteCellChangeSpeed: number;
  31521. /**
  31522. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  31523. */
  31524. startSpriteCellID: number;
  31525. /**
  31526. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  31527. */
  31528. endSpriteCellID: number;
  31529. /**
  31530. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  31531. */
  31532. spriteCellWidth: number;
  31533. /**
  31534. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  31535. */
  31536. spriteCellHeight: number;
  31537. /**
  31538. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  31539. */
  31540. spriteRandomStartCell: boolean;
  31541. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  31542. translationPivot: Vector2;
  31543. /** @hidden */
  31544. protected _isAnimationSheetEnabled: boolean;
  31545. /**
  31546. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  31547. */
  31548. beginAnimationOnStart: boolean;
  31549. /**
  31550. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  31551. */
  31552. beginAnimationFrom: number;
  31553. /**
  31554. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  31555. */
  31556. beginAnimationTo: number;
  31557. /**
  31558. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  31559. */
  31560. beginAnimationLoop: boolean;
  31561. /**
  31562. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  31563. */
  31564. isAnimationSheetEnabled: boolean;
  31565. /**
  31566. * Get hosting scene
  31567. * @returns the scene
  31568. */
  31569. getScene(): Scene;
  31570. /**
  31571. * You can use gravity if you want to give an orientation to your particles.
  31572. */
  31573. gravity: Vector3;
  31574. protected _colorGradients: Nullable<Array<ColorGradient>>;
  31575. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  31576. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  31577. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  31578. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  31579. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  31580. protected _dragGradients: Nullable<Array<FactorGradient>>;
  31581. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  31582. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  31583. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  31584. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  31585. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  31586. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  31587. /**
  31588. * Defines the delay in milliseconds before starting the system (0 by default)
  31589. */
  31590. startDelay: number;
  31591. /**
  31592. * Gets the current list of drag gradients.
  31593. * You must use addDragGradient and removeDragGradient to udpate this list
  31594. * @returns the list of drag gradients
  31595. */
  31596. getDragGradients(): Nullable<Array<FactorGradient>>;
  31597. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  31598. limitVelocityDamping: number;
  31599. /**
  31600. * Gets the current list of limit velocity gradients.
  31601. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  31602. * @returns the list of limit velocity gradients
  31603. */
  31604. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  31605. /**
  31606. * Gets the current list of color gradients.
  31607. * You must use addColorGradient and removeColorGradient to udpate this list
  31608. * @returns the list of color gradients
  31609. */
  31610. getColorGradients(): Nullable<Array<ColorGradient>>;
  31611. /**
  31612. * Gets the current list of size gradients.
  31613. * You must use addSizeGradient and removeSizeGradient to udpate this list
  31614. * @returns the list of size gradients
  31615. */
  31616. getSizeGradients(): Nullable<Array<FactorGradient>>;
  31617. /**
  31618. * Gets the current list of color remap gradients.
  31619. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  31620. * @returns the list of color remap gradients
  31621. */
  31622. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  31623. /**
  31624. * Gets the current list of alpha remap gradients.
  31625. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  31626. * @returns the list of alpha remap gradients
  31627. */
  31628. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  31629. /**
  31630. * Gets the current list of life time gradients.
  31631. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  31632. * @returns the list of life time gradients
  31633. */
  31634. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  31635. /**
  31636. * Gets the current list of angular speed gradients.
  31637. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  31638. * @returns the list of angular speed gradients
  31639. */
  31640. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  31641. /**
  31642. * Gets the current list of velocity gradients.
  31643. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  31644. * @returns the list of velocity gradients
  31645. */
  31646. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  31647. /**
  31648. * Gets the current list of start size gradients.
  31649. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  31650. * @returns the list of start size gradients
  31651. */
  31652. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  31653. /**
  31654. * Gets the current list of emit rate gradients.
  31655. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  31656. * @returns the list of emit rate gradients
  31657. */
  31658. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  31659. /**
  31660. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  31661. * This only works when particleEmitterTyps is a BoxParticleEmitter
  31662. */
  31663. direction1: Vector3;
  31664. /**
  31665. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  31666. * This only works when particleEmitterTyps is a BoxParticleEmitter
  31667. */
  31668. direction2: Vector3;
  31669. /**
  31670. * 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.
  31671. * This only works when particleEmitterTyps is a BoxParticleEmitter
  31672. */
  31673. minEmitBox: Vector3;
  31674. /**
  31675. * 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.
  31676. * This only works when particleEmitterTyps is a BoxParticleEmitter
  31677. */
  31678. maxEmitBox: Vector3;
  31679. /**
  31680. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  31681. */
  31682. color1: Color4;
  31683. /**
  31684. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  31685. */
  31686. color2: Color4;
  31687. /**
  31688. * Color the particle will have at the end of its lifetime
  31689. */
  31690. colorDead: Color4;
  31691. /**
  31692. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  31693. */
  31694. textureMask: Color4;
  31695. /**
  31696. * The particle emitter type defines the emitter used by the particle system.
  31697. * It can be for example box, sphere, or cone...
  31698. */
  31699. particleEmitterType: IParticleEmitterType;
  31700. /** @hidden */
  31701. _isSubEmitter: boolean;
  31702. /**
  31703. * Gets or sets the billboard mode to use when isBillboardBased = true.
  31704. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  31705. */
  31706. billboardMode: number;
  31707. protected _isBillboardBased: boolean;
  31708. /**
  31709. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  31710. */
  31711. isBillboardBased: boolean;
  31712. /**
  31713. * The scene the particle system belongs to.
  31714. */
  31715. protected _scene: Scene;
  31716. /**
  31717. * Local cache of defines for image processing.
  31718. */
  31719. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  31720. /**
  31721. * Default configuration related to image processing available in the standard Material.
  31722. */
  31723. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31724. /**
  31725. * Gets the image processing configuration used either in this material.
  31726. */
  31727. /**
  31728. * Sets the Default image processing configuration used either in the this material.
  31729. *
  31730. * If sets to null, the scene one is in use.
  31731. */
  31732. imageProcessingConfiguration: ImageProcessingConfiguration;
  31733. /**
  31734. * Attaches a new image processing configuration to the Standard Material.
  31735. * @param configuration
  31736. */
  31737. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31738. /** @hidden */
  31739. protected _reset(): void;
  31740. /** @hidden */
  31741. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  31742. /**
  31743. * Instantiates a particle system.
  31744. * 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.
  31745. * @param name The name of the particle system
  31746. */
  31747. constructor(name: string);
  31748. /**
  31749. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  31750. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31751. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31752. * @returns the emitter
  31753. */
  31754. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  31755. /**
  31756. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  31757. * @param radius The radius of the hemisphere to emit from
  31758. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31759. * @returns the emitter
  31760. */
  31761. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  31762. /**
  31763. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  31764. * @param radius The radius of the sphere to emit from
  31765. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31766. * @returns the emitter
  31767. */
  31768. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  31769. /**
  31770. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  31771. * @param radius The radius of the sphere to emit from
  31772. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  31773. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  31774. * @returns the emitter
  31775. */
  31776. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  31777. /**
  31778. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  31779. * @param radius The radius of the emission cylinder
  31780. * @param height The height of the emission cylinder
  31781. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  31782. * @param directionRandomizer How much to randomize the particle direction [0-1]
  31783. * @returns the emitter
  31784. */
  31785. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  31786. /**
  31787. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  31788. * @param radius The radius of the cylinder to emit from
  31789. * @param height The height of the emission cylinder
  31790. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  31791. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  31792. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  31793. * @returns the emitter
  31794. */
  31795. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  31796. /**
  31797. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  31798. * @param radius The radius of the cone to emit from
  31799. * @param angle The base angle of the cone
  31800. * @returns the emitter
  31801. */
  31802. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  31803. /**
  31804. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  31805. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31806. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31807. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31808. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31809. * @returns the emitter
  31810. */
  31811. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  31812. }
  31813. }
  31814. declare module BABYLON {
  31815. /**
  31816. * This represents a GPU particle system in Babylon
  31817. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  31818. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  31819. */
  31820. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  31821. /**
  31822. * The layer mask we are rendering the particles through.
  31823. */
  31824. layerMask: number;
  31825. private _capacity;
  31826. private _activeCount;
  31827. private _currentActiveCount;
  31828. private _accumulatedCount;
  31829. private _renderEffect;
  31830. private _updateEffect;
  31831. private _buffer0;
  31832. private _buffer1;
  31833. private _spriteBuffer;
  31834. private _updateVAO;
  31835. private _renderVAO;
  31836. private _targetIndex;
  31837. private _sourceBuffer;
  31838. private _targetBuffer;
  31839. private _engine;
  31840. private _currentRenderId;
  31841. private _started;
  31842. private _stopped;
  31843. private _timeDelta;
  31844. private _randomTexture;
  31845. private _randomTexture2;
  31846. private _attributesStrideSize;
  31847. private _updateEffectOptions;
  31848. private _randomTextureSize;
  31849. private _actualFrame;
  31850. private readonly _rawTextureWidth;
  31851. /**
  31852. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  31853. */
  31854. static readonly IsSupported: boolean;
  31855. /**
  31856. * An event triggered when the system is disposed.
  31857. */
  31858. onDisposeObservable: Observable<GPUParticleSystem>;
  31859. /**
  31860. * Gets the maximum number of particles active at the same time.
  31861. * @returns The max number of active particles.
  31862. */
  31863. getCapacity(): number;
  31864. /**
  31865. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  31866. * to override the particles.
  31867. */
  31868. forceDepthWrite: boolean;
  31869. /**
  31870. * Gets or set the number of active particles
  31871. */
  31872. activeParticleCount: number;
  31873. private _preWarmDone;
  31874. /**
  31875. * Is this system ready to be used/rendered
  31876. * @return true if the system is ready
  31877. */
  31878. isReady(): boolean;
  31879. /**
  31880. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31881. * @returns True if it has been started, otherwise false.
  31882. */
  31883. isStarted(): boolean;
  31884. /**
  31885. * Starts the particle system and begins to emit
  31886. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  31887. */
  31888. start(delay?: number): void;
  31889. /**
  31890. * Stops the particle system.
  31891. */
  31892. stop(): void;
  31893. /**
  31894. * Remove all active particles
  31895. */
  31896. reset(): void;
  31897. /**
  31898. * Returns the string "GPUParticleSystem"
  31899. * @returns a string containing the class name
  31900. */
  31901. getClassName(): string;
  31902. private _colorGradientsTexture;
  31903. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  31904. /**
  31905. * Adds a new color gradient
  31906. * @param gradient defines the gradient to use (between 0 and 1)
  31907. * @param color1 defines the color to affect to the specified gradient
  31908. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31909. * @returns the current particle system
  31910. */
  31911. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  31912. /**
  31913. * Remove a specific color gradient
  31914. * @param gradient defines the gradient to remove
  31915. * @returns the current particle system
  31916. */
  31917. removeColorGradient(gradient: number): GPUParticleSystem;
  31918. private _angularSpeedGradientsTexture;
  31919. private _sizeGradientsTexture;
  31920. private _velocityGradientsTexture;
  31921. private _limitVelocityGradientsTexture;
  31922. private _dragGradientsTexture;
  31923. private _addFactorGradient;
  31924. /**
  31925. * Adds a new size gradient
  31926. * @param gradient defines the gradient to use (between 0 and 1)
  31927. * @param factor defines the size factor to affect to the specified gradient
  31928. * @returns the current particle system
  31929. */
  31930. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  31931. /**
  31932. * Remove a specific size gradient
  31933. * @param gradient defines the gradient to remove
  31934. * @returns the current particle system
  31935. */
  31936. removeSizeGradient(gradient: number): GPUParticleSystem;
  31937. /**
  31938. * Adds a new angular speed gradient
  31939. * @param gradient defines the gradient to use (between 0 and 1)
  31940. * @param factor defines the angular speed to affect to the specified gradient
  31941. * @returns the current particle system
  31942. */
  31943. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  31944. /**
  31945. * Remove a specific angular speed gradient
  31946. * @param gradient defines the gradient to remove
  31947. * @returns the current particle system
  31948. */
  31949. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  31950. /**
  31951. * Adds a new velocity gradient
  31952. * @param gradient defines the gradient to use (between 0 and 1)
  31953. * @param factor defines the velocity to affect to the specified gradient
  31954. * @returns the current particle system
  31955. */
  31956. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  31957. /**
  31958. * Remove a specific velocity gradient
  31959. * @param gradient defines the gradient to remove
  31960. * @returns the current particle system
  31961. */
  31962. removeVelocityGradient(gradient: number): GPUParticleSystem;
  31963. /**
  31964. * Adds a new limit velocity gradient
  31965. * @param gradient defines the gradient to use (between 0 and 1)
  31966. * @param factor defines the limit velocity value to affect to the specified gradient
  31967. * @returns the current particle system
  31968. */
  31969. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  31970. /**
  31971. * Remove a specific limit velocity gradient
  31972. * @param gradient defines the gradient to remove
  31973. * @returns the current particle system
  31974. */
  31975. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  31976. /**
  31977. * Adds a new drag gradient
  31978. * @param gradient defines the gradient to use (between 0 and 1)
  31979. * @param factor defines the drag value to affect to the specified gradient
  31980. * @returns the current particle system
  31981. */
  31982. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  31983. /**
  31984. * Remove a specific drag gradient
  31985. * @param gradient defines the gradient to remove
  31986. * @returns the current particle system
  31987. */
  31988. removeDragGradient(gradient: number): GPUParticleSystem;
  31989. /**
  31990. * Not supported by GPUParticleSystem
  31991. * @param gradient defines the gradient to use (between 0 and 1)
  31992. * @param factor defines the emit rate value to affect to the specified gradient
  31993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31994. * @returns the current particle system
  31995. */
  31996. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31997. /**
  31998. * Not supported by GPUParticleSystem
  31999. * @param gradient defines the gradient to remove
  32000. * @returns the current particle system
  32001. */
  32002. removeEmitRateGradient(gradient: number): IParticleSystem;
  32003. /**
  32004. * Not supported by GPUParticleSystem
  32005. * @param gradient defines the gradient to use (between 0 and 1)
  32006. * @param factor defines the start size value to affect to the specified gradient
  32007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32008. * @returns the current particle system
  32009. */
  32010. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32011. /**
  32012. * Not supported by GPUParticleSystem
  32013. * @param gradient defines the gradient to remove
  32014. * @returns the current particle system
  32015. */
  32016. removeStartSizeGradient(gradient: number): IParticleSystem;
  32017. /**
  32018. * Not supported by GPUParticleSystem
  32019. * @param gradient defines the gradient to use (between 0 and 1)
  32020. * @param min defines the color remap minimal range
  32021. * @param max defines the color remap maximal range
  32022. * @returns the current particle system
  32023. */
  32024. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32025. /**
  32026. * Not supported by GPUParticleSystem
  32027. * @param gradient defines the gradient to remove
  32028. * @returns the current particle system
  32029. */
  32030. removeColorRemapGradient(gradient: number): IParticleSystem;
  32031. /**
  32032. * Not supported by GPUParticleSystem
  32033. * @param gradient defines the gradient to use (between 0 and 1)
  32034. * @param min defines the alpha remap minimal range
  32035. * @param max defines the alpha remap maximal range
  32036. * @returns the current particle system
  32037. */
  32038. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32039. /**
  32040. * Not supported by GPUParticleSystem
  32041. * @param gradient defines the gradient to remove
  32042. * @returns the current particle system
  32043. */
  32044. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  32045. /**
  32046. * Not supported by GPUParticleSystem
  32047. * @param gradient defines the gradient to use (between 0 and 1)
  32048. * @param color defines the color to affect to the specified gradient
  32049. * @returns the current particle system
  32050. */
  32051. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  32052. /**
  32053. * Not supported by GPUParticleSystem
  32054. * @param gradient defines the gradient to remove
  32055. * @returns the current particle system
  32056. */
  32057. removeRampGradient(gradient: number): IParticleSystem;
  32058. /**
  32059. * Not supported by GPUParticleSystem
  32060. * @returns the list of ramp gradients
  32061. */
  32062. getRampGradients(): Nullable<Array<Color3Gradient>>;
  32063. /**
  32064. * Not supported by GPUParticleSystem
  32065. * Gets or sets a boolean indicating that ramp gradients must be used
  32066. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  32067. */
  32068. useRampGradients: boolean;
  32069. /**
  32070. * Not supported by GPUParticleSystem
  32071. * @param gradient defines the gradient to use (between 0 and 1)
  32072. * @param factor defines the life time factor to affect to the specified gradient
  32073. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32074. * @returns the current particle system
  32075. */
  32076. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32077. /**
  32078. * Not supported by GPUParticleSystem
  32079. * @param gradient defines the gradient to remove
  32080. * @returns the current particle system
  32081. */
  32082. removeLifeTimeGradient(gradient: number): IParticleSystem;
  32083. /**
  32084. * Instantiates a GPU particle system.
  32085. * 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.
  32086. * @param name The name of the particle system
  32087. * @param options The options used to create the system
  32088. * @param scene The scene the particle system belongs to
  32089. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  32090. */
  32091. constructor(name: string, options: Partial<{
  32092. capacity: number;
  32093. randomTextureSize: number;
  32094. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  32095. protected _reset(): void;
  32096. private _createUpdateVAO;
  32097. private _createRenderVAO;
  32098. private _initialize;
  32099. /** @hidden */
  32100. _recreateUpdateEffect(): void;
  32101. /** @hidden */
  32102. _recreateRenderEffect(): void;
  32103. /**
  32104. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  32105. * @param preWarm defines if we are in the pre-warmimg phase
  32106. */
  32107. animate(preWarm?: boolean): void;
  32108. private _createFactorGradientTexture;
  32109. private _createSizeGradientTexture;
  32110. private _createAngularSpeedGradientTexture;
  32111. private _createVelocityGradientTexture;
  32112. private _createLimitVelocityGradientTexture;
  32113. private _createDragGradientTexture;
  32114. private _createColorGradientTexture;
  32115. /**
  32116. * Renders the particle system in its current state
  32117. * @param preWarm defines if the system should only update the particles but not render them
  32118. * @returns the current number of particles
  32119. */
  32120. render(preWarm?: boolean): number;
  32121. /**
  32122. * Rebuilds the particle system
  32123. */
  32124. rebuild(): void;
  32125. private _releaseBuffers;
  32126. private _releaseVAOs;
  32127. /**
  32128. * Disposes the particle system and free the associated resources
  32129. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32130. */
  32131. dispose(disposeTexture?: boolean): void;
  32132. /**
  32133. * Clones the particle system.
  32134. * @param name The name of the cloned object
  32135. * @param newEmitter The new emitter to use
  32136. * @returns the cloned particle system
  32137. */
  32138. clone(name: string, newEmitter: any): GPUParticleSystem;
  32139. /**
  32140. * Serializes the particle system to a JSON object.
  32141. * @returns the JSON object
  32142. */
  32143. serialize(): any;
  32144. /**
  32145. * Parses a JSON object to create a GPU particle system.
  32146. * @param parsedParticleSystem The JSON object to parse
  32147. * @param scene The scene to create the particle system in
  32148. * @param rootUrl The root url to use to load external dependencies like texture
  32149. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  32150. * @returns the parsed GPU particle system
  32151. */
  32152. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  32153. }
  32154. }
  32155. declare module BABYLON {
  32156. /**
  32157. * Interface representing a particle system in Babylon.js.
  32158. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  32159. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  32160. */
  32161. interface IParticleSystem {
  32162. /**
  32163. * List of animations used by the particle system.
  32164. */
  32165. animations: Animation[];
  32166. /**
  32167. * The id of the Particle system.
  32168. */
  32169. id: string;
  32170. /**
  32171. * The name of the Particle system.
  32172. */
  32173. name: string;
  32174. /**
  32175. * The emitter represents the Mesh or position we are attaching the particle system to.
  32176. */
  32177. emitter: Nullable<AbstractMesh | Vector3>;
  32178. /**
  32179. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  32180. */
  32181. isBillboardBased: boolean;
  32182. /**
  32183. * The rendering group used by the Particle system to chose when to render.
  32184. */
  32185. renderingGroupId: number;
  32186. /**
  32187. * The layer mask we are rendering the particles through.
  32188. */
  32189. layerMask: number;
  32190. /**
  32191. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  32192. */
  32193. updateSpeed: number;
  32194. /**
  32195. * The amount of time the particle system is running (depends of the overall update speed).
  32196. */
  32197. targetStopDuration: number;
  32198. /**
  32199. * The texture used to render each particle. (this can be a spritesheet)
  32200. */
  32201. particleTexture: Nullable<Texture>;
  32202. /**
  32203. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  32204. */
  32205. blendMode: number;
  32206. /**
  32207. * Minimum life time of emitting particles.
  32208. */
  32209. minLifeTime: number;
  32210. /**
  32211. * Maximum life time of emitting particles.
  32212. */
  32213. maxLifeTime: number;
  32214. /**
  32215. * Minimum Size of emitting particles.
  32216. */
  32217. minSize: number;
  32218. /**
  32219. * Maximum Size of emitting particles.
  32220. */
  32221. maxSize: number;
  32222. /**
  32223. * Minimum scale of emitting particles on X axis.
  32224. */
  32225. minScaleX: number;
  32226. /**
  32227. * Maximum scale of emitting particles on X axis.
  32228. */
  32229. maxScaleX: number;
  32230. /**
  32231. * Minimum scale of emitting particles on Y axis.
  32232. */
  32233. minScaleY: number;
  32234. /**
  32235. * Maximum scale of emitting particles on Y axis.
  32236. */
  32237. maxScaleY: number;
  32238. /**
  32239. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  32240. */
  32241. color1: Color4;
  32242. /**
  32243. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  32244. */
  32245. color2: Color4;
  32246. /**
  32247. * Color the particle will have at the end of its lifetime.
  32248. */
  32249. colorDead: Color4;
  32250. /**
  32251. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  32252. */
  32253. emitRate: number;
  32254. /**
  32255. * You can use gravity if you want to give an orientation to your particles.
  32256. */
  32257. gravity: Vector3;
  32258. /**
  32259. * Minimum power of emitting particles.
  32260. */
  32261. minEmitPower: number;
  32262. /**
  32263. * Maximum power of emitting particles.
  32264. */
  32265. maxEmitPower: number;
  32266. /**
  32267. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  32268. */
  32269. minAngularSpeed: number;
  32270. /**
  32271. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  32272. */
  32273. maxAngularSpeed: number;
  32274. /**
  32275. * Gets or sets the minimal initial rotation in radians.
  32276. */
  32277. minInitialRotation: number;
  32278. /**
  32279. * Gets or sets the maximal initial rotation in radians.
  32280. */
  32281. maxInitialRotation: number;
  32282. /**
  32283. * The particle emitter type defines the emitter used by the particle system.
  32284. * It can be for example box, sphere, or cone...
  32285. */
  32286. particleEmitterType: Nullable<IParticleEmitterType>;
  32287. /**
  32288. * Defines the delay in milliseconds before starting the system (0 by default)
  32289. */
  32290. startDelay: number;
  32291. /**
  32292. * 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
  32293. */
  32294. preWarmCycles: number;
  32295. /**
  32296. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  32297. */
  32298. preWarmStepOffset: number;
  32299. /**
  32300. * 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)
  32301. */
  32302. spriteCellChangeSpeed: number;
  32303. /**
  32304. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  32305. */
  32306. startSpriteCellID: number;
  32307. /**
  32308. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  32309. */
  32310. endSpriteCellID: number;
  32311. /**
  32312. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  32313. */
  32314. spriteCellWidth: number;
  32315. /**
  32316. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  32317. */
  32318. spriteCellHeight: number;
  32319. /**
  32320. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  32321. */
  32322. spriteRandomStartCell: boolean;
  32323. /**
  32324. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  32325. */
  32326. isAnimationSheetEnabled: boolean;
  32327. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  32328. translationPivot: Vector2;
  32329. /**
  32330. * Gets or sets a texture used to add random noise to particle positions
  32331. */
  32332. noiseTexture: Nullable<BaseTexture>;
  32333. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  32334. noiseStrength: Vector3;
  32335. /**
  32336. * Gets or sets the billboard mode to use when isBillboardBased = true.
  32337. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  32338. */
  32339. billboardMode: number;
  32340. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  32341. limitVelocityDamping: number;
  32342. /**
  32343. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  32344. */
  32345. beginAnimationOnStart: boolean;
  32346. /**
  32347. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  32348. */
  32349. beginAnimationFrom: number;
  32350. /**
  32351. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  32352. */
  32353. beginAnimationTo: number;
  32354. /**
  32355. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  32356. */
  32357. beginAnimationLoop: boolean;
  32358. /**
  32359. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  32360. */
  32361. disposeOnStop: boolean;
  32362. /**
  32363. * Gets the maximum number of particles active at the same time.
  32364. * @returns The max number of active particles.
  32365. */
  32366. getCapacity(): number;
  32367. /**
  32368. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32369. * @returns True if it has been started, otherwise false.
  32370. */
  32371. isStarted(): boolean;
  32372. /**
  32373. * Animates the particle system for this frame.
  32374. */
  32375. animate(): void;
  32376. /**
  32377. * Renders the particle system in its current state.
  32378. * @returns the current number of particles
  32379. */
  32380. render(): number;
  32381. /**
  32382. * Dispose the particle system and frees its associated resources.
  32383. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32384. */
  32385. dispose(disposeTexture?: boolean): void;
  32386. /**
  32387. * Clones the particle system.
  32388. * @param name The name of the cloned object
  32389. * @param newEmitter The new emitter to use
  32390. * @returns the cloned particle system
  32391. */
  32392. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  32393. /**
  32394. * Serializes the particle system to a JSON object.
  32395. * @returns the JSON object
  32396. */
  32397. serialize(): any;
  32398. /**
  32399. * Rebuild the particle system
  32400. */
  32401. rebuild(): void;
  32402. /**
  32403. * Starts the particle system and begins to emit
  32404. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  32405. */
  32406. start(delay?: number): void;
  32407. /**
  32408. * Stops the particle system.
  32409. */
  32410. stop(): void;
  32411. /**
  32412. * Remove all active particles
  32413. */
  32414. reset(): void;
  32415. /**
  32416. * Is this system ready to be used/rendered
  32417. * @return true if the system is ready
  32418. */
  32419. isReady(): boolean;
  32420. /**
  32421. * Adds a new color gradient
  32422. * @param gradient defines the gradient to use (between 0 and 1)
  32423. * @param color1 defines the color to affect to the specified gradient
  32424. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32425. * @returns the current particle system
  32426. */
  32427. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  32428. /**
  32429. * Remove a specific color gradient
  32430. * @param gradient defines the gradient to remove
  32431. * @returns the current particle system
  32432. */
  32433. removeColorGradient(gradient: number): IParticleSystem;
  32434. /**
  32435. * Adds a new size gradient
  32436. * @param gradient defines the gradient to use (between 0 and 1)
  32437. * @param factor defines the size factor to affect to the specified gradient
  32438. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32439. * @returns the current particle system
  32440. */
  32441. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32442. /**
  32443. * Remove a specific size gradient
  32444. * @param gradient defines the gradient to remove
  32445. * @returns the current particle system
  32446. */
  32447. removeSizeGradient(gradient: number): IParticleSystem;
  32448. /**
  32449. * Gets the current list of color gradients.
  32450. * You must use addColorGradient and removeColorGradient to udpate this list
  32451. * @returns the list of color gradients
  32452. */
  32453. getColorGradients(): Nullable<Array<ColorGradient>>;
  32454. /**
  32455. * Gets the current list of size gradients.
  32456. * You must use addSizeGradient and removeSizeGradient to udpate this list
  32457. * @returns the list of size gradients
  32458. */
  32459. getSizeGradients(): Nullable<Array<FactorGradient>>;
  32460. /**
  32461. * Gets the current list of angular speed gradients.
  32462. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  32463. * @returns the list of angular speed gradients
  32464. */
  32465. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  32466. /**
  32467. * Adds a new angular speed gradient
  32468. * @param gradient defines the gradient to use (between 0 and 1)
  32469. * @param factor defines the angular speed to affect to the specified gradient
  32470. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32471. * @returns the current particle system
  32472. */
  32473. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32474. /**
  32475. * Remove a specific angular speed gradient
  32476. * @param gradient defines the gradient to remove
  32477. * @returns the current particle system
  32478. */
  32479. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  32480. /**
  32481. * Gets the current list of velocity gradients.
  32482. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  32483. * @returns the list of velocity gradients
  32484. */
  32485. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  32486. /**
  32487. * Adds a new velocity gradient
  32488. * @param gradient defines the gradient to use (between 0 and 1)
  32489. * @param factor defines the velocity to affect to the specified gradient
  32490. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32491. * @returns the current particle system
  32492. */
  32493. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32494. /**
  32495. * Remove a specific velocity gradient
  32496. * @param gradient defines the gradient to remove
  32497. * @returns the current particle system
  32498. */
  32499. removeVelocityGradient(gradient: number): IParticleSystem;
  32500. /**
  32501. * Gets the current list of limit velocity gradients.
  32502. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  32503. * @returns the list of limit velocity gradients
  32504. */
  32505. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  32506. /**
  32507. * Adds a new limit velocity gradient
  32508. * @param gradient defines the gradient to use (between 0 and 1)
  32509. * @param factor defines the limit velocity to affect to the specified gradient
  32510. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32511. * @returns the current particle system
  32512. */
  32513. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32514. /**
  32515. * Remove a specific limit velocity gradient
  32516. * @param gradient defines the gradient to remove
  32517. * @returns the current particle system
  32518. */
  32519. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  32520. /**
  32521. * Adds a new drag gradient
  32522. * @param gradient defines the gradient to use (between 0 and 1)
  32523. * @param factor defines the drag to affect to the specified gradient
  32524. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32525. * @returns the current particle system
  32526. */
  32527. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32528. /**
  32529. * Remove a specific drag gradient
  32530. * @param gradient defines the gradient to remove
  32531. * @returns the current particle system
  32532. */
  32533. removeDragGradient(gradient: number): IParticleSystem;
  32534. /**
  32535. * Gets the current list of drag gradients.
  32536. * You must use addDragGradient and removeDragGradient to udpate this list
  32537. * @returns the list of drag gradients
  32538. */
  32539. getDragGradients(): Nullable<Array<FactorGradient>>;
  32540. /**
  32541. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  32542. * @param gradient defines the gradient to use (between 0 and 1)
  32543. * @param factor defines the emit rate to affect to the specified gradient
  32544. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32545. * @returns the current particle system
  32546. */
  32547. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32548. /**
  32549. * Remove a specific emit rate gradient
  32550. * @param gradient defines the gradient to remove
  32551. * @returns the current particle system
  32552. */
  32553. removeEmitRateGradient(gradient: number): IParticleSystem;
  32554. /**
  32555. * Gets the current list of emit rate gradients.
  32556. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  32557. * @returns the list of emit rate gradients
  32558. */
  32559. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  32560. /**
  32561. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  32562. * @param gradient defines the gradient to use (between 0 and 1)
  32563. * @param factor defines the start size to affect to the specified gradient
  32564. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32565. * @returns the current particle system
  32566. */
  32567. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32568. /**
  32569. * Remove a specific start size gradient
  32570. * @param gradient defines the gradient to remove
  32571. * @returns the current particle system
  32572. */
  32573. removeStartSizeGradient(gradient: number): IParticleSystem;
  32574. /**
  32575. * Gets the current list of start size gradients.
  32576. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  32577. * @returns the list of start size gradients
  32578. */
  32579. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  32580. /**
  32581. * Adds a new life time gradient
  32582. * @param gradient defines the gradient to use (between 0 and 1)
  32583. * @param factor defines the life time factor to affect to the specified gradient
  32584. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32585. * @returns the current particle system
  32586. */
  32587. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32588. /**
  32589. * Remove a specific life time gradient
  32590. * @param gradient defines the gradient to remove
  32591. * @returns the current particle system
  32592. */
  32593. removeLifeTimeGradient(gradient: number): IParticleSystem;
  32594. /**
  32595. * Gets the current list of life time gradients.
  32596. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  32597. * @returns the list of life time gradients
  32598. */
  32599. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  32600. /**
  32601. * Gets the current list of color gradients.
  32602. * You must use addColorGradient and removeColorGradient to udpate this list
  32603. * @returns the list of color gradients
  32604. */
  32605. getColorGradients(): Nullable<Array<ColorGradient>>;
  32606. /**
  32607. * Adds a new ramp gradient used to remap particle colors
  32608. * @param gradient defines the gradient to use (between 0 and 1)
  32609. * @param color defines the color to affect to the specified gradient
  32610. * @returns the current particle system
  32611. */
  32612. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  32613. /**
  32614. * Gets the current list of ramp gradients.
  32615. * You must use addRampGradient and removeRampGradient to udpate this list
  32616. * @returns the list of ramp gradients
  32617. */
  32618. getRampGradients(): Nullable<Array<Color3Gradient>>;
  32619. /** Gets or sets a boolean indicating that ramp gradients must be used
  32620. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  32621. */
  32622. useRampGradients: boolean;
  32623. /**
  32624. * Adds a new color remap gradient
  32625. * @param gradient defines the gradient to use (between 0 and 1)
  32626. * @param min defines the color remap minimal range
  32627. * @param max defines the color remap maximal range
  32628. * @returns the current particle system
  32629. */
  32630. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32631. /**
  32632. * Gets the current list of color remap gradients.
  32633. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  32634. * @returns the list of color remap gradients
  32635. */
  32636. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  32637. /**
  32638. * Adds a new alpha remap gradient
  32639. * @param gradient defines the gradient to use (between 0 and 1)
  32640. * @param min defines the alpha remap minimal range
  32641. * @param max defines the alpha remap maximal range
  32642. * @returns the current particle system
  32643. */
  32644. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32645. /**
  32646. * Gets the current list of alpha remap gradients.
  32647. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  32648. * @returns the list of alpha remap gradients
  32649. */
  32650. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  32651. /**
  32652. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  32653. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  32654. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  32655. * @returns the emitter
  32656. */
  32657. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  32658. /**
  32659. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  32660. * @param radius The radius of the hemisphere to emit from
  32661. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  32662. * @returns the emitter
  32663. */
  32664. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  32665. /**
  32666. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  32667. * @param radius The radius of the sphere to emit from
  32668. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  32669. * @returns the emitter
  32670. */
  32671. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  32672. /**
  32673. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  32674. * @param radius The radius of the sphere to emit from
  32675. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  32676. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  32677. * @returns the emitter
  32678. */
  32679. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  32680. /**
  32681. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  32682. * @param radius The radius of the emission cylinder
  32683. * @param height The height of the emission cylinder
  32684. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  32685. * @param directionRandomizer How much to randomize the particle direction [0-1]
  32686. * @returns the emitter
  32687. */
  32688. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  32689. /**
  32690. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  32691. * @param radius The radius of the cylinder to emit from
  32692. * @param height The height of the emission cylinder
  32693. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  32694. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  32695. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  32696. * @returns the emitter
  32697. */
  32698. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  32699. /**
  32700. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  32701. * @param radius The radius of the cone to emit from
  32702. * @param angle The base angle of the cone
  32703. * @returns the emitter
  32704. */
  32705. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  32706. /**
  32707. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  32708. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  32709. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  32710. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  32711. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  32712. * @returns the emitter
  32713. */
  32714. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  32715. /**
  32716. * Get hosting scene
  32717. * @returns the scene
  32718. */
  32719. getScene(): Scene;
  32720. }
  32721. }
  32722. declare module BABYLON {
  32723. /**
  32724. * A particle represents one of the element emitted by a particle system.
  32725. * This is mainly define by its coordinates, direction, velocity and age.
  32726. */
  32727. class Particle {
  32728. /**
  32729. * The particle system the particle belongs to.
  32730. */
  32731. particleSystem: ParticleSystem;
  32732. private static _Count;
  32733. /**
  32734. * Unique ID of the particle
  32735. */
  32736. id: number;
  32737. /**
  32738. * The world position of the particle in the scene.
  32739. */
  32740. position: Vector3;
  32741. /**
  32742. * The world direction of the particle in the scene.
  32743. */
  32744. direction: Vector3;
  32745. /**
  32746. * The color of the particle.
  32747. */
  32748. color: Color4;
  32749. /**
  32750. * The color change of the particle per step.
  32751. */
  32752. colorStep: Color4;
  32753. /**
  32754. * Defines how long will the life of the particle be.
  32755. */
  32756. lifeTime: number;
  32757. /**
  32758. * The current age of the particle.
  32759. */
  32760. age: number;
  32761. /**
  32762. * The current size of the particle.
  32763. */
  32764. size: number;
  32765. /**
  32766. * The current scale of the particle.
  32767. */
  32768. scale: Vector2;
  32769. /**
  32770. * The current angle of the particle.
  32771. */
  32772. angle: number;
  32773. /**
  32774. * Defines how fast is the angle changing.
  32775. */
  32776. angularSpeed: number;
  32777. /**
  32778. * Defines the cell index used by the particle to be rendered from a sprite.
  32779. */
  32780. cellIndex: number;
  32781. /**
  32782. * The information required to support color remapping
  32783. */
  32784. remapData: Vector4;
  32785. /** @hidden */
  32786. _randomCellOffset?: number;
  32787. /** @hidden */
  32788. _initialDirection: Nullable<Vector3>;
  32789. /** @hidden */
  32790. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  32791. /** @hidden */
  32792. _initialStartSpriteCellID: number;
  32793. /** @hidden */
  32794. _initialEndSpriteCellID: number;
  32795. /** @hidden */
  32796. _currentColorGradient: Nullable<ColorGradient>;
  32797. /** @hidden */
  32798. _currentColor1: Color4;
  32799. /** @hidden */
  32800. _currentColor2: Color4;
  32801. /** @hidden */
  32802. _currentSizeGradient: Nullable<FactorGradient>;
  32803. /** @hidden */
  32804. _currentSize1: number;
  32805. /** @hidden */
  32806. _currentSize2: number;
  32807. /** @hidden */
  32808. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  32809. /** @hidden */
  32810. _currentAngularSpeed1: number;
  32811. /** @hidden */
  32812. _currentAngularSpeed2: number;
  32813. /** @hidden */
  32814. _currentVelocityGradient: Nullable<FactorGradient>;
  32815. /** @hidden */
  32816. _currentVelocity1: number;
  32817. /** @hidden */
  32818. _currentVelocity2: number;
  32819. /** @hidden */
  32820. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  32821. /** @hidden */
  32822. _currentLimitVelocity1: number;
  32823. /** @hidden */
  32824. _currentLimitVelocity2: number;
  32825. /** @hidden */
  32826. _currentDragGradient: Nullable<FactorGradient>;
  32827. /** @hidden */
  32828. _currentDrag1: number;
  32829. /** @hidden */
  32830. _currentDrag2: number;
  32831. /** @hidden */
  32832. _randomNoiseCoordinates1: Vector3;
  32833. /** @hidden */
  32834. _randomNoiseCoordinates2: Vector3;
  32835. /**
  32836. * Creates a new instance Particle
  32837. * @param particleSystem the particle system the particle belongs to
  32838. */
  32839. constructor(
  32840. /**
  32841. * The particle system the particle belongs to.
  32842. */
  32843. particleSystem: ParticleSystem);
  32844. private updateCellInfoFromSystem;
  32845. /**
  32846. * Defines how the sprite cell index is updated for the particle
  32847. */
  32848. updateCellIndex(): void;
  32849. /** @hidden */
  32850. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  32851. /** @hidden */
  32852. _inheritParticleInfoToSubEmitters(): void;
  32853. /** @hidden */
  32854. _reset(): void;
  32855. /**
  32856. * Copy the properties of particle to another one.
  32857. * @param other the particle to copy the information to.
  32858. */
  32859. copyTo(other: Particle): void;
  32860. }
  32861. }
  32862. declare module BABYLON {
  32863. /**
  32864. * This class is made for on one-liner static method to help creating particle system set.
  32865. */
  32866. class ParticleHelper {
  32867. /**
  32868. * Gets or sets base Assets URL
  32869. */
  32870. static BaseAssetsUrl: string;
  32871. /**
  32872. * Create a default particle system that you can tweak
  32873. * @param emitter defines the emitter to use
  32874. * @param capacity defines the system capacity (default is 500 particles)
  32875. * @param scene defines the hosting scene
  32876. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  32877. * @returns the new Particle system
  32878. */
  32879. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  32880. /**
  32881. * This is the main static method (one-liner) of this helper to create different particle systems
  32882. * @param type This string represents the type to the particle system to create
  32883. * @param scene The scene where the particle system should live
  32884. * @param gpu If the system will use gpu
  32885. * @returns the ParticleSystemSet created
  32886. */
  32887. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  32888. /**
  32889. * Static function used to export a particle system to a ParticleSystemSet variable.
  32890. * Please note that the emitter shape is not exported
  32891. * @param systems defines the particle systems to export
  32892. * @returns the created particle system set
  32893. */
  32894. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  32895. }
  32896. }
  32897. declare module BABYLON {
  32898. /**
  32899. * This represents a particle system in Babylon.
  32900. * 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.
  32901. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  32902. * @example https://doc.babylonjs.com/babylon101/particles
  32903. */
  32904. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  32905. /**
  32906. * Billboard mode will only apply to Y axis
  32907. */
  32908. static readonly BILLBOARDMODE_Y: number;
  32909. /**
  32910. * Billboard mode will apply to all axes
  32911. */
  32912. static readonly BILLBOARDMODE_ALL: number;
  32913. /**
  32914. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  32915. */
  32916. static readonly BILLBOARDMODE_STRETCHED: number;
  32917. /**
  32918. * This function can be defined to provide custom update for active particles.
  32919. * This function will be called instead of regular update (age, position, color, etc.).
  32920. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  32921. */
  32922. updateFunction: (particles: Particle[]) => void;
  32923. private _emitterWorldMatrix;
  32924. /**
  32925. * This function can be defined to specify initial direction for every new particle.
  32926. * It by default use the emitterType defined function
  32927. */
  32928. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  32929. /**
  32930. * This function can be defined to specify initial position for every new particle.
  32931. * It by default use the emitterType defined function
  32932. */
  32933. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  32934. /**
  32935. * @hidden
  32936. */
  32937. _inheritedVelocityOffset: Vector3;
  32938. /**
  32939. * An event triggered when the system is disposed
  32940. */
  32941. onDisposeObservable: Observable<ParticleSystem>;
  32942. private _onDisposeObserver;
  32943. /**
  32944. * Sets a callback that will be triggered when the system is disposed
  32945. */
  32946. onDispose: () => void;
  32947. private _particles;
  32948. private _epsilon;
  32949. private _capacity;
  32950. private _stockParticles;
  32951. private _newPartsExcess;
  32952. private _vertexData;
  32953. private _vertexBuffer;
  32954. private _vertexBuffers;
  32955. private _spriteBuffer;
  32956. private _indexBuffer;
  32957. private _effect;
  32958. private _customEffect;
  32959. private _cachedDefines;
  32960. private _scaledColorStep;
  32961. private _colorDiff;
  32962. private _scaledDirection;
  32963. private _scaledGravity;
  32964. private _currentRenderId;
  32965. private _alive;
  32966. private _useInstancing;
  32967. private _started;
  32968. private _stopped;
  32969. private _actualFrame;
  32970. private _scaledUpdateSpeed;
  32971. private _vertexBufferSize;
  32972. /** @hidden */
  32973. _currentEmitRateGradient: Nullable<FactorGradient>;
  32974. /** @hidden */
  32975. _currentEmitRate1: number;
  32976. /** @hidden */
  32977. _currentEmitRate2: number;
  32978. /** @hidden */
  32979. _currentStartSizeGradient: Nullable<FactorGradient>;
  32980. /** @hidden */
  32981. _currentStartSize1: number;
  32982. /** @hidden */
  32983. _currentStartSize2: number;
  32984. private readonly _rawTextureWidth;
  32985. private _rampGradientsTexture;
  32986. private _useRampGradients;
  32987. /** Gets or sets a boolean indicating that ramp gradients must be used
  32988. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  32989. */
  32990. useRampGradients: boolean;
  32991. /**
  32992. * 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.
  32993. * 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: [])
  32994. */
  32995. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  32996. private _subEmitters;
  32997. /**
  32998. * @hidden
  32999. * If the particle systems emitter should be disposed when the particle system is disposed
  33000. */
  33001. _disposeEmitterOnDispose: boolean;
  33002. /**
  33003. * The current active Sub-systems, this property is used by the root particle system only.
  33004. */
  33005. activeSubSystems: Array<ParticleSystem>;
  33006. private _rootParticleSystem;
  33007. /**
  33008. * Gets the current list of active particles
  33009. */
  33010. readonly particles: Particle[];
  33011. /**
  33012. * Returns the string "ParticleSystem"
  33013. * @returns a string containing the class name
  33014. */
  33015. getClassName(): string;
  33016. /**
  33017. * Instantiates a particle system.
  33018. * 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.
  33019. * @param name The name of the particle system
  33020. * @param capacity The max number of particles alive at the same time
  33021. * @param scene The scene the particle system belongs to
  33022. * @param customEffect a custom effect used to change the way particles are rendered by default
  33023. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  33024. * @param epsilon Offset used to render the particles
  33025. */
  33026. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  33027. private _addFactorGradient;
  33028. private _removeFactorGradient;
  33029. /**
  33030. * Adds a new life time gradient
  33031. * @param gradient defines the gradient to use (between 0 and 1)
  33032. * @param factor defines the life time factor to affect to the specified gradient
  33033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33034. * @returns the current particle system
  33035. */
  33036. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33037. /**
  33038. * Remove a specific life time gradient
  33039. * @param gradient defines the gradient to remove
  33040. * @returns the current particle system
  33041. */
  33042. removeLifeTimeGradient(gradient: number): IParticleSystem;
  33043. /**
  33044. * Adds a new size gradient
  33045. * @param gradient defines the gradient to use (between 0 and 1)
  33046. * @param factor defines the size factor to affect to the specified gradient
  33047. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33048. * @returns the current particle system
  33049. */
  33050. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33051. /**
  33052. * Remove a specific size gradient
  33053. * @param gradient defines the gradient to remove
  33054. * @returns the current particle system
  33055. */
  33056. removeSizeGradient(gradient: number): IParticleSystem;
  33057. /**
  33058. * Adds a new color remap gradient
  33059. * @param gradient defines the gradient to use (between 0 and 1)
  33060. * @param min defines the color remap minimal range
  33061. * @param max defines the color remap maximal range
  33062. * @returns the current particle system
  33063. */
  33064. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  33065. /**
  33066. * Remove a specific color remap gradient
  33067. * @param gradient defines the gradient to remove
  33068. * @returns the current particle system
  33069. */
  33070. removeColorRemapGradient(gradient: number): IParticleSystem;
  33071. /**
  33072. * Adds a new alpha remap gradient
  33073. * @param gradient defines the gradient to use (between 0 and 1)
  33074. * @param min defines the alpha remap minimal range
  33075. * @param max defines the alpha remap maximal range
  33076. * @returns the current particle system
  33077. */
  33078. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  33079. /**
  33080. * Remove a specific alpha remap gradient
  33081. * @param gradient defines the gradient to remove
  33082. * @returns the current particle system
  33083. */
  33084. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  33085. /**
  33086. * Adds a new angular speed gradient
  33087. * @param gradient defines the gradient to use (between 0 and 1)
  33088. * @param factor defines the angular speed to affect to the specified gradient
  33089. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33090. * @returns the current particle system
  33091. */
  33092. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33093. /**
  33094. * Remove a specific angular speed gradient
  33095. * @param gradient defines the gradient to remove
  33096. * @returns the current particle system
  33097. */
  33098. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  33099. /**
  33100. * Adds a new velocity gradient
  33101. * @param gradient defines the gradient to use (between 0 and 1)
  33102. * @param factor defines the velocity to affect to the specified gradient
  33103. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33104. * @returns the current particle system
  33105. */
  33106. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33107. /**
  33108. * Remove a specific velocity gradient
  33109. * @param gradient defines the gradient to remove
  33110. * @returns the current particle system
  33111. */
  33112. removeVelocityGradient(gradient: number): IParticleSystem;
  33113. /**
  33114. * Adds a new limit velocity gradient
  33115. * @param gradient defines the gradient to use (between 0 and 1)
  33116. * @param factor defines the limit velocity value to affect to the specified gradient
  33117. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33118. * @returns the current particle system
  33119. */
  33120. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33121. /**
  33122. * Remove a specific limit velocity gradient
  33123. * @param gradient defines the gradient to remove
  33124. * @returns the current particle system
  33125. */
  33126. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  33127. /**
  33128. * Adds a new drag gradient
  33129. * @param gradient defines the gradient to use (between 0 and 1)
  33130. * @param factor defines the drag value to affect to the specified gradient
  33131. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33132. * @returns the current particle system
  33133. */
  33134. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33135. /**
  33136. * Remove a specific drag gradient
  33137. * @param gradient defines the gradient to remove
  33138. * @returns the current particle system
  33139. */
  33140. removeDragGradient(gradient: number): IParticleSystem;
  33141. /**
  33142. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  33143. * @param gradient defines the gradient to use (between 0 and 1)
  33144. * @param factor defines the emit rate value to affect to the specified gradient
  33145. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33146. * @returns the current particle system
  33147. */
  33148. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33149. /**
  33150. * Remove a specific emit rate gradient
  33151. * @param gradient defines the gradient to remove
  33152. * @returns the current particle system
  33153. */
  33154. removeEmitRateGradient(gradient: number): IParticleSystem;
  33155. /**
  33156. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  33157. * @param gradient defines the gradient to use (between 0 and 1)
  33158. * @param factor defines the start size value to affect to the specified gradient
  33159. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33160. * @returns the current particle system
  33161. */
  33162. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33163. /**
  33164. * Remove a specific start size gradient
  33165. * @param gradient defines the gradient to remove
  33166. * @returns the current particle system
  33167. */
  33168. removeStartSizeGradient(gradient: number): IParticleSystem;
  33169. private _createRampGradientTexture;
  33170. /**
  33171. * Gets the current list of ramp gradients.
  33172. * You must use addRampGradient and removeRampGradient to udpate this list
  33173. * @returns the list of ramp gradients
  33174. */
  33175. getRampGradients(): Nullable<Array<Color3Gradient>>;
  33176. /**
  33177. * Adds a new ramp gradient used to remap particle colors
  33178. * @param gradient defines the gradient to use (between 0 and 1)
  33179. * @param color defines the color to affect to the specified gradient
  33180. * @returns the current particle system
  33181. */
  33182. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  33183. /**
  33184. * Remove a specific ramp gradient
  33185. * @param gradient defines the gradient to remove
  33186. * @returns the current particle system
  33187. */
  33188. removeRampGradient(gradient: number): ParticleSystem;
  33189. /**
  33190. * Adds a new color gradient
  33191. * @param gradient defines the gradient to use (between 0 and 1)
  33192. * @param color1 defines the color to affect to the specified gradient
  33193. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  33194. * @returns this particle system
  33195. */
  33196. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  33197. /**
  33198. * Remove a specific color gradient
  33199. * @param gradient defines the gradient to remove
  33200. * @returns this particle system
  33201. */
  33202. removeColorGradient(gradient: number): IParticleSystem;
  33203. private _fetchR;
  33204. protected _reset(): void;
  33205. private _resetEffect;
  33206. private _createVertexBuffers;
  33207. private _createIndexBuffer;
  33208. /**
  33209. * Gets the maximum number of particles active at the same time.
  33210. * @returns The max number of active particles.
  33211. */
  33212. getCapacity(): number;
  33213. /**
  33214. * Gets whether there are still active particles in the system.
  33215. * @returns True if it is alive, otherwise false.
  33216. */
  33217. isAlive(): boolean;
  33218. /**
  33219. * Gets if the system has been started. (Note: this will still be true after stop is called)
  33220. * @returns True if it has been started, otherwise false.
  33221. */
  33222. isStarted(): boolean;
  33223. private _prepareSubEmitterInternalArray;
  33224. /**
  33225. * Starts the particle system and begins to emit
  33226. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  33227. */
  33228. start(delay?: number): void;
  33229. /**
  33230. * Stops the particle system.
  33231. * @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.
  33232. */
  33233. stop(stopSubEmitters?: boolean): void;
  33234. /**
  33235. * Remove all active particles
  33236. */
  33237. reset(): void;
  33238. /**
  33239. * @hidden (for internal use only)
  33240. */
  33241. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  33242. /**
  33243. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  33244. * Its lifetime will start back at 0.
  33245. */
  33246. recycleParticle: (particle: Particle) => void;
  33247. private _stopSubEmitters;
  33248. private _createParticle;
  33249. private _removeFromRoot;
  33250. private _emitFromParticle;
  33251. private _update;
  33252. /** @hidden */
  33253. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  33254. /** @hidden */
  33255. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  33256. /** @hidden */
  33257. private _getEffect;
  33258. /**
  33259. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  33260. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  33261. */
  33262. animate(preWarmOnly?: boolean): void;
  33263. private _appendParticleVertices;
  33264. /**
  33265. * Rebuilds the particle system.
  33266. */
  33267. rebuild(): void;
  33268. /**
  33269. * Is this system ready to be used/rendered
  33270. * @return true if the system is ready
  33271. */
  33272. isReady(): boolean;
  33273. private _render;
  33274. /**
  33275. * Renders the particle system in its current state.
  33276. * @returns the current number of particles
  33277. */
  33278. render(): number;
  33279. /**
  33280. * Disposes the particle system and free the associated resources
  33281. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  33282. */
  33283. dispose(disposeTexture?: boolean): void;
  33284. /**
  33285. * Clones the particle system.
  33286. * @param name The name of the cloned object
  33287. * @param newEmitter The new emitter to use
  33288. * @returns the cloned particle system
  33289. */
  33290. clone(name: string, newEmitter: any): ParticleSystem;
  33291. /**
  33292. * Serializes the particle system to a JSON object.
  33293. * @returns the JSON object
  33294. */
  33295. serialize(): any;
  33296. /** @hidden */
  33297. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  33298. /** @hidden */
  33299. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  33300. /**
  33301. * Parses a JSON object to create a particle system.
  33302. * @param parsedParticleSystem The JSON object to parse
  33303. * @param scene The scene to create the particle system in
  33304. * @param rootUrl The root url to use to load external dependencies like texture
  33305. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  33306. * @returns the Parsed particle system
  33307. */
  33308. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  33309. }
  33310. }
  33311. declare module BABYLON {
  33312. interface Engine {
  33313. /**
  33314. * Create an effect to use with particle systems.
  33315. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  33316. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  33317. * @param uniformsNames defines a list of attribute names
  33318. * @param samplers defines an array of string used to represent textures
  33319. * @param defines defines the string containing the defines to use to compile the shaders
  33320. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  33321. * @param onCompiled defines a function to call when the effect creation is successful
  33322. * @param onError defines a function to call when the effect creation has failed
  33323. * @returns the new Effect
  33324. */
  33325. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  33326. }
  33327. interface Mesh {
  33328. /**
  33329. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  33330. * @returns an array of IParticleSystem
  33331. */
  33332. getEmittedParticleSystems(): IParticleSystem[];
  33333. /**
  33334. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  33335. * @returns an array of IParticleSystem
  33336. */
  33337. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  33338. }
  33339. }
  33340. declare module BABYLON {
  33341. /**
  33342. * Represents a set of particle systems working together to create a specific effect
  33343. */
  33344. class ParticleSystemSet implements IDisposable {
  33345. private _emitterCreationOptions;
  33346. private _emitterNode;
  33347. /**
  33348. * Gets the particle system list
  33349. */
  33350. systems: IParticleSystem[];
  33351. /**
  33352. * Gets the emitter node used with this set
  33353. */
  33354. readonly emitterNode: Nullable<TransformNode>;
  33355. /**
  33356. * Creates a new emitter mesh as a sphere
  33357. * @param options defines the options used to create the sphere
  33358. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  33359. * @param scene defines the hosting scene
  33360. */
  33361. setEmitterAsSphere(options: {
  33362. diameter: number;
  33363. segments: number;
  33364. color: Color3;
  33365. }, renderingGroupId: number, scene: Scene): void;
  33366. /**
  33367. * Starts all particle systems of the set
  33368. * @param emitter defines an optional mesh to use as emitter for the particle systems
  33369. */
  33370. start(emitter?: AbstractMesh): void;
  33371. /**
  33372. * Release all associated resources
  33373. */
  33374. dispose(): void;
  33375. /**
  33376. * Serialize the set into a JSON compatible object
  33377. * @returns a JSON compatible representation of the set
  33378. */
  33379. serialize(): any;
  33380. /**
  33381. * Parse a new ParticleSystemSet from a serialized source
  33382. * @param data defines a JSON compatible representation of the set
  33383. * @param scene defines the hosting scene
  33384. * @param gpu defines if we want GPU particles or CPU particles
  33385. * @returns a new ParticleSystemSet
  33386. */
  33387. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  33388. }
  33389. }
  33390. declare module BABYLON {
  33391. /**
  33392. * Represents one particle of a solid particle system.
  33393. */
  33394. class SolidParticle {
  33395. /**
  33396. * particle global index
  33397. */
  33398. idx: number;
  33399. /**
  33400. * The color of the particle
  33401. */
  33402. color: Nullable<Color4>;
  33403. /**
  33404. * The world space position of the particle.
  33405. */
  33406. position: Vector3;
  33407. /**
  33408. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  33409. */
  33410. rotation: Vector3;
  33411. /**
  33412. * The world space rotation quaternion of the particle.
  33413. */
  33414. rotationQuaternion: Nullable<Quaternion>;
  33415. /**
  33416. * The scaling of the particle.
  33417. */
  33418. scaling: Vector3;
  33419. /**
  33420. * The uvs of the particle.
  33421. */
  33422. uvs: Vector4;
  33423. /**
  33424. * The current speed of the particle.
  33425. */
  33426. velocity: Vector3;
  33427. /**
  33428. * The pivot point in the particle local space.
  33429. */
  33430. pivot: Vector3;
  33431. /**
  33432. * Must the particle be translated from its pivot point in its local space ?
  33433. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  33434. * Default : false
  33435. */
  33436. translateFromPivot: boolean;
  33437. /**
  33438. * Is the particle active or not ?
  33439. */
  33440. alive: boolean;
  33441. /**
  33442. * Is the particle visible or not ?
  33443. */
  33444. isVisible: boolean;
  33445. /**
  33446. * Index of this particle in the global "positions" array (Internal use)
  33447. * @hidden
  33448. */
  33449. _pos: number;
  33450. /**
  33451. * @hidden Index of this particle in the global "indices" array (Internal use)
  33452. */
  33453. _ind: number;
  33454. /**
  33455. * @hidden ModelShape of this particle (Internal use)
  33456. */
  33457. _model: ModelShape;
  33458. /**
  33459. * ModelShape id of this particle
  33460. */
  33461. shapeId: number;
  33462. /**
  33463. * Index of the particle in its shape id (Internal use)
  33464. */
  33465. idxInShape: number;
  33466. /**
  33467. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  33468. */
  33469. _modelBoundingInfo: BoundingInfo;
  33470. /**
  33471. * @hidden Particle BoundingInfo object (Internal use)
  33472. */
  33473. _boundingInfo: BoundingInfo;
  33474. /**
  33475. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  33476. */
  33477. _sps: SolidParticleSystem;
  33478. /**
  33479. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  33480. */
  33481. _stillInvisible: boolean;
  33482. /**
  33483. * @hidden Last computed particle rotation matrix
  33484. */
  33485. _rotationMatrix: number[];
  33486. /**
  33487. * Parent particle Id, if any.
  33488. * Default null.
  33489. */
  33490. parentId: Nullable<number>;
  33491. /**
  33492. * @hidden Internal global position in the SPS.
  33493. */
  33494. _globalPosition: Vector3;
  33495. /**
  33496. * Creates a Solid Particle object.
  33497. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  33498. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  33499. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  33500. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  33501. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  33502. * @param shapeId (integer) is the model shape identifier in the SPS.
  33503. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  33504. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  33505. */
  33506. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  33507. /**
  33508. * Legacy support, changed scale to scaling
  33509. */
  33510. /**
  33511. * Legacy support, changed scale to scaling
  33512. */
  33513. scale: Vector3;
  33514. /**
  33515. * Legacy support, changed quaternion to rotationQuaternion
  33516. */
  33517. /**
  33518. * Legacy support, changed quaternion to rotationQuaternion
  33519. */
  33520. quaternion: Nullable<Quaternion>;
  33521. /**
  33522. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  33523. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  33524. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  33525. * @returns true if it intersects
  33526. */
  33527. intersectsMesh(target: Mesh | SolidParticle): boolean;
  33528. /**
  33529. * get the rotation matrix of the particle
  33530. * @hidden
  33531. */
  33532. getRotationMatrix(m: Matrix): void;
  33533. }
  33534. /**
  33535. * Represents the shape of the model used by one particle of a solid particle system.
  33536. * SPS internal tool, don't use it manually.
  33537. */
  33538. class ModelShape {
  33539. /**
  33540. * The shape id
  33541. * @hidden
  33542. */
  33543. shapeID: number;
  33544. /**
  33545. * flat array of model positions (internal use)
  33546. * @hidden
  33547. */
  33548. _shape: Vector3[];
  33549. /**
  33550. * flat array of model UVs (internal use)
  33551. * @hidden
  33552. */
  33553. _shapeUV: number[];
  33554. /**
  33555. * length of the shape in the model indices array (internal use)
  33556. * @hidden
  33557. */
  33558. _indicesLength: number;
  33559. /**
  33560. * Custom position function (internal use)
  33561. * @hidden
  33562. */
  33563. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  33564. /**
  33565. * Custom vertex function (internal use)
  33566. * @hidden
  33567. */
  33568. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  33569. /**
  33570. * 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.
  33571. * SPS internal tool, don't use it manually.
  33572. * @hidden
  33573. */
  33574. 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>);
  33575. }
  33576. /**
  33577. * Represents a Depth Sorted Particle in the solid particle system.
  33578. */
  33579. class DepthSortedParticle {
  33580. /**
  33581. * Index of the particle in the "indices" array
  33582. */
  33583. ind: number;
  33584. /**
  33585. * Length of the particle shape in the "indices" array
  33586. */
  33587. indicesLength: number;
  33588. /**
  33589. * Squared distance from the particle to the camera
  33590. */
  33591. sqDistance: number;
  33592. }
  33593. }
  33594. declare module BABYLON {
  33595. /**
  33596. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  33597. *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.
  33598. * The SPS is also a particle system. It provides some methods to manage the particles.
  33599. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  33600. *
  33601. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  33602. */
  33603. class SolidParticleSystem implements IDisposable {
  33604. /**
  33605. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  33606. * Example : var p = SPS.particles[i];
  33607. */
  33608. particles: SolidParticle[];
  33609. /**
  33610. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  33611. */
  33612. nbParticles: number;
  33613. /**
  33614. * If the particles must ever face the camera (default false). Useful for planar particles.
  33615. */
  33616. billboard: boolean;
  33617. /**
  33618. * Recompute normals when adding a shape
  33619. */
  33620. recomputeNormals: boolean;
  33621. /**
  33622. * This a counter ofr your own usage. It's not set by any SPS functions.
  33623. */
  33624. counter: number;
  33625. /**
  33626. * The SPS name. This name is also given to the underlying mesh.
  33627. */
  33628. name: string;
  33629. /**
  33630. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  33631. */
  33632. mesh: Mesh;
  33633. /**
  33634. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  33635. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  33636. */
  33637. vars: any;
  33638. /**
  33639. * This array is populated when the SPS is set as 'pickable'.
  33640. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  33641. * Each element of this array is an object `{idx: int, faceId: int}`.
  33642. * `idx` is the picked particle index in the `SPS.particles` array
  33643. * `faceId` is the picked face index counted within this particle.
  33644. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  33645. */
  33646. pickedParticles: {
  33647. idx: number;
  33648. faceId: number;
  33649. }[];
  33650. /**
  33651. * This array is populated when `enableDepthSort` is set to true.
  33652. * Each element of this array is an instance of the class DepthSortedParticle.
  33653. */
  33654. depthSortedParticles: DepthSortedParticle[];
  33655. /**
  33656. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  33657. * @hidden
  33658. */
  33659. _bSphereOnly: boolean;
  33660. /**
  33661. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  33662. * @hidden
  33663. */
  33664. _bSphereRadiusFactor: number;
  33665. private _scene;
  33666. private _positions;
  33667. private _indices;
  33668. private _normals;
  33669. private _colors;
  33670. private _uvs;
  33671. private _indices32;
  33672. private _positions32;
  33673. private _normals32;
  33674. private _fixedNormal32;
  33675. private _colors32;
  33676. private _uvs32;
  33677. private _index;
  33678. private _updatable;
  33679. private _pickable;
  33680. private _isVisibilityBoxLocked;
  33681. private _alwaysVisible;
  33682. private _depthSort;
  33683. private _shapeCounter;
  33684. private _copy;
  33685. private _color;
  33686. private _computeParticleColor;
  33687. private _computeParticleTexture;
  33688. private _computeParticleRotation;
  33689. private _computeParticleVertex;
  33690. private _computeBoundingBox;
  33691. private _depthSortParticles;
  33692. private _camera;
  33693. private _mustUnrotateFixedNormals;
  33694. private _particlesIntersect;
  33695. private _needs32Bits;
  33696. /**
  33697. * Creates a SPS (Solid Particle System) object.
  33698. * @param name (String) is the SPS name, this will be the underlying mesh name.
  33699. * @param scene (Scene) is the scene in which the SPS is added.
  33700. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  33701. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  33702. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  33703. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  33704. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  33705. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  33706. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  33707. */
  33708. constructor(name: string, scene: Scene, options?: {
  33709. updatable?: boolean;
  33710. isPickable?: boolean;
  33711. enableDepthSort?: boolean;
  33712. particleIntersection?: boolean;
  33713. boundingSphereOnly?: boolean;
  33714. bSphereRadiusFactor?: number;
  33715. });
  33716. /**
  33717. * Builds the SPS underlying mesh. Returns a standard Mesh.
  33718. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  33719. * @returns the created mesh
  33720. */
  33721. buildMesh(): Mesh;
  33722. /**
  33723. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  33724. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  33725. * Thus the particles generated from `digest()` have their property `position` set yet.
  33726. * @param mesh ( Mesh ) is the mesh to be digested
  33727. * @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
  33728. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  33729. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  33730. * @returns the current SPS
  33731. */
  33732. digest(mesh: Mesh, options?: {
  33733. facetNb?: number;
  33734. number?: number;
  33735. delta?: number;
  33736. }): SolidParticleSystem;
  33737. private _unrotateFixedNormals;
  33738. private _resetCopy;
  33739. private _meshBuilder;
  33740. private _posToShape;
  33741. private _uvsToShapeUV;
  33742. private _addParticle;
  33743. /**
  33744. * Adds some particles to the SPS from the model shape. Returns the shape id.
  33745. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  33746. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  33747. * @param nb (positive integer) the number of particles to be created from this model
  33748. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  33749. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  33750. * @returns the number of shapes in the system
  33751. */
  33752. addShape(mesh: Mesh, nb: number, options?: {
  33753. positionFunction?: any;
  33754. vertexFunction?: any;
  33755. }): number;
  33756. private _rebuildParticle;
  33757. /**
  33758. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  33759. * @returns the SPS.
  33760. */
  33761. rebuildMesh(): SolidParticleSystem;
  33762. /**
  33763. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  33764. * This method calls `updateParticle()` for each particle of the SPS.
  33765. * For an animated SPS, it is usually called within the render loop.
  33766. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  33767. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  33768. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  33769. * @returns the SPS.
  33770. */
  33771. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  33772. /**
  33773. * Disposes the SPS.
  33774. */
  33775. dispose(): void;
  33776. /**
  33777. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  33778. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33779. * @returns the SPS.
  33780. */
  33781. refreshVisibleSize(): SolidParticleSystem;
  33782. /**
  33783. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  33784. * @param size the size (float) of the visibility box
  33785. * note : this doesn't lock the SPS mesh bounding box.
  33786. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33787. */
  33788. setVisibilityBox(size: number): void;
  33789. /**
  33790. * Gets whether the SPS as always visible or not
  33791. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33792. */
  33793. /**
  33794. * Sets the SPS as always visible or not
  33795. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33796. */
  33797. isAlwaysVisible: boolean;
  33798. /**
  33799. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  33800. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33801. */
  33802. /**
  33803. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  33804. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33805. */
  33806. isVisibilityBoxLocked: boolean;
  33807. /**
  33808. * Tells to `setParticles()` to compute the particle rotations or not.
  33809. * Default value : true. The SPS is faster when it's set to false.
  33810. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  33811. */
  33812. /**
  33813. * Gets if `setParticles()` computes the particle rotations or not.
  33814. * Default value : true. The SPS is faster when it's set to false.
  33815. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  33816. */
  33817. computeParticleRotation: boolean;
  33818. /**
  33819. * Tells to `setParticles()` to compute the particle colors or not.
  33820. * Default value : true. The SPS is faster when it's set to false.
  33821. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  33822. */
  33823. /**
  33824. * Gets if `setParticles()` computes the particle colors or not.
  33825. * Default value : true. The SPS is faster when it's set to false.
  33826. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  33827. */
  33828. computeParticleColor: boolean;
  33829. /**
  33830. * Gets if `setParticles()` computes the particle textures or not.
  33831. * Default value : true. The SPS is faster when it's set to false.
  33832. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  33833. */
  33834. computeParticleTexture: boolean;
  33835. /**
  33836. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  33837. * Default value : false. The SPS is faster when it's set to false.
  33838. * Note : the particle custom vertex positions aren't stored values.
  33839. */
  33840. /**
  33841. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  33842. * Default value : false. The SPS is faster when it's set to false.
  33843. * Note : the particle custom vertex positions aren't stored values.
  33844. */
  33845. computeParticleVertex: boolean;
  33846. /**
  33847. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  33848. */
  33849. /**
  33850. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  33851. */
  33852. computeBoundingBox: boolean;
  33853. /**
  33854. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  33855. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  33856. * Default : `true`
  33857. */
  33858. /**
  33859. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  33860. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  33861. * Default : `true`
  33862. */
  33863. depthSortParticles: boolean;
  33864. /**
  33865. * This function does nothing. It may be overwritten to set all the particle first values.
  33866. * The SPS doesn't call this function, you may have to call it by your own.
  33867. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  33868. */
  33869. initParticles(): void;
  33870. /**
  33871. * This function does nothing. It may be overwritten to recycle a particle.
  33872. * The SPS doesn't call this function, you may have to call it by your own.
  33873. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  33874. * @param particle The particle to recycle
  33875. * @returns the recycled particle
  33876. */
  33877. recycleParticle(particle: SolidParticle): SolidParticle;
  33878. /**
  33879. * Updates a particle : this function should be overwritten by the user.
  33880. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  33881. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  33882. * @example : just set a particle position or velocity and recycle conditions
  33883. * @param particle The particle to update
  33884. * @returns the updated particle
  33885. */
  33886. updateParticle(particle: SolidParticle): SolidParticle;
  33887. /**
  33888. * Updates a vertex of a particle : it can be overwritten by the user.
  33889. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  33890. * @param particle the current particle
  33891. * @param vertex the current index of the current particle
  33892. * @param pt the index of the current vertex in the particle shape
  33893. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  33894. * @example : just set a vertex particle position
  33895. * @returns the updated vertex
  33896. */
  33897. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  33898. /**
  33899. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  33900. * This does nothing and may be overwritten by the user.
  33901. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  33902. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  33903. * @param update the boolean update value actually passed to setParticles()
  33904. */
  33905. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  33906. /**
  33907. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  33908. * This will be passed three parameters.
  33909. * This does nothing and may be overwritten by the user.
  33910. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  33911. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  33912. * @param update the boolean update value actually passed to setParticles()
  33913. */
  33914. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  33915. }
  33916. }
  33917. declare module BABYLON {
  33918. /**
  33919. * Type of sub emitter
  33920. */
  33921. enum SubEmitterType {
  33922. /**
  33923. * Attached to the particle over it's lifetime
  33924. */
  33925. ATTACHED = 0,
  33926. /**
  33927. * Created when the particle dies
  33928. */
  33929. END = 1
  33930. }
  33931. /**
  33932. * Sub emitter class used to emit particles from an existing particle
  33933. */
  33934. class SubEmitter {
  33935. /**
  33936. * the particle system to be used by the sub emitter
  33937. */
  33938. particleSystem: ParticleSystem;
  33939. /**
  33940. * Type of the submitter (Default: END)
  33941. */
  33942. type: SubEmitterType;
  33943. /**
  33944. * 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)
  33945. * Note: This only is supported when using an emitter of type Mesh
  33946. */
  33947. inheritDirection: boolean;
  33948. /**
  33949. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  33950. */
  33951. inheritedVelocityAmount: number;
  33952. /**
  33953. * Creates a sub emitter
  33954. * @param particleSystem the particle system to be used by the sub emitter
  33955. */
  33956. constructor(
  33957. /**
  33958. * the particle system to be used by the sub emitter
  33959. */
  33960. particleSystem: ParticleSystem);
  33961. /**
  33962. * Clones the sub emitter
  33963. * @returns the cloned sub emitter
  33964. */
  33965. clone(): SubEmitter;
  33966. /**
  33967. * Serialize current object to a JSON object
  33968. * @returns the serialized object
  33969. */
  33970. serialize(): any;
  33971. /**
  33972. * Creates a new SubEmitter from a serialized JSON version
  33973. * @param serializationObject defines the JSON object to read from
  33974. * @param scene defines the hosting scene
  33975. * @param rootUrl defines the rootUrl for data loading
  33976. * @returns a new SubEmitter
  33977. */
  33978. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  33979. /** Release associated resources */
  33980. dispose(): void;
  33981. }
  33982. }
  33983. declare module BABYLON {
  33984. interface Scene {
  33985. /**
  33986. * The list of reflection probes added to the scene
  33987. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  33988. */
  33989. reflectionProbes: Array<ReflectionProbe>;
  33990. }
  33991. /**
  33992. * Class used to generate realtime reflection / refraction cube textures
  33993. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  33994. */
  33995. class ReflectionProbe {
  33996. /** defines the name of the probe */
  33997. name: string;
  33998. private _scene;
  33999. private _renderTargetTexture;
  34000. private _projectionMatrix;
  34001. private _viewMatrix;
  34002. private _target;
  34003. private _add;
  34004. private _attachedMesh;
  34005. private _invertYAxis;
  34006. /** Gets or sets probe position (center of the cube map) */
  34007. position: Vector3;
  34008. /**
  34009. * Creates a new reflection probe
  34010. * @param name defines the name of the probe
  34011. * @param size defines the texture resolution (for each face)
  34012. * @param scene defines the hosting scene
  34013. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  34014. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  34015. */
  34016. constructor(
  34017. /** defines the name of the probe */
  34018. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  34019. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  34020. samples: number;
  34021. /** Gets or sets the refresh rate to use (on every frame by default) */
  34022. refreshRate: number;
  34023. /**
  34024. * Gets the hosting scene
  34025. * @returns a Scene
  34026. */
  34027. getScene(): Scene;
  34028. /** Gets the internal CubeTexture used to render to */
  34029. readonly cubeTexture: RenderTargetTexture;
  34030. /** Gets the list of meshes to render */
  34031. readonly renderList: Nullable<AbstractMesh[]>;
  34032. /**
  34033. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  34034. * @param mesh defines the mesh to attach to
  34035. */
  34036. attachToMesh(mesh: AbstractMesh): void;
  34037. /**
  34038. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  34039. * @param renderingGroupId The rendering group id corresponding to its index
  34040. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34041. */
  34042. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34043. /**
  34044. * Clean all associated resources
  34045. */
  34046. dispose(): void;
  34047. }
  34048. }
  34049. declare module BABYLON {
  34050. /**
  34051. * Postprocess used to generate anaglyphic rendering
  34052. */
  34053. class AnaglyphPostProcess extends PostProcess {
  34054. private _passedProcess;
  34055. /**
  34056. * Creates a new AnaglyphPostProcess
  34057. * @param name defines postprocess name
  34058. * @param options defines creation options or target ratio scale
  34059. * @param rigCameras defines cameras using this postprocess
  34060. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  34061. * @param engine defines hosting engine
  34062. * @param reusable defines if the postprocess will be reused multiple times per frame
  34063. */
  34064. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  34065. }
  34066. }
  34067. declare module BABYLON {
  34068. /**
  34069. * Post process used to render in black and white
  34070. */
  34071. class BlackAndWhitePostProcess extends PostProcess {
  34072. /**
  34073. * Linear about to convert he result to black and white (default: 1)
  34074. */
  34075. degree: number;
  34076. /**
  34077. * Creates a black and white post process
  34078. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  34079. * @param name The name of the effect.
  34080. * @param options The required width/height ratio to downsize to before computing the render pass.
  34081. * @param camera The camera to apply the render pass to.
  34082. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34083. * @param engine The engine which the post process will be applied. (default: current engine)
  34084. * @param reusable If the post process can be reused on the same frame. (default: false)
  34085. */
  34086. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34087. }
  34088. }
  34089. declare module BABYLON {
  34090. /**
  34091. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  34092. */
  34093. class BloomEffect extends PostProcessRenderEffect {
  34094. private bloomScale;
  34095. /**
  34096. * @hidden Internal
  34097. */
  34098. _effects: Array<PostProcess>;
  34099. /**
  34100. * @hidden Internal
  34101. */
  34102. _downscale: ExtractHighlightsPostProcess;
  34103. private _blurX;
  34104. private _blurY;
  34105. private _merge;
  34106. /**
  34107. * The luminance threshold to find bright areas of the image to bloom.
  34108. */
  34109. threshold: number;
  34110. /**
  34111. * The strength of the bloom.
  34112. */
  34113. weight: number;
  34114. /**
  34115. * Specifies the size of the bloom blur kernel, relative to the final output size
  34116. */
  34117. kernel: number;
  34118. /**
  34119. * Creates a new instance of @see BloomEffect
  34120. * @param scene The scene the effect belongs to.
  34121. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  34122. * @param bloomKernel The size of the kernel to be used when applying the blur.
  34123. * @param bloomWeight The the strength of bloom.
  34124. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34125. * @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)
  34126. */
  34127. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  34128. /**
  34129. * Disposes each of the internal effects for a given camera.
  34130. * @param camera The camera to dispose the effect on.
  34131. */
  34132. disposeEffects(camera: Camera): void;
  34133. /**
  34134. * @hidden Internal
  34135. */
  34136. _updateEffects(): void;
  34137. /**
  34138. * Internal
  34139. * @returns if all the contained post processes are ready.
  34140. * @hidden
  34141. */
  34142. _isReady(): boolean;
  34143. }
  34144. }
  34145. declare module BABYLON {
  34146. /**
  34147. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34148. */
  34149. class BloomMergePostProcess extends PostProcess {
  34150. /** Weight of the bloom to be added to the original input. */
  34151. weight: number;
  34152. /**
  34153. * Creates a new instance of @see BloomMergePostProcess
  34154. * @param name The name of the effect.
  34155. * @param originalFromInput Post process which's input will be used for the merge.
  34156. * @param blurred Blurred highlights post process which's output will be used.
  34157. * @param weight Weight of the bloom to be added to the original input.
  34158. * @param options The required width/height ratio to downsize to before computing the render pass.
  34159. * @param camera The camera to apply the render pass to.
  34160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34161. * @param engine The engine which the post process will be applied. (default: current engine)
  34162. * @param reusable If the post process can be reused on the same frame. (default: false)
  34163. * @param textureType Type of textures used when performing the post process. (default: 0)
  34164. * @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)
  34165. */
  34166. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  34167. /** Weight of the bloom to be added to the original input. */
  34168. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34169. }
  34170. }
  34171. declare module BABYLON {
  34172. /**
  34173. * The Blur Post Process which blurs an image based on a kernel and direction.
  34174. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  34175. */
  34176. class BlurPostProcess extends PostProcess {
  34177. /** The direction in which to blur the image. */
  34178. direction: Vector2;
  34179. private blockCompilation;
  34180. protected _kernel: number;
  34181. protected _idealKernel: number;
  34182. protected _packedFloat: boolean;
  34183. private _staticDefines;
  34184. /**
  34185. * Sets the length in pixels of the blur sample region
  34186. */
  34187. /**
  34188. * Gets the length in pixels of the blur sample region
  34189. */
  34190. kernel: number;
  34191. /**
  34192. * Sets wether or not the blur needs to unpack/repack floats
  34193. */
  34194. /**
  34195. * Gets wether or not the blur is unpacking/repacking floats
  34196. */
  34197. packedFloat: boolean;
  34198. /**
  34199. * Creates a new instance BlurPostProcess
  34200. * @param name The name of the effect.
  34201. * @param direction The direction in which to blur the image.
  34202. * @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.
  34203. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  34204. * @param camera The camera to apply the render pass to.
  34205. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34206. * @param engine The engine which the post process will be applied. (default: current engine)
  34207. * @param reusable If the post process can be reused on the same frame. (default: false)
  34208. * @param textureType Type of textures used when performing the post process. (default: 0)
  34209. * @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)
  34210. */
  34211. constructor(name: string,
  34212. /** The direction in which to blur the image. */
  34213. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  34214. /**
  34215. * Updates the effect with the current post process compile time values and recompiles the shader.
  34216. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34217. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34218. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34219. * @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
  34220. * @param onCompiled Called when the shader has been compiled.
  34221. * @param onError Called if there is an error when compiling a shader.
  34222. */
  34223. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34224. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34225. /**
  34226. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  34227. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  34228. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  34229. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  34230. * The gaps between physical kernels are compensated for in the weighting of the samples
  34231. * @param idealKernel Ideal blur kernel.
  34232. * @return Nearest best kernel.
  34233. */
  34234. protected _nearestBestKernel(idealKernel: number): number;
  34235. /**
  34236. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  34237. * @param x The point on the Gaussian distribution to sample.
  34238. * @return the value of the Gaussian function at x.
  34239. */
  34240. protected _gaussianWeight(x: number): number;
  34241. /**
  34242. * Generates a string that can be used as a floating point number in GLSL.
  34243. * @param x Value to print.
  34244. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  34245. * @return GLSL float string.
  34246. */
  34247. protected _glslFloat(x: number, decimalFigures?: number): string;
  34248. }
  34249. }
  34250. declare module BABYLON {
  34251. /**
  34252. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  34253. */
  34254. class ChromaticAberrationPostProcess extends PostProcess {
  34255. /**
  34256. * The amount of seperation of rgb channels (default: 30)
  34257. */
  34258. aberrationAmount: number;
  34259. /**
  34260. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  34261. */
  34262. radialIntensity: number;
  34263. /**
  34264. * 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))
  34265. */
  34266. direction: Vector2;
  34267. /**
  34268. * 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))
  34269. */
  34270. centerPosition: Vector2;
  34271. /**
  34272. * Creates a new instance ChromaticAberrationPostProcess
  34273. * @param name The name of the effect.
  34274. * @param screenWidth The width of the screen to apply the effect on.
  34275. * @param screenHeight The height of the screen to apply the effect on.
  34276. * @param options The required width/height ratio to downsize to before computing the render pass.
  34277. * @param camera The camera to apply the render pass to.
  34278. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34279. * @param engine The engine which the post process will be applied. (default: current engine)
  34280. * @param reusable If the post process can be reused on the same frame. (default: false)
  34281. * @param textureType Type of textures used when performing the post process. (default: 0)
  34282. * @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)
  34283. */
  34284. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34285. }
  34286. }
  34287. declare module BABYLON {
  34288. /**
  34289. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  34290. */
  34291. class CircleOfConfusionPostProcess extends PostProcess {
  34292. /**
  34293. * 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.
  34294. */
  34295. lensSize: number;
  34296. /**
  34297. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34298. */
  34299. fStop: number;
  34300. /**
  34301. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34302. */
  34303. focusDistance: number;
  34304. /**
  34305. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  34306. */
  34307. focalLength: number;
  34308. private _depthTexture;
  34309. /**
  34310. * Creates a new instance CircleOfConfusionPostProcess
  34311. * @param name The name of the effect.
  34312. * @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.
  34313. * @param options The required width/height ratio to downsize to before computing the render pass.
  34314. * @param camera The camera to apply the render pass to.
  34315. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34316. * @param engine The engine which the post process will be applied. (default: current engine)
  34317. * @param reusable If the post process can be reused on the same frame. (default: false)
  34318. * @param textureType Type of textures used when performing the post process. (default: 0)
  34319. * @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)
  34320. */
  34321. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34322. /**
  34323. * 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.
  34324. */
  34325. depthTexture: RenderTargetTexture;
  34326. }
  34327. }
  34328. declare module BABYLON {
  34329. /**
  34330. *
  34331. * This post-process allows the modification of rendered colors by using
  34332. * a 'look-up table' (LUT). This effect is also called Color Grading.
  34333. *
  34334. * The object needs to be provided an url to a texture containing the color
  34335. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  34336. * Use an image editing software to tweak the LUT to match your needs.
  34337. *
  34338. * For an example of a color LUT, see here:
  34339. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  34340. * For explanations on color grading, see here:
  34341. * @see http://udn.epicgames.com/Three/ColorGrading.html
  34342. *
  34343. */
  34344. class ColorCorrectionPostProcess extends PostProcess {
  34345. private _colorTableTexture;
  34346. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34347. }
  34348. }
  34349. declare module BABYLON {
  34350. /**
  34351. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  34352. * input texture to perform effects such as edge detection or sharpening
  34353. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  34354. */
  34355. class ConvolutionPostProcess extends PostProcess {
  34356. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34357. kernel: number[];
  34358. /**
  34359. * Creates a new instance ConvolutionPostProcess
  34360. * @param name The name of the effect.
  34361. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  34362. * @param options The required width/height ratio to downsize to before computing the render pass.
  34363. * @param camera The camera to apply the render pass to.
  34364. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34365. * @param engine The engine which the post process will be applied. (default: current engine)
  34366. * @param reusable If the post process can be reused on the same frame. (default: false)
  34367. * @param textureType Type of textures used when performing the post process. (default: 0)
  34368. */
  34369. constructor(name: string,
  34370. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34371. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34372. /**
  34373. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34374. */
  34375. static EdgeDetect0Kernel: number[];
  34376. /**
  34377. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34378. */
  34379. static EdgeDetect1Kernel: number[];
  34380. /**
  34381. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34382. */
  34383. static EdgeDetect2Kernel: number[];
  34384. /**
  34385. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34386. */
  34387. static SharpenKernel: number[];
  34388. /**
  34389. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34390. */
  34391. static EmbossKernel: number[];
  34392. /**
  34393. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34394. */
  34395. static GaussianKernel: number[];
  34396. }
  34397. }
  34398. declare module BABYLON {
  34399. /**
  34400. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  34401. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  34402. * based on samples that have a large difference in distance than the center pixel.
  34403. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  34404. */
  34405. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  34406. direction: Vector2;
  34407. /**
  34408. * Creates a new instance CircleOfConfusionPostProcess
  34409. * @param name The name of the effect.
  34410. * @param scene The scene the effect belongs to.
  34411. * @param direction The direction the blur should be applied.
  34412. * @param kernel The size of the kernel used to blur.
  34413. * @param options The required width/height ratio to downsize to before computing the render pass.
  34414. * @param camera The camera to apply the render pass to.
  34415. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  34416. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  34417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34418. * @param engine The engine which the post process will be applied. (default: current engine)
  34419. * @param reusable If the post process can be reused on the same frame. (default: false)
  34420. * @param textureType Type of textures used when performing the post process. (default: 0)
  34421. * @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)
  34422. */
  34423. 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);
  34424. }
  34425. }
  34426. declare module BABYLON {
  34427. /**
  34428. * Specifies the level of max blur that should be applied when using the depth of field effect
  34429. */
  34430. enum DepthOfFieldEffectBlurLevel {
  34431. /**
  34432. * Subtle blur
  34433. */
  34434. Low = 0,
  34435. /**
  34436. * Medium blur
  34437. */
  34438. Medium = 1,
  34439. /**
  34440. * Large blur
  34441. */
  34442. High = 2
  34443. }
  34444. /**
  34445. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  34446. */
  34447. class DepthOfFieldEffect extends PostProcessRenderEffect {
  34448. private _circleOfConfusion;
  34449. /**
  34450. * @hidden Internal, blurs from high to low
  34451. */
  34452. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  34453. private _depthOfFieldBlurY;
  34454. private _dofMerge;
  34455. /**
  34456. * @hidden Internal post processes in depth of field effect
  34457. */
  34458. _effects: Array<PostProcess>;
  34459. /**
  34460. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  34461. */
  34462. focalLength: number;
  34463. /**
  34464. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34465. */
  34466. fStop: number;
  34467. /**
  34468. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34469. */
  34470. focusDistance: number;
  34471. /**
  34472. * 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.
  34473. */
  34474. lensSize: number;
  34475. /**
  34476. * Creates a new instance DepthOfFieldEffect
  34477. * @param scene The scene the effect belongs to.
  34478. * @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.
  34479. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34480. * @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)
  34481. */
  34482. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  34483. /**
  34484. * 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.
  34485. */
  34486. depthTexture: RenderTargetTexture;
  34487. /**
  34488. * Disposes each of the internal effects for a given camera.
  34489. * @param camera The camera to dispose the effect on.
  34490. */
  34491. disposeEffects(camera: Camera): void;
  34492. /**
  34493. * @hidden Internal
  34494. */
  34495. _updateEffects(): void;
  34496. /**
  34497. * Internal
  34498. * @returns if all the contained post processes are ready.
  34499. * @hidden
  34500. */
  34501. _isReady(): boolean;
  34502. }
  34503. }
  34504. declare module BABYLON {
  34505. /**
  34506. * Options to be set when merging outputs from the default pipeline.
  34507. */
  34508. class DepthOfFieldMergePostProcessOptions {
  34509. /**
  34510. * The original image to merge on top of
  34511. */
  34512. originalFromInput: PostProcess;
  34513. /**
  34514. * Parameters to perform the merge of the depth of field effect
  34515. */
  34516. depthOfField?: {
  34517. circleOfConfusion: PostProcess;
  34518. blurSteps: Array<PostProcess>;
  34519. };
  34520. /**
  34521. * Parameters to perform the merge of bloom effect
  34522. */
  34523. bloom?: {
  34524. blurred: PostProcess;
  34525. weight: number;
  34526. };
  34527. }
  34528. /**
  34529. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34530. */
  34531. class DepthOfFieldMergePostProcess extends PostProcess {
  34532. private blurSteps;
  34533. /**
  34534. * Creates a new instance of DepthOfFieldMergePostProcess
  34535. * @param name The name of the effect.
  34536. * @param originalFromInput Post process which's input will be used for the merge.
  34537. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  34538. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  34539. * @param options The required width/height ratio to downsize to before computing the render pass.
  34540. * @param camera The camera to apply the render pass to.
  34541. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34542. * @param engine The engine which the post process will be applied. (default: current engine)
  34543. * @param reusable If the post process can be reused on the same frame. (default: false)
  34544. * @param textureType Type of textures used when performing the post process. (default: 0)
  34545. * @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)
  34546. */
  34547. 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);
  34548. /**
  34549. * Updates the effect with the current post process compile time values and recompiles the shader.
  34550. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34551. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34552. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34553. * @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
  34554. * @param onCompiled Called when the shader has been compiled.
  34555. * @param onError Called if there is an error when compiling a shader.
  34556. */
  34557. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34558. }
  34559. }
  34560. declare module BABYLON {
  34561. /**
  34562. * DisplayPassPostProcess which produces an output the same as it's input
  34563. */
  34564. class DisplayPassPostProcess extends PostProcess {
  34565. /**
  34566. * Creates the DisplayPassPostProcess
  34567. * @param name The name of the effect.
  34568. * @param options The required width/height ratio to downsize to before computing the render pass.
  34569. * @param camera The camera to apply the render pass to.
  34570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34571. * @param engine The engine which the post process will be applied. (default: current engine)
  34572. * @param reusable If the post process can be reused on the same frame. (default: false)
  34573. */
  34574. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34575. }
  34576. }
  34577. declare module BABYLON {
  34578. /**
  34579. * 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.
  34580. */
  34581. class ExtractHighlightsPostProcess extends PostProcess {
  34582. /**
  34583. * The luminance threshold, pixels below this value will be set to black.
  34584. */
  34585. threshold: number;
  34586. /** @hidden */
  34587. _exposure: number;
  34588. /**
  34589. * Post process which has the input texture to be used when performing highlight extraction
  34590. * @hidden
  34591. */
  34592. _inputPostProcess: Nullable<PostProcess>;
  34593. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34594. }
  34595. }
  34596. declare module BABYLON {
  34597. /**
  34598. * Applies a kernel filter to the image
  34599. */
  34600. class FilterPostProcess extends PostProcess {
  34601. /** The matrix to be applied to the image */
  34602. kernelMatrix: Matrix;
  34603. /**
  34604. *
  34605. * @param name The name of the effect.
  34606. * @param kernelMatrix The matrix to be applied to the image
  34607. * @param options The required width/height ratio to downsize to before computing the render pass.
  34608. * @param camera The camera to apply the render pass to.
  34609. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34610. * @param engine The engine which the post process will be applied. (default: current engine)
  34611. * @param reusable If the post process can be reused on the same frame. (default: false)
  34612. */
  34613. constructor(name: string,
  34614. /** The matrix to be applied to the image */
  34615. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34616. }
  34617. }
  34618. declare module BABYLON {
  34619. /**
  34620. * Fxaa post process
  34621. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  34622. */
  34623. class FxaaPostProcess extends PostProcess {
  34624. /** @hidden */
  34625. texelWidth: number;
  34626. /** @hidden */
  34627. texelHeight: number;
  34628. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34629. private _getDefines;
  34630. }
  34631. }
  34632. declare module BABYLON {
  34633. /**
  34634. * The GrainPostProcess adds noise to the image at mid luminance levels
  34635. */
  34636. class GrainPostProcess extends PostProcess {
  34637. /**
  34638. * The intensity of the grain added (default: 30)
  34639. */
  34640. intensity: number;
  34641. /**
  34642. * If the grain should be randomized on every frame
  34643. */
  34644. animated: boolean;
  34645. /**
  34646. * Creates a new instance of @see GrainPostProcess
  34647. * @param name The name of the effect.
  34648. * @param options The required width/height ratio to downsize to before computing the render pass.
  34649. * @param camera The camera to apply the render pass to.
  34650. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34651. * @param engine The engine which the post process will be applied. (default: current engine)
  34652. * @param reusable If the post process can be reused on the same frame. (default: false)
  34653. * @param textureType Type of textures used when performing the post process. (default: 0)
  34654. * @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)
  34655. */
  34656. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34657. }
  34658. }
  34659. declare module BABYLON {
  34660. /**
  34661. * Extracts highlights from the image
  34662. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34663. */
  34664. class HighlightsPostProcess extends PostProcess {
  34665. /**
  34666. * Extracts highlights from the image
  34667. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34668. * @param name The name of the effect.
  34669. * @param options The required width/height ratio to downsize to before computing the render pass.
  34670. * @param camera The camera to apply the render pass to.
  34671. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34672. * @param engine The engine which the post process will be applied. (default: current engine)
  34673. * @param reusable If the post process can be reused on the same frame. (default: false)
  34674. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  34675. */
  34676. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34677. }
  34678. }
  34679. declare module BABYLON {
  34680. /**
  34681. * ImageProcessingPostProcess
  34682. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  34683. */
  34684. class ImageProcessingPostProcess extends PostProcess {
  34685. /**
  34686. * Default configuration related to image processing available in the PBR Material.
  34687. */
  34688. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34689. /**
  34690. * Gets the image processing configuration used either in this material.
  34691. */
  34692. /**
  34693. * Sets the Default image processing configuration used either in the this material.
  34694. *
  34695. * If sets to null, the scene one is in use.
  34696. */
  34697. imageProcessingConfiguration: ImageProcessingConfiguration;
  34698. /**
  34699. * Keep track of the image processing observer to allow dispose and replace.
  34700. */
  34701. private _imageProcessingObserver;
  34702. /**
  34703. * Attaches a new image processing configuration to the PBR Material.
  34704. * @param configuration
  34705. */
  34706. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  34707. /**
  34708. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  34709. */
  34710. /**
  34711. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  34712. */
  34713. colorCurves: Nullable<ColorCurves>;
  34714. /**
  34715. * Gets wether the color curves effect is enabled.
  34716. */
  34717. /**
  34718. * Sets wether the color curves effect is enabled.
  34719. */
  34720. colorCurvesEnabled: boolean;
  34721. /**
  34722. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  34723. */
  34724. /**
  34725. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  34726. */
  34727. colorGradingTexture: Nullable<BaseTexture>;
  34728. /**
  34729. * Gets wether the color grading effect is enabled.
  34730. */
  34731. /**
  34732. * Gets wether the color grading effect is enabled.
  34733. */
  34734. colorGradingEnabled: boolean;
  34735. /**
  34736. * Gets exposure used in the effect.
  34737. */
  34738. /**
  34739. * Sets exposure used in the effect.
  34740. */
  34741. exposure: number;
  34742. /**
  34743. * Gets wether tonemapping is enabled or not.
  34744. */
  34745. /**
  34746. * Sets wether tonemapping is enabled or not
  34747. */
  34748. toneMappingEnabled: boolean;
  34749. /**
  34750. * Gets contrast used in the effect.
  34751. */
  34752. /**
  34753. * Sets contrast used in the effect.
  34754. */
  34755. contrast: number;
  34756. /**
  34757. * Gets Vignette stretch size.
  34758. */
  34759. /**
  34760. * Sets Vignette stretch size.
  34761. */
  34762. vignetteStretch: number;
  34763. /**
  34764. * Gets Vignette centre X Offset.
  34765. */
  34766. /**
  34767. * Sets Vignette centre X Offset.
  34768. */
  34769. vignetteCentreX: number;
  34770. /**
  34771. * Gets Vignette centre Y Offset.
  34772. */
  34773. /**
  34774. * Sets Vignette centre Y Offset.
  34775. */
  34776. vignetteCentreY: number;
  34777. /**
  34778. * Gets Vignette weight or intensity of the vignette effect.
  34779. */
  34780. /**
  34781. * Sets Vignette weight or intensity of the vignette effect.
  34782. */
  34783. vignetteWeight: number;
  34784. /**
  34785. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  34786. * if vignetteEnabled is set to true.
  34787. */
  34788. /**
  34789. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  34790. * if vignetteEnabled is set to true.
  34791. */
  34792. vignetteColor: Color4;
  34793. /**
  34794. * Gets Camera field of view used by the Vignette effect.
  34795. */
  34796. /**
  34797. * Sets Camera field of view used by the Vignette effect.
  34798. */
  34799. vignetteCameraFov: number;
  34800. /**
  34801. * Gets the vignette blend mode allowing different kind of effect.
  34802. */
  34803. /**
  34804. * Sets the vignette blend mode allowing different kind of effect.
  34805. */
  34806. vignetteBlendMode: number;
  34807. /**
  34808. * Gets wether the vignette effect is enabled.
  34809. */
  34810. /**
  34811. * Sets wether the vignette effect is enabled.
  34812. */
  34813. vignetteEnabled: boolean;
  34814. private _fromLinearSpace;
  34815. /**
  34816. * Gets wether the input of the processing is in Gamma or Linear Space.
  34817. */
  34818. /**
  34819. * Sets wether the input of the processing is in Gamma or Linear Space.
  34820. */
  34821. fromLinearSpace: boolean;
  34822. /**
  34823. * Defines cache preventing GC.
  34824. */
  34825. private _defines;
  34826. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  34827. /**
  34828. * "ImageProcessingPostProcess"
  34829. * @returns "ImageProcessingPostProcess"
  34830. */
  34831. getClassName(): string;
  34832. protected _updateParameters(): void;
  34833. dispose(camera?: Camera): void;
  34834. }
  34835. }
  34836. declare module BABYLON {
  34837. /**
  34838. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  34839. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  34840. * As an example, all you have to do is to create the post-process:
  34841. * var mb = new BABYLON.MotionBlurPostProcess(
  34842. * 'mb', // The name of the effect.
  34843. * scene, // The scene containing the objects to blur according to their velocity.
  34844. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  34845. * camera // The camera to apply the render pass to.
  34846. * );
  34847. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  34848. */
  34849. class MotionBlurPostProcess extends PostProcess {
  34850. /**
  34851. * Defines how much the image is blurred by the movement. Default value is equal to 1
  34852. */
  34853. motionStrength: number;
  34854. /**
  34855. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  34856. */
  34857. /**
  34858. * Sets the number of iterations to be used for motion blur quality
  34859. */
  34860. motionBlurSamples: number;
  34861. private _motionBlurSamples;
  34862. private _geometryBufferRenderer;
  34863. /**
  34864. * Creates a new instance MotionBlurPostProcess
  34865. * @param name The name of the effect.
  34866. * @param scene The scene containing the objects to blur according to their velocity.
  34867. * @param options The required width/height ratio to downsize to before computing the render pass.
  34868. * @param camera The camera to apply the render pass to.
  34869. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34870. * @param engine The engine which the post process will be applied. (default: current engine)
  34871. * @param reusable If the post process can be reused on the same frame. (default: false)
  34872. * @param textureType Type of textures used when performing the post process. (default: 0)
  34873. * @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)
  34874. */
  34875. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34876. /**
  34877. * Disposes the post process.
  34878. * @param camera The camera to dispose the post process on.
  34879. */
  34880. dispose(camera?: Camera): void;
  34881. }
  34882. }
  34883. declare module BABYLON {
  34884. /**
  34885. * PassPostProcess which produces an output the same as it's input
  34886. */
  34887. class PassPostProcess extends PostProcess {
  34888. /**
  34889. * Creates the PassPostProcess
  34890. * @param name The name of the effect.
  34891. * @param options The required width/height ratio to downsize to before computing the render pass.
  34892. * @param camera The camera to apply the render pass to.
  34893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34894. * @param engine The engine which the post process will be applied. (default: current engine)
  34895. * @param reusable If the post process can be reused on the same frame. (default: false)
  34896. * @param textureType The type of texture to be used when performing the post processing.
  34897. * @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)
  34898. */
  34899. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34900. }
  34901. }
  34902. declare module BABYLON {
  34903. /**
  34904. * Size options for a post process
  34905. */
  34906. type PostProcessOptions = {
  34907. width: number;
  34908. height: number;
  34909. };
  34910. /**
  34911. * PostProcess can be used to apply a shader to a texture after it has been rendered
  34912. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34913. */
  34914. class PostProcess {
  34915. /** Name of the PostProcess. */
  34916. name: string;
  34917. /**
  34918. * Width of the texture to apply the post process on
  34919. */
  34920. width: number;
  34921. /**
  34922. * Height of the texture to apply the post process on
  34923. */
  34924. height: number;
  34925. /**
  34926. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  34927. * @hidden
  34928. */
  34929. _outputTexture: Nullable<InternalTexture>;
  34930. /**
  34931. * Sampling mode used by the shader
  34932. * See https://doc.babylonjs.com/classes/3.1/texture
  34933. */
  34934. renderTargetSamplingMode: number;
  34935. /**
  34936. * Clear color to use when screen clearing
  34937. */
  34938. clearColor: Color4;
  34939. /**
  34940. * If the buffer needs to be cleared before applying the post process. (default: true)
  34941. * Should be set to false if shader will overwrite all previous pixels.
  34942. */
  34943. autoClear: boolean;
  34944. /**
  34945. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  34946. */
  34947. alphaMode: number;
  34948. /**
  34949. * Sets the setAlphaBlendConstants of the babylon engine
  34950. */
  34951. alphaConstants: Color4;
  34952. /**
  34953. * Animations to be used for the post processing
  34954. */
  34955. animations: Animation[];
  34956. /**
  34957. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  34958. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  34959. */
  34960. enablePixelPerfectMode: boolean;
  34961. /**
  34962. * Force the postprocess to be applied without taking in account viewport
  34963. */
  34964. forceFullscreenViewport: boolean;
  34965. /**
  34966. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  34967. *
  34968. * | Value | Type | Description |
  34969. * | ----- | ----------------------------------- | ----------- |
  34970. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  34971. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  34972. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  34973. *
  34974. */
  34975. scaleMode: number;
  34976. /**
  34977. * Force textures to be a power of two (default: false)
  34978. */
  34979. alwaysForcePOT: boolean;
  34980. private _samples;
  34981. /**
  34982. * Number of sample textures (default: 1)
  34983. */
  34984. samples: number;
  34985. /**
  34986. * Modify the scale of the post process to be the same as the viewport (default: false)
  34987. */
  34988. adaptScaleToCurrentViewport: boolean;
  34989. private _camera;
  34990. private _scene;
  34991. private _engine;
  34992. private _options;
  34993. private _reusable;
  34994. private _textureType;
  34995. /**
  34996. * Smart array of input and output textures for the post process.
  34997. * @hidden
  34998. */
  34999. _textures: SmartArray<InternalTexture>;
  35000. /**
  35001. * The index in _textures that corresponds to the output texture.
  35002. * @hidden
  35003. */
  35004. _currentRenderTextureInd: number;
  35005. private _effect;
  35006. private _samplers;
  35007. private _fragmentUrl;
  35008. private _vertexUrl;
  35009. private _parameters;
  35010. private _scaleRatio;
  35011. protected _indexParameters: any;
  35012. private _shareOutputWithPostProcess;
  35013. private _texelSize;
  35014. private _forcedOutputTexture;
  35015. /**
  35016. * An event triggered when the postprocess is activated.
  35017. */
  35018. onActivateObservable: Observable<Camera>;
  35019. private _onActivateObserver;
  35020. /**
  35021. * A function that is added to the onActivateObservable
  35022. */
  35023. onActivate: Nullable<(camera: Camera) => void>;
  35024. /**
  35025. * An event triggered when the postprocess changes its size.
  35026. */
  35027. onSizeChangedObservable: Observable<PostProcess>;
  35028. private _onSizeChangedObserver;
  35029. /**
  35030. * A function that is added to the onSizeChangedObservable
  35031. */
  35032. onSizeChanged: (postProcess: PostProcess) => void;
  35033. /**
  35034. * An event triggered when the postprocess applies its effect.
  35035. */
  35036. onApplyObservable: Observable<Effect>;
  35037. private _onApplyObserver;
  35038. /**
  35039. * A function that is added to the onApplyObservable
  35040. */
  35041. onApply: (effect: Effect) => void;
  35042. /**
  35043. * An event triggered before rendering the postprocess
  35044. */
  35045. onBeforeRenderObservable: Observable<Effect>;
  35046. private _onBeforeRenderObserver;
  35047. /**
  35048. * A function that is added to the onBeforeRenderObservable
  35049. */
  35050. onBeforeRender: (effect: Effect) => void;
  35051. /**
  35052. * An event triggered after rendering the postprocess
  35053. */
  35054. onAfterRenderObservable: Observable<Effect>;
  35055. private _onAfterRenderObserver;
  35056. /**
  35057. * A function that is added to the onAfterRenderObservable
  35058. */
  35059. onAfterRender: (efect: Effect) => void;
  35060. /**
  35061. * 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
  35062. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  35063. */
  35064. inputTexture: InternalTexture;
  35065. /**
  35066. * Gets the camera which post process is applied to.
  35067. * @returns The camera the post process is applied to.
  35068. */
  35069. getCamera(): Camera;
  35070. /**
  35071. * Gets the texel size of the postprocess.
  35072. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  35073. */
  35074. readonly texelSize: Vector2;
  35075. /**
  35076. * Creates a new instance PostProcess
  35077. * @param name The name of the PostProcess.
  35078. * @param fragmentUrl The url of the fragment shader to be used.
  35079. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  35080. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  35081. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35082. * @param camera The camera to apply the render pass to.
  35083. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35084. * @param engine The engine which the post process will be applied. (default: current engine)
  35085. * @param reusable If the post process can be reused on the same frame. (default: false)
  35086. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  35087. * @param textureType Type of textures used when performing the post process. (default: 0)
  35088. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  35089. * @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
  35090. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  35091. */
  35092. constructor(
  35093. /** Name of the PostProcess. */
  35094. 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);
  35095. /**
  35096. * Gets the engine which this post process belongs to.
  35097. * @returns The engine the post process was enabled with.
  35098. */
  35099. getEngine(): Engine;
  35100. /**
  35101. * The effect that is created when initializing the post process.
  35102. * @returns The created effect corrisponding the the postprocess.
  35103. */
  35104. getEffect(): Effect;
  35105. /**
  35106. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  35107. * @param postProcess The post process to share the output with.
  35108. * @returns This post process.
  35109. */
  35110. shareOutputWith(postProcess: PostProcess): PostProcess;
  35111. /**
  35112. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  35113. * This should be called if the post process that shares output with this post process is disabled/disposed.
  35114. */
  35115. useOwnOutput(): void;
  35116. /**
  35117. * Updates the effect with the current post process compile time values and recompiles the shader.
  35118. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35119. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35120. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35121. * @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
  35122. * @param onCompiled Called when the shader has been compiled.
  35123. * @param onError Called if there is an error when compiling a shader.
  35124. */
  35125. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35126. /**
  35127. * The post process is reusable if it can be used multiple times within one frame.
  35128. * @returns If the post process is reusable
  35129. */
  35130. isReusable(): boolean;
  35131. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  35132. markTextureDirty(): void;
  35133. /**
  35134. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  35135. * 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.
  35136. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  35137. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  35138. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  35139. * @returns The target texture that was bound to be written to.
  35140. */
  35141. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  35142. /**
  35143. * If the post process is supported.
  35144. */
  35145. readonly isSupported: boolean;
  35146. /**
  35147. * The aspect ratio of the output texture.
  35148. */
  35149. readonly aspectRatio: number;
  35150. /**
  35151. * Get a value indicating if the post-process is ready to be used
  35152. * @returns true if the post-process is ready (shader is compiled)
  35153. */
  35154. isReady(): boolean;
  35155. /**
  35156. * Binds all textures and uniforms to the shader, this will be run on every pass.
  35157. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  35158. */
  35159. apply(): Nullable<Effect>;
  35160. private _disposeTextures;
  35161. /**
  35162. * Disposes the post process.
  35163. * @param camera The camera to dispose the post process on.
  35164. */
  35165. dispose(camera?: Camera): void;
  35166. }
  35167. }
  35168. declare module BABYLON {
  35169. /**
  35170. * PostProcessManager is used to manage one or more post processes or post process pipelines
  35171. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35172. */
  35173. class PostProcessManager {
  35174. private _scene;
  35175. private _indexBuffer;
  35176. private _vertexBuffers;
  35177. /**
  35178. * Creates a new instance PostProcess
  35179. * @param scene The scene that the post process is associated with.
  35180. */
  35181. constructor(scene: Scene);
  35182. private _prepareBuffers;
  35183. private _buildIndexBuffer;
  35184. /**
  35185. * Rebuilds the vertex buffers of the manager.
  35186. * @hidden
  35187. */
  35188. _rebuild(): void;
  35189. /**
  35190. * Prepares a frame to be run through a post process.
  35191. * @param sourceTexture The input texture to the post procesess. (default: null)
  35192. * @param postProcesses An array of post processes to be run. (default: null)
  35193. * @returns True if the post processes were able to be run.
  35194. * @hidden
  35195. */
  35196. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  35197. /**
  35198. * Manually render a set of post processes to a texture.
  35199. * @param postProcesses An array of post processes to be run.
  35200. * @param targetTexture The target texture to render to.
  35201. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  35202. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  35203. * @param lodLevel defines which lod of the texture to render to
  35204. */
  35205. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  35206. /**
  35207. * Finalize the result of the output of the postprocesses.
  35208. * @param doNotPresent If true the result will not be displayed to the screen.
  35209. * @param targetTexture The target texture to render to.
  35210. * @param faceIndex The index of the face to bind the target texture to.
  35211. * @param postProcesses The array of post processes to render.
  35212. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  35213. * @hidden
  35214. */
  35215. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  35216. /**
  35217. * Disposes of the post process manager.
  35218. */
  35219. dispose(): void;
  35220. }
  35221. }
  35222. declare module BABYLON {
  35223. /**
  35224. * Post process which applies a refractin texture
  35225. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35226. */
  35227. class RefractionPostProcess extends PostProcess {
  35228. /** the base color of the refraction (used to taint the rendering) */
  35229. color: Color3;
  35230. /** simulated refraction depth */
  35231. depth: number;
  35232. /** the coefficient of the base color (0 to remove base color tainting) */
  35233. colorLevel: number;
  35234. private _refTexture;
  35235. private _ownRefractionTexture;
  35236. /**
  35237. * Gets or sets the refraction texture
  35238. * Please note that you are responsible for disposing the texture if you set it manually
  35239. */
  35240. refractionTexture: Texture;
  35241. /**
  35242. * Initializes the RefractionPostProcess
  35243. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35244. * @param name The name of the effect.
  35245. * @param refractionTextureUrl Url of the refraction texture to use
  35246. * @param color the base color of the refraction (used to taint the rendering)
  35247. * @param depth simulated refraction depth
  35248. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  35249. * @param camera The camera to apply the render pass to.
  35250. * @param options The required width/height ratio to downsize to before computing the render pass.
  35251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35252. * @param engine The engine which the post process will be applied. (default: current engine)
  35253. * @param reusable If the post process can be reused on the same frame. (default: false)
  35254. */
  35255. constructor(name: string, refractionTextureUrl: string,
  35256. /** the base color of the refraction (used to taint the rendering) */
  35257. color: Color3,
  35258. /** simulated refraction depth */
  35259. depth: number,
  35260. /** the coefficient of the base color (0 to remove base color tainting) */
  35261. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35262. /**
  35263. * Disposes of the post process
  35264. * @param camera Camera to dispose post process on
  35265. */
  35266. dispose(camera: Camera): void;
  35267. }
  35268. }
  35269. declare module BABYLON {
  35270. /**
  35271. * The SharpenPostProcess applies a sharpen kernel to every pixel
  35272. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35273. */
  35274. class SharpenPostProcess extends PostProcess {
  35275. /**
  35276. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  35277. */
  35278. colorAmount: number;
  35279. /**
  35280. * How much sharpness should be applied (default: 0.3)
  35281. */
  35282. edgeAmount: number;
  35283. /**
  35284. * Creates a new instance ConvolutionPostProcess
  35285. * @param name The name of the effect.
  35286. * @param options The required width/height ratio to downsize to before computing the render pass.
  35287. * @param camera The camera to apply the render pass to.
  35288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35289. * @param engine The engine which the post process will be applied. (default: current engine)
  35290. * @param reusable If the post process can be reused on the same frame. (default: false)
  35291. * @param textureType Type of textures used when performing the post process. (default: 0)
  35292. * @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)
  35293. */
  35294. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35295. }
  35296. }
  35297. declare module BABYLON {
  35298. /**
  35299. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  35300. */
  35301. class StereoscopicInterlacePostProcess extends PostProcess {
  35302. private _stepSize;
  35303. private _passedProcess;
  35304. /**
  35305. * Initializes a StereoscopicInterlacePostProcess
  35306. * @param name The name of the effect.
  35307. * @param rigCameras The rig cameras to be appled to the post process
  35308. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  35309. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35310. * @param engine The engine which the post process will be applied. (default: current engine)
  35311. * @param reusable If the post process can be reused on the same frame. (default: false)
  35312. */
  35313. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35314. }
  35315. }
  35316. declare module BABYLON {
  35317. /** Defines operator used for tonemapping */
  35318. enum TonemappingOperator {
  35319. /** Hable */
  35320. Hable = 0,
  35321. /** Reinhard */
  35322. Reinhard = 1,
  35323. /** HejiDawson */
  35324. HejiDawson = 2,
  35325. /** Photographic */
  35326. Photographic = 3
  35327. }
  35328. /**
  35329. * Defines a post process to apply tone mapping
  35330. */
  35331. class TonemapPostProcess extends PostProcess {
  35332. private _operator;
  35333. /** Defines the required exposure adjustement */
  35334. exposureAdjustment: number;
  35335. /**
  35336. * Creates a new TonemapPostProcess
  35337. * @param name defines the name of the postprocess
  35338. * @param _operator defines the operator to use
  35339. * @param exposureAdjustment defines the required exposure adjustement
  35340. * @param camera defines the camera to use (can be null)
  35341. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  35342. * @param engine defines the hosting engine (can be ignore if camera is set)
  35343. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  35344. */
  35345. constructor(name: string, _operator: TonemappingOperator,
  35346. /** Defines the required exposure adjustement */
  35347. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  35348. }
  35349. }
  35350. declare module BABYLON {
  35351. /**
  35352. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  35353. */
  35354. class VolumetricLightScatteringPostProcess extends PostProcess {
  35355. private _volumetricLightScatteringPass;
  35356. private _volumetricLightScatteringRTT;
  35357. private _viewPort;
  35358. private _screenCoordinates;
  35359. private _cachedDefines;
  35360. /**
  35361. * If not undefined, the mesh position is computed from the attached node position
  35362. */
  35363. attachedNode: {
  35364. position: Vector3;
  35365. };
  35366. /**
  35367. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  35368. */
  35369. customMeshPosition: Vector3;
  35370. /**
  35371. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  35372. */
  35373. useCustomMeshPosition: boolean;
  35374. /**
  35375. * If the post-process should inverse the light scattering direction
  35376. */
  35377. invert: boolean;
  35378. /**
  35379. * The internal mesh used by the post-process
  35380. */
  35381. mesh: Mesh;
  35382. /**
  35383. * @hidden
  35384. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  35385. */
  35386. useDiffuseColor: boolean;
  35387. /**
  35388. * Array containing the excluded meshes not rendered in the internal pass
  35389. */
  35390. excludedMeshes: AbstractMesh[];
  35391. /**
  35392. * Controls the overall intensity of the post-process
  35393. */
  35394. exposure: number;
  35395. /**
  35396. * Dissipates each sample's contribution in range [0, 1]
  35397. */
  35398. decay: number;
  35399. /**
  35400. * Controls the overall intensity of each sample
  35401. */
  35402. weight: number;
  35403. /**
  35404. * Controls the density of each sample
  35405. */
  35406. density: number;
  35407. /**
  35408. * @constructor
  35409. * @param name The post-process name
  35410. * @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)
  35411. * @param camera The camera that the post-process will be attached to
  35412. * @param mesh The mesh used to create the light scattering
  35413. * @param samples The post-process quality, default 100
  35414. * @param samplingModeThe post-process filtering mode
  35415. * @param engine The babylon engine
  35416. * @param reusable If the post-process is reusable
  35417. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  35418. */
  35419. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  35420. /**
  35421. * Returns the string "VolumetricLightScatteringPostProcess"
  35422. * @returns "VolumetricLightScatteringPostProcess"
  35423. */
  35424. getClassName(): string;
  35425. private _isReady;
  35426. /**
  35427. * Sets the new light position for light scattering effect
  35428. * @param position The new custom light position
  35429. */
  35430. setCustomMeshPosition(position: Vector3): void;
  35431. /**
  35432. * Returns the light position for light scattering effect
  35433. * @return Vector3 The custom light position
  35434. */
  35435. getCustomMeshPosition(): Vector3;
  35436. /**
  35437. * Disposes the internal assets and detaches the post-process from the camera
  35438. */
  35439. dispose(camera: Camera): void;
  35440. /**
  35441. * Returns the render target texture used by the post-process
  35442. * @return the render target texture used by the post-process
  35443. */
  35444. getPass(): RenderTargetTexture;
  35445. private _meshExcluded;
  35446. private _createPass;
  35447. private _updateMeshScreenCoordinates;
  35448. /**
  35449. * Creates a default mesh for the Volumeric Light Scattering post-process
  35450. * @param name The mesh name
  35451. * @param scene The scene where to create the mesh
  35452. * @return the default mesh
  35453. */
  35454. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  35455. }
  35456. }
  35457. declare module BABYLON {
  35458. /**
  35459. * VRDistortionCorrectionPostProcess used for mobile VR
  35460. */
  35461. class VRDistortionCorrectionPostProcess extends PostProcess {
  35462. private _isRightEye;
  35463. private _distortionFactors;
  35464. private _postProcessScaleFactor;
  35465. private _lensCenterOffset;
  35466. private _scaleIn;
  35467. private _scaleFactor;
  35468. private _lensCenter;
  35469. /**
  35470. * Initializes the VRDistortionCorrectionPostProcess
  35471. * @param name The name of the effect.
  35472. * @param camera The camera to apply the render pass to.
  35473. * @param isRightEye If this is for the right eye distortion
  35474. * @param vrMetrics All the required metrics for the VR camera
  35475. */
  35476. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  35477. }
  35478. }
  35479. declare module BABYLON {
  35480. interface Scene {
  35481. /** @hidden (Backing field) */
  35482. _boundingBoxRenderer: BoundingBoxRenderer;
  35483. /** @hidden (Backing field) */
  35484. _forceShowBoundingBoxes: boolean;
  35485. /**
  35486. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  35487. */
  35488. forceShowBoundingBoxes: boolean;
  35489. /**
  35490. * Gets the bounding box renderer associated with the scene
  35491. * @returns a BoundingBoxRenderer
  35492. */
  35493. getBoundingBoxRenderer(): BoundingBoxRenderer;
  35494. }
  35495. interface AbstractMesh {
  35496. /** @hidden (Backing field) */
  35497. _showBoundingBox: boolean;
  35498. /**
  35499. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  35500. */
  35501. showBoundingBox: boolean;
  35502. }
  35503. /**
  35504. * Component responsible of rendering the bounding box of the meshes in a scene.
  35505. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  35506. */
  35507. class BoundingBoxRenderer implements ISceneComponent {
  35508. /**
  35509. * The component name helpfull to identify the component in the list of scene components.
  35510. */
  35511. readonly name: string;
  35512. /**
  35513. * The scene the component belongs to.
  35514. */
  35515. scene: Scene;
  35516. /**
  35517. * Color of the bounding box lines placed in front of an object
  35518. */
  35519. frontColor: Color3;
  35520. /**
  35521. * Color of the bounding box lines placed behind an object
  35522. */
  35523. backColor: Color3;
  35524. /**
  35525. * Defines if the renderer should show the back lines or not
  35526. */
  35527. showBackLines: boolean;
  35528. /**
  35529. * @hidden
  35530. */
  35531. renderList: SmartArray<BoundingBox>;
  35532. private _colorShader;
  35533. private _vertexBuffers;
  35534. private _indexBuffer;
  35535. /**
  35536. * Instantiates a new bounding box renderer in a scene.
  35537. * @param scene the scene the renderer renders in
  35538. */
  35539. constructor(scene: Scene);
  35540. /**
  35541. * Registers the component in a given scene
  35542. */
  35543. register(): void;
  35544. private _evaluateSubMesh;
  35545. private _activeMesh;
  35546. private _prepareRessources;
  35547. private _createIndexBuffer;
  35548. /**
  35549. * Rebuilds the elements related to this component in case of
  35550. * context lost for instance.
  35551. */
  35552. rebuild(): void;
  35553. /**
  35554. * @hidden
  35555. */
  35556. reset(): void;
  35557. /**
  35558. * Render the bounding boxes of a specific rendering group
  35559. * @param renderingGroupId defines the rendering group to render
  35560. */
  35561. render(renderingGroupId: number): void;
  35562. /**
  35563. * In case of occlusion queries, we can render the occlusion bounding box through this method
  35564. * @param mesh Define the mesh to render the occlusion bounding box for
  35565. */
  35566. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  35567. /**
  35568. * Dispose and release the resources attached to this renderer.
  35569. */
  35570. dispose(): void;
  35571. }
  35572. }
  35573. declare module BABYLON {
  35574. /**
  35575. * This represents a depth renderer in Babylon.
  35576. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  35577. */
  35578. class DepthRenderer {
  35579. private _scene;
  35580. private _depthMap;
  35581. private _effect;
  35582. private _cachedDefines;
  35583. private _camera;
  35584. /**
  35585. * Specifiess that the depth renderer will only be used within
  35586. * the camera it is created for.
  35587. * This can help forcing its rendering during the camera processing.
  35588. */
  35589. useOnlyInActiveCamera: boolean;
  35590. /**
  35591. * Instantiates a depth renderer
  35592. * @param scene The scene the renderer belongs to
  35593. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  35594. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  35595. */
  35596. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  35597. /**
  35598. * Creates the depth rendering effect and checks if the effect is ready.
  35599. * @param subMesh The submesh to be used to render the depth map of
  35600. * @param useInstances If multiple world instances should be used
  35601. * @returns if the depth renderer is ready to render the depth map
  35602. */
  35603. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35604. /**
  35605. * Gets the texture which the depth map will be written to.
  35606. * @returns The depth map texture
  35607. */
  35608. getDepthMap(): RenderTargetTexture;
  35609. /**
  35610. * Disposes of the depth renderer.
  35611. */
  35612. dispose(): void;
  35613. }
  35614. }
  35615. declare module BABYLON {
  35616. interface Scene {
  35617. /** @hidden (Backing field) */
  35618. _depthRenderer: {
  35619. [id: string]: DepthRenderer;
  35620. };
  35621. /**
  35622. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  35623. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  35624. * @returns the created depth renderer
  35625. */
  35626. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  35627. /**
  35628. * Disables a depth renderer for a given camera
  35629. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  35630. */
  35631. disableDepthRenderer(camera?: Nullable<Camera>): void;
  35632. }
  35633. /**
  35634. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  35635. * in several rendering techniques.
  35636. */
  35637. class DepthRendererSceneComponent implements ISceneComponent {
  35638. /**
  35639. * The component name helpfull to identify the component in the list of scene components.
  35640. */
  35641. readonly name: string;
  35642. /**
  35643. * The scene the component belongs to.
  35644. */
  35645. scene: Scene;
  35646. /**
  35647. * Creates a new instance of the component for the given scene
  35648. * @param scene Defines the scene to register the component in
  35649. */
  35650. constructor(scene: Scene);
  35651. /**
  35652. * Registers the component in a given scene
  35653. */
  35654. register(): void;
  35655. /**
  35656. * Rebuilds the elements related to this component in case of
  35657. * context lost for instance.
  35658. */
  35659. rebuild(): void;
  35660. /**
  35661. * Disposes the component and the associated ressources
  35662. */
  35663. dispose(): void;
  35664. private _gatherRenderTargets;
  35665. private _gatherActiveCameraRenderTargets;
  35666. }
  35667. }
  35668. declare module BABYLON {
  35669. interface AbstractMesh {
  35670. /**
  35671. * Disables the mesh edge rendering mode
  35672. * @returns the currentAbstractMesh
  35673. */
  35674. disableEdgesRendering(): AbstractMesh;
  35675. /**
  35676. * Enables the edge rendering mode on the mesh.
  35677. * This mode makes the mesh edges visible
  35678. * @param epsilon defines the maximal distance between two angles to detect a face
  35679. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35680. * @returns the currentAbstractMesh
  35681. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35682. */
  35683. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35684. /**
  35685. * Gets the edgesRenderer associated with the mesh
  35686. */
  35687. edgesRenderer: Nullable<EdgesRenderer>;
  35688. }
  35689. interface LinesMesh {
  35690. /**
  35691. * Enables the edge rendering mode on the mesh.
  35692. * This mode makes the mesh edges visible
  35693. * @param epsilon defines the maximal distance between two angles to detect a face
  35694. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35695. * @returns the currentAbstractMesh
  35696. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35697. */
  35698. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35699. }
  35700. interface InstancedMesh {
  35701. /**
  35702. * Enables the edge rendering mode on the mesh.
  35703. * This mode makes the mesh edges visible
  35704. * @param epsilon defines the maximal distance between two angles to detect a face
  35705. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35706. * @returns the currentInstancedMesh
  35707. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35708. */
  35709. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedMesh;
  35710. }
  35711. /**
  35712. * Defines the minimum contract an Edges renderer should follow.
  35713. */
  35714. interface IEdgesRenderer extends IDisposable {
  35715. /**
  35716. * Gets or sets a boolean indicating if the edgesRenderer is active
  35717. */
  35718. isEnabled: boolean;
  35719. /**
  35720. * Renders the edges of the attached mesh,
  35721. */
  35722. render(): void;
  35723. /**
  35724. * Checks wether or not the edges renderer is ready to render.
  35725. * @return true if ready, otherwise false.
  35726. */
  35727. isReady(): boolean;
  35728. }
  35729. /**
  35730. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  35731. */
  35732. class EdgesRenderer implements IEdgesRenderer {
  35733. /**
  35734. * Define the size of the edges with an orthographic camera
  35735. */
  35736. edgesWidthScalerForOrthographic: number;
  35737. /**
  35738. * Define the size of the edges with a perspective camera
  35739. */
  35740. edgesWidthScalerForPerspective: number;
  35741. protected _source: AbstractMesh;
  35742. protected _linesPositions: number[];
  35743. protected _linesNormals: number[];
  35744. protected _linesIndices: number[];
  35745. protected _epsilon: number;
  35746. protected _indicesCount: number;
  35747. protected _lineShader: ShaderMaterial;
  35748. protected _ib: WebGLBuffer;
  35749. protected _buffers: {
  35750. [key: string]: Nullable<VertexBuffer>;
  35751. };
  35752. protected _checkVerticesInsteadOfIndices: boolean;
  35753. private _meshRebuildObserver;
  35754. private _meshDisposeObserver;
  35755. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  35756. isEnabled: boolean;
  35757. /**
  35758. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  35759. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  35760. * @param source Mesh used to create edges
  35761. * @param epsilon sum of angles in adjacency to check for edge
  35762. * @param checkVerticesInsteadOfIndices
  35763. * @param generateEdgesLines - should generate Lines or only prepare resources.
  35764. */
  35765. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  35766. protected _prepareRessources(): void;
  35767. /** @hidden */
  35768. _rebuild(): void;
  35769. /**
  35770. * Releases the required resources for the edges renderer
  35771. */
  35772. dispose(): void;
  35773. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  35774. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  35775. /**
  35776. * Checks if the pair of p0 and p1 is en edge
  35777. * @param faceIndex
  35778. * @param edge
  35779. * @param faceNormals
  35780. * @param p0
  35781. * @param p1
  35782. * @private
  35783. */
  35784. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  35785. /**
  35786. * push line into the position, normal and index buffer
  35787. * @protected
  35788. */
  35789. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  35790. /**
  35791. * Generates lines edges from adjacencjes
  35792. * @private
  35793. */
  35794. _generateEdgesLines(): void;
  35795. /**
  35796. * Checks wether or not the edges renderer is ready to render.
  35797. * @return true if ready, otherwise false.
  35798. */
  35799. isReady(): boolean;
  35800. /**
  35801. * Renders the edges of the attached mesh,
  35802. */
  35803. render(): void;
  35804. }
  35805. }
  35806. declare module BABYLON {
  35807. /**
  35808. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  35809. */
  35810. class GeometryBufferRenderer {
  35811. /**
  35812. * Constant used to retrieve the position texture index in the G-Buffer textures array
  35813. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  35814. */
  35815. static readonly POSITION_TEXTURE_TYPE: number;
  35816. /**
  35817. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  35818. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  35819. */
  35820. static readonly VELOCITY_TEXTURE_TYPE: number;
  35821. /**
  35822. * Dictionary used to store the previous transformation matrices of each rendered mesh
  35823. * in order to compute objects velocities when enableVelocity is set to "true"
  35824. * @hidden
  35825. */
  35826. _previousTransformationMatrices: {
  35827. [index: number]: Matrix;
  35828. };
  35829. private _scene;
  35830. private _multiRenderTarget;
  35831. private _ratio;
  35832. private _enablePosition;
  35833. private _enableVelocity;
  35834. private _positionIndex;
  35835. private _velocityIndex;
  35836. protected _effect: Effect;
  35837. protected _cachedDefines: string;
  35838. /**
  35839. * Set the render list (meshes to be rendered) used in the G buffer.
  35840. */
  35841. renderList: Mesh[];
  35842. /**
  35843. * Gets wether or not G buffer are supported by the running hardware.
  35844. * This requires draw buffer supports
  35845. */
  35846. readonly isSupported: boolean;
  35847. /**
  35848. * Returns the index of the given texture type in the G-Buffer textures array
  35849. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  35850. * @returns the index of the given texture type in the G-Buffer textures array
  35851. */
  35852. getTextureIndex(textureType: number): number;
  35853. /**
  35854. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  35855. */
  35856. /**
  35857. * Sets whether or not objects positions are enabled for the G buffer.
  35858. */
  35859. enablePosition: boolean;
  35860. /**
  35861. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  35862. */
  35863. /**
  35864. * Sets wether or not objects velocities are enabled for the G buffer.
  35865. */
  35866. enableVelocity: boolean;
  35867. /**
  35868. * Gets the scene associated with the buffer.
  35869. */
  35870. readonly scene: Scene;
  35871. /**
  35872. * Gets the ratio used by the buffer during its creation.
  35873. * How big is the buffer related to the main canvas.
  35874. */
  35875. readonly ratio: number;
  35876. /**
  35877. * Creates a new G Buffer for the scene
  35878. * @param scene The scene the buffer belongs to
  35879. * @param ratio How big is the buffer related to the main canvas.
  35880. */
  35881. constructor(scene: Scene, ratio?: number);
  35882. /**
  35883. * Checks wether everything is ready to render a submesh to the G buffer.
  35884. * @param subMesh the submesh to check readiness for
  35885. * @param useInstances is the mesh drawn using instance or not
  35886. * @returns true if ready otherwise false
  35887. */
  35888. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35889. /**
  35890. * Gets the current underlying G Buffer.
  35891. * @returns the buffer
  35892. */
  35893. getGBuffer(): MultiRenderTarget;
  35894. /**
  35895. * Gets the number of samples used to render the buffer (anti aliasing).
  35896. */
  35897. /**
  35898. * Sets the number of samples used to render the buffer (anti aliasing).
  35899. */
  35900. samples: number;
  35901. /**
  35902. * Disposes the renderer and frees up associated resources.
  35903. */
  35904. dispose(): void;
  35905. protected _createRenderTargets(): void;
  35906. }
  35907. }
  35908. declare module BABYLON {
  35909. interface Scene {
  35910. /** @hidden (Backing field) */
  35911. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  35912. /**
  35913. * Gets or Sets the current geometry buffer associated to the scene.
  35914. */
  35915. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  35916. /**
  35917. * Enables a GeometryBufferRender and associates it with the scene
  35918. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  35919. * @returns the GeometryBufferRenderer
  35920. */
  35921. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  35922. /**
  35923. * Disables the GeometryBufferRender associated with the scene
  35924. */
  35925. disableGeometryBufferRenderer(): void;
  35926. }
  35927. /**
  35928. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  35929. * in several rendering techniques.
  35930. */
  35931. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  35932. /**
  35933. * The component name helpful to identify the component in the list of scene components.
  35934. */
  35935. readonly name: string;
  35936. /**
  35937. * The scene the component belongs to.
  35938. */
  35939. scene: Scene;
  35940. /**
  35941. * Creates a new instance of the component for the given scene
  35942. * @param scene Defines the scene to register the component in
  35943. */
  35944. constructor(scene: Scene);
  35945. /**
  35946. * Registers the component in a given scene
  35947. */
  35948. register(): void;
  35949. /**
  35950. * Rebuilds the elements related to this component in case of
  35951. * context lost for instance.
  35952. */
  35953. rebuild(): void;
  35954. /**
  35955. * Disposes the component and the associated ressources
  35956. */
  35957. dispose(): void;
  35958. private _gatherRenderTargets;
  35959. }
  35960. }
  35961. declare module BABYLON {
  35962. /**
  35963. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  35964. */
  35965. class LineEdgesRenderer extends EdgesRenderer {
  35966. /**
  35967. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  35968. * @param source LineMesh used to generate edges
  35969. * @param epsilon not important (specified angle for edge detection)
  35970. * @param checkVerticesInsteadOfIndices not important for LineMesh
  35971. */
  35972. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  35973. /**
  35974. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  35975. */
  35976. _generateEdgesLines(): void;
  35977. }
  35978. }
  35979. declare module BABYLON {
  35980. interface Scene {
  35981. /** @hidden */
  35982. _outlineRenderer: OutlineRenderer;
  35983. /**
  35984. * Gets the outline renderer associated with the scene
  35985. * @returns a OutlineRenderer
  35986. */
  35987. getOutlineRenderer(): OutlineRenderer;
  35988. }
  35989. interface AbstractMesh {
  35990. /** @hidden (Backing field) */
  35991. _renderOutline: boolean;
  35992. /**
  35993. * Gets or sets a boolean indicating if the outline must be rendered as well
  35994. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  35995. */
  35996. renderOutline: boolean;
  35997. /** @hidden (Backing field) */
  35998. _renderOverlay: boolean;
  35999. /**
  36000. * Gets or sets a boolean indicating if the overlay must be rendered as well
  36001. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  36002. */
  36003. renderOverlay: boolean;
  36004. }
  36005. /**
  36006. * This class is responsible to draw bothe outline/overlay of meshes.
  36007. * It should not be used directly but through the available method on mesh.
  36008. */
  36009. class OutlineRenderer implements ISceneComponent {
  36010. /**
  36011. * The name of the component. Each component must have a unique name.
  36012. */
  36013. name: string;
  36014. /**
  36015. * The scene the component belongs to.
  36016. */
  36017. scene: Scene;
  36018. /**
  36019. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  36020. */
  36021. zOffset: number;
  36022. private _engine;
  36023. private _effect;
  36024. private _cachedDefines;
  36025. private _savedDepthWrite;
  36026. /**
  36027. * Instantiates a new outline renderer. (There could be only one per scene).
  36028. * @param scene Defines the scene it belongs to
  36029. */
  36030. constructor(scene: Scene);
  36031. /**
  36032. * Register the component to one instance of a scene.
  36033. */
  36034. register(): void;
  36035. /**
  36036. * Rebuilds the elements related to this component in case of
  36037. * context lost for instance.
  36038. */
  36039. rebuild(): void;
  36040. /**
  36041. * Disposes the component and the associated ressources.
  36042. */
  36043. dispose(): void;
  36044. /**
  36045. * Renders the outline in the canvas.
  36046. * @param subMesh Defines the sumesh to render
  36047. * @param batch Defines the batch of meshes in case of instances
  36048. * @param useOverlay Defines if the rendering is for the overlay or the outline
  36049. */
  36050. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  36051. /**
  36052. * Returns whether or not the outline renderer is ready for a given submesh.
  36053. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  36054. * @param subMesh Defines the submesh to check readyness for
  36055. * @param useInstances Defines wheter wee are trying to render instances or not
  36056. * @returns true if ready otherwise false
  36057. */
  36058. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36059. private _beforeRenderingMesh;
  36060. private _afterRenderingMesh;
  36061. }
  36062. }
  36063. declare module BABYLON {
  36064. /**
  36065. * This represents the object necessary to create a rendering group.
  36066. * This is exclusively used and created by the rendering manager.
  36067. * To modify the behavior, you use the available helpers in your scene or meshes.
  36068. * @hidden
  36069. */
  36070. class RenderingGroup {
  36071. index: number;
  36072. private _scene;
  36073. private _opaqueSubMeshes;
  36074. private _transparentSubMeshes;
  36075. private _alphaTestSubMeshes;
  36076. private _depthOnlySubMeshes;
  36077. private _particleSystems;
  36078. private _spriteManagers;
  36079. private _opaqueSortCompareFn;
  36080. private _alphaTestSortCompareFn;
  36081. private _transparentSortCompareFn;
  36082. private _renderOpaque;
  36083. private _renderAlphaTest;
  36084. private _renderTransparent;
  36085. private _edgesRenderers;
  36086. onBeforeTransparentRendering: () => void;
  36087. /**
  36088. * Set the opaque sort comparison function.
  36089. * If null the sub meshes will be render in the order they were created
  36090. */
  36091. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36092. /**
  36093. * Set the alpha test sort comparison function.
  36094. * If null the sub meshes will be render in the order they were created
  36095. */
  36096. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36097. /**
  36098. * Set the transparent sort comparison function.
  36099. * If null the sub meshes will be render in the order they were created
  36100. */
  36101. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36102. /**
  36103. * Creates a new rendering group.
  36104. * @param index The rendering group index
  36105. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  36106. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  36107. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  36108. */
  36109. 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>);
  36110. /**
  36111. * Render all the sub meshes contained in the group.
  36112. * @param customRenderFunction Used to override the default render behaviour of the group.
  36113. * @returns true if rendered some submeshes.
  36114. */
  36115. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  36116. /**
  36117. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  36118. * @param subMeshes The submeshes to render
  36119. */
  36120. private renderOpaqueSorted;
  36121. /**
  36122. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  36123. * @param subMeshes The submeshes to render
  36124. */
  36125. private renderAlphaTestSorted;
  36126. /**
  36127. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  36128. * @param subMeshes The submeshes to render
  36129. */
  36130. private renderTransparentSorted;
  36131. /**
  36132. * Renders the submeshes in a specified order.
  36133. * @param subMeshes The submeshes to sort before render
  36134. * @param sortCompareFn The comparison function use to sort
  36135. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  36136. * @param transparent Specifies to activate blending if true
  36137. */
  36138. private static renderSorted;
  36139. /**
  36140. * Renders the submeshes in the order they were dispatched (no sort applied).
  36141. * @param subMeshes The submeshes to render
  36142. */
  36143. private static renderUnsorted;
  36144. /**
  36145. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36146. * are rendered back to front if in the same alpha index.
  36147. *
  36148. * @param a The first submesh
  36149. * @param b The second submesh
  36150. * @returns The result of the comparison
  36151. */
  36152. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  36153. /**
  36154. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36155. * are rendered back to front.
  36156. *
  36157. * @param a The first submesh
  36158. * @param b The second submesh
  36159. * @returns The result of the comparison
  36160. */
  36161. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  36162. /**
  36163. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36164. * are rendered front to back (prevent overdraw).
  36165. *
  36166. * @param a The first submesh
  36167. * @param b The second submesh
  36168. * @returns The result of the comparison
  36169. */
  36170. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  36171. /**
  36172. * Resets the different lists of submeshes to prepare a new frame.
  36173. */
  36174. prepare(): void;
  36175. dispose(): void;
  36176. /**
  36177. * Inserts the submesh in its correct queue depending on its material.
  36178. * @param subMesh The submesh to dispatch
  36179. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36180. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36181. */
  36182. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36183. dispatchSprites(spriteManager: ISpriteManager): void;
  36184. dispatchParticles(particleSystem: IParticleSystem): void;
  36185. private _renderParticles;
  36186. private _renderSprites;
  36187. }
  36188. }
  36189. declare module BABYLON {
  36190. /**
  36191. * Interface describing the different options available in the rendering manager
  36192. * regarding Auto Clear between groups.
  36193. */
  36194. interface IRenderingManagerAutoClearSetup {
  36195. /**
  36196. * Defines whether or not autoclear is enable.
  36197. */
  36198. autoClear: boolean;
  36199. /**
  36200. * Defines whether or not to autoclear the depth buffer.
  36201. */
  36202. depth: boolean;
  36203. /**
  36204. * Defines whether or not to autoclear the stencil buffer.
  36205. */
  36206. stencil: boolean;
  36207. }
  36208. /**
  36209. * This is the manager responsible of all the rendering for meshes sprites and particles.
  36210. * It is enable to manage the different groups as well as the different necessary sort functions.
  36211. * This should not be used directly aside of the few static configurations
  36212. */
  36213. class RenderingManager {
  36214. /**
  36215. * The max id used for rendering groups (not included)
  36216. */
  36217. static MAX_RENDERINGGROUPS: number;
  36218. /**
  36219. * The min id used for rendering groups (included)
  36220. */
  36221. static MIN_RENDERINGGROUPS: number;
  36222. /**
  36223. * Used to globally prevent autoclearing scenes.
  36224. */
  36225. static AUTOCLEAR: boolean;
  36226. /**
  36227. * @hidden
  36228. */
  36229. _useSceneAutoClearSetup: boolean;
  36230. private _scene;
  36231. private _renderingGroups;
  36232. private _depthStencilBufferAlreadyCleaned;
  36233. private _autoClearDepthStencil;
  36234. private _customOpaqueSortCompareFn;
  36235. private _customAlphaTestSortCompareFn;
  36236. private _customTransparentSortCompareFn;
  36237. private _renderingGroupInfo;
  36238. /**
  36239. * Instantiates a new rendering group for a particular scene
  36240. * @param scene Defines the scene the groups belongs to
  36241. */
  36242. constructor(scene: Scene);
  36243. private _clearDepthStencilBuffer;
  36244. /**
  36245. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  36246. * @hidden
  36247. */
  36248. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  36249. /**
  36250. * Resets the different information of the group to prepare a new frame
  36251. * @hidden
  36252. */
  36253. reset(): void;
  36254. /**
  36255. * Dispose and release the group and its associated resources.
  36256. * @hidden
  36257. */
  36258. dispose(): void;
  36259. /**
  36260. * Clear the info related to rendering groups preventing retention points during dispose.
  36261. */
  36262. freeRenderingGroups(): void;
  36263. private _prepareRenderingGroup;
  36264. /**
  36265. * Add a sprite manager to the rendering manager in order to render it this frame.
  36266. * @param spriteManager Define the sprite manager to render
  36267. */
  36268. dispatchSprites(spriteManager: ISpriteManager): void;
  36269. /**
  36270. * Add a particle system to the rendering manager in order to render it this frame.
  36271. * @param particleSystem Define the particle system to render
  36272. */
  36273. dispatchParticles(particleSystem: IParticleSystem): void;
  36274. /**
  36275. * Add a submesh to the manager in order to render it this frame
  36276. * @param subMesh The submesh to dispatch
  36277. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36278. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36279. */
  36280. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36281. /**
  36282. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36283. * This allowed control for front to back rendering or reversly depending of the special needs.
  36284. *
  36285. * @param renderingGroupId The rendering group id corresponding to its index
  36286. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36287. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36288. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36289. */
  36290. 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;
  36291. /**
  36292. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36293. *
  36294. * @param renderingGroupId The rendering group id corresponding to its index
  36295. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36296. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36297. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36298. */
  36299. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36300. /**
  36301. * Gets the current auto clear configuration for one rendering group of the rendering
  36302. * manager.
  36303. * @param index the rendering group index to get the information for
  36304. * @returns The auto clear setup for the requested rendering group
  36305. */
  36306. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36307. }
  36308. }
  36309. declare module BABYLON {
  36310. /**
  36311. * Renders a layer on top of an existing scene
  36312. */
  36313. class UtilityLayerRenderer implements IDisposable {
  36314. /** the original scene that will be rendered on top of */
  36315. originalScene: Scene;
  36316. private _pointerCaptures;
  36317. private _lastPointerEvents;
  36318. private static _DefaultUtilityLayer;
  36319. private static _DefaultKeepDepthUtilityLayer;
  36320. /**
  36321. * 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)
  36322. */
  36323. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  36324. /**
  36325. * 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)
  36326. */
  36327. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  36328. /**
  36329. * The scene that is rendered on top of the original scene
  36330. */
  36331. utilityLayerScene: Scene;
  36332. /**
  36333. * If the utility layer should automatically be rendered on top of existing scene
  36334. */
  36335. shouldRender: boolean;
  36336. /**
  36337. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  36338. */
  36339. onlyCheckPointerDownEvents: boolean;
  36340. /**
  36341. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  36342. */
  36343. processAllEvents: boolean;
  36344. /**
  36345. * Observable raised when the pointer move from the utility layer scene to the main scene
  36346. */
  36347. onPointerOutObservable: Observable<number>;
  36348. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  36349. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  36350. private _afterRenderObserver;
  36351. private _sceneDisposeObserver;
  36352. private _originalPointerObserver;
  36353. /**
  36354. * Instantiates a UtilityLayerRenderer
  36355. * @param originalScene the original scene that will be rendered on top of
  36356. */
  36357. constructor(
  36358. /** the original scene that will be rendered on top of */
  36359. originalScene: Scene);
  36360. private _notifyObservers;
  36361. /**
  36362. * Renders the utility layers scene on top of the original scene
  36363. */
  36364. render(): void;
  36365. /**
  36366. * Disposes of the renderer
  36367. */
  36368. dispose(): void;
  36369. private _updateCamera;
  36370. }
  36371. }
  36372. declare module BABYLON {
  36373. /**
  36374. * Class used to represent a sprite
  36375. * @see http://doc.babylonjs.com/babylon101/sprites
  36376. */
  36377. class Sprite {
  36378. /** defines the name */
  36379. name: string;
  36380. /** Gets or sets the current world position */
  36381. position: Vector3;
  36382. /** Gets or sets the main color */
  36383. color: Color4;
  36384. /** Gets or sets the width */
  36385. width: number;
  36386. /** Gets or sets the height */
  36387. height: number;
  36388. /** Gets or sets rotation angle */
  36389. angle: number;
  36390. /** Gets or sets the cell index in the sprite sheet */
  36391. cellIndex: number;
  36392. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  36393. invertU: number;
  36394. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  36395. invertV: number;
  36396. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  36397. disposeWhenFinishedAnimating: boolean;
  36398. /** Gets the list of attached animations */
  36399. animations: Animation[];
  36400. /** Gets or sets a boolean indicating if the sprite can be picked */
  36401. isPickable: boolean;
  36402. /**
  36403. * Gets or sets the associated action manager
  36404. */
  36405. actionManager: Nullable<ActionManager>;
  36406. private _animationStarted;
  36407. private _loopAnimation;
  36408. private _fromIndex;
  36409. private _toIndex;
  36410. private _delay;
  36411. private _direction;
  36412. private _manager;
  36413. private _time;
  36414. private _onAnimationEnd;
  36415. /**
  36416. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  36417. */
  36418. isVisible: boolean;
  36419. /**
  36420. * Gets or sets the sprite size
  36421. */
  36422. size: number;
  36423. /**
  36424. * Creates a new Sprite
  36425. * @param name defines the name
  36426. * @param manager defines the manager
  36427. */
  36428. constructor(
  36429. /** defines the name */
  36430. name: string, manager: ISpriteManager);
  36431. /**
  36432. * Starts an animation
  36433. * @param from defines the initial key
  36434. * @param to defines the end key
  36435. * @param loop defines if the animation must loop
  36436. * @param delay defines the start delay (in ms)
  36437. * @param onAnimationEnd defines a callback to call when animation ends
  36438. */
  36439. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  36440. /** Stops current animation (if any) */
  36441. stopAnimation(): void;
  36442. /** @hidden */
  36443. _animate(deltaTime: number): void;
  36444. /** Release associated resources */
  36445. dispose(): void;
  36446. }
  36447. }
  36448. declare module BABYLON {
  36449. /**
  36450. * Defines the minimum interface to fullfil in order to be a sprite manager.
  36451. */
  36452. interface ISpriteManager extends IDisposable {
  36453. /**
  36454. * Restricts the camera to viewing objects with the same layerMask.
  36455. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  36456. */
  36457. layerMask: number;
  36458. /**
  36459. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36460. */
  36461. isPickable: boolean;
  36462. /**
  36463. * Specifies the rendering group id for this mesh (0 by default)
  36464. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36465. */
  36466. renderingGroupId: number;
  36467. /**
  36468. * Defines the list of sprites managed by the manager.
  36469. */
  36470. sprites: Array<Sprite>;
  36471. /**
  36472. * Tests the intersection of a sprite with a specific ray.
  36473. * @param ray The ray we are sending to test the collision
  36474. * @param camera The camera space we are sending rays in
  36475. * @param predicate A predicate allowing excluding sprites from the list of object to test
  36476. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  36477. * @returns picking info or null.
  36478. */
  36479. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36480. /**
  36481. * Renders the list of sprites on screen.
  36482. */
  36483. render(): void;
  36484. }
  36485. /**
  36486. * Class used to manage multiple sprites on the same spritesheet
  36487. * @see http://doc.babylonjs.com/babylon101/sprites
  36488. */
  36489. class SpriteManager implements ISpriteManager {
  36490. /** defines the manager's name */
  36491. name: string;
  36492. /** Gets the list of sprites */
  36493. sprites: Sprite[];
  36494. /** Gets or sets the rendering group id (0 by default) */
  36495. renderingGroupId: number;
  36496. /** Gets or sets camera layer mask */
  36497. layerMask: number;
  36498. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  36499. fogEnabled: boolean;
  36500. /** Gets or sets a boolean indicating if the sprites are pickable */
  36501. isPickable: boolean;
  36502. /** Defines the default width of a cell in the spritesheet */
  36503. cellWidth: number;
  36504. /** Defines the default height of a cell in the spritesheet */
  36505. cellHeight: number;
  36506. /**
  36507. * An event triggered when the manager is disposed.
  36508. */
  36509. onDisposeObservable: Observable<SpriteManager>;
  36510. private _onDisposeObserver;
  36511. /**
  36512. * Callback called when the manager is disposed
  36513. */
  36514. onDispose: () => void;
  36515. private _capacity;
  36516. private _spriteTexture;
  36517. private _epsilon;
  36518. private _scene;
  36519. private _vertexData;
  36520. private _buffer;
  36521. private _vertexBuffers;
  36522. private _indexBuffer;
  36523. private _effectBase;
  36524. private _effectFog;
  36525. /**
  36526. * Gets or sets the spritesheet texture
  36527. */
  36528. texture: Texture;
  36529. /**
  36530. * Creates a new sprite manager
  36531. * @param name defines the manager's name
  36532. * @param imgUrl defines the sprite sheet url
  36533. * @param capacity defines the maximum allowed number of sprites
  36534. * @param cellSize defines the size of a sprite cell
  36535. * @param scene defines the hosting scene
  36536. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  36537. * @param samplingMode defines the smapling mode to use with spritesheet
  36538. */
  36539. constructor(
  36540. /** defines the manager's name */
  36541. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  36542. private _appendSpriteVertex;
  36543. /**
  36544. * Intersects the sprites with a ray
  36545. * @param ray defines the ray to intersect with
  36546. * @param camera defines the current active camera
  36547. * @param predicate defines a predicate used to select candidate sprites
  36548. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  36549. * @returns null if no hit or a PickingInfo
  36550. */
  36551. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36552. /**
  36553. * Render all child sprites
  36554. */
  36555. render(): void;
  36556. /**
  36557. * Release associated resources
  36558. */
  36559. dispose(): void;
  36560. }
  36561. }
  36562. declare module BABYLON {
  36563. interface Scene {
  36564. /** @hidden */
  36565. _pointerOverSprite: Nullable<Sprite>;
  36566. /** @hidden */
  36567. _pickedDownSprite: Nullable<Sprite>;
  36568. /** @hidden */
  36569. _tempSpritePickingRay: Nullable<Ray>;
  36570. /**
  36571. * All of the sprite managers added to this scene
  36572. * @see http://doc.babylonjs.com/babylon101/sprites
  36573. */
  36574. spriteManagers: Array<ISpriteManager>;
  36575. /**
  36576. * An event triggered when sprites rendering is about to start
  36577. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  36578. */
  36579. onBeforeSpritesRenderingObservable: Observable<Scene>;
  36580. /**
  36581. * An event triggered when sprites rendering is done
  36582. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  36583. */
  36584. onAfterSpritesRenderingObservable: Observable<Scene>;
  36585. /** @hidden */
  36586. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36587. /** Launch a ray to try to pick a sprite in the scene
  36588. * @param x position on screen
  36589. * @param y position on screen
  36590. * @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
  36591. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36592. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36593. * @returns a PickingInfo
  36594. */
  36595. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36596. /** Use the given ray to pick a sprite in the scene
  36597. * @param ray The ray (in world space) to use to pick meshes
  36598. * @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
  36599. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36600. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  36601. * @returns a PickingInfo
  36602. */
  36603. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36604. /**
  36605. * Force the sprite under the pointer
  36606. * @param sprite defines the sprite to use
  36607. */
  36608. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  36609. /**
  36610. * Gets the sprite under the pointer
  36611. * @returns a Sprite or null if no sprite is under the pointer
  36612. */
  36613. getPointerOverSprite(): Nullable<Sprite>;
  36614. }
  36615. /**
  36616. * Defines the sprite scene component responsible to manage sprites
  36617. * in a given scene.
  36618. */
  36619. class SpriteSceneComponent implements ISceneComponent {
  36620. /**
  36621. * The component name helpfull to identify the component in the list of scene components.
  36622. */
  36623. readonly name: string;
  36624. /**
  36625. * The scene the component belongs to.
  36626. */
  36627. scene: Scene;
  36628. /** @hidden */
  36629. private _spritePredicate;
  36630. /**
  36631. * Creates a new instance of the component for the given scene
  36632. * @param scene Defines the scene to register the component in
  36633. */
  36634. constructor(scene: Scene);
  36635. /**
  36636. * Registers the component in a given scene
  36637. */
  36638. register(): void;
  36639. /**
  36640. * Rebuilds the elements related to this component in case of
  36641. * context lost for instance.
  36642. */
  36643. rebuild(): void;
  36644. /**
  36645. * Disposes the component and the associated ressources.
  36646. */
  36647. dispose(): void;
  36648. private _pickSpriteButKeepRay;
  36649. private _pointerMove;
  36650. private _pointerDown;
  36651. private _pointerUp;
  36652. }
  36653. }
  36654. declare module BABYLON {
  36655. /**
  36656. * @hidden
  36657. **/
  36658. class _AlphaState {
  36659. private _isAlphaBlendDirty;
  36660. private _isBlendFunctionParametersDirty;
  36661. private _isBlendEquationParametersDirty;
  36662. private _isBlendConstantsDirty;
  36663. private _alphaBlend;
  36664. private _blendFunctionParameters;
  36665. private _blendEquationParameters;
  36666. private _blendConstants;
  36667. /**
  36668. * Initializes the state.
  36669. */
  36670. constructor();
  36671. readonly isDirty: boolean;
  36672. alphaBlend: boolean;
  36673. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36674. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36675. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36676. reset(): void;
  36677. apply(gl: WebGLRenderingContext): void;
  36678. }
  36679. }
  36680. declare module BABYLON {
  36681. /**
  36682. * @hidden
  36683. **/
  36684. class _DepthCullingState {
  36685. private _isDepthTestDirty;
  36686. private _isDepthMaskDirty;
  36687. private _isDepthFuncDirty;
  36688. private _isCullFaceDirty;
  36689. private _isCullDirty;
  36690. private _isZOffsetDirty;
  36691. private _isFrontFaceDirty;
  36692. private _depthTest;
  36693. private _depthMask;
  36694. private _depthFunc;
  36695. private _cull;
  36696. private _cullFace;
  36697. private _zOffset;
  36698. private _frontFace;
  36699. /**
  36700. * Initializes the state.
  36701. */
  36702. constructor();
  36703. readonly isDirty: boolean;
  36704. zOffset: number;
  36705. cullFace: Nullable<number>;
  36706. cull: Nullable<boolean>;
  36707. depthFunc: Nullable<number>;
  36708. depthMask: boolean;
  36709. depthTest: boolean;
  36710. frontFace: Nullable<number>;
  36711. reset(): void;
  36712. apply(gl: WebGLRenderingContext): void;
  36713. }
  36714. }
  36715. declare module BABYLON {
  36716. /**
  36717. * @hidden
  36718. **/
  36719. class _StencilState {
  36720. private _isStencilTestDirty;
  36721. private _isStencilMaskDirty;
  36722. private _isStencilFuncDirty;
  36723. private _isStencilOpDirty;
  36724. private _stencilTest;
  36725. private _stencilMask;
  36726. private _stencilFunc;
  36727. private _stencilFuncRef;
  36728. private _stencilFuncMask;
  36729. private _stencilOpStencilFail;
  36730. private _stencilOpDepthFail;
  36731. private _stencilOpStencilDepthPass;
  36732. readonly isDirty: boolean;
  36733. stencilFunc: number;
  36734. stencilFuncRef: number;
  36735. stencilFuncMask: number;
  36736. stencilOpStencilFail: number;
  36737. stencilOpDepthFail: number;
  36738. stencilOpStencilDepthPass: number;
  36739. stencilMask: number;
  36740. stencilTest: boolean;
  36741. constructor();
  36742. reset(): void;
  36743. apply(gl: WebGLRenderingContext): void;
  36744. }
  36745. }
  36746. declare module BABYLON {
  36747. /**
  36748. * Class used to evalaute queries containing `and` and `or` operators
  36749. */
  36750. class AndOrNotEvaluator {
  36751. /**
  36752. * Evaluate a query
  36753. * @param query defines the query to evaluate
  36754. * @param evaluateCallback defines the callback used to filter result
  36755. * @returns true if the query matches
  36756. */
  36757. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  36758. private static _HandleParenthesisContent;
  36759. private static _SimplifyNegation;
  36760. }
  36761. }
  36762. declare module BABYLON {
  36763. /**
  36764. * Defines the list of states available for a task inside a AssetsManager
  36765. */
  36766. enum AssetTaskState {
  36767. /**
  36768. * Initialization
  36769. */
  36770. INIT = 0,
  36771. /**
  36772. * Running
  36773. */
  36774. RUNNING = 1,
  36775. /**
  36776. * Done
  36777. */
  36778. DONE = 2,
  36779. /**
  36780. * Error
  36781. */
  36782. ERROR = 3
  36783. }
  36784. /**
  36785. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  36786. */
  36787. abstract class AbstractAssetTask {
  36788. /**
  36789. * Task name
  36790. */ name: string;
  36791. /**
  36792. * Callback called when the task is successful
  36793. */
  36794. onSuccess: (task: any) => void;
  36795. /**
  36796. * Callback called when the task is not successful
  36797. */
  36798. onError: (task: any, message?: string, exception?: any) => void;
  36799. /**
  36800. * Creates a new AssetsManager
  36801. * @param name defines the name of the task
  36802. */
  36803. constructor(
  36804. /**
  36805. * Task name
  36806. */ name: string);
  36807. private _isCompleted;
  36808. private _taskState;
  36809. private _errorObject;
  36810. /**
  36811. * Get if the task is completed
  36812. */
  36813. readonly isCompleted: boolean;
  36814. /**
  36815. * Gets the current state of the task
  36816. */
  36817. readonly taskState: AssetTaskState;
  36818. /**
  36819. * Gets the current error object (if task is in error)
  36820. */
  36821. readonly errorObject: {
  36822. message?: string;
  36823. exception?: any;
  36824. };
  36825. /**
  36826. * Internal only
  36827. * @hidden
  36828. */
  36829. _setErrorObject(message?: string, exception?: any): void;
  36830. /**
  36831. * Execute the current task
  36832. * @param scene defines the scene where you want your assets to be loaded
  36833. * @param onSuccess is a callback called when the task is successfully executed
  36834. * @param onError is a callback called if an error occurs
  36835. */
  36836. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36837. /**
  36838. * Execute the current task
  36839. * @param scene defines the scene where you want your assets to be loaded
  36840. * @param onSuccess is a callback called when the task is successfully executed
  36841. * @param onError is a callback called if an error occurs
  36842. */
  36843. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36844. /**
  36845. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  36846. * This can be used with failed tasks that have the reason for failure fixed.
  36847. */
  36848. reset(): void;
  36849. private onErrorCallback;
  36850. private onDoneCallback;
  36851. }
  36852. /**
  36853. * Define the interface used by progress events raised during assets loading
  36854. */
  36855. interface IAssetsProgressEvent {
  36856. /**
  36857. * Defines the number of remaining tasks to process
  36858. */
  36859. remainingCount: number;
  36860. /**
  36861. * Defines the total number of tasks
  36862. */
  36863. totalCount: number;
  36864. /**
  36865. * Defines the task that was just processed
  36866. */
  36867. task: AbstractAssetTask;
  36868. }
  36869. /**
  36870. * Class used to share progress information about assets loading
  36871. */
  36872. class AssetsProgressEvent implements IAssetsProgressEvent {
  36873. /**
  36874. * Defines the number of remaining tasks to process
  36875. */
  36876. remainingCount: number;
  36877. /**
  36878. * Defines the total number of tasks
  36879. */
  36880. totalCount: number;
  36881. /**
  36882. * Defines the task that was just processed
  36883. */
  36884. task: AbstractAssetTask;
  36885. /**
  36886. * Creates a AssetsProgressEvent
  36887. * @param remainingCount defines the number of remaining tasks to process
  36888. * @param totalCount defines the total number of tasks
  36889. * @param task defines the task that was just processed
  36890. */
  36891. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  36892. }
  36893. /**
  36894. * Define a task used by AssetsManager to load meshes
  36895. */
  36896. class MeshAssetTask extends AbstractAssetTask {
  36897. /**
  36898. * Defines the name of the task
  36899. */
  36900. name: string;
  36901. /**
  36902. * Defines the list of mesh's names you want to load
  36903. */
  36904. meshesNames: any;
  36905. /**
  36906. * Defines the root url to use as a base to load your meshes and associated resources
  36907. */
  36908. rootUrl: string;
  36909. /**
  36910. * Defines the filename of the scene to load from
  36911. */
  36912. sceneFilename: string;
  36913. /**
  36914. * Gets the list of loaded meshes
  36915. */
  36916. loadedMeshes: Array<AbstractMesh>;
  36917. /**
  36918. * Gets the list of loaded particle systems
  36919. */
  36920. loadedParticleSystems: Array<IParticleSystem>;
  36921. /**
  36922. * Gets the list of loaded skeletons
  36923. */
  36924. loadedSkeletons: Array<Skeleton>;
  36925. /**
  36926. * Callback called when the task is successful
  36927. */
  36928. onSuccess: (task: MeshAssetTask) => void;
  36929. /**
  36930. * Callback called when the task is successful
  36931. */
  36932. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  36933. /**
  36934. * Creates a new MeshAssetTask
  36935. * @param name defines the name of the task
  36936. * @param meshesNames defines the list of mesh's names you want to load
  36937. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  36938. * @param sceneFilename defines the filename of the scene to load from
  36939. */
  36940. constructor(
  36941. /**
  36942. * Defines the name of the task
  36943. */
  36944. name: string,
  36945. /**
  36946. * Defines the list of mesh's names you want to load
  36947. */
  36948. meshesNames: any,
  36949. /**
  36950. * Defines the root url to use as a base to load your meshes and associated resources
  36951. */
  36952. rootUrl: string,
  36953. /**
  36954. * Defines the filename of the scene to load from
  36955. */
  36956. sceneFilename: string);
  36957. /**
  36958. * Execute the current task
  36959. * @param scene defines the scene where you want your assets to be loaded
  36960. * @param onSuccess is a callback called when the task is successfully executed
  36961. * @param onError is a callback called if an error occurs
  36962. */
  36963. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36964. }
  36965. /**
  36966. * Define a task used by AssetsManager to load text content
  36967. */
  36968. class TextFileAssetTask extends AbstractAssetTask {
  36969. /**
  36970. * Defines the name of the task
  36971. */
  36972. name: string;
  36973. /**
  36974. * Defines the location of the file to load
  36975. */
  36976. url: string;
  36977. /**
  36978. * Gets the loaded text string
  36979. */
  36980. text: string;
  36981. /**
  36982. * Callback called when the task is successful
  36983. */
  36984. onSuccess: (task: TextFileAssetTask) => void;
  36985. /**
  36986. * Callback called when the task is successful
  36987. */
  36988. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  36989. /**
  36990. * Creates a new TextFileAssetTask object
  36991. * @param name defines the name of the task
  36992. * @param url defines the location of the file to load
  36993. */
  36994. constructor(
  36995. /**
  36996. * Defines the name of the task
  36997. */
  36998. name: string,
  36999. /**
  37000. * Defines the location of the file to load
  37001. */
  37002. url: string);
  37003. /**
  37004. * Execute the current task
  37005. * @param scene defines the scene where you want your assets to be loaded
  37006. * @param onSuccess is a callback called when the task is successfully executed
  37007. * @param onError is a callback called if an error occurs
  37008. */
  37009. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37010. }
  37011. /**
  37012. * Define a task used by AssetsManager to load binary data
  37013. */
  37014. class BinaryFileAssetTask extends AbstractAssetTask {
  37015. /**
  37016. * Defines the name of the task
  37017. */
  37018. name: string;
  37019. /**
  37020. * Defines the location of the file to load
  37021. */
  37022. url: string;
  37023. /**
  37024. * Gets the lodaded data (as an array buffer)
  37025. */
  37026. data: ArrayBuffer;
  37027. /**
  37028. * Callback called when the task is successful
  37029. */
  37030. onSuccess: (task: BinaryFileAssetTask) => void;
  37031. /**
  37032. * Callback called when the task is successful
  37033. */
  37034. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  37035. /**
  37036. * Creates a new BinaryFileAssetTask object
  37037. * @param name defines the name of the new task
  37038. * @param url defines the location of the file to load
  37039. */
  37040. constructor(
  37041. /**
  37042. * Defines the name of the task
  37043. */
  37044. name: string,
  37045. /**
  37046. * Defines the location of the file to load
  37047. */
  37048. url: string);
  37049. /**
  37050. * Execute the current task
  37051. * @param scene defines the scene where you want your assets to be loaded
  37052. * @param onSuccess is a callback called when the task is successfully executed
  37053. * @param onError is a callback called if an error occurs
  37054. */
  37055. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37056. }
  37057. /**
  37058. * Define a task used by AssetsManager to load images
  37059. */
  37060. class ImageAssetTask extends AbstractAssetTask {
  37061. /**
  37062. * Defines the name of the task
  37063. */
  37064. name: string;
  37065. /**
  37066. * Defines the location of the image to load
  37067. */
  37068. url: string;
  37069. /**
  37070. * Gets the loaded images
  37071. */
  37072. image: HTMLImageElement;
  37073. /**
  37074. * Callback called when the task is successful
  37075. */
  37076. onSuccess: (task: ImageAssetTask) => void;
  37077. /**
  37078. * Callback called when the task is successful
  37079. */
  37080. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  37081. /**
  37082. * Creates a new ImageAssetTask
  37083. * @param name defines the name of the task
  37084. * @param url defines the location of the image to load
  37085. */
  37086. constructor(
  37087. /**
  37088. * Defines the name of the task
  37089. */
  37090. name: string,
  37091. /**
  37092. * Defines the location of the image to load
  37093. */
  37094. url: string);
  37095. /**
  37096. * Execute the current task
  37097. * @param scene defines the scene where you want your assets to be loaded
  37098. * @param onSuccess is a callback called when the task is successfully executed
  37099. * @param onError is a callback called if an error occurs
  37100. */
  37101. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37102. }
  37103. /**
  37104. * Defines the interface used by texture loading tasks
  37105. */
  37106. interface ITextureAssetTask<TEX extends BaseTexture> {
  37107. /**
  37108. * Gets the loaded texture
  37109. */
  37110. texture: TEX;
  37111. }
  37112. /**
  37113. * Define a task used by AssetsManager to load 2D textures
  37114. */
  37115. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  37116. /**
  37117. * Defines the name of the task
  37118. */
  37119. name: string;
  37120. /**
  37121. * Defines the location of the file to load
  37122. */
  37123. url: string;
  37124. /**
  37125. * Defines if mipmap should not be generated (default is false)
  37126. */
  37127. noMipmap?: boolean | undefined;
  37128. /**
  37129. * Defines if texture must be inverted on Y axis (default is false)
  37130. */
  37131. invertY?: boolean | undefined;
  37132. /**
  37133. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37134. */
  37135. samplingMode: number;
  37136. /**
  37137. * Gets the loaded texture
  37138. */
  37139. texture: Texture;
  37140. /**
  37141. * Callback called when the task is successful
  37142. */
  37143. onSuccess: (task: TextureAssetTask) => void;
  37144. /**
  37145. * Callback called when the task is successful
  37146. */
  37147. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  37148. /**
  37149. * Creates a new TextureAssetTask object
  37150. * @param name defines the name of the task
  37151. * @param url defines the location of the file to load
  37152. * @param noMipmap defines if mipmap should not be generated (default is false)
  37153. * @param invertY defines if texture must be inverted on Y axis (default is false)
  37154. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37155. */
  37156. constructor(
  37157. /**
  37158. * Defines the name of the task
  37159. */
  37160. name: string,
  37161. /**
  37162. * Defines the location of the file to load
  37163. */
  37164. url: string,
  37165. /**
  37166. * Defines if mipmap should not be generated (default is false)
  37167. */
  37168. noMipmap?: boolean | undefined,
  37169. /**
  37170. * Defines if texture must be inverted on Y axis (default is false)
  37171. */
  37172. invertY?: boolean | undefined,
  37173. /**
  37174. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37175. */
  37176. samplingMode?: number);
  37177. /**
  37178. * Execute the current task
  37179. * @param scene defines the scene where you want your assets to be loaded
  37180. * @param onSuccess is a callback called when the task is successfully executed
  37181. * @param onError is a callback called if an error occurs
  37182. */
  37183. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37184. }
  37185. /**
  37186. * Define a task used by AssetsManager to load cube textures
  37187. */
  37188. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37189. /**
  37190. * Defines the name of the task
  37191. */
  37192. name: string;
  37193. /**
  37194. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37195. */
  37196. url: string;
  37197. /**
  37198. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37199. */
  37200. extensions?: string[] | undefined;
  37201. /**
  37202. * Defines if mipmaps should not be generated (default is false)
  37203. */
  37204. noMipmap?: boolean | undefined;
  37205. /**
  37206. * Defines the explicit list of files (undefined by default)
  37207. */
  37208. files?: string[] | undefined;
  37209. /**
  37210. * Gets the loaded texture
  37211. */
  37212. texture: CubeTexture;
  37213. /**
  37214. * Callback called when the task is successful
  37215. */
  37216. onSuccess: (task: CubeTextureAssetTask) => void;
  37217. /**
  37218. * Callback called when the task is successful
  37219. */
  37220. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37221. /**
  37222. * Creates a new CubeTextureAssetTask
  37223. * @param name defines the name of the task
  37224. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37225. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37226. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37227. * @param files defines the explicit list of files (undefined by default)
  37228. */
  37229. constructor(
  37230. /**
  37231. * Defines the name of the task
  37232. */
  37233. name: string,
  37234. /**
  37235. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37236. */
  37237. url: string,
  37238. /**
  37239. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37240. */
  37241. extensions?: string[] | undefined,
  37242. /**
  37243. * Defines if mipmaps should not be generated (default is false)
  37244. */
  37245. noMipmap?: boolean | undefined,
  37246. /**
  37247. * Defines the explicit list of files (undefined by default)
  37248. */
  37249. files?: string[] | undefined);
  37250. /**
  37251. * Execute the current task
  37252. * @param scene defines the scene where you want your assets to be loaded
  37253. * @param onSuccess is a callback called when the task is successfully executed
  37254. * @param onError is a callback called if an error occurs
  37255. */
  37256. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37257. }
  37258. /**
  37259. * Define a task used by AssetsManager to load HDR cube textures
  37260. */
  37261. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37262. /**
  37263. * Defines the name of the task
  37264. */
  37265. name: string;
  37266. /**
  37267. * Defines the location of the file to load
  37268. */
  37269. url: string;
  37270. /**
  37271. * Defines the desired size (the more it increases the longer the generation will be)
  37272. */
  37273. size: number;
  37274. /**
  37275. * Defines if mipmaps should not be generated (default is false)
  37276. */
  37277. noMipmap: boolean;
  37278. /**
  37279. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37280. */
  37281. generateHarmonics: boolean;
  37282. /**
  37283. * 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)
  37284. */
  37285. gammaSpace: boolean;
  37286. /**
  37287. * Internal Use Only
  37288. */
  37289. reserved: boolean;
  37290. /**
  37291. * Gets the loaded texture
  37292. */
  37293. texture: HDRCubeTexture;
  37294. /**
  37295. * Callback called when the task is successful
  37296. */
  37297. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37298. /**
  37299. * Callback called when the task is successful
  37300. */
  37301. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37302. /**
  37303. * Creates a new HDRCubeTextureAssetTask object
  37304. * @param name defines the name of the task
  37305. * @param url defines the location of the file to load
  37306. * @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.
  37307. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37308. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37309. * @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)
  37310. * @param reserved Internal use only
  37311. */
  37312. constructor(
  37313. /**
  37314. * Defines the name of the task
  37315. */
  37316. name: string,
  37317. /**
  37318. * Defines the location of the file to load
  37319. */
  37320. url: string,
  37321. /**
  37322. * Defines the desired size (the more it increases the longer the generation will be)
  37323. */
  37324. size: number,
  37325. /**
  37326. * Defines if mipmaps should not be generated (default is false)
  37327. */
  37328. noMipmap?: boolean,
  37329. /**
  37330. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37331. */
  37332. generateHarmonics?: boolean,
  37333. /**
  37334. * 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)
  37335. */
  37336. gammaSpace?: boolean,
  37337. /**
  37338. * Internal Use Only
  37339. */
  37340. reserved?: boolean);
  37341. /**
  37342. * Execute the current task
  37343. * @param scene defines the scene where you want your assets to be loaded
  37344. * @param onSuccess is a callback called when the task is successfully executed
  37345. * @param onError is a callback called if an error occurs
  37346. */
  37347. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37348. }
  37349. /**
  37350. * This class can be used to easily import assets into a scene
  37351. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37352. */
  37353. class AssetsManager {
  37354. private _scene;
  37355. private _isLoading;
  37356. protected _tasks: AbstractAssetTask[];
  37357. protected _waitingTasksCount: number;
  37358. protected _totalTasksCount: number;
  37359. /**
  37360. * Callback called when all tasks are processed
  37361. */
  37362. onFinish: (tasks: AbstractAssetTask[]) => void;
  37363. /**
  37364. * Callback called when a task is successful
  37365. */
  37366. onTaskSuccess: (task: AbstractAssetTask) => void;
  37367. /**
  37368. * Callback called when a task had an error
  37369. */
  37370. onTaskError: (task: AbstractAssetTask) => void;
  37371. /**
  37372. * Callback called when a task is done (whatever the result is)
  37373. */
  37374. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37375. /**
  37376. * Observable called when all tasks are processed
  37377. */
  37378. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37379. /**
  37380. * Observable called when a task had an error
  37381. */
  37382. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37383. /**
  37384. * Observable called when a task is successful
  37385. */
  37386. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37387. /**
  37388. * Observable called when a task is done (whatever the result is)
  37389. */
  37390. onProgressObservable: Observable<IAssetsProgressEvent>;
  37391. /**
  37392. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37393. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37394. */
  37395. useDefaultLoadingScreen: boolean;
  37396. /**
  37397. * Creates a new AssetsManager
  37398. * @param scene defines the scene to work on
  37399. */
  37400. constructor(scene: Scene);
  37401. /**
  37402. * Add a MeshAssetTask to the list of active tasks
  37403. * @param taskName defines the name of the new task
  37404. * @param meshesNames defines the name of meshes to load
  37405. * @param rootUrl defines the root url to use to locate files
  37406. * @param sceneFilename defines the filename of the scene file
  37407. * @returns a new MeshAssetTask object
  37408. */
  37409. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37410. /**
  37411. * Add a TextFileAssetTask to the list of active tasks
  37412. * @param taskName defines the name of the new task
  37413. * @param url defines the url of the file to load
  37414. * @returns a new TextFileAssetTask object
  37415. */
  37416. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37417. /**
  37418. * Add a BinaryFileAssetTask to the list of active tasks
  37419. * @param taskName defines the name of the new task
  37420. * @param url defines the url of the file to load
  37421. * @returns a new BinaryFileAssetTask object
  37422. */
  37423. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37424. /**
  37425. * Add a ImageAssetTask to the list of active tasks
  37426. * @param taskName defines the name of the new task
  37427. * @param url defines the url of the file to load
  37428. * @returns a new ImageAssetTask object
  37429. */
  37430. addImageTask(taskName: string, url: string): ImageAssetTask;
  37431. /**
  37432. * Add a TextureAssetTask to the list of active tasks
  37433. * @param taskName defines the name of the new task
  37434. * @param url defines the url of the file to load
  37435. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37436. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37437. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37438. * @returns a new TextureAssetTask object
  37439. */
  37440. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  37441. /**
  37442. * Add a CubeTextureAssetTask to the list of active tasks
  37443. * @param taskName defines the name of the new task
  37444. * @param url defines the url of the file to load
  37445. * @param extensions defines the extension to use to load the cube map (can be null)
  37446. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37447. * @param files defines the list of files to load (can be null)
  37448. * @returns a new CubeTextureAssetTask object
  37449. */
  37450. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  37451. /**
  37452. *
  37453. * Add a HDRCubeTextureAssetTask to the list of active tasks
  37454. * @param taskName defines the name of the new task
  37455. * @param url defines the url of the file to load
  37456. * @param size defines the size you want for the cubemap (can be null)
  37457. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37458. * @param generateHarmonics defines if you want to automatically generate (true by default)
  37459. * @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)
  37460. * @param reserved Internal use only
  37461. * @returns a new HDRCubeTextureAssetTask object
  37462. */
  37463. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  37464. /**
  37465. * Remove a task from the assets manager.
  37466. * @param task the task to remove
  37467. */
  37468. removeTask(task: AbstractAssetTask): void;
  37469. private _decreaseWaitingTasksCount;
  37470. private _runTask;
  37471. /**
  37472. * Reset the AssetsManager and remove all tasks
  37473. * @return the current instance of the AssetsManager
  37474. */
  37475. reset(): AssetsManager;
  37476. /**
  37477. * Start the loading process
  37478. * @return the current instance of the AssetsManager
  37479. */
  37480. load(): AssetsManager;
  37481. }
  37482. }
  37483. declare module BABYLON {
  37484. /**
  37485. * Direct draw surface info
  37486. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  37487. */
  37488. interface DDSInfo {
  37489. /**
  37490. * Width of the texture
  37491. */
  37492. width: number;
  37493. /**
  37494. * Width of the texture
  37495. */
  37496. height: number;
  37497. /**
  37498. * Number of Mipmaps for the texture
  37499. * @see https://en.wikipedia.org/wiki/Mipmap
  37500. */
  37501. mipmapCount: number;
  37502. /**
  37503. * If the textures format is a known fourCC format
  37504. * @see https://www.fourcc.org/
  37505. */
  37506. isFourCC: boolean;
  37507. /**
  37508. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  37509. */
  37510. isRGB: boolean;
  37511. /**
  37512. * If the texture is a lumincance format
  37513. */
  37514. isLuminance: boolean;
  37515. /**
  37516. * If this is a cube texture
  37517. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  37518. */
  37519. isCube: boolean;
  37520. /**
  37521. * If the texture is a compressed format eg. FOURCC_DXT1
  37522. */
  37523. isCompressed: boolean;
  37524. /**
  37525. * The dxgiFormat of the texture
  37526. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  37527. */
  37528. dxgiFormat: number;
  37529. /**
  37530. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  37531. */
  37532. textureType: number;
  37533. /**
  37534. * Sphericle polynomial created for the dds texture
  37535. */
  37536. sphericalPolynomial?: SphericalPolynomial;
  37537. }
  37538. /**
  37539. * Class used to provide DDS decompression tools
  37540. */
  37541. class DDSTools {
  37542. /**
  37543. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  37544. */
  37545. static StoreLODInAlphaChannel: boolean;
  37546. /**
  37547. * Gets DDS information from an array buffer
  37548. * @param arrayBuffer defines the array buffer to read data from
  37549. * @returns the DDS information
  37550. */
  37551. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  37552. private static _FloatView;
  37553. private static _Int32View;
  37554. private static _ToHalfFloat;
  37555. private static _FromHalfFloat;
  37556. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  37557. private static _GetHalfFloatRGBAArrayBuffer;
  37558. private static _GetFloatRGBAArrayBuffer;
  37559. private static _GetFloatAsUIntRGBAArrayBuffer;
  37560. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  37561. private static _GetRGBAArrayBuffer;
  37562. private static _ExtractLongWordOrder;
  37563. private static _GetRGBArrayBuffer;
  37564. private static _GetLuminanceArrayBuffer;
  37565. /**
  37566. * Uploads DDS Levels to a Babylon Texture
  37567. * @hidden
  37568. */
  37569. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  37570. }
  37571. }
  37572. declare module BABYLON {
  37573. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37574. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37575. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37576. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37577. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37578. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37579. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37580. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37581. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37582. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37583. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37584. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37585. /**
  37586. * Decorator used to define property that can be serialized as reference to a camera
  37587. * @param sourceName defines the name of the property to decorate
  37588. */
  37589. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37590. /**
  37591. * Class used to help serialization objects
  37592. */
  37593. class SerializationHelper {
  37594. /**
  37595. * Static function used to serialized a specific entity
  37596. * @param entity defines the entity to serialize
  37597. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37598. * @returns a JSON compatible object representing the serialization of the entity
  37599. */
  37600. static Serialize<T>(entity: T, serializationObject?: any): any;
  37601. /**
  37602. * Creates a new entity from a serialization data object
  37603. * @param creationFunction defines a function used to instanciated the new entity
  37604. * @param source defines the source serialization data
  37605. * @param scene defines the hosting scene
  37606. * @param rootUrl defines the root url for resources
  37607. * @returns a new entity
  37608. */
  37609. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37610. /**
  37611. * Clones an object
  37612. * @param creationFunction defines the function used to instanciate the new object
  37613. * @param source defines the source object
  37614. * @returns the cloned object
  37615. */
  37616. static Clone<T>(creationFunction: () => T, source: T): T;
  37617. /**
  37618. * Instanciates a new object based on a source one (some data will be shared between both object)
  37619. * @param creationFunction defines the function used to instanciate the new object
  37620. * @param source defines the source object
  37621. * @returns the new object
  37622. */
  37623. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37624. }
  37625. }
  37626. declare module BABYLON {
  37627. /**
  37628. * Wrapper class for promise with external resolve and reject.
  37629. */
  37630. class Deferred<T> {
  37631. /**
  37632. * The promise associated with this deferred object.
  37633. */
  37634. readonly promise: Promise<T>;
  37635. private _resolve;
  37636. private _reject;
  37637. /**
  37638. * The resolve method of the promise associated with this deferred object.
  37639. */
  37640. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  37641. /**
  37642. * The reject method of the promise associated with this deferred object.
  37643. */
  37644. readonly reject: (reason?: any) => void;
  37645. /**
  37646. * Constructor for this deferred object.
  37647. */
  37648. constructor();
  37649. }
  37650. }
  37651. declare module BABYLON {
  37652. /**
  37653. * Raw texture data and descriptor sufficient for WebGL texture upload
  37654. */
  37655. interface EnvironmentTextureInfo {
  37656. /**
  37657. * Version of the environment map
  37658. */
  37659. version: number;
  37660. /**
  37661. * Width of image
  37662. */
  37663. width: number;
  37664. /**
  37665. * Irradiance information stored in the file.
  37666. */
  37667. irradiance: any;
  37668. /**
  37669. * Specular information stored in the file.
  37670. */
  37671. specular: any;
  37672. }
  37673. /**
  37674. * Sets of helpers addressing the serialization and deserialization of environment texture
  37675. * stored in a BabylonJS env file.
  37676. * Those files are usually stored as .env files.
  37677. */
  37678. class EnvironmentTextureTools {
  37679. /**
  37680. * Magic number identifying the env file.
  37681. */
  37682. private static _MagicBytes;
  37683. /**
  37684. * Gets the environment info from an env file.
  37685. * @param data The array buffer containing the .env bytes.
  37686. * @returns the environment file info (the json header) if successfully parsed.
  37687. */
  37688. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  37689. /**
  37690. * Creates an environment texture from a loaded cube texture.
  37691. * @param texture defines the cube texture to convert in env file
  37692. * @return a promise containing the environment data if succesfull.
  37693. */
  37694. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  37695. /**
  37696. * Creates a JSON representation of the spherical data.
  37697. * @param texture defines the texture containing the polynomials
  37698. * @return the JSON representation of the spherical info
  37699. */
  37700. private static _CreateEnvTextureIrradiance;
  37701. /**
  37702. * Uploads the texture info contained in the env file to the GPU.
  37703. * @param texture defines the internal texture to upload to
  37704. * @param arrayBuffer defines the buffer cotaining the data to load
  37705. * @param info defines the texture info retrieved through the GetEnvInfo method
  37706. * @returns a promise
  37707. */
  37708. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  37709. /**
  37710. * Uploads the levels of image data to the GPU.
  37711. * @param texture defines the internal texture to upload to
  37712. * @param imageData defines the array buffer views of image data [mipmap][face]
  37713. * @returns a promise
  37714. */
  37715. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  37716. /**
  37717. * Uploads spherical polynomials information to the texture.
  37718. * @param texture defines the texture we are trying to upload the information to
  37719. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  37720. */
  37721. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  37722. }
  37723. }
  37724. declare module BABYLON {
  37725. /**
  37726. * Class used to help managing file picking and drag'n'drop
  37727. */
  37728. class FilesInput {
  37729. /**
  37730. * List of files ready to be loaded
  37731. */
  37732. static FilesToLoad: {
  37733. [key: string]: File;
  37734. };
  37735. /**
  37736. * Callback called when a file is processed
  37737. */
  37738. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  37739. private _engine;
  37740. private _currentScene;
  37741. private _sceneLoadedCallback;
  37742. private _progressCallback;
  37743. private _additionalRenderLoopLogicCallback;
  37744. private _textureLoadingCallback;
  37745. private _startingProcessingFilesCallback;
  37746. private _onReloadCallback;
  37747. private _errorCallback;
  37748. private _elementToMonitor;
  37749. private _sceneFileToLoad;
  37750. private _filesToLoad;
  37751. /**
  37752. * Creates a new FilesInput
  37753. * @param engine defines the rendering engine
  37754. * @param scene defines the hosting scene
  37755. * @param sceneLoadedCallback callback called when scene is loaded
  37756. * @param progressCallback callback called to track progress
  37757. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  37758. * @param textureLoadingCallback callback called when a texture is loading
  37759. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  37760. * @param onReloadCallback callback called when a reload is requested
  37761. * @param errorCallback callback call if an error occurs
  37762. */
  37763. 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);
  37764. private _dragEnterHandler;
  37765. private _dragOverHandler;
  37766. private _dropHandler;
  37767. /**
  37768. * Calls this function to listen to drag'n'drop events on a specific DOM element
  37769. * @param elementToMonitor defines the DOM element to track
  37770. */
  37771. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  37772. /**
  37773. * Release all associated resources
  37774. */
  37775. dispose(): void;
  37776. private renderFunction;
  37777. private drag;
  37778. private drop;
  37779. private _traverseFolder;
  37780. private _processFiles;
  37781. /**
  37782. * Load files from a drop event
  37783. * @param event defines the drop event to use as source
  37784. */
  37785. loadFiles(event: any): void;
  37786. private _processReload;
  37787. /**
  37788. * Reload the current scene from the loaded files
  37789. */
  37790. reload(): void;
  37791. }
  37792. }
  37793. declare module BABYLON {
  37794. /**
  37795. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  37796. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  37797. */
  37798. class KhronosTextureContainer {
  37799. /** contents of the KTX container file */
  37800. arrayBuffer: any;
  37801. private static HEADER_LEN;
  37802. private static COMPRESSED_2D;
  37803. private static COMPRESSED_3D;
  37804. private static TEX_2D;
  37805. private static TEX_3D;
  37806. /**
  37807. * Gets the openGL type
  37808. */
  37809. glType: number;
  37810. /**
  37811. * Gets the openGL type size
  37812. */
  37813. glTypeSize: number;
  37814. /**
  37815. * Gets the openGL format
  37816. */
  37817. glFormat: number;
  37818. /**
  37819. * Gets the openGL internal format
  37820. */
  37821. glInternalFormat: number;
  37822. /**
  37823. * Gets the base internal format
  37824. */
  37825. glBaseInternalFormat: number;
  37826. /**
  37827. * Gets image width in pixel
  37828. */
  37829. pixelWidth: number;
  37830. /**
  37831. * Gets image height in pixel
  37832. */
  37833. pixelHeight: number;
  37834. /**
  37835. * Gets image depth in pixels
  37836. */
  37837. pixelDepth: number;
  37838. /**
  37839. * Gets the number of array elements
  37840. */
  37841. numberOfArrayElements: number;
  37842. /**
  37843. * Gets the number of faces
  37844. */
  37845. numberOfFaces: number;
  37846. /**
  37847. * Gets the number of mipmap levels
  37848. */
  37849. numberOfMipmapLevels: number;
  37850. /**
  37851. * Gets the bytes of key value data
  37852. */
  37853. bytesOfKeyValueData: number;
  37854. /**
  37855. * Gets the load type
  37856. */
  37857. loadType: number;
  37858. /**
  37859. * Creates a new KhronosTextureContainer
  37860. * @param arrayBuffer contents of the KTX container file
  37861. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  37862. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  37863. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  37864. */
  37865. constructor(
  37866. /** contents of the KTX container file */
  37867. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  37868. /**
  37869. * Revert the endianness of a value.
  37870. * Not as fast hardware based, but will probably never need to use
  37871. * @param val defines the value to convert
  37872. * @returns the new value
  37873. */
  37874. switchEndianness(val: number): number;
  37875. /**
  37876. * Uploads KTX content to a Babylon Texture.
  37877. * It is assumed that the texture has already been created & is currently bound
  37878. * @hidden
  37879. */
  37880. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  37881. private _upload2DCompressedLevels;
  37882. }
  37883. }
  37884. declare module BABYLON {
  37885. /**
  37886. * A class serves as a medium between the observable and its observers
  37887. */
  37888. class EventState {
  37889. /**
  37890. * Create a new EventState
  37891. * @param mask defines the mask associated with this state
  37892. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  37893. * @param target defines the original target of the state
  37894. * @param currentTarget defines the current target of the state
  37895. */
  37896. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  37897. /**
  37898. * Initialize the current event state
  37899. * @param mask defines the mask associated with this state
  37900. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  37901. * @param target defines the original target of the state
  37902. * @param currentTarget defines the current target of the state
  37903. * @returns the current event state
  37904. */
  37905. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  37906. /**
  37907. * An Observer can set this property to true to prevent subsequent observers of being notified
  37908. */
  37909. skipNextObservers: boolean;
  37910. /**
  37911. * Get the mask value that were used to trigger the event corresponding to this EventState object
  37912. */
  37913. mask: number;
  37914. /**
  37915. * The object that originally notified the event
  37916. */
  37917. target?: any;
  37918. /**
  37919. * The current object in the bubbling phase
  37920. */
  37921. currentTarget?: any;
  37922. /**
  37923. * This will be populated with the return value of the last function that was executed.
  37924. * If it is the first function in the callback chain it will be the event data.
  37925. */
  37926. lastReturnValue?: any;
  37927. }
  37928. /**
  37929. * Represent an Observer registered to a given Observable object.
  37930. */
  37931. class Observer<T> {
  37932. /**
  37933. * Defines the callback to call when the observer is notified
  37934. */
  37935. callback: (eventData: T, eventState: EventState) => void;
  37936. /**
  37937. * Defines the mask of the observer (used to filter notifications)
  37938. */
  37939. mask: number;
  37940. /**
  37941. * Defines the current scope used to restore the JS context
  37942. */
  37943. scope: any;
  37944. /** @hidden */
  37945. _willBeUnregistered: boolean;
  37946. /**
  37947. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  37948. */
  37949. unregisterOnNextCall: boolean;
  37950. /**
  37951. * Creates a new observer
  37952. * @param callback defines the callback to call when the observer is notified
  37953. * @param mask defines the mask of the observer (used to filter notifications)
  37954. * @param scope defines the current scope used to restore the JS context
  37955. */
  37956. constructor(
  37957. /**
  37958. * Defines the callback to call when the observer is notified
  37959. */
  37960. callback: (eventData: T, eventState: EventState) => void,
  37961. /**
  37962. * Defines the mask of the observer (used to filter notifications)
  37963. */
  37964. mask: number,
  37965. /**
  37966. * Defines the current scope used to restore the JS context
  37967. */
  37968. scope?: any);
  37969. }
  37970. /**
  37971. * Represent a list of observers registered to multiple Observables object.
  37972. */
  37973. class MultiObserver<T> {
  37974. private _observers;
  37975. private _observables;
  37976. /**
  37977. * Release associated resources
  37978. */
  37979. dispose(): void;
  37980. /**
  37981. * Raise a callback when one of the observable will notify
  37982. * @param observables defines a list of observables to watch
  37983. * @param callback defines the callback to call on notification
  37984. * @param mask defines the mask used to filter notifications
  37985. * @param scope defines the current scope used to restore the JS context
  37986. * @returns the new MultiObserver
  37987. */
  37988. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  37989. }
  37990. /**
  37991. * The Observable class is a simple implementation of the Observable pattern.
  37992. *
  37993. * 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.
  37994. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  37995. * 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).
  37996. * 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.
  37997. */
  37998. class Observable<T> {
  37999. private _observers;
  38000. private _eventState;
  38001. private _onObserverAdded;
  38002. /**
  38003. * Creates a new observable
  38004. * @param onObserverAdded defines a callback to call when a new observer is added
  38005. */
  38006. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  38007. /**
  38008. * Create a new Observer with the specified callback
  38009. * @param callback the callback that will be executed for that Observer
  38010. * @param mask the mask used to filter observers
  38011. * @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.
  38012. * @param scope optional scope for the callback to be called from
  38013. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  38014. * @returns the new observer created for the callback
  38015. */
  38016. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  38017. /**
  38018. * Create a new Observer with the specified callback and unregisters after the next notification
  38019. * @param callback the callback that will be executed for that Observer
  38020. * @returns the new observer created for the callback
  38021. */
  38022. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  38023. /**
  38024. * Remove an Observer from the Observable object
  38025. * @param observer the instance of the Observer to remove
  38026. * @returns false if it doesn't belong to this Observable
  38027. */
  38028. remove(observer: Nullable<Observer<T>>): boolean;
  38029. /**
  38030. * Remove a callback from the Observable object
  38031. * @param callback the callback to remove
  38032. * @param scope optional scope. If used only the callbacks with this scope will be removed
  38033. * @returns false if it doesn't belong to this Observable
  38034. */
  38035. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  38036. private _deferUnregister;
  38037. private _remove;
  38038. /**
  38039. * Notify all Observers by calling their respective callback with the given data
  38040. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  38041. * @param eventData defines the data to send to all observers
  38042. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  38043. * @param target defines the original target of the state
  38044. * @param currentTarget defines the current target of the state
  38045. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  38046. */
  38047. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  38048. /**
  38049. * Calling this will execute each callback, expecting it to be a promise or return a value.
  38050. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  38051. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  38052. * and it is crucial that all callbacks will be executed.
  38053. * The order of the callbacks is kept, callbacks are not executed parallel.
  38054. *
  38055. * @param eventData The data to be sent to each callback
  38056. * @param mask is used to filter observers defaults to -1
  38057. * @param target defines the callback target (see EventState)
  38058. * @param currentTarget defines he current object in the bubbling phase
  38059. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  38060. */
  38061. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  38062. /**
  38063. * Notify a specific observer
  38064. * @param observer defines the observer to notify
  38065. * @param eventData defines the data to be sent to each callback
  38066. * @param mask is used to filter observers defaults to -1
  38067. */
  38068. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  38069. /**
  38070. * Gets a boolean indicating if the observable has at least one observer
  38071. * @returns true is the Observable has at least one Observer registered
  38072. */
  38073. hasObservers(): boolean;
  38074. /**
  38075. * Clear the list of observers
  38076. */
  38077. clear(): void;
  38078. /**
  38079. * Clone the current observable
  38080. * @returns a new observable
  38081. */
  38082. clone(): Observable<T>;
  38083. /**
  38084. * Does this observable handles observer registered with a given mask
  38085. * @param mask defines the mask to be tested
  38086. * @return whether or not one observer registered with the given mask is handeled
  38087. **/
  38088. hasSpecificMask(mask?: number): boolean;
  38089. }
  38090. }
  38091. declare module BABYLON {
  38092. /**
  38093. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38094. */
  38095. class PerformanceMonitor {
  38096. private _enabled;
  38097. private _rollingFrameTime;
  38098. private _lastFrameTimeMs;
  38099. /**
  38100. * constructor
  38101. * @param frameSampleSize The number of samples required to saturate the sliding window
  38102. */
  38103. constructor(frameSampleSize?: number);
  38104. /**
  38105. * Samples current frame
  38106. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38107. */
  38108. sampleFrame(timeMs?: number): void;
  38109. /**
  38110. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38111. */
  38112. readonly averageFrameTime: number;
  38113. /**
  38114. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38115. */
  38116. readonly averageFrameTimeVariance: number;
  38117. /**
  38118. * Returns the frame time of the most recent frame
  38119. */
  38120. readonly instantaneousFrameTime: number;
  38121. /**
  38122. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38123. */
  38124. readonly averageFPS: number;
  38125. /**
  38126. * Returns the average framerate in frames per second using the most recent frame time
  38127. */
  38128. readonly instantaneousFPS: number;
  38129. /**
  38130. * Returns true if enough samples have been taken to completely fill the sliding window
  38131. */
  38132. readonly isSaturated: boolean;
  38133. /**
  38134. * Enables contributions to the sliding window sample set
  38135. */
  38136. enable(): void;
  38137. /**
  38138. * Disables contributions to the sliding window sample set
  38139. * Samples will not be interpolated over the disabled period
  38140. */
  38141. disable(): void;
  38142. /**
  38143. * Returns true if sampling is enabled
  38144. */
  38145. readonly isEnabled: boolean;
  38146. /**
  38147. * Resets performance monitor
  38148. */
  38149. reset(): void;
  38150. }
  38151. /**
  38152. * RollingAverage
  38153. *
  38154. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38155. */
  38156. class RollingAverage {
  38157. /**
  38158. * Current average
  38159. */
  38160. average: number;
  38161. /**
  38162. * Current variance
  38163. */
  38164. variance: number;
  38165. protected _samples: Array<number>;
  38166. protected _sampleCount: number;
  38167. protected _pos: number;
  38168. protected _m2: number;
  38169. /**
  38170. * constructor
  38171. * @param length The number of samples required to saturate the sliding window
  38172. */
  38173. constructor(length: number);
  38174. /**
  38175. * Adds a sample to the sample set
  38176. * @param v The sample value
  38177. */
  38178. add(v: number): void;
  38179. /**
  38180. * Returns previously added values or null if outside of history or outside the sliding window domain
  38181. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38182. * @return Value previously recorded with add() or null if outside of range
  38183. */
  38184. history(i: number): number;
  38185. /**
  38186. * Returns true if enough samples have been taken to completely fill the sliding window
  38187. * @return true if sample-set saturated
  38188. */
  38189. isSaturated(): boolean;
  38190. /**
  38191. * Resets the rolling average (equivalent to 0 samples taken so far)
  38192. */
  38193. reset(): void;
  38194. /**
  38195. * Wraps a value around the sample range boundaries
  38196. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38197. * @return Wrapped position in sample range
  38198. */
  38199. protected _wrapPosition(i: number): number;
  38200. }
  38201. }
  38202. declare module BABYLON {
  38203. /**
  38204. * Helper class that provides a small promise polyfill
  38205. */
  38206. class PromisePolyfill {
  38207. /**
  38208. * Static function used to check if the polyfill is required
  38209. * If this is the case then the function will inject the polyfill to window.Promise
  38210. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38211. */
  38212. static Apply(force?: boolean): void;
  38213. }
  38214. }
  38215. declare module BABYLON {
  38216. /**
  38217. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38218. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38219. */
  38220. class SceneOptimization {
  38221. /**
  38222. * Defines the priority of this optimization (0 by default which means first in the list)
  38223. */
  38224. priority: number;
  38225. /**
  38226. * Gets a string describing the action executed by the current optimization
  38227. * @returns description string
  38228. */
  38229. getDescription(): string;
  38230. /**
  38231. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38232. * @param scene defines the current scene where to apply this optimization
  38233. * @param optimizer defines the current optimizer
  38234. * @returns true if everything that can be done was applied
  38235. */
  38236. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38237. /**
  38238. * Creates the SceneOptimization object
  38239. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38240. * @param desc defines the description associated with the optimization
  38241. */
  38242. constructor(
  38243. /**
  38244. * Defines the priority of this optimization (0 by default which means first in the list)
  38245. */
  38246. priority?: number);
  38247. }
  38248. /**
  38249. * Defines an optimization used to reduce the size of render target textures
  38250. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38251. */
  38252. class TextureOptimization extends SceneOptimization {
  38253. /**
  38254. * Defines the priority of this optimization (0 by default which means first in the list)
  38255. */
  38256. priority: number;
  38257. /**
  38258. * 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
  38259. */
  38260. maximumSize: number;
  38261. /**
  38262. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38263. */
  38264. step: number;
  38265. /**
  38266. * Gets a string describing the action executed by the current optimization
  38267. * @returns description string
  38268. */
  38269. getDescription(): string;
  38270. /**
  38271. * Creates the TextureOptimization object
  38272. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38273. * @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
  38274. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38275. */
  38276. constructor(
  38277. /**
  38278. * Defines the priority of this optimization (0 by default which means first in the list)
  38279. */
  38280. priority?: number,
  38281. /**
  38282. * 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
  38283. */
  38284. maximumSize?: number,
  38285. /**
  38286. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38287. */
  38288. step?: number);
  38289. /**
  38290. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38291. * @param scene defines the current scene where to apply this optimization
  38292. * @param optimizer defines the current optimizer
  38293. * @returns true if everything that can be done was applied
  38294. */
  38295. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38296. }
  38297. /**
  38298. * Defines an optimization used to increase or decrease the rendering resolution
  38299. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38300. */
  38301. class HardwareScalingOptimization extends SceneOptimization {
  38302. /**
  38303. * Defines the priority of this optimization (0 by default which means first in the list)
  38304. */
  38305. priority: number;
  38306. /**
  38307. * Defines the maximum scale to use (2 by default)
  38308. */
  38309. maximumScale: number;
  38310. /**
  38311. * Defines the step to use between two passes (0.5 by default)
  38312. */
  38313. step: number;
  38314. private _currentScale;
  38315. private _directionOffset;
  38316. /**
  38317. * Gets a string describing the action executed by the current optimization
  38318. * @return description string
  38319. */
  38320. getDescription(): string;
  38321. /**
  38322. * Creates the HardwareScalingOptimization object
  38323. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38324. * @param maximumScale defines the maximum scale to use (2 by default)
  38325. * @param step defines the step to use between two passes (0.5 by default)
  38326. */
  38327. constructor(
  38328. /**
  38329. * Defines the priority of this optimization (0 by default which means first in the list)
  38330. */
  38331. priority?: number,
  38332. /**
  38333. * Defines the maximum scale to use (2 by default)
  38334. */
  38335. maximumScale?: number,
  38336. /**
  38337. * Defines the step to use between two passes (0.5 by default)
  38338. */
  38339. step?: number);
  38340. /**
  38341. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38342. * @param scene defines the current scene where to apply this optimization
  38343. * @param optimizer defines the current optimizer
  38344. * @returns true if everything that can be done was applied
  38345. */
  38346. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38347. }
  38348. /**
  38349. * Defines an optimization used to remove shadows
  38350. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38351. */
  38352. class ShadowsOptimization extends SceneOptimization {
  38353. /**
  38354. * Gets a string describing the action executed by the current optimization
  38355. * @return description string
  38356. */
  38357. getDescription(): string;
  38358. /**
  38359. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38360. * @param scene defines the current scene where to apply this optimization
  38361. * @param optimizer defines the current optimizer
  38362. * @returns true if everything that can be done was applied
  38363. */
  38364. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38365. }
  38366. /**
  38367. * Defines an optimization used to turn post-processes off
  38368. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38369. */
  38370. class PostProcessesOptimization extends SceneOptimization {
  38371. /**
  38372. * Gets a string describing the action executed by the current optimization
  38373. * @return description string
  38374. */
  38375. getDescription(): string;
  38376. /**
  38377. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38378. * @param scene defines the current scene where to apply this optimization
  38379. * @param optimizer defines the current optimizer
  38380. * @returns true if everything that can be done was applied
  38381. */
  38382. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38383. }
  38384. /**
  38385. * Defines an optimization used to turn lens flares off
  38386. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38387. */
  38388. class LensFlaresOptimization extends SceneOptimization {
  38389. /**
  38390. * Gets a string describing the action executed by the current optimization
  38391. * @return description string
  38392. */
  38393. getDescription(): string;
  38394. /**
  38395. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38396. * @param scene defines the current scene where to apply this optimization
  38397. * @param optimizer defines the current optimizer
  38398. * @returns true if everything that can be done was applied
  38399. */
  38400. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38401. }
  38402. /**
  38403. * Defines an optimization based on user defined callback.
  38404. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38405. */
  38406. class CustomOptimization extends SceneOptimization {
  38407. /**
  38408. * Callback called to apply the custom optimization.
  38409. */
  38410. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38411. /**
  38412. * Callback called to get custom description
  38413. */
  38414. onGetDescription: () => string;
  38415. /**
  38416. * Gets a string describing the action executed by the current optimization
  38417. * @returns description string
  38418. */
  38419. getDescription(): string;
  38420. /**
  38421. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38422. * @param scene defines the current scene where to apply this optimization
  38423. * @param optimizer defines the current optimizer
  38424. * @returns true if everything that can be done was applied
  38425. */
  38426. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38427. }
  38428. /**
  38429. * Defines an optimization used to turn particles off
  38430. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38431. */
  38432. class ParticlesOptimization extends SceneOptimization {
  38433. /**
  38434. * Gets a string describing the action executed by the current optimization
  38435. * @return description string
  38436. */
  38437. getDescription(): string;
  38438. /**
  38439. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38440. * @param scene defines the current scene where to apply this optimization
  38441. * @param optimizer defines the current optimizer
  38442. * @returns true if everything that can be done was applied
  38443. */
  38444. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38445. }
  38446. /**
  38447. * Defines an optimization used to turn render targets off
  38448. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38449. */
  38450. class RenderTargetsOptimization extends SceneOptimization {
  38451. /**
  38452. * Gets a string describing the action executed by the current optimization
  38453. * @return description string
  38454. */
  38455. getDescription(): string;
  38456. /**
  38457. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38458. * @param scene defines the current scene where to apply this optimization
  38459. * @param optimizer defines the current optimizer
  38460. * @returns true if everything that can be done was applied
  38461. */
  38462. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38463. }
  38464. /**
  38465. * Defines an optimization used to merge meshes with compatible materials
  38466. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38467. */
  38468. class MergeMeshesOptimization extends SceneOptimization {
  38469. private static _UpdateSelectionTree;
  38470. /**
  38471. * Gets or sets a boolean which defines if optimization octree has to be updated
  38472. */
  38473. /**
  38474. * Gets or sets a boolean which defines if optimization octree has to be updated
  38475. */
  38476. static UpdateSelectionTree: boolean;
  38477. /**
  38478. * Gets a string describing the action executed by the current optimization
  38479. * @return description string
  38480. */
  38481. getDescription(): string;
  38482. private _canBeMerged;
  38483. /**
  38484. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38485. * @param scene defines the current scene where to apply this optimization
  38486. * @param optimizer defines the current optimizer
  38487. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  38488. * @returns true if everything that can be done was applied
  38489. */
  38490. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  38491. }
  38492. /**
  38493. * Defines a list of options used by SceneOptimizer
  38494. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38495. */
  38496. class SceneOptimizerOptions {
  38497. /**
  38498. * Defines the target frame rate to reach (60 by default)
  38499. */
  38500. targetFrameRate: number;
  38501. /**
  38502. * Defines the interval between two checkes (2000ms by default)
  38503. */
  38504. trackerDuration: number;
  38505. /**
  38506. * Gets the list of optimizations to apply
  38507. */
  38508. optimizations: SceneOptimization[];
  38509. /**
  38510. * Creates a new list of options used by SceneOptimizer
  38511. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  38512. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  38513. */
  38514. constructor(
  38515. /**
  38516. * Defines the target frame rate to reach (60 by default)
  38517. */
  38518. targetFrameRate?: number,
  38519. /**
  38520. * Defines the interval between two checkes (2000ms by default)
  38521. */
  38522. trackerDuration?: number);
  38523. /**
  38524. * Add a new optimization
  38525. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  38526. * @returns the current SceneOptimizerOptions
  38527. */
  38528. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  38529. /**
  38530. * Add a new custom optimization
  38531. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  38532. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  38533. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38534. * @returns the current SceneOptimizerOptions
  38535. */
  38536. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  38537. /**
  38538. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  38539. * @param targetFrameRate defines the target frame rate (60 by default)
  38540. * @returns a SceneOptimizerOptions object
  38541. */
  38542. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38543. /**
  38544. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  38545. * @param targetFrameRate defines the target frame rate (60 by default)
  38546. * @returns a SceneOptimizerOptions object
  38547. */
  38548. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38549. /**
  38550. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  38551. * @param targetFrameRate defines the target frame rate (60 by default)
  38552. * @returns a SceneOptimizerOptions object
  38553. */
  38554. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38555. }
  38556. /**
  38557. * Class used to run optimizations in order to reach a target frame rate
  38558. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38559. */
  38560. class SceneOptimizer implements IDisposable {
  38561. private _isRunning;
  38562. private _options;
  38563. private _scene;
  38564. private _currentPriorityLevel;
  38565. private _targetFrameRate;
  38566. private _trackerDuration;
  38567. private _currentFrameRate;
  38568. private _sceneDisposeObserver;
  38569. private _improvementMode;
  38570. /**
  38571. * Defines an observable called when the optimizer reaches the target frame rate
  38572. */
  38573. onSuccessObservable: Observable<SceneOptimizer>;
  38574. /**
  38575. * Defines an observable called when the optimizer enables an optimization
  38576. */
  38577. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  38578. /**
  38579. * Defines an observable called when the optimizer is not able to reach the target frame rate
  38580. */
  38581. onFailureObservable: Observable<SceneOptimizer>;
  38582. /**
  38583. * Gets a boolean indicating if the optimizer is in improvement mode
  38584. */
  38585. readonly isInImprovementMode: boolean;
  38586. /**
  38587. * Gets the current priority level (0 at start)
  38588. */
  38589. readonly currentPriorityLevel: number;
  38590. /**
  38591. * Gets the current frame rate checked by the SceneOptimizer
  38592. */
  38593. readonly currentFrameRate: number;
  38594. /**
  38595. * Gets or sets the current target frame rate (60 by default)
  38596. */
  38597. /**
  38598. * Gets or sets the current target frame rate (60 by default)
  38599. */
  38600. targetFrameRate: number;
  38601. /**
  38602. * Gets or sets the current interval between two checks (every 2000ms by default)
  38603. */
  38604. /**
  38605. * Gets or sets the current interval between two checks (every 2000ms by default)
  38606. */
  38607. trackerDuration: number;
  38608. /**
  38609. * Gets the list of active optimizations
  38610. */
  38611. readonly optimizations: SceneOptimization[];
  38612. /**
  38613. * Creates a new SceneOptimizer
  38614. * @param scene defines the scene to work on
  38615. * @param options defines the options to use with the SceneOptimizer
  38616. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  38617. * @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)
  38618. */
  38619. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  38620. /**
  38621. * Stops the current optimizer
  38622. */
  38623. stop(): void;
  38624. /**
  38625. * Reset the optimizer to initial step (current priority level = 0)
  38626. */
  38627. reset(): void;
  38628. /**
  38629. * Start the optimizer. By default it will try to reach a specific framerate
  38630. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  38631. */
  38632. start(): void;
  38633. private _checkCurrentState;
  38634. /**
  38635. * Release all resources
  38636. */
  38637. dispose(): void;
  38638. /**
  38639. * Helper function to create a SceneOptimizer with one single line of code
  38640. * @param scene defines the scene to work on
  38641. * @param options defines the options to use with the SceneOptimizer
  38642. * @param onSuccess defines a callback to call on success
  38643. * @param onFailure defines a callback to call on failure
  38644. * @returns the new SceneOptimizer object
  38645. */
  38646. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  38647. }
  38648. }
  38649. declare module BABYLON {
  38650. /**
  38651. * Class used to serialize a scene into a string
  38652. */
  38653. class SceneSerializer {
  38654. /**
  38655. * Clear cache used by a previous serialization
  38656. */
  38657. static ClearCache(): void;
  38658. /**
  38659. * Serialize a scene into a JSON compatible object
  38660. * @param scene defines the scene to serialize
  38661. * @returns a JSON compatible object
  38662. */
  38663. static Serialize(scene: Scene): any;
  38664. /**
  38665. * Serialize a mesh into a JSON compatible object
  38666. * @param toSerialize defines the mesh to serialize
  38667. * @param withParents defines if parents must be serialized as well
  38668. * @param withChildren defines if children must be serialized as well
  38669. * @returns a JSON compatible object
  38670. */
  38671. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  38672. }
  38673. }
  38674. declare module BABYLON {
  38675. /**
  38676. * Defines an array and its length.
  38677. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  38678. */
  38679. interface ISmartArrayLike<T> {
  38680. /**
  38681. * The data of the array.
  38682. */
  38683. data: Array<T>;
  38684. /**
  38685. * The active length of the array.
  38686. */
  38687. length: number;
  38688. }
  38689. /**
  38690. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38691. */
  38692. class SmartArray<T> implements ISmartArrayLike<T> {
  38693. /**
  38694. * The full set of data from the array.
  38695. */
  38696. data: Array<T>;
  38697. /**
  38698. * The active length of the array.
  38699. */
  38700. length: number;
  38701. protected _id: number;
  38702. /**
  38703. * Instantiates a Smart Array.
  38704. * @param capacity defines the default capacity of the array.
  38705. */
  38706. constructor(capacity: number);
  38707. /**
  38708. * Pushes a value at the end of the active data.
  38709. * @param value defines the object to push in the array.
  38710. */
  38711. push(value: T): void;
  38712. /**
  38713. * Iterates over the active data and apply the lambda to them.
  38714. * @param func defines the action to apply on each value.
  38715. */
  38716. forEach(func: (content: T) => void): void;
  38717. /**
  38718. * Sorts the full sets of data.
  38719. * @param compareFn defines the comparison function to apply.
  38720. */
  38721. sort(compareFn: (a: T, b: T) => number): void;
  38722. /**
  38723. * Resets the active data to an empty array.
  38724. */
  38725. reset(): void;
  38726. /**
  38727. * Releases all the data from the array as well as the array.
  38728. */
  38729. dispose(): void;
  38730. /**
  38731. * Concats the active data with a given array.
  38732. * @param array defines the data to concatenate with.
  38733. */
  38734. concat(array: any): void;
  38735. /**
  38736. * Returns the position of a value in the active data.
  38737. * @param value defines the value to find the index for
  38738. * @returns the index if found in the active data otherwise -1
  38739. */
  38740. indexOf(value: T): number;
  38741. /**
  38742. * Returns whether an element is part of the active data.
  38743. * @param value defines the value to look for
  38744. * @returns true if found in the active data otherwise false
  38745. */
  38746. contains(value: T): boolean;
  38747. private static _GlobalId;
  38748. }
  38749. /**
  38750. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38751. * The data in this array can only be present once
  38752. */
  38753. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  38754. private _duplicateId;
  38755. /**
  38756. * Pushes a value at the end of the active data.
  38757. * THIS DOES NOT PREVENT DUPPLICATE DATA
  38758. * @param value defines the object to push in the array.
  38759. */
  38760. push(value: T): void;
  38761. /**
  38762. * Pushes a value at the end of the active data.
  38763. * If the data is already present, it won t be added again
  38764. * @param value defines the object to push in the array.
  38765. * @returns true if added false if it was already present
  38766. */
  38767. pushNoDuplicate(value: T): boolean;
  38768. /**
  38769. * Resets the active data to an empty array.
  38770. */
  38771. reset(): void;
  38772. /**
  38773. * Concats the active data with a given array.
  38774. * This ensures no dupplicate will be present in the result.
  38775. * @param array defines the data to concatenate with.
  38776. */
  38777. concatWithNoDuplicate(array: any): void;
  38778. }
  38779. }
  38780. declare module BABYLON {
  38781. /**
  38782. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38783. * The underlying implementation relies on an associative array to ensure the best performances.
  38784. * The value can be anything including 'null' but except 'undefined'
  38785. */
  38786. class StringDictionary<T> {
  38787. /**
  38788. * This will clear this dictionary and copy the content from the 'source' one.
  38789. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38790. * @param source the dictionary to take the content from and copy to this dictionary
  38791. */
  38792. copyFrom(source: StringDictionary<T>): void;
  38793. /**
  38794. * Get a value based from its key
  38795. * @param key the given key to get the matching value from
  38796. * @return the value if found, otherwise undefined is returned
  38797. */
  38798. get(key: string): T | undefined;
  38799. /**
  38800. * Get a value from its key or add it if it doesn't exist.
  38801. * This method will ensure you that a given key/data will be present in the dictionary.
  38802. * @param key the given key to get the matching value from
  38803. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38804. * The factory will only be invoked if there's no data for the given key.
  38805. * @return the value corresponding to the key.
  38806. */
  38807. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38808. /**
  38809. * Get a value from its key if present in the dictionary otherwise add it
  38810. * @param key the key to get the value from
  38811. * @param val if there's no such key/value pair in the dictionary add it with this value
  38812. * @return the value corresponding to the key
  38813. */
  38814. getOrAdd(key: string, val: T): T;
  38815. /**
  38816. * Check if there's a given key in the dictionary
  38817. * @param key the key to check for
  38818. * @return true if the key is present, false otherwise
  38819. */
  38820. contains(key: string): boolean;
  38821. /**
  38822. * Add a new key and its corresponding value
  38823. * @param key the key to add
  38824. * @param value the value corresponding to the key
  38825. * @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
  38826. */
  38827. add(key: string, value: T): boolean;
  38828. /**
  38829. * Update a specific value associated to a key
  38830. * @param key defines the key to use
  38831. * @param value defines the value to store
  38832. * @returns true if the value was updated (or false if the key was not found)
  38833. */
  38834. set(key: string, value: T): boolean;
  38835. /**
  38836. * Get the element of the given key and remove it from the dictionary
  38837. * @param key defines the key to search
  38838. * @returns the value associated with the key or null if not found
  38839. */
  38840. getAndRemove(key: string): Nullable<T>;
  38841. /**
  38842. * Remove a key/value from the dictionary.
  38843. * @param key the key to remove
  38844. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38845. */
  38846. remove(key: string): boolean;
  38847. /**
  38848. * Clear the whole content of the dictionary
  38849. */
  38850. clear(): void;
  38851. /**
  38852. * Gets the current count
  38853. */
  38854. readonly count: number;
  38855. /**
  38856. * Execute a callback on each key/val of the dictionary.
  38857. * Note that you can remove any element in this dictionary in the callback implementation
  38858. * @param callback the callback to execute on a given key/value pair
  38859. */
  38860. forEach(callback: (key: string, val: T) => void): void;
  38861. /**
  38862. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38863. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38864. * Note that you can remove any element in this dictionary in the callback implementation
  38865. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38866. * @returns the first item
  38867. */
  38868. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38869. private _count;
  38870. private _data;
  38871. }
  38872. }
  38873. declare module BABYLON {
  38874. /**
  38875. * Class used to store custom tags
  38876. */
  38877. class Tags {
  38878. /**
  38879. * Adds support for tags on the given object
  38880. * @param obj defines the object to use
  38881. */
  38882. static EnableFor(obj: any): void;
  38883. /**
  38884. * Removes tags support
  38885. * @param obj defines the object to use
  38886. */
  38887. static DisableFor(obj: any): void;
  38888. /**
  38889. * Gets a boolean indicating if the given object has tags
  38890. * @param obj defines the object to use
  38891. * @returns a boolean
  38892. */
  38893. static HasTags(obj: any): boolean;
  38894. /**
  38895. * Gets the tags available on a given object
  38896. * @param obj defines the object to use
  38897. * @param asString defines if the tags must be returned as a string instead of an array of strings
  38898. * @returns the tags
  38899. */
  38900. static GetTags(obj: any, asString?: boolean): any;
  38901. /**
  38902. * Adds tags to an object
  38903. * @param obj defines the object to use
  38904. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  38905. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  38906. */
  38907. static AddTagsTo(obj: any, tagsString: string): void;
  38908. /**
  38909. * @hidden
  38910. */
  38911. static _AddTagTo(obj: any, tag: string): void;
  38912. /**
  38913. * Removes specific tags from a specific object
  38914. * @param obj defines the object to use
  38915. * @param tagsString defines the tags to remove
  38916. */
  38917. static RemoveTagsFrom(obj: any, tagsString: string): void;
  38918. /**
  38919. * @hidden
  38920. */
  38921. static _RemoveTagFrom(obj: any, tag: string): void;
  38922. /**
  38923. * Defines if tags hosted on an object match a given query
  38924. * @param obj defines the object to use
  38925. * @param tagsQuery defines the tag query
  38926. * @returns a boolean
  38927. */
  38928. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  38929. }
  38930. }
  38931. declare module BABYLON {
  38932. /**
  38933. * Class used to host texture specific utilities
  38934. */
  38935. class TextureTools {
  38936. /**
  38937. * Uses the GPU to create a copy texture rescaled at a given size
  38938. * @param texture Texture to copy from
  38939. * @param width defines the desired width
  38940. * @param height defines the desired height
  38941. * @param useBilinearMode defines if bilinear mode has to be used
  38942. * @return the generated texture
  38943. */
  38944. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  38945. /**
  38946. * Gets an environment BRDF texture for a given scene
  38947. * @param scene defines the hosting scene
  38948. * @returns the environment BRDF texture
  38949. */
  38950. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  38951. private static _environmentBRDFBase64Texture;
  38952. }
  38953. }
  38954. declare module BABYLON {
  38955. /**
  38956. * Based on jsTGALoader - Javascript loader for TGA file
  38957. * By Vincent Thibault
  38958. * @see http://blog.robrowser.com/javascript-tga-loader.html
  38959. */
  38960. class TGATools {
  38961. private static _TYPE_INDEXED;
  38962. private static _TYPE_RGB;
  38963. private static _TYPE_GREY;
  38964. private static _TYPE_RLE_INDEXED;
  38965. private static _TYPE_RLE_RGB;
  38966. private static _TYPE_RLE_GREY;
  38967. private static _ORIGIN_MASK;
  38968. private static _ORIGIN_SHIFT;
  38969. private static _ORIGIN_BL;
  38970. private static _ORIGIN_BR;
  38971. private static _ORIGIN_UL;
  38972. private static _ORIGIN_UR;
  38973. /**
  38974. * Gets the header of a TGA file
  38975. * @param data defines the TGA data
  38976. * @returns the header
  38977. */
  38978. static GetTGAHeader(data: Uint8Array): any;
  38979. /**
  38980. * Uploads TGA content to a Babylon Texture
  38981. * @hidden
  38982. */
  38983. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  38984. /** @hidden */
  38985. 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;
  38986. /** @hidden */
  38987. 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;
  38988. /** @hidden */
  38989. 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;
  38990. /** @hidden */
  38991. 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;
  38992. /** @hidden */
  38993. 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;
  38994. /** @hidden */
  38995. 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;
  38996. }
  38997. }
  38998. declare module BABYLON {
  38999. /**
  39000. * Interface for any object that can request an animation frame
  39001. */
  39002. interface ICustomAnimationFrameRequester {
  39003. /**
  39004. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  39005. */
  39006. renderFunction?: Function;
  39007. /**
  39008. * Called to request the next frame to render to
  39009. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  39010. */
  39011. requestAnimationFrame: Function;
  39012. /**
  39013. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  39014. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  39015. */
  39016. requestID?: number;
  39017. }
  39018. /**
  39019. * Interface containing an array of animations
  39020. */
  39021. interface IAnimatable {
  39022. /**
  39023. * Array of animations
  39024. */
  39025. animations: Array<Animation>;
  39026. }
  39027. /** Interface used by value gradients (color, factor, ...) */
  39028. interface IValueGradient {
  39029. /**
  39030. * Gets or sets the gradient value (between 0 and 1)
  39031. */
  39032. gradient: number;
  39033. }
  39034. /** Class used to store color4 gradient */
  39035. class ColorGradient implements IValueGradient {
  39036. /**
  39037. * Gets or sets the gradient value (between 0 and 1)
  39038. */
  39039. gradient: number;
  39040. /**
  39041. * Gets or sets first associated color
  39042. */
  39043. color1: Color4;
  39044. /**
  39045. * Gets or sets second associated color
  39046. */
  39047. color2?: Color4;
  39048. /**
  39049. * Will get a color picked randomly between color1 and color2.
  39050. * If color2 is undefined then color1 will be used
  39051. * @param result defines the target Color4 to store the result in
  39052. */
  39053. getColorToRef(result: Color4): void;
  39054. }
  39055. /** Class used to store color 3 gradient */
  39056. class Color3Gradient implements IValueGradient {
  39057. /**
  39058. * Gets or sets the gradient value (between 0 and 1)
  39059. */
  39060. gradient: number;
  39061. /**
  39062. * Gets or sets the associated color
  39063. */
  39064. color: Color3;
  39065. }
  39066. /** Class used to store factor gradient */
  39067. class FactorGradient implements IValueGradient {
  39068. /**
  39069. * Gets or sets the gradient value (between 0 and 1)
  39070. */
  39071. gradient: number;
  39072. /**
  39073. * Gets or sets first associated factor
  39074. */
  39075. factor1: number;
  39076. /**
  39077. * Gets or sets second associated factor
  39078. */
  39079. factor2?: number;
  39080. /**
  39081. * Will get a number picked randomly between factor1 and factor2.
  39082. * If factor2 is undefined then factor1 will be used
  39083. * @returns the picked number
  39084. */
  39085. getFactor(): number;
  39086. }
  39087. /**
  39088. * @ignore
  39089. * Application error to support additional information when loading a file
  39090. */
  39091. class LoadFileError extends Error {
  39092. /** defines the optional XHR request */
  39093. request?: XMLHttpRequest | undefined;
  39094. private static _setPrototypeOf;
  39095. /**
  39096. * Creates a new LoadFileError
  39097. * @param message defines the message of the error
  39098. * @param request defines the optional XHR request
  39099. */
  39100. constructor(message: string,
  39101. /** defines the optional XHR request */
  39102. request?: XMLHttpRequest | undefined);
  39103. }
  39104. /**
  39105. * Class used to define a retry strategy when error happens while loading assets
  39106. */
  39107. class RetryStrategy {
  39108. /**
  39109. * Function used to defines an exponential back off strategy
  39110. * @param maxRetries defines the maximum number of retries (3 by default)
  39111. * @param baseInterval defines the interval between retries
  39112. * @returns the strategy function to use
  39113. */
  39114. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39115. }
  39116. /**
  39117. * File request interface
  39118. */
  39119. interface IFileRequest {
  39120. /**
  39121. * Raised when the request is complete (success or error).
  39122. */
  39123. onCompleteObservable: Observable<IFileRequest>;
  39124. /**
  39125. * Aborts the request for a file.
  39126. */
  39127. abort: () => void;
  39128. }
  39129. /**
  39130. * Class containing a set of static utilities functions
  39131. */
  39132. class Tools {
  39133. /**
  39134. * Gets or sets the base URL to use to load assets
  39135. */
  39136. static BaseUrl: string;
  39137. /**
  39138. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39139. */
  39140. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39141. /**
  39142. * Default behaviour for cors in the application.
  39143. * It can be a string if the expected behavior is identical in the entire app.
  39144. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39145. */
  39146. static CorsBehavior: string | ((url: string | string[]) => string);
  39147. /**
  39148. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39149. * @ignorenaming
  39150. */
  39151. static UseFallbackTexture: boolean;
  39152. /**
  39153. * Use this object to register external classes like custom textures or material
  39154. * to allow the laoders to instantiate them
  39155. */
  39156. static RegisteredExternalClasses: {
  39157. [key: string]: Object;
  39158. };
  39159. /**
  39160. * Texture content used if a texture cannot loaded
  39161. * @ignorenaming
  39162. */
  39163. static fallbackTexture: string;
  39164. /**
  39165. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39166. * @param u defines the coordinate on X axis
  39167. * @param v defines the coordinate on Y axis
  39168. * @param width defines the width of the source data
  39169. * @param height defines the height of the source data
  39170. * @param pixels defines the source byte array
  39171. * @param color defines the output color
  39172. */
  39173. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39174. /**
  39175. * Interpolates between a and b via alpha
  39176. * @param a The lower value (returned when alpha = 0)
  39177. * @param b The upper value (returned when alpha = 1)
  39178. * @param alpha The interpolation-factor
  39179. * @return The mixed value
  39180. */
  39181. static Mix(a: number, b: number, alpha: number): number;
  39182. /**
  39183. * Tries to instantiate a new object from a given class name
  39184. * @param className defines the class name to instantiate
  39185. * @returns the new object or null if the system was not able to do the instantiation
  39186. */
  39187. static Instantiate(className: string): any;
  39188. /**
  39189. * Provides a slice function that will work even on IE
  39190. * @param data defines the array to slice
  39191. * @param start defines the start of the data (optional)
  39192. * @param end defines the end of the data (optional)
  39193. * @returns the new sliced array
  39194. */
  39195. static Slice<T>(data: T, start?: number, end?: number): T;
  39196. /**
  39197. * Polyfill for setImmediate
  39198. * @param action defines the action to execute after the current execution block
  39199. */
  39200. static SetImmediate(action: () => void): void;
  39201. /**
  39202. * Function indicating if a number is an exponent of 2
  39203. * @param value defines the value to test
  39204. * @returns true if the value is an exponent of 2
  39205. */
  39206. static IsExponentOfTwo(value: number): boolean;
  39207. private static _tmpFloatArray;
  39208. /**
  39209. * Returns the nearest 32-bit single precision float representation of a Number
  39210. * @param value A Number. If the parameter is of a different type, it will get converted
  39211. * to a number or to NaN if it cannot be converted
  39212. * @returns number
  39213. */
  39214. static FloatRound(value: number): number;
  39215. /**
  39216. * Find the next highest power of two.
  39217. * @param x Number to start search from.
  39218. * @return Next highest power of two.
  39219. */
  39220. static CeilingPOT(x: number): number;
  39221. /**
  39222. * Find the next lowest power of two.
  39223. * @param x Number to start search from.
  39224. * @return Next lowest power of two.
  39225. */
  39226. static FloorPOT(x: number): number;
  39227. /**
  39228. * Find the nearest power of two.
  39229. * @param x Number to start search from.
  39230. * @return Next nearest power of two.
  39231. */
  39232. static NearestPOT(x: number): number;
  39233. /**
  39234. * Get the closest exponent of two
  39235. * @param value defines the value to approximate
  39236. * @param max defines the maximum value to return
  39237. * @param mode defines how to define the closest value
  39238. * @returns closest exponent of two of the given value
  39239. */
  39240. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39241. /**
  39242. * Extracts the filename from a path
  39243. * @param path defines the path to use
  39244. * @returns the filename
  39245. */
  39246. static GetFilename(path: string): string;
  39247. /**
  39248. * Extracts the "folder" part of a path (everything before the filename).
  39249. * @param uri The URI to extract the info from
  39250. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39251. * @returns The "folder" part of the path
  39252. */
  39253. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39254. /**
  39255. * Extracts text content from a DOM element hierarchy
  39256. * @param element defines the root element
  39257. * @returns a string
  39258. */
  39259. static GetDOMTextContent(element: HTMLElement): string;
  39260. /**
  39261. * Convert an angle in radians to degrees
  39262. * @param angle defines the angle to convert
  39263. * @returns the angle in degrees
  39264. */
  39265. static ToDegrees(angle: number): number;
  39266. /**
  39267. * Convert an angle in degrees to radians
  39268. * @param angle defines the angle to convert
  39269. * @returns the angle in radians
  39270. */
  39271. static ToRadians(angle: number): number;
  39272. /**
  39273. * Encode a buffer to a base64 string
  39274. * @param buffer defines the buffer to encode
  39275. * @returns the encoded string
  39276. */
  39277. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39278. /**
  39279. * Extracts minimum and maximum values from a list of indexed positions
  39280. * @param positions defines the positions to use
  39281. * @param indices defines the indices to the positions
  39282. * @param indexStart defines the start index
  39283. * @param indexCount defines the end index
  39284. * @param bias defines bias value to add to the result
  39285. * @return minimum and maximum values
  39286. */
  39287. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39288. minimum: Vector3;
  39289. maximum: Vector3;
  39290. };
  39291. /**
  39292. * Extracts minimum and maximum values from a list of positions
  39293. * @param positions defines the positions to use
  39294. * @param start defines the start index in the positions array
  39295. * @param count defines the number of positions to handle
  39296. * @param bias defines bias value to add to the result
  39297. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39298. * @return minimum and maximum values
  39299. */
  39300. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39301. minimum: Vector3;
  39302. maximum: Vector3;
  39303. };
  39304. /**
  39305. * Returns an array if obj is not an array
  39306. * @param obj defines the object to evaluate as an array
  39307. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39308. * @returns either obj directly if obj is an array or a new array containing obj
  39309. */
  39310. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39311. /**
  39312. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39313. * @param size the number of element to construct and put in the array
  39314. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39315. * @returns a new array filled with new objects
  39316. */
  39317. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39318. /**
  39319. * Gets the pointer prefix to use
  39320. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39321. */
  39322. static GetPointerPrefix(): string;
  39323. /**
  39324. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39325. * @param func - the function to be called
  39326. * @param requester - the object that will request the next frame. Falls back to window.
  39327. * @returns frame number
  39328. */
  39329. static QueueNewFrame(func: () => void, requester?: any): number;
  39330. /**
  39331. * Ask the browser to promote the current element to fullscreen rendering mode
  39332. * @param element defines the DOM element to promote
  39333. */
  39334. static RequestFullscreen(element: HTMLElement): void;
  39335. /**
  39336. * Asks the browser to exit fullscreen mode
  39337. */
  39338. static ExitFullscreen(): void;
  39339. /**
  39340. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39341. * @param url define the url we are trying
  39342. * @param element define the dom element where to configure the cors policy
  39343. */
  39344. static SetCorsBehavior(url: string | string[], element: {
  39345. crossOrigin: string | null;
  39346. }): void;
  39347. /**
  39348. * Removes unwanted characters from an url
  39349. * @param url defines the url to clean
  39350. * @returns the cleaned url
  39351. */
  39352. static CleanUrl(url: string): string;
  39353. /**
  39354. * Gets or sets a function used to pre-process url before using them to load assets
  39355. */
  39356. static PreprocessUrl: (url: string) => string;
  39357. /**
  39358. * Loads an image as an HTMLImageElement.
  39359. * @param input url string, ArrayBuffer, or Blob to load
  39360. * @param onLoad callback called when the image successfully loads
  39361. * @param onError callback called when the image fails to load
  39362. * @param offlineProvider offline provider for caching
  39363. * @returns the HTMLImageElement of the loaded image
  39364. */
  39365. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39366. /**
  39367. * Loads a file
  39368. * @param url url string, ArrayBuffer, or Blob to load
  39369. * @param onSuccess callback called when the file successfully loads
  39370. * @param onProgress callback called while file is loading (if the server supports this mode)
  39371. * @param offlineProvider defines the offline provider for caching
  39372. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39373. * @param onError callback called when the file fails to load
  39374. * @returns a file request object
  39375. */
  39376. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  39377. /**
  39378. * Load a script (identified by an url). When the url returns, the
  39379. * content of this file is added into a new script element, attached to the DOM (body element)
  39380. * @param scriptUrl defines the url of the script to laod
  39381. * @param onSuccess defines the callback called when the script is loaded
  39382. * @param onError defines the callback to call if an error occurs
  39383. */
  39384. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39385. /**
  39386. * Loads a file from a blob
  39387. * @param fileToLoad defines the blob to use
  39388. * @param callback defines the callback to call when data is loaded
  39389. * @param progressCallback defines the callback to call during loading process
  39390. * @returns a file request object
  39391. */
  39392. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39393. /**
  39394. * Loads a file
  39395. * @param fileToLoad defines the file to load
  39396. * @param callback defines the callback to call when data is loaded
  39397. * @param progressCallBack defines the callback to call during loading process
  39398. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39399. * @returns a file request object
  39400. */
  39401. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39402. /**
  39403. * Creates a data url from a given string content
  39404. * @param content defines the content to convert
  39405. * @returns the new data url link
  39406. */
  39407. static FileAsURL(content: string): string;
  39408. /**
  39409. * Format the given number to a specific decimal format
  39410. * @param value defines the number to format
  39411. * @param decimals defines the number of decimals to use
  39412. * @returns the formatted string
  39413. */
  39414. static Format(value: number, decimals?: number): string;
  39415. /**
  39416. * Checks if a given vector is inside a specific range
  39417. * @param v defines the vector to test
  39418. * @param min defines the minimum range
  39419. * @param max defines the maximum range
  39420. */
  39421. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39422. /**
  39423. * Tries to copy an object by duplicating every property
  39424. * @param source defines the source object
  39425. * @param destination defines the target object
  39426. * @param doNotCopyList defines a list of properties to avoid
  39427. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39428. */
  39429. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39430. /**
  39431. * Gets a boolean indicating if the given object has no own property
  39432. * @param obj defines the object to test
  39433. * @returns true if object has no own property
  39434. */
  39435. static IsEmpty(obj: any): boolean;
  39436. /**
  39437. * Function used to register events at window level
  39438. * @param events defines the events to register
  39439. */
  39440. static RegisterTopRootEvents(events: {
  39441. name: string;
  39442. handler: Nullable<(e: FocusEvent) => any>;
  39443. }[]): void;
  39444. /**
  39445. * Function used to unregister events from window level
  39446. * @param events defines the events to unregister
  39447. */
  39448. static UnregisterTopRootEvents(events: {
  39449. name: string;
  39450. handler: Nullable<(e: FocusEvent) => any>;
  39451. }[]): void;
  39452. /**
  39453. * Dumps the current bound framebuffer
  39454. * @param width defines the rendering width
  39455. * @param height defines the rendering height
  39456. * @param engine defines the hosting engine
  39457. * @param successCallback defines the callback triggered once the data are available
  39458. * @param mimeType defines the mime type of the result
  39459. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39460. */
  39461. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39462. /**
  39463. * Converts the canvas data to blob.
  39464. * This acts as a polyfill for browsers not supporting the to blob function.
  39465. * @param canvas Defines the canvas to extract the data from
  39466. * @param successCallback Defines the callback triggered once the data are available
  39467. * @param mimeType Defines the mime type of the result
  39468. */
  39469. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39470. /**
  39471. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39472. * @param successCallback defines the callback triggered once the data are available
  39473. * @param mimeType defines the mime type of the result
  39474. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39475. */
  39476. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39477. /**
  39478. * Downloads a blob in the browser
  39479. * @param blob defines the blob to download
  39480. * @param fileName defines the name of the downloaded file
  39481. */
  39482. static Download(blob: Blob, fileName: string): void;
  39483. /**
  39484. * Captures a screenshot of the current rendering
  39485. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39486. * @param engine defines the rendering engine
  39487. * @param camera defines the source camera
  39488. * @param size This parameter can be set to a single number or to an object with the
  39489. * following (optional) properties: precision, width, height. If a single number is passed,
  39490. * it will be used for both width and height. If an object is passed, the screenshot size
  39491. * will be derived from the parameters. The precision property is a multiplier allowing
  39492. * rendering at a higher or lower resolution
  39493. * @param successCallback defines the callback receives a single parameter which contains the
  39494. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39495. * src parameter of an <img> to display it
  39496. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39497. * Check your browser for supported MIME types
  39498. */
  39499. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  39500. /**
  39501. * Generates an image screenshot from the specified camera.
  39502. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39503. * @param engine The engine to use for rendering
  39504. * @param camera The camera to use for rendering
  39505. * @param size This parameter can be set to a single number or to an object with the
  39506. * following (optional) properties: precision, width, height. If a single number is passed,
  39507. * it will be used for both width and height. If an object is passed, the screenshot size
  39508. * will be derived from the parameters. The precision property is a multiplier allowing
  39509. * rendering at a higher or lower resolution
  39510. * @param successCallback The callback receives a single parameter which contains the
  39511. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39512. * src parameter of an <img> to display it
  39513. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39514. * Check your browser for supported MIME types
  39515. * @param samples Texture samples (default: 1)
  39516. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39517. * @param fileName A name for for the downloaded file.
  39518. */
  39519. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39520. /**
  39521. * Validates if xhr data is correct
  39522. * @param xhr defines the request to validate
  39523. * @param dataType defines the expected data type
  39524. * @returns true if data is correct
  39525. */
  39526. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  39527. /**
  39528. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39529. * Be aware Math.random() could cause collisions, but:
  39530. * "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"
  39531. * @returns a pseudo random id
  39532. */
  39533. static RandomId(): string;
  39534. /**
  39535. * Test if the given uri is a base64 string
  39536. * @param uri The uri to test
  39537. * @return True if the uri is a base64 string or false otherwise
  39538. */
  39539. static IsBase64(uri: string): boolean;
  39540. /**
  39541. * Decode the given base64 uri.
  39542. * @param uri The uri to decode
  39543. * @return The decoded base64 data.
  39544. */
  39545. static DecodeBase64(uri: string): ArrayBuffer;
  39546. /**
  39547. * No log
  39548. */
  39549. static readonly NoneLogLevel: number;
  39550. /**
  39551. * Only message logs
  39552. */
  39553. static readonly MessageLogLevel: number;
  39554. /**
  39555. * Only warning logs
  39556. */
  39557. static readonly WarningLogLevel: number;
  39558. /**
  39559. * Only error logs
  39560. */
  39561. static readonly ErrorLogLevel: number;
  39562. /**
  39563. * All logs
  39564. */
  39565. static readonly AllLogLevel: number;
  39566. private static _LogCache;
  39567. /**
  39568. * Gets a value indicating the number of loading errors
  39569. * @ignorenaming
  39570. */
  39571. static errorsCount: number;
  39572. /**
  39573. * Callback called when a new log is added
  39574. */
  39575. static OnNewCacheEntry: (entry: string) => void;
  39576. private static _AddLogEntry;
  39577. private static _FormatMessage;
  39578. private static _LogDisabled;
  39579. private static _LogEnabled;
  39580. private static _WarnDisabled;
  39581. private static _WarnEnabled;
  39582. private static _ErrorDisabled;
  39583. private static _ErrorEnabled;
  39584. /**
  39585. * Log a message to the console
  39586. */
  39587. static Log: (message: string) => void;
  39588. /**
  39589. * Write a warning message to the console
  39590. */
  39591. static Warn: (message: string) => void;
  39592. /**
  39593. * Write an error message to the console
  39594. */
  39595. static Error: (message: string) => void;
  39596. /**
  39597. * Gets current log cache (list of logs)
  39598. */
  39599. static readonly LogCache: string;
  39600. /**
  39601. * Clears the log cache
  39602. */
  39603. static ClearLogCache(): void;
  39604. /**
  39605. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39606. */
  39607. static LogLevels: number;
  39608. /**
  39609. * Checks if the loaded document was accessed via `file:`-Protocol.
  39610. * @returns boolean
  39611. */
  39612. static IsFileURL(): boolean;
  39613. /**
  39614. * Checks if the window object exists
  39615. * @returns true if the window object exists
  39616. */
  39617. static IsWindowObjectExist(): boolean;
  39618. /**
  39619. * No performance log
  39620. */
  39621. static readonly PerformanceNoneLogLevel: number;
  39622. /**
  39623. * Use user marks to log performance
  39624. */
  39625. static readonly PerformanceUserMarkLogLevel: number;
  39626. /**
  39627. * Log performance to the console
  39628. */
  39629. static readonly PerformanceConsoleLogLevel: number;
  39630. private static _performance;
  39631. /**
  39632. * Sets the current performance log level
  39633. */
  39634. static PerformanceLogLevel: number;
  39635. private static _StartPerformanceCounterDisabled;
  39636. private static _EndPerformanceCounterDisabled;
  39637. private static _StartUserMark;
  39638. private static _EndUserMark;
  39639. private static _StartPerformanceConsole;
  39640. private static _EndPerformanceConsole;
  39641. /**
  39642. * Starts a performance counter
  39643. */
  39644. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39645. /**
  39646. * Ends a specific performance coutner
  39647. */
  39648. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39649. /**
  39650. * Gets either window.performance.now() if supported or Date.now() else
  39651. */
  39652. static readonly Now: number;
  39653. /**
  39654. * This method will return the name of the class used to create the instance of the given object.
  39655. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39656. * @param object the object to get the class name from
  39657. * @param isType defines if the object is actually a type
  39658. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39659. */
  39660. static GetClassName(object: any, isType?: boolean): string;
  39661. /**
  39662. * Gets the first element of an array satisfying a given predicate
  39663. * @param array defines the array to browse
  39664. * @param predicate defines the predicate to use
  39665. * @returns null if not found or the element
  39666. */
  39667. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39668. /**
  39669. * This method will return the name of the full name of the class, including its owning module (if any).
  39670. * 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).
  39671. * @param object the object to get the class name from
  39672. * @param isType defines if the object is actually a type
  39673. * @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.
  39674. * @ignorenaming
  39675. */
  39676. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39677. /**
  39678. * Returns a promise that resolves after the given amount of time.
  39679. * @param delay Number of milliseconds to delay
  39680. * @returns Promise that resolves after the given amount of time
  39681. */
  39682. static DelayAsync(delay: number): Promise<void>;
  39683. /**
  39684. * Gets the current gradient from an array of IValueGradient
  39685. * @param ratio defines the current ratio to get
  39686. * @param gradients defines the array of IValueGradient
  39687. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  39688. */
  39689. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  39690. }
  39691. /**
  39692. * This class is used to track a performance counter which is number based.
  39693. * The user has access to many properties which give statistics of different nature.
  39694. *
  39695. * The implementer can track two kinds of Performance Counter: time and count.
  39696. * 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.
  39697. * 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.
  39698. */
  39699. class PerfCounter {
  39700. /**
  39701. * Gets or sets a global boolean to turn on and off all the counters
  39702. */
  39703. static Enabled: boolean;
  39704. /**
  39705. * Returns the smallest value ever
  39706. */
  39707. readonly min: number;
  39708. /**
  39709. * Returns the biggest value ever
  39710. */
  39711. readonly max: number;
  39712. /**
  39713. * Returns the average value since the performance counter is running
  39714. */
  39715. readonly average: number;
  39716. /**
  39717. * Returns the average value of the last second the counter was monitored
  39718. */
  39719. readonly lastSecAverage: number;
  39720. /**
  39721. * Returns the current value
  39722. */
  39723. readonly current: number;
  39724. /**
  39725. * Gets the accumulated total
  39726. */
  39727. readonly total: number;
  39728. /**
  39729. * Gets the total value count
  39730. */
  39731. readonly count: number;
  39732. /**
  39733. * Creates a new counter
  39734. */
  39735. constructor();
  39736. /**
  39737. * Call this method to start monitoring a new frame.
  39738. * 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.
  39739. */
  39740. fetchNewFrame(): void;
  39741. /**
  39742. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  39743. * @param newCount the count value to add to the monitored count
  39744. * @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.
  39745. */
  39746. addCount(newCount: number, fetchResult: boolean): void;
  39747. /**
  39748. * Start monitoring this performance counter
  39749. */
  39750. beginMonitoring(): void;
  39751. /**
  39752. * Compute the time lapsed since the previous beginMonitoring() call.
  39753. * @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
  39754. */
  39755. endMonitoring(newFrame?: boolean): void;
  39756. private _fetchResult;
  39757. private _startMonitoringTime;
  39758. private _min;
  39759. private _max;
  39760. private _average;
  39761. private _current;
  39762. private _totalValueCount;
  39763. private _totalAccumulated;
  39764. private _lastSecAverage;
  39765. private _lastSecAccumulated;
  39766. private _lastSecTime;
  39767. private _lastSecValueCount;
  39768. }
  39769. /**
  39770. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39771. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39772. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39773. * @param name The name of the class, case should be preserved
  39774. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39775. */
  39776. function className(name: string, module?: string): (target: Object) => void;
  39777. /**
  39778. * An implementation of a loop for asynchronous functions.
  39779. */
  39780. class AsyncLoop {
  39781. /**
  39782. * Defines the number of iterations for the loop
  39783. */
  39784. iterations: number;
  39785. /**
  39786. * Defines the current index of the loop.
  39787. */
  39788. index: number;
  39789. private _done;
  39790. private _fn;
  39791. private _successCallback;
  39792. /**
  39793. * Constructor.
  39794. * @param iterations the number of iterations.
  39795. * @param func the function to run each iteration
  39796. * @param successCallback the callback that will be called upon succesful execution
  39797. * @param offset starting offset.
  39798. */
  39799. constructor(
  39800. /**
  39801. * Defines the number of iterations for the loop
  39802. */
  39803. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39804. /**
  39805. * Execute the next iteration. Must be called after the last iteration was finished.
  39806. */
  39807. executeNext(): void;
  39808. /**
  39809. * Break the loop and run the success callback.
  39810. */
  39811. breakLoop(): void;
  39812. /**
  39813. * Create and run an async loop.
  39814. * @param iterations the number of iterations.
  39815. * @param fn the function to run each iteration
  39816. * @param successCallback the callback that will be called upon succesful execution
  39817. * @param offset starting offset.
  39818. * @returns the created async loop object
  39819. */
  39820. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39821. /**
  39822. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39823. * @param iterations total number of iterations
  39824. * @param syncedIterations number of synchronous iterations in each async iteration.
  39825. * @param fn the function to call each iteration.
  39826. * @param callback a success call back that will be called when iterating stops.
  39827. * @param breakFunction a break condition (optional)
  39828. * @param timeout timeout settings for the setTimeout function. default - 0.
  39829. * @returns the created async loop object
  39830. */
  39831. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39832. }
  39833. }
  39834. interface HTMLCanvasElement {
  39835. /** Track wether a record is in progress */
  39836. isRecording: boolean;
  39837. /** Capture Stream method defined by some browsers */
  39838. captureStream(fps?: number): MediaStream;
  39839. }
  39840. interface MediaRecorder {
  39841. /** Starts recording */
  39842. start(timeSlice: number): void;
  39843. /** Stops recording */
  39844. stop(): void;
  39845. /** Event raised when an error arised. */
  39846. onerror: (event: ErrorEvent) => void;
  39847. /** Event raised when the recording stops. */
  39848. onstop: (event: Event) => void;
  39849. /** Event raised when a new chunk of data is available and should be tracked. */
  39850. ondataavailable: (event: Event) => void;
  39851. }
  39852. interface MediaRecorderOptions {
  39853. /** The mime type you want to use as the recording container for the new MediaRecorder */
  39854. mimeType?: string;
  39855. /** The chosen bitrate for the audio component of the media. */
  39856. audioBitsPerSecond?: number;
  39857. /** The chosen bitrate for the video component of the media. */
  39858. videoBitsPerSecond?: number;
  39859. /** The chosen bitrate for the audio and video components of the media. This can be specified instead of the above two properties. If this is specified along with one or the other of the above properties, this will be used for the one that isn't specified. */
  39860. bitsPerSecond?: number;
  39861. }
  39862. interface MediaRecorderConstructor {
  39863. /**
  39864. * A reference to the prototype.
  39865. */
  39866. readonly prototype: MediaRecorder;
  39867. /**
  39868. * Creates a new MediaRecorder.
  39869. * @param stream Defines the stream to record.
  39870. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  39871. */
  39872. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  39873. }
  39874. /**
  39875. * MediaRecoreder object available in some browsers.
  39876. */
  39877. declare var MediaRecorder: MediaRecorderConstructor;
  39878. declare module BABYLON {
  39879. /**
  39880. * This represents the different options avilable for the video capture.
  39881. */
  39882. interface VideoRecorderOptions {
  39883. /** Defines the mime type of the video */
  39884. mimeType: string;
  39885. /** Defines the video the video should be recorded at */
  39886. fps: number;
  39887. /** Defines the chunk size for the recording data */
  39888. recordChunckSize: number;
  39889. }
  39890. /**
  39891. * This can helps recording videos from BabylonJS.
  39892. * This is based on the available WebRTC functionalities of the browser.
  39893. *
  39894. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  39895. */
  39896. class VideoRecorder {
  39897. private static readonly _defaultOptions;
  39898. /**
  39899. * Returns wehther or not the VideoRecorder is available in your browser.
  39900. * @param engine Defines the Babylon Engine to check the support for
  39901. * @returns true if supported otherwise false
  39902. */
  39903. static IsSupported(engine: Engine): boolean;
  39904. private readonly _options;
  39905. private _canvas;
  39906. private _mediaRecorder;
  39907. private _recordedChunks;
  39908. private _fileName;
  39909. private _resolve;
  39910. private _reject;
  39911. /**
  39912. * True wether a recording is already in progress.
  39913. */
  39914. readonly isRecording: boolean;
  39915. /**
  39916. * Create a new VideoCapture object which can help converting what you see in Babylon to
  39917. * a video file.
  39918. * @param engine Defines the BabylonJS Engine you wish to record
  39919. * @param options Defines options that can be used to customized the capture
  39920. */
  39921. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  39922. /**
  39923. * Stops the current recording before the default capture timeout passed in the startRecording
  39924. * functions.
  39925. */
  39926. stopRecording(): void;
  39927. /**
  39928. * Starts recording the canvas for a max duration specified in parameters.
  39929. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  39930. * @param maxDuration Defines the maximum recording time in seconds.
  39931. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  39932. * @return a promise callback at the end of the recording with the video data in Blob.
  39933. */
  39934. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  39935. /**
  39936. * Releases internal resources used during the recording.
  39937. */
  39938. dispose(): void;
  39939. private _handleDataAvailable;
  39940. private _handleError;
  39941. private _handleStop;
  39942. }
  39943. }
  39944. declare module BABYLON {
  39945. /**
  39946. * Defines the potential axis of a Joystick
  39947. */
  39948. enum JoystickAxis {
  39949. /** X axis */
  39950. X = 0,
  39951. /** Y axis */
  39952. Y = 1,
  39953. /** Z axis */
  39954. Z = 2
  39955. }
  39956. /**
  39957. * Class used to define virtual joystick (used in touch mode)
  39958. */
  39959. class VirtualJoystick {
  39960. /**
  39961. * Gets or sets a boolean indicating that left and right values must be inverted
  39962. */
  39963. reverseLeftRight: boolean;
  39964. /**
  39965. * Gets or sets a boolean indicating that up and down values must be inverted
  39966. */
  39967. reverseUpDown: boolean;
  39968. /**
  39969. * Gets the offset value for the position (ie. the change of the position value)
  39970. */
  39971. deltaPosition: Vector3;
  39972. /**
  39973. * Gets a boolean indicating if the virtual joystick was pressed
  39974. */
  39975. pressed: boolean;
  39976. private static _globalJoystickIndex;
  39977. private static vjCanvas;
  39978. private static vjCanvasContext;
  39979. private static vjCanvasWidth;
  39980. private static vjCanvasHeight;
  39981. private static halfWidth;
  39982. private _action;
  39983. private _axisTargetedByLeftAndRight;
  39984. private _axisTargetedByUpAndDown;
  39985. private _joystickSensibility;
  39986. private _inversedSensibility;
  39987. private _joystickPointerID;
  39988. private _joystickColor;
  39989. private _joystickPointerPos;
  39990. private _joystickPreviousPointerPos;
  39991. private _joystickPointerStartPos;
  39992. private _deltaJoystickVector;
  39993. private _leftJoystick;
  39994. private _touches;
  39995. private _onPointerDownHandlerRef;
  39996. private _onPointerMoveHandlerRef;
  39997. private _onPointerUpHandlerRef;
  39998. private _onResize;
  39999. /**
  40000. * Creates a new virtual joystick
  40001. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40002. */
  40003. constructor(leftJoystick?: boolean);
  40004. /**
  40005. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40006. * @param newJoystickSensibility defines the new sensibility
  40007. */
  40008. setJoystickSensibility(newJoystickSensibility: number): void;
  40009. private _onPointerDown;
  40010. private _onPointerMove;
  40011. private _onPointerUp;
  40012. /**
  40013. * Change the color of the virtual joystick
  40014. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40015. */
  40016. setJoystickColor(newColor: string): void;
  40017. /**
  40018. * Defines a callback to call when the joystick is touched
  40019. * @param action defines the callback
  40020. */
  40021. setActionOnTouch(action: () => any): void;
  40022. /**
  40023. * Defines which axis you'd like to control for left & right
  40024. * @param axis defines the axis to use
  40025. */
  40026. setAxisForLeftRight(axis: JoystickAxis): void;
  40027. /**
  40028. * Defines which axis you'd like to control for up & down
  40029. * @param axis defines the axis to use
  40030. */
  40031. setAxisForUpDown(axis: JoystickAxis): void;
  40032. private _drawVirtualJoystick;
  40033. /**
  40034. * Release internal HTML canvas
  40035. */
  40036. releaseCanvas(): void;
  40037. }
  40038. }
  40039. declare module BABYLON {
  40040. /**
  40041. * Helper class to push actions to a pool of workers.
  40042. */
  40043. class WorkerPool implements IDisposable {
  40044. private _workerInfos;
  40045. private _pendingActions;
  40046. /**
  40047. * Constructor
  40048. * @param workers Array of workers to use for actions
  40049. */
  40050. constructor(workers: Array<Worker>);
  40051. /**
  40052. * Terminates all workers and clears any pending actions.
  40053. */
  40054. dispose(): void;
  40055. /**
  40056. * Pushes an action to the worker pool. If all the workers are active, the action will be
  40057. * pended until a worker has completed its action.
  40058. * @param action The action to perform. Call onComplete when the action is complete.
  40059. */
  40060. push(action: (worker: Worker, onComplete: () => void) => void): void;
  40061. private _execute;
  40062. }
  40063. }
  40064. declare module BABYLON {
  40065. /**
  40066. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40067. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40068. */
  40069. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40070. /**
  40071. * Gets the name of the behavior.
  40072. */
  40073. readonly name: string;
  40074. private _zoomStopsAnimation;
  40075. private _idleRotationSpeed;
  40076. private _idleRotationWaitTime;
  40077. private _idleRotationSpinupTime;
  40078. /**
  40079. * Sets the flag that indicates if user zooming should stop animation.
  40080. */
  40081. /**
  40082. * Gets the flag that indicates if user zooming should stop animation.
  40083. */
  40084. zoomStopsAnimation: boolean;
  40085. /**
  40086. * Sets the default speed at which the camera rotates around the model.
  40087. */
  40088. /**
  40089. * Gets the default speed at which the camera rotates around the model.
  40090. */
  40091. idleRotationSpeed: number;
  40092. /**
  40093. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40094. */
  40095. /**
  40096. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40097. */
  40098. idleRotationWaitTime: number;
  40099. /**
  40100. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40101. */
  40102. /**
  40103. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40104. */
  40105. idleRotationSpinupTime: number;
  40106. /**
  40107. * Gets a value indicating if the camera is currently rotating because of this behavior
  40108. */
  40109. readonly rotationInProgress: boolean;
  40110. private _onPrePointerObservableObserver;
  40111. private _onAfterCheckInputsObserver;
  40112. private _attachedCamera;
  40113. private _isPointerDown;
  40114. private _lastFrameTime;
  40115. private _lastInteractionTime;
  40116. private _cameraRotationSpeed;
  40117. /**
  40118. * Initializes the behavior.
  40119. */
  40120. init(): void;
  40121. /**
  40122. * Attaches the behavior to its arc rotate camera.
  40123. * @param camera Defines the camera to attach the behavior to
  40124. */
  40125. attach(camera: ArcRotateCamera): void;
  40126. /**
  40127. * Detaches the behavior from its current arc rotate camera.
  40128. */
  40129. detach(): void;
  40130. /**
  40131. * Returns true if user is scrolling.
  40132. * @return true if user is scrolling.
  40133. */
  40134. private _userIsZooming;
  40135. private _lastFrameRadius;
  40136. private _shouldAnimationStopForInteraction;
  40137. /**
  40138. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40139. */
  40140. private _applyUserInteraction;
  40141. private _userIsMoving;
  40142. }
  40143. }
  40144. declare module BABYLON {
  40145. /**
  40146. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40147. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40148. */
  40149. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40150. /**
  40151. * Gets the name of the behavior.
  40152. */
  40153. readonly name: string;
  40154. /**
  40155. * The easing function used by animations
  40156. */
  40157. static EasingFunction: BackEase;
  40158. /**
  40159. * The easing mode used by animations
  40160. */
  40161. static EasingMode: number;
  40162. /**
  40163. * The duration of the animation, in milliseconds
  40164. */
  40165. transitionDuration: number;
  40166. /**
  40167. * Length of the distance animated by the transition when lower radius is reached
  40168. */
  40169. lowerRadiusTransitionRange: number;
  40170. /**
  40171. * Length of the distance animated by the transition when upper radius is reached
  40172. */
  40173. upperRadiusTransitionRange: number;
  40174. private _autoTransitionRange;
  40175. /**
  40176. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40177. */
  40178. /**
  40179. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40180. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40181. */
  40182. autoTransitionRange: boolean;
  40183. private _attachedCamera;
  40184. private _onAfterCheckInputsObserver;
  40185. private _onMeshTargetChangedObserver;
  40186. /**
  40187. * Initializes the behavior.
  40188. */
  40189. init(): void;
  40190. /**
  40191. * Attaches the behavior to its arc rotate camera.
  40192. * @param camera Defines the camera to attach the behavior to
  40193. */
  40194. attach(camera: ArcRotateCamera): void;
  40195. /**
  40196. * Detaches the behavior from its current arc rotate camera.
  40197. */
  40198. detach(): void;
  40199. private _radiusIsAnimating;
  40200. private _radiusBounceTransition;
  40201. private _animatables;
  40202. private _cachedWheelPrecision;
  40203. /**
  40204. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40205. * @param radiusLimit The limit to check against.
  40206. * @return Bool to indicate if at limit.
  40207. */
  40208. private _isRadiusAtLimit;
  40209. /**
  40210. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40211. * @param radiusDelta The delta by which to animate to. Can be negative.
  40212. */
  40213. private _applyBoundRadiusAnimation;
  40214. /**
  40215. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40216. */
  40217. protected _clearAnimationLocks(): void;
  40218. /**
  40219. * Stops and removes all animations that have been applied to the camera
  40220. */
  40221. stopAllAnimations(): void;
  40222. }
  40223. }
  40224. declare module BABYLON {
  40225. /**
  40226. * The framing behavior (BABYLON.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.
  40227. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40228. */
  40229. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40230. /**
  40231. * Gets the name of the behavior.
  40232. */
  40233. readonly name: string;
  40234. private _mode;
  40235. private _radiusScale;
  40236. private _positionScale;
  40237. private _defaultElevation;
  40238. private _elevationReturnTime;
  40239. private _elevationReturnWaitTime;
  40240. private _zoomStopsAnimation;
  40241. private _framingTime;
  40242. /**
  40243. * The easing function used by animations
  40244. */
  40245. static EasingFunction: ExponentialEase;
  40246. /**
  40247. * The easing mode used by animations
  40248. */
  40249. static EasingMode: number;
  40250. /**
  40251. * Sets the current mode used by the behavior
  40252. */
  40253. /**
  40254. * Gets current mode used by the behavior.
  40255. */
  40256. mode: number;
  40257. /**
  40258. * Sets the scale applied to the radius (1 by default)
  40259. */
  40260. /**
  40261. * Gets the scale applied to the radius
  40262. */
  40263. radiusScale: number;
  40264. /**
  40265. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40266. */
  40267. /**
  40268. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40269. */
  40270. positionScale: number;
  40271. /**
  40272. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40273. * behaviour is triggered, in radians.
  40274. */
  40275. /**
  40276. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40277. * behaviour is triggered, in radians.
  40278. */
  40279. defaultElevation: number;
  40280. /**
  40281. * Sets the time (in milliseconds) taken to return to the default beta position.
  40282. * Negative value indicates camera should not return to default.
  40283. */
  40284. /**
  40285. * Gets the time (in milliseconds) taken to return to the default beta position.
  40286. * Negative value indicates camera should not return to default.
  40287. */
  40288. elevationReturnTime: number;
  40289. /**
  40290. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40291. */
  40292. /**
  40293. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40294. */
  40295. elevationReturnWaitTime: number;
  40296. /**
  40297. * Sets the flag that indicates if user zooming should stop animation.
  40298. */
  40299. /**
  40300. * Gets the flag that indicates if user zooming should stop animation.
  40301. */
  40302. zoomStopsAnimation: boolean;
  40303. /**
  40304. * Sets the transition time when framing the mesh, in milliseconds
  40305. */
  40306. /**
  40307. * Gets the transition time when framing the mesh, in milliseconds
  40308. */
  40309. framingTime: number;
  40310. /**
  40311. * Define if the behavior should automatically change the configured
  40312. * camera limits and sensibilities.
  40313. */
  40314. autoCorrectCameraLimitsAndSensibility: boolean;
  40315. private _onPrePointerObservableObserver;
  40316. private _onAfterCheckInputsObserver;
  40317. private _onMeshTargetChangedObserver;
  40318. private _attachedCamera;
  40319. private _isPointerDown;
  40320. private _lastInteractionTime;
  40321. /**
  40322. * Initializes the behavior.
  40323. */
  40324. init(): void;
  40325. /**
  40326. * Attaches the behavior to its arc rotate camera.
  40327. * @param camera Defines the camera to attach the behavior to
  40328. */
  40329. attach(camera: ArcRotateCamera): void;
  40330. /**
  40331. * Detaches the behavior from its current arc rotate camera.
  40332. */
  40333. detach(): void;
  40334. private _animatables;
  40335. private _betaIsAnimating;
  40336. private _betaTransition;
  40337. private _radiusTransition;
  40338. private _vectorTransition;
  40339. /**
  40340. * Targets the given mesh and updates zoom level accordingly.
  40341. * @param mesh The mesh to target.
  40342. * @param radius Optional. If a cached radius position already exists, overrides default.
  40343. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40344. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40345. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40346. */
  40347. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40348. /**
  40349. * Targets the given mesh with its children and updates zoom level accordingly.
  40350. * @param mesh The mesh to target.
  40351. * @param radius Optional. If a cached radius position already exists, overrides default.
  40352. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40353. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40354. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40355. */
  40356. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40357. /**
  40358. * Targets the given meshes with their children and updates zoom level accordingly.
  40359. * @param meshes The mesh to target.
  40360. * @param radius Optional. If a cached radius position already exists, overrides default.
  40361. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40362. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40363. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40364. */
  40365. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40366. /**
  40367. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40368. * @param minimumWorld Determines the smaller position of the bounding box extend
  40369. * @param maximumWorld Determines the bigger position of the bounding box extend
  40370. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40371. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40372. */
  40373. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40374. /**
  40375. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40376. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40377. * frustum width.
  40378. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40379. * to fully enclose the mesh in the viewing frustum.
  40380. */
  40381. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40382. /**
  40383. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40384. * is automatically returned to its default position (expected to be above ground plane).
  40385. */
  40386. private _maintainCameraAboveGround;
  40387. /**
  40388. * Returns the frustum slope based on the canvas ratio and camera FOV
  40389. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40390. */
  40391. private _getFrustumSlope;
  40392. /**
  40393. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40394. */
  40395. private _clearAnimationLocks;
  40396. /**
  40397. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40398. */
  40399. private _applyUserInteraction;
  40400. /**
  40401. * Stops and removes all animations that have been applied to the camera
  40402. */
  40403. stopAllAnimations(): void;
  40404. /**
  40405. * Gets a value indicating if the user is moving the camera
  40406. */
  40407. readonly isUserIsMoving: boolean;
  40408. /**
  40409. * The camera can move all the way towards the mesh.
  40410. */
  40411. static IgnoreBoundsSizeMode: number;
  40412. /**
  40413. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40414. */
  40415. static FitFrustumSidesMode: number;
  40416. }
  40417. }
  40418. declare module BABYLON {
  40419. /**
  40420. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40421. */
  40422. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  40423. private ui;
  40424. /**
  40425. * The name of the behavior
  40426. */
  40427. name: string;
  40428. /**
  40429. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40430. */
  40431. distanceAwayFromFace: number;
  40432. /**
  40433. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40434. */
  40435. distanceAwayFromBottomOfFace: number;
  40436. private _faceVectors;
  40437. private _target;
  40438. private _scene;
  40439. private _onRenderObserver;
  40440. private _tmpMatrix;
  40441. private _tmpVector;
  40442. /**
  40443. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40444. * @param ui The transform node that should be attched to the mesh
  40445. */
  40446. constructor(ui: BABYLON.TransformNode);
  40447. /**
  40448. * Initializes the behavior
  40449. */
  40450. init(): void;
  40451. private _closestFace;
  40452. private _zeroVector;
  40453. private _lookAtTmpMatrix;
  40454. private _lookAtToRef;
  40455. /**
  40456. * Attaches the AttachToBoxBehavior to the passed in mesh
  40457. * @param target The mesh that the specified node will be attached to
  40458. */
  40459. attach(target: BABYLON.Mesh): void;
  40460. /**
  40461. * Detaches the behavior from the mesh
  40462. */
  40463. detach(): void;
  40464. }
  40465. }
  40466. declare module BABYLON {
  40467. /**
  40468. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40469. */
  40470. class FadeInOutBehavior implements Behavior<Mesh> {
  40471. /**
  40472. * Time in milliseconds to delay before fading in (Default: 0)
  40473. */
  40474. delay: number;
  40475. /**
  40476. * Time in milliseconds for the mesh to fade in (Default: 300)
  40477. */
  40478. fadeInTime: number;
  40479. private _millisecondsPerFrame;
  40480. private _hovered;
  40481. private _hoverValue;
  40482. private _ownerNode;
  40483. /**
  40484. * Instatiates the FadeInOutBehavior
  40485. */
  40486. constructor();
  40487. /**
  40488. * The name of the behavior
  40489. */
  40490. readonly name: string;
  40491. /**
  40492. * Initializes the behavior
  40493. */
  40494. init(): void;
  40495. /**
  40496. * Attaches the fade behavior on the passed in mesh
  40497. * @param ownerNode The mesh that will be faded in/out once attached
  40498. */
  40499. attach(ownerNode: Mesh): void;
  40500. /**
  40501. * Detaches the behavior from the mesh
  40502. */
  40503. detach(): void;
  40504. /**
  40505. * Triggers the mesh to begin fading in or out
  40506. * @param value if the object should fade in or out (true to fade in)
  40507. */
  40508. fadeIn(value: boolean): void;
  40509. private _update;
  40510. private _setAllVisibility;
  40511. }
  40512. }
  40513. declare module BABYLON {
  40514. /**
  40515. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40516. */
  40517. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40518. private _dragBehaviorA;
  40519. private _dragBehaviorB;
  40520. private _startDistance;
  40521. private _initialScale;
  40522. private _targetScale;
  40523. private _ownerNode;
  40524. private _sceneRenderObserver;
  40525. /**
  40526. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40527. */
  40528. constructor();
  40529. /**
  40530. * The name of the behavior
  40531. */
  40532. readonly name: string;
  40533. /**
  40534. * Initializes the behavior
  40535. */
  40536. init(): void;
  40537. private _getCurrentDistance;
  40538. /**
  40539. * Attaches the scale behavior the passed in mesh
  40540. * @param ownerNode The mesh that will be scaled around once attached
  40541. */
  40542. attach(ownerNode: Mesh): void;
  40543. /**
  40544. * Detaches the behavior from the mesh
  40545. */
  40546. detach(): void;
  40547. }
  40548. }
  40549. declare module BABYLON {
  40550. /**
  40551. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40552. */
  40553. class PointerDragBehavior implements Behavior<Mesh> {
  40554. private static _AnyMouseID;
  40555. private _attachedNode;
  40556. private _dragPlane;
  40557. private _scene;
  40558. private _pointerObserver;
  40559. private _beforeRenderObserver;
  40560. private static _planeScene;
  40561. /**
  40562. * 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)
  40563. */
  40564. maxDragAngle: number;
  40565. /**
  40566. * @hidden
  40567. */
  40568. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40569. /**
  40570. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40571. */
  40572. currentDraggingPointerID: number;
  40573. /**
  40574. * The last position where the pointer hit the drag plane in world space
  40575. */
  40576. lastDragPosition: Vector3;
  40577. /**
  40578. * If the behavior is currently in a dragging state
  40579. */
  40580. dragging: boolean;
  40581. /**
  40582. * 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)
  40583. */
  40584. dragDeltaRatio: number;
  40585. /**
  40586. * If the drag plane orientation should be updated during the dragging (Default: true)
  40587. */
  40588. updateDragPlane: boolean;
  40589. private _debugMode;
  40590. private _moving;
  40591. /**
  40592. * Fires each time the attached mesh is dragged with the pointer
  40593. * * delta between last drag position and current drag position in world space
  40594. * * dragDistance along the drag axis
  40595. * * dragPlaneNormal normal of the current drag plane used during the drag
  40596. * * dragPlanePoint in world space where the drag intersects the drag plane
  40597. */
  40598. onDragObservable: Observable<{
  40599. delta: Vector3;
  40600. dragPlanePoint: Vector3;
  40601. dragPlaneNormal: Vector3;
  40602. dragDistance: number;
  40603. pointerId: number;
  40604. }>;
  40605. /**
  40606. * Fires each time a drag begins (eg. mouse down on mesh)
  40607. */
  40608. onDragStartObservable: Observable<{
  40609. dragPlanePoint: Vector3;
  40610. pointerId: number;
  40611. }>;
  40612. /**
  40613. * Fires each time a drag ends (eg. mouse release after drag)
  40614. */
  40615. onDragEndObservable: Observable<{
  40616. dragPlanePoint: Vector3;
  40617. pointerId: number;
  40618. }>;
  40619. /**
  40620. * If the attached mesh should be moved when dragged
  40621. */
  40622. moveAttached: boolean;
  40623. /**
  40624. * If the drag behavior will react to drag events (Default: true)
  40625. */
  40626. enabled: boolean;
  40627. /**
  40628. * If camera controls should be detached during the drag
  40629. */
  40630. detachCameraControls: boolean;
  40631. /**
  40632. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40633. */
  40634. useObjectOrienationForDragging: boolean;
  40635. private _options;
  40636. /**
  40637. * Creates a pointer drag behavior that can be attached to a mesh
  40638. * @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)
  40639. */
  40640. constructor(options?: {
  40641. dragAxis?: Vector3;
  40642. dragPlaneNormal?: Vector3;
  40643. });
  40644. /**
  40645. * The name of the behavior
  40646. */
  40647. readonly name: string;
  40648. /**
  40649. * Initializes the behavior
  40650. */
  40651. init(): void;
  40652. private _tmpVector;
  40653. private _alternatePickedPoint;
  40654. private _worldDragAxis;
  40655. private _targetPosition;
  40656. private _attachedElement;
  40657. /**
  40658. * Attaches the drag behavior the passed in mesh
  40659. * @param ownerNode The mesh that will be dragged around once attached
  40660. */
  40661. attach(ownerNode: Mesh): void;
  40662. /**
  40663. * Force relase the drag action by code.
  40664. */
  40665. releaseDrag(): void;
  40666. private _startDragRay;
  40667. private _lastPointerRay;
  40668. /**
  40669. * Simulates the start of a pointer drag event on the behavior
  40670. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40671. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40672. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40673. */
  40674. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40675. private _startDrag;
  40676. private _dragDelta;
  40677. private _moveDrag;
  40678. private _pickWithRayOnDragPlane;
  40679. private _pointA;
  40680. private _pointB;
  40681. private _pointC;
  40682. private _lineA;
  40683. private _lineB;
  40684. private _localAxis;
  40685. private _lookAt;
  40686. private _updateDragPlanePosition;
  40687. /**
  40688. * Detaches the behavior from the mesh
  40689. */
  40690. detach(): void;
  40691. }
  40692. }
  40693. declare module BABYLON {
  40694. /**
  40695. * 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
  40696. */
  40697. class SixDofDragBehavior implements Behavior<Mesh> {
  40698. private static _virtualScene;
  40699. private _ownerNode;
  40700. private _sceneRenderObserver;
  40701. private _scene;
  40702. private _targetPosition;
  40703. private _virtualOriginMesh;
  40704. private _virtualDragMesh;
  40705. private _pointerObserver;
  40706. private _moving;
  40707. private _startingOrientation;
  40708. /**
  40709. * 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)
  40710. */
  40711. private zDragFactor;
  40712. /**
  40713. * If the behavior is currently in a dragging state
  40714. */
  40715. dragging: boolean;
  40716. /**
  40717. * 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)
  40718. */
  40719. dragDeltaRatio: number;
  40720. /**
  40721. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40722. */
  40723. currentDraggingPointerID: number;
  40724. /**
  40725. * If camera controls should be detached during the drag
  40726. */
  40727. detachCameraControls: boolean;
  40728. /**
  40729. * Fires each time a drag starts
  40730. */
  40731. onDragStartObservable: Observable<{}>;
  40732. /**
  40733. * Fires each time a drag ends (eg. mouse release after drag)
  40734. */
  40735. onDragEndObservable: Observable<{}>;
  40736. /**
  40737. * 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
  40738. */
  40739. constructor();
  40740. /**
  40741. * The name of the behavior
  40742. */
  40743. readonly name: string;
  40744. /**
  40745. * Initializes the behavior
  40746. */
  40747. init(): void;
  40748. /**
  40749. * Attaches the scale behavior the passed in mesh
  40750. * @param ownerNode The mesh that will be scaled around once attached
  40751. */
  40752. attach(ownerNode: Mesh): void;
  40753. /**
  40754. * Detaches the behavior from the mesh
  40755. */
  40756. detach(): void;
  40757. }
  40758. }
  40759. declare module BABYLON {
  40760. /**
  40761. * Contains an array of blocks representing the octree
  40762. */
  40763. interface IOctreeContainer<T> {
  40764. /**
  40765. * Blocks within the octree
  40766. */
  40767. blocks: Array<OctreeBlock<T>>;
  40768. }
  40769. /**
  40770. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40771. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40772. */
  40773. class Octree<T> {
  40774. /** 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.) */
  40775. maxDepth: number;
  40776. /**
  40777. * Blocks within the octree containing objects
  40778. */
  40779. blocks: Array<OctreeBlock<T>>;
  40780. /**
  40781. * Content stored in the octree
  40782. */
  40783. dynamicContent: T[];
  40784. private _maxBlockCapacity;
  40785. private _selectionContent;
  40786. private _creationFunc;
  40787. /**
  40788. * Creates a octree
  40789. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40790. * @param creationFunc function to be used to instatiate the octree
  40791. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40792. * @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.)
  40793. */
  40794. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40795. /** 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.) */
  40796. maxDepth?: number);
  40797. /**
  40798. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40799. * @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);
  40800. * @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);
  40801. * @param entries meshes to be added to the octree blocks
  40802. */
  40803. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40804. /**
  40805. * Adds a mesh to the octree
  40806. * @param entry Mesh to add to the octree
  40807. */
  40808. addMesh(entry: T): void;
  40809. /**
  40810. * Selects an array of meshes within the frustum
  40811. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40812. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40813. * @returns array of meshes within the frustum
  40814. */
  40815. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40816. /**
  40817. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40818. * @param sphereCenter defines the bounding sphere center
  40819. * @param sphereRadius defines the bounding sphere radius
  40820. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40821. * @returns an array of objects that intersect the sphere
  40822. */
  40823. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40824. /**
  40825. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40826. * @param ray defines the ray to test with
  40827. * @returns array of intersected objects
  40828. */
  40829. intersectsRay(ray: Ray): SmartArray<T>;
  40830. /**
  40831. * @hidden
  40832. */
  40833. 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;
  40834. /**
  40835. * Adds a mesh into the octree block if it intersects the block
  40836. */
  40837. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40838. /**
  40839. * Adds a submesh into the octree block if it intersects the block
  40840. */
  40841. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40842. }
  40843. }
  40844. declare module BABYLON {
  40845. /**
  40846. * Class used to store a cell in an octree
  40847. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40848. */
  40849. class OctreeBlock<T> {
  40850. /**
  40851. * Gets the content of the current block
  40852. */
  40853. entries: T[];
  40854. /**
  40855. * Gets the list of block children
  40856. */
  40857. blocks: Array<OctreeBlock<T>>;
  40858. private _depth;
  40859. private _maxDepth;
  40860. private _capacity;
  40861. private _minPoint;
  40862. private _maxPoint;
  40863. private _boundingVectors;
  40864. private _creationFunc;
  40865. /**
  40866. * Creates a new block
  40867. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40868. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40869. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40870. * @param depth defines the current depth of this block in the octree
  40871. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40872. * @param creationFunc defines a callback to call when an element is added to the block
  40873. */
  40874. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40875. /**
  40876. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40877. */
  40878. readonly capacity: number;
  40879. /**
  40880. * Gets the minimum vector (in world space) of the block's bounding box
  40881. */
  40882. readonly minPoint: Vector3;
  40883. /**
  40884. * Gets the maximum vector (in world space) of the block's bounding box
  40885. */
  40886. readonly maxPoint: Vector3;
  40887. /**
  40888. * Add a new element to this block
  40889. * @param entry defines the element to add
  40890. */
  40891. addEntry(entry: T): void;
  40892. /**
  40893. * Add an array of elements to this block
  40894. * @param entries defines the array of elements to add
  40895. */
  40896. addEntries(entries: T[]): void;
  40897. /**
  40898. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40899. * @param frustumPlanes defines the frustum planes to test
  40900. * @param selection defines the array to store current content if selection is positive
  40901. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40902. */
  40903. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40904. /**
  40905. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40906. * @param sphereCenter defines the bounding sphere center
  40907. * @param sphereRadius defines the bounding sphere radius
  40908. * @param selection defines the array to store current content if selection is positive
  40909. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40910. */
  40911. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40912. /**
  40913. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40914. * @param ray defines the ray to test with
  40915. * @param selection defines the array to store current content if selection is positive
  40916. */
  40917. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40918. /**
  40919. * Subdivide the content into child blocks (this block will then be empty)
  40920. */
  40921. createInnerBlocks(): void;
  40922. }
  40923. }
  40924. declare module BABYLON {
  40925. interface Scene {
  40926. /**
  40927. * @hidden
  40928. * Backing Filed
  40929. */
  40930. _selectionOctree: Octree<AbstractMesh>;
  40931. /**
  40932. * Gets the octree used to boost mesh selection (picking)
  40933. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40934. */
  40935. selectionOctree: Octree<AbstractMesh>;
  40936. /**
  40937. * Creates or updates the octree used to boost selection (picking)
  40938. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40939. * @param maxCapacity defines the maximum capacity per leaf
  40940. * @param maxDepth defines the maximum depth of the octree
  40941. * @returns an octree of AbstractMesh
  40942. */
  40943. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40944. }
  40945. interface AbstractMesh {
  40946. /**
  40947. * @hidden
  40948. * Backing Field
  40949. */
  40950. _submeshesOctree: Octree<SubMesh>;
  40951. /**
  40952. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40953. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40954. * @param maxCapacity defines the maximum size of each block (64 by default)
  40955. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40956. * @returns the new octree
  40957. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40958. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40959. */
  40960. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40961. }
  40962. /**
  40963. * Defines the octree scene component responsible to manage any octrees
  40964. * in a given scene.
  40965. */
  40966. class OctreeSceneComponent {
  40967. /**
  40968. * The component name helpfull to identify the component in the list of scene components.
  40969. */
  40970. readonly name: string;
  40971. /**
  40972. * The scene the component belongs to.
  40973. */
  40974. scene: Scene;
  40975. /**
  40976. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40977. */
  40978. readonly checksIsEnabled: boolean;
  40979. /**
  40980. * Creates a new instance of the component for the given scene
  40981. * @param scene Defines the scene to register the component in
  40982. */
  40983. constructor(scene: Scene);
  40984. /**
  40985. * Registers the component in a given scene
  40986. */
  40987. register(): void;
  40988. /**
  40989. * Return the list of active meshes
  40990. * @returns the list of active meshes
  40991. */
  40992. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40993. /**
  40994. * Return the list of active sub meshes
  40995. * @param mesh The mesh to get the candidates sub meshes from
  40996. * @returns the list of active sub meshes
  40997. */
  40998. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40999. private _tempRay;
  41000. /**
  41001. * Return the list of sub meshes intersecting with a given local ray
  41002. * @param mesh defines the mesh to find the submesh for
  41003. * @param localRay defines the ray in local space
  41004. * @returns the list of intersecting sub meshes
  41005. */
  41006. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41007. /**
  41008. * Return the list of sub meshes colliding with a collider
  41009. * @param mesh defines the mesh to find the submesh for
  41010. * @param collider defines the collider to evaluate the collision against
  41011. * @returns the list of colliding sub meshes
  41012. */
  41013. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41014. /**
  41015. * Rebuilds the elements related to this component in case of
  41016. * context lost for instance.
  41017. */
  41018. rebuild(): void;
  41019. /**
  41020. * Disposes the component and the associated ressources.
  41021. */
  41022. dispose(): void;
  41023. }
  41024. }
  41025. declare module BABYLON {
  41026. /**
  41027. * Manage the gamepad inputs to control an arc rotate camera.
  41028. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41029. */
  41030. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41031. /**
  41032. * Defines the camera the input is attached to.
  41033. */
  41034. camera: ArcRotateCamera;
  41035. /**
  41036. * Defines the gamepad the input is gathering event from.
  41037. */
  41038. gamepad: Nullable<Gamepad>;
  41039. /**
  41040. * Defines the gamepad rotation sensiblity.
  41041. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41042. */
  41043. gamepadRotationSensibility: number;
  41044. /**
  41045. * Defines the gamepad move sensiblity.
  41046. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41047. */
  41048. gamepadMoveSensibility: number;
  41049. private _onGamepadConnectedObserver;
  41050. private _onGamepadDisconnectedObserver;
  41051. /**
  41052. * Attach the input controls to a specific dom element to get the input from.
  41053. * @param element Defines the element the controls should be listened from
  41054. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41055. */
  41056. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41057. /**
  41058. * Detach the current controls from the specified dom element.
  41059. * @param element Defines the element to stop listening the inputs from
  41060. */
  41061. detachControl(element: Nullable<HTMLElement>): void;
  41062. /**
  41063. * Update the current camera state depending on the inputs that have been used this frame.
  41064. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41065. */
  41066. checkInputs(): void;
  41067. /**
  41068. * Gets the class name of the current intput.
  41069. * @returns the class name
  41070. */
  41071. getClassName(): string;
  41072. /**
  41073. * Get the friendly name associated with the input class.
  41074. * @returns the input friendly name
  41075. */
  41076. getSimpleName(): string;
  41077. }
  41078. }
  41079. declare module BABYLON {
  41080. /**
  41081. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41082. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41083. */
  41084. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41085. /**
  41086. * Defines the camera the input is attached to.
  41087. */
  41088. camera: ArcRotateCamera;
  41089. /**
  41090. * Defines the list of key codes associated with the up action (increase alpha)
  41091. */
  41092. keysUp: number[];
  41093. /**
  41094. * Defines the list of key codes associated with the down action (decrease alpha)
  41095. */
  41096. keysDown: number[];
  41097. /**
  41098. * Defines the list of key codes associated with the left action (increase beta)
  41099. */
  41100. keysLeft: number[];
  41101. /**
  41102. * Defines the list of key codes associated with the right action (decrease beta)
  41103. */
  41104. keysRight: number[];
  41105. /**
  41106. * Defines the list of key codes associated with the reset action.
  41107. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41108. */
  41109. keysReset: number[];
  41110. /**
  41111. * Defines the panning sensibility of the inputs.
  41112. * (How fast is the camera paning)
  41113. */
  41114. panningSensibility: number;
  41115. /**
  41116. * Defines the zooming sensibility of the inputs.
  41117. * (How fast is the camera zooming)
  41118. */
  41119. zoomingSensibility: number;
  41120. /**
  41121. * Defines wether maintaining the alt key down switch the movement mode from
  41122. * orientation to zoom.
  41123. */
  41124. useAltToZoom: boolean;
  41125. /**
  41126. * Rotation speed of the camera
  41127. */
  41128. angularSpeed: number;
  41129. private _keys;
  41130. private _ctrlPressed;
  41131. private _altPressed;
  41132. private _onCanvasBlurObserver;
  41133. private _onKeyboardObserver;
  41134. private _engine;
  41135. private _scene;
  41136. /**
  41137. * Attach the input controls to a specific dom element to get the input from.
  41138. * @param element Defines the element the controls should be listened from
  41139. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41140. */
  41141. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41142. /**
  41143. * Detach the current controls from the specified dom element.
  41144. * @param element Defines the element to stop listening the inputs from
  41145. */
  41146. detachControl(element: Nullable<HTMLElement>): void;
  41147. /**
  41148. * Update the current camera state depending on the inputs that have been used this frame.
  41149. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41150. */
  41151. checkInputs(): void;
  41152. /**
  41153. * Gets the class name of the current intput.
  41154. * @returns the class name
  41155. */
  41156. getClassName(): string;
  41157. /**
  41158. * Get the friendly name associated with the input class.
  41159. * @returns the input friendly name
  41160. */
  41161. getSimpleName(): string;
  41162. }
  41163. }
  41164. declare module BABYLON {
  41165. /**
  41166. * Manage the mouse wheel inputs to control an arc rotate camera.
  41167. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41168. */
  41169. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41170. /**
  41171. * Defines the camera the input is attached to.
  41172. */
  41173. camera: ArcRotateCamera;
  41174. /**
  41175. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41176. */
  41177. wheelPrecision: number;
  41178. /**
  41179. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41180. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41181. */
  41182. wheelDeltaPercentage: number;
  41183. private _wheel;
  41184. private _observer;
  41185. /**
  41186. * Attach the input controls to a specific dom element to get the input from.
  41187. * @param element Defines the element the controls should be listened from
  41188. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41189. */
  41190. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41191. /**
  41192. * Detach the current controls from the specified dom element.
  41193. * @param element Defines the element to stop listening the inputs from
  41194. */
  41195. detachControl(element: Nullable<HTMLElement>): void;
  41196. /**
  41197. * Gets the class name of the current intput.
  41198. * @returns the class name
  41199. */
  41200. getClassName(): string;
  41201. /**
  41202. * Get the friendly name associated with the input class.
  41203. * @returns the input friendly name
  41204. */
  41205. getSimpleName(): string;
  41206. }
  41207. }
  41208. declare module BABYLON {
  41209. /**
  41210. * Manage the pointers inputs to control an arc rotate camera.
  41211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41212. */
  41213. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  41214. /**
  41215. * Defines the camera the input is attached to.
  41216. */
  41217. camera: ArcRotateCamera;
  41218. /**
  41219. * Defines the buttons associated with the input to handle camera move.
  41220. */
  41221. buttons: number[];
  41222. /**
  41223. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41224. */
  41225. angularSensibilityX: number;
  41226. /**
  41227. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41228. */
  41229. angularSensibilityY: number;
  41230. /**
  41231. * Defines the pointer pinch precision or how fast is the camera zooming.
  41232. */
  41233. pinchPrecision: number;
  41234. /**
  41235. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  41236. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41237. */
  41238. pinchDeltaPercentage: number;
  41239. /**
  41240. * Defines the pointer panning sensibility or how fast is the camera moving.
  41241. */
  41242. panningSensibility: number;
  41243. /**
  41244. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41245. */
  41246. multiTouchPanning: boolean;
  41247. /**
  41248. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  41249. */
  41250. multiTouchPanAndZoom: boolean;
  41251. /**
  41252. * Revers pinch action direction.
  41253. */
  41254. pinchInwards: boolean;
  41255. private _isPanClick;
  41256. private _pointerInput;
  41257. private _observer;
  41258. private _onMouseMove;
  41259. private _onGestureStart;
  41260. private _onGesture;
  41261. private _MSGestureHandler;
  41262. private _onLostFocus;
  41263. private _onContextMenu;
  41264. /**
  41265. * Attach the input controls to a specific dom element to get the input from.
  41266. * @param element Defines the element the controls should be listened from
  41267. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41268. */
  41269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41270. /**
  41271. * Detach the current controls from the specified dom element.
  41272. * @param element Defines the element to stop listening the inputs from
  41273. */
  41274. detachControl(element: Nullable<HTMLElement>): void;
  41275. /**
  41276. * Gets the class name of the current intput.
  41277. * @returns the class name
  41278. */
  41279. getClassName(): string;
  41280. /**
  41281. * Get the friendly name associated with the input class.
  41282. * @returns the input friendly name
  41283. */
  41284. getSimpleName(): string;
  41285. }
  41286. }
  41287. declare module BABYLON {
  41288. /**
  41289. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41290. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41291. */
  41292. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41293. /**
  41294. * Defines the camera the input is attached to.
  41295. */
  41296. camera: ArcRotateCamera;
  41297. /**
  41298. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41299. */
  41300. alphaCorrection: number;
  41301. /**
  41302. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41303. */
  41304. gammaCorrection: number;
  41305. private _alpha;
  41306. private _gamma;
  41307. private _dirty;
  41308. private _deviceOrientationHandler;
  41309. /**
  41310. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41311. */
  41312. constructor();
  41313. /**
  41314. * Attach the input controls to a specific dom element to get the input from.
  41315. * @param element Defines the element the controls should be listened from
  41316. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41317. */
  41318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41319. /** @hidden */
  41320. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41321. /**
  41322. * Update the current camera state depending on the inputs that have been used this frame.
  41323. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41324. */
  41325. checkInputs(): void;
  41326. /**
  41327. * Detach the current controls from the specified dom element.
  41328. * @param element Defines the element to stop listening the inputs from
  41329. */
  41330. detachControl(element: Nullable<HTMLElement>): void;
  41331. /**
  41332. * Gets the class name of the current intput.
  41333. * @returns the class name
  41334. */
  41335. getClassName(): string;
  41336. /**
  41337. * Get the friendly name associated with the input class.
  41338. * @returns the input friendly name
  41339. */
  41340. getSimpleName(): string;
  41341. }
  41342. }
  41343. declare module BABYLON {
  41344. /**
  41345. * Listen to keyboard events to control the camera.
  41346. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41347. */
  41348. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41349. /**
  41350. * Defines the camera the input is attached to.
  41351. */
  41352. camera: FlyCamera;
  41353. /**
  41354. * The list of keyboard keys used to control the forward move of the camera.
  41355. */
  41356. keysForward: number[];
  41357. /**
  41358. * The list of keyboard keys used to control the backward move of the camera.
  41359. */
  41360. keysBackward: number[];
  41361. /**
  41362. * The list of keyboard keys used to control the forward move of the camera.
  41363. */
  41364. keysUp: number[];
  41365. /**
  41366. * The list of keyboard keys used to control the backward move of the camera.
  41367. */
  41368. keysDown: number[];
  41369. /**
  41370. * The list of keyboard keys used to control the right strafe move of the camera.
  41371. */
  41372. keysRight: number[];
  41373. /**
  41374. * The list of keyboard keys used to control the left strafe move of the camera.
  41375. */
  41376. keysLeft: number[];
  41377. private _keys;
  41378. private _onCanvasBlurObserver;
  41379. private _onKeyboardObserver;
  41380. private _engine;
  41381. private _scene;
  41382. /**
  41383. * Attach the input controls to a specific dom element to get the input from.
  41384. * @param element Defines the element the controls should be listened from
  41385. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41386. */
  41387. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41388. /**
  41389. * Detach the current controls from the specified dom element.
  41390. * @param element Defines the element to stop listening the inputs from
  41391. */
  41392. detachControl(element: Nullable<HTMLElement>): void;
  41393. /**
  41394. * Gets the class name of the current intput.
  41395. * @returns the class name
  41396. */
  41397. getClassName(): string;
  41398. /** @hidden */
  41399. _onLostFocus(e: FocusEvent): void;
  41400. /**
  41401. * Get the friendly name associated with the input class.
  41402. * @returns the input friendly name
  41403. */
  41404. getSimpleName(): string;
  41405. /**
  41406. * Update the current camera state depending on the inputs that have been used this frame.
  41407. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41408. */
  41409. checkInputs(): void;
  41410. }
  41411. }
  41412. declare module BABYLON {
  41413. /**
  41414. * Listen to mouse events to control the camera.
  41415. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41416. */
  41417. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41418. /**
  41419. * Defines the camera the input is attached to.
  41420. */
  41421. camera: FlyCamera;
  41422. /**
  41423. * Defines if touch is enabled. (Default is true.)
  41424. */
  41425. touchEnabled: boolean;
  41426. /**
  41427. * Defines the buttons associated with the input to handle camera rotation.
  41428. */
  41429. buttons: number[];
  41430. /**
  41431. * Assign buttons for Yaw control.
  41432. */
  41433. buttonsYaw: number[];
  41434. /**
  41435. * Assign buttons for Pitch control.
  41436. */
  41437. buttonsPitch: number[];
  41438. /**
  41439. * Assign buttons for Roll control.
  41440. */
  41441. buttonsRoll: number[];
  41442. /**
  41443. * Detect if any button is being pressed while mouse is moved.
  41444. * -1 = Mouse locked.
  41445. * 0 = Left button.
  41446. * 1 = Middle Button.
  41447. * 2 = Right Button.
  41448. */
  41449. activeButton: number;
  41450. /**
  41451. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41452. * Higher values reduce its sensitivity.
  41453. */
  41454. angularSensibility: number;
  41455. private _mousemoveCallback;
  41456. private _observer;
  41457. private _rollObserver;
  41458. private previousPosition;
  41459. private noPreventDefault;
  41460. private element;
  41461. /**
  41462. * Listen to mouse events to control the camera.
  41463. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41464. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41465. */
  41466. constructor(touchEnabled?: boolean);
  41467. /**
  41468. * Attach the mouse control to the HTML DOM element.
  41469. * @param element Defines the element that listens to the input events.
  41470. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41471. */
  41472. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41473. /**
  41474. * Detach the current controls from the specified dom element.
  41475. * @param element Defines the element to stop listening the inputs from
  41476. */
  41477. detachControl(element: Nullable<HTMLElement>): void;
  41478. /**
  41479. * Gets the class name of the current input.
  41480. * @returns the class name.
  41481. */
  41482. getClassName(): string;
  41483. /**
  41484. * Get the friendly name associated with the input class.
  41485. * @returns the input's friendly name.
  41486. */
  41487. getSimpleName(): string;
  41488. private _pointerInput;
  41489. private _onMouseMove;
  41490. /**
  41491. * Rotate camera by mouse offset.
  41492. */
  41493. private rotateCamera;
  41494. }
  41495. }
  41496. declare module BABYLON {
  41497. /**
  41498. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41499. * Screen rotation is taken into account.
  41500. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41501. */
  41502. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41503. private _camera;
  41504. private _screenOrientationAngle;
  41505. private _constantTranform;
  41506. private _screenQuaternion;
  41507. private _alpha;
  41508. private _beta;
  41509. private _gamma;
  41510. /**
  41511. * Instantiates a new input
  41512. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41513. */
  41514. constructor();
  41515. /**
  41516. * Define the camera controlled by the input.
  41517. */
  41518. camera: FreeCamera;
  41519. /**
  41520. * Attach the input controls to a specific dom element to get the input from.
  41521. * @param element Defines the element the controls should be listened from
  41522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41523. */
  41524. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41525. private _orientationChanged;
  41526. private _deviceOrientation;
  41527. /**
  41528. * Detach the current controls from the specified dom element.
  41529. * @param element Defines the element to stop listening the inputs from
  41530. */
  41531. detachControl(element: Nullable<HTMLElement>): void;
  41532. /**
  41533. * Update the current camera state depending on the inputs that have been used this frame.
  41534. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41535. */
  41536. checkInputs(): void;
  41537. /**
  41538. * Gets the class name of the current intput.
  41539. * @returns the class name
  41540. */
  41541. getClassName(): string;
  41542. /**
  41543. * Get the friendly name associated with the input class.
  41544. * @returns the input friendly name
  41545. */
  41546. getSimpleName(): string;
  41547. }
  41548. }
  41549. declare module BABYLON {
  41550. /**
  41551. * Manage the gamepad inputs to control a free camera.
  41552. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41553. */
  41554. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41555. /**
  41556. * Define the camera the input is attached to.
  41557. */
  41558. camera: FreeCamera;
  41559. /**
  41560. * Define the Gamepad controlling the input
  41561. */
  41562. gamepad: Nullable<Gamepad>;
  41563. /**
  41564. * Defines the gamepad rotation sensiblity.
  41565. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41566. */
  41567. gamepadAngularSensibility: number;
  41568. /**
  41569. * Defines the gamepad move sensiblity.
  41570. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41571. */
  41572. gamepadMoveSensibility: number;
  41573. private _onGamepadConnectedObserver;
  41574. private _onGamepadDisconnectedObserver;
  41575. private _cameraTransform;
  41576. private _deltaTransform;
  41577. private _vector3;
  41578. private _vector2;
  41579. /**
  41580. * Attach the input controls to a specific dom element to get the input from.
  41581. * @param element Defines the element the controls should be listened from
  41582. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41583. */
  41584. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41585. /**
  41586. * Detach the current controls from the specified dom element.
  41587. * @param element Defines the element to stop listening the inputs from
  41588. */
  41589. detachControl(element: Nullable<HTMLElement>): void;
  41590. /**
  41591. * Update the current camera state depending on the inputs that have been used this frame.
  41592. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41593. */
  41594. checkInputs(): void;
  41595. /**
  41596. * Gets the class name of the current intput.
  41597. * @returns the class name
  41598. */
  41599. getClassName(): string;
  41600. /**
  41601. * Get the friendly name associated with the input class.
  41602. * @returns the input friendly name
  41603. */
  41604. getSimpleName(): string;
  41605. }
  41606. }
  41607. declare module BABYLON {
  41608. /**
  41609. * Manage the keyboard inputs to control the movement of a free camera.
  41610. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41611. */
  41612. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  41613. /**
  41614. * Defines the camera the input is attached to.
  41615. */
  41616. camera: FreeCamera;
  41617. /**
  41618. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  41619. */
  41620. keysUp: number[];
  41621. /**
  41622. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  41623. */
  41624. keysDown: number[];
  41625. /**
  41626. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  41627. */
  41628. keysLeft: number[];
  41629. /**
  41630. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  41631. */
  41632. keysRight: number[];
  41633. private _keys;
  41634. private _onCanvasBlurObserver;
  41635. private _onKeyboardObserver;
  41636. private _engine;
  41637. private _scene;
  41638. /**
  41639. * Attach the input controls to a specific dom element to get the input from.
  41640. * @param element Defines the element the controls should be listened from
  41641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41642. */
  41643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41644. /**
  41645. * Detach the current controls from the specified dom element.
  41646. * @param element Defines the element to stop listening the inputs from
  41647. */
  41648. detachControl(element: Nullable<HTMLElement>): void;
  41649. /**
  41650. * Update the current camera state depending on the inputs that have been used this frame.
  41651. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41652. */
  41653. checkInputs(): void;
  41654. /**
  41655. * Gets the class name of the current intput.
  41656. * @returns the class name
  41657. */
  41658. getClassName(): string;
  41659. /** @hidden */
  41660. _onLostFocus(e: FocusEvent): void;
  41661. /**
  41662. * Get the friendly name associated with the input class.
  41663. * @returns the input friendly name
  41664. */
  41665. getSimpleName(): string;
  41666. }
  41667. }
  41668. declare module BABYLON {
  41669. /**
  41670. * Manage the mouse inputs to control the movement of a free camera.
  41671. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41672. */
  41673. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  41674. /**
  41675. * Define if touch is enabled in the mouse input
  41676. */
  41677. touchEnabled: boolean;
  41678. /**
  41679. * Defines the camera the input is attached to.
  41680. */
  41681. camera: FreeCamera;
  41682. /**
  41683. * Defines the buttons associated with the input to handle camera move.
  41684. */
  41685. buttons: number[];
  41686. /**
  41687. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  41688. */
  41689. angularSensibility: number;
  41690. private _pointerInput;
  41691. private _onMouseMove;
  41692. private _observer;
  41693. private previousPosition;
  41694. /**
  41695. * Manage the mouse inputs to control the movement of a free camera.
  41696. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41697. * @param touchEnabled Defines if touch is enabled or not
  41698. */
  41699. constructor(
  41700. /**
  41701. * Define if touch is enabled in the mouse input
  41702. */
  41703. touchEnabled?: boolean);
  41704. /**
  41705. * Attach the input controls to a specific dom element to get the input from.
  41706. * @param element Defines the element the controls should be listened from
  41707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41708. */
  41709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41710. /**
  41711. * Detach the current controls from the specified dom element.
  41712. * @param element Defines the element to stop listening the inputs from
  41713. */
  41714. detachControl(element: Nullable<HTMLElement>): void;
  41715. /**
  41716. * Gets the class name of the current intput.
  41717. * @returns the class name
  41718. */
  41719. getClassName(): string;
  41720. /**
  41721. * Get the friendly name associated with the input class.
  41722. * @returns the input friendly name
  41723. */
  41724. getSimpleName(): string;
  41725. }
  41726. }
  41727. declare module BABYLON {
  41728. /**
  41729. * Manage the touch inputs to control the movement of a free camera.
  41730. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41731. */
  41732. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  41733. /**
  41734. * Defines the camera the input is attached to.
  41735. */
  41736. camera: FreeCamera;
  41737. /**
  41738. * Defines the touch sensibility for rotation.
  41739. * The higher the faster.
  41740. */
  41741. touchAngularSensibility: number;
  41742. /**
  41743. * Defines the touch sensibility for move.
  41744. * The higher the faster.
  41745. */
  41746. touchMoveSensibility: number;
  41747. private _offsetX;
  41748. private _offsetY;
  41749. private _pointerPressed;
  41750. private _pointerInput;
  41751. private _observer;
  41752. private _onLostFocus;
  41753. /**
  41754. * Attach the input controls to a specific dom element to get the input from.
  41755. * @param element Defines the element the controls should be listened from
  41756. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41757. */
  41758. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41759. /**
  41760. * Detach the current controls from the specified dom element.
  41761. * @param element Defines the element to stop listening the inputs from
  41762. */
  41763. detachControl(element: Nullable<HTMLElement>): void;
  41764. /**
  41765. * Update the current camera state depending on the inputs that have been used this frame.
  41766. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41767. */
  41768. checkInputs(): void;
  41769. /**
  41770. * Gets the class name of the current intput.
  41771. * @returns the class name
  41772. */
  41773. getClassName(): string;
  41774. /**
  41775. * Get the friendly name associated with the input class.
  41776. * @returns the input friendly name
  41777. */
  41778. getSimpleName(): string;
  41779. }
  41780. }
  41781. declare module BABYLON {
  41782. /**
  41783. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41784. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41785. */
  41786. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41787. /**
  41788. * Defines the camera the input is attached to.
  41789. */
  41790. camera: FreeCamera;
  41791. private _leftjoystick;
  41792. private _rightjoystick;
  41793. /**
  41794. * Gets the left stick of the virtual joystick.
  41795. * @returns The virtual Joystick
  41796. */
  41797. getLeftJoystick(): VirtualJoystick;
  41798. /**
  41799. * Gets the right stick of the virtual joystick.
  41800. * @returns The virtual Joystick
  41801. */
  41802. getRightJoystick(): VirtualJoystick;
  41803. /**
  41804. * Update the current camera state depending on the inputs that have been used this frame.
  41805. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41806. */
  41807. checkInputs(): void;
  41808. /**
  41809. * Attach the input controls to a specific dom element to get the input from.
  41810. * @param element Defines the element the controls should be listened from
  41811. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41812. */
  41813. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41814. /**
  41815. * Detach the current controls from the specified dom element.
  41816. * @param element Defines the element to stop listening the inputs from
  41817. */
  41818. detachControl(element: Nullable<HTMLElement>): void;
  41819. /**
  41820. * Gets the class name of the current intput.
  41821. * @returns the class name
  41822. */
  41823. getClassName(): string;
  41824. /**
  41825. * Get the friendly name associated with the input class.
  41826. * @returns the input friendly name
  41827. */
  41828. getSimpleName(): string;
  41829. }
  41830. }
  41831. declare module BABYLON {
  41832. /**
  41833. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41834. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41835. */
  41836. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41837. /**
  41838. * Creates a new AnaglyphArcRotateCamera
  41839. * @param name defines camera name
  41840. * @param alpha defines alpha angle (in radians)
  41841. * @param beta defines beta angle (in radians)
  41842. * @param radius defines radius
  41843. * @param target defines camera target
  41844. * @param interaxialDistance defines distance between each color axis
  41845. * @param scene defines the hosting scene
  41846. */
  41847. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41848. /**
  41849. * Gets camera class name
  41850. * @returns AnaglyphArcRotateCamera
  41851. */
  41852. getClassName(): string;
  41853. }
  41854. }
  41855. declare module BABYLON {
  41856. /**
  41857. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41858. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41859. */
  41860. class AnaglyphFreeCamera extends FreeCamera {
  41861. /**
  41862. * Creates a new AnaglyphFreeCamera
  41863. * @param name defines camera name
  41864. * @param position defines initial position
  41865. * @param interaxialDistance defines distance between each color axis
  41866. * @param scene defines the hosting scene
  41867. */
  41868. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41869. /**
  41870. * Gets camera class name
  41871. * @returns AnaglyphFreeCamera
  41872. */
  41873. getClassName(): string;
  41874. }
  41875. }
  41876. declare module BABYLON {
  41877. /**
  41878. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41879. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41880. */
  41881. class AnaglyphGamepadCamera extends GamepadCamera {
  41882. /**
  41883. * Creates a new AnaglyphGamepadCamera
  41884. * @param name defines camera name
  41885. * @param position defines initial position
  41886. * @param interaxialDistance defines distance between each color axis
  41887. * @param scene defines the hosting scene
  41888. */
  41889. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41890. /**
  41891. * Gets camera class name
  41892. * @returns AnaglyphGamepadCamera
  41893. */
  41894. getClassName(): string;
  41895. }
  41896. }
  41897. declare module BABYLON {
  41898. /**
  41899. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41900. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41901. */
  41902. class AnaglyphUniversalCamera extends UniversalCamera {
  41903. /**
  41904. * Creates a new AnaglyphUniversalCamera
  41905. * @param name defines camera name
  41906. * @param position defines initial position
  41907. * @param interaxialDistance defines distance between each color axis
  41908. * @param scene defines the hosting scene
  41909. */
  41910. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41911. /**
  41912. * Gets camera class name
  41913. * @returns AnaglyphUniversalCamera
  41914. */
  41915. getClassName(): string;
  41916. }
  41917. }
  41918. declare module BABYLON {
  41919. /**
  41920. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41921. * @see http://doc.babylonjs.com/features/cameras
  41922. */
  41923. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41924. /**
  41925. * Creates a new StereoscopicArcRotateCamera
  41926. * @param name defines camera name
  41927. * @param alpha defines alpha angle (in radians)
  41928. * @param beta defines beta angle (in radians)
  41929. * @param radius defines radius
  41930. * @param target defines camera target
  41931. * @param interaxialDistance defines distance between each color axis
  41932. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41933. * @param scene defines the hosting scene
  41934. */
  41935. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41936. /**
  41937. * Gets camera class name
  41938. * @returns StereoscopicArcRotateCamera
  41939. */
  41940. getClassName(): string;
  41941. }
  41942. }
  41943. declare module BABYLON {
  41944. /**
  41945. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41946. * @see http://doc.babylonjs.com/features/cameras
  41947. */
  41948. class StereoscopicFreeCamera extends FreeCamera {
  41949. /**
  41950. * Creates a new StereoscopicFreeCamera
  41951. * @param name defines camera name
  41952. * @param position defines initial position
  41953. * @param interaxialDistance defines distance between each color axis
  41954. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41955. * @param scene defines the hosting scene
  41956. */
  41957. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41958. /**
  41959. * Gets camera class name
  41960. * @returns StereoscopicFreeCamera
  41961. */
  41962. getClassName(): string;
  41963. }
  41964. }
  41965. declare module BABYLON {
  41966. /**
  41967. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41968. * @see http://doc.babylonjs.com/features/cameras
  41969. */
  41970. class StereoscopicGamepadCamera extends GamepadCamera {
  41971. /**
  41972. * Creates a new StereoscopicGamepadCamera
  41973. * @param name defines camera name
  41974. * @param position defines initial position
  41975. * @param interaxialDistance defines distance between each color axis
  41976. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41977. * @param scene defines the hosting scene
  41978. */
  41979. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41980. /**
  41981. * Gets camera class name
  41982. * @returns StereoscopicGamepadCamera
  41983. */
  41984. getClassName(): string;
  41985. }
  41986. }
  41987. declare module BABYLON {
  41988. /**
  41989. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41990. * @see http://doc.babylonjs.com/features/cameras
  41991. */
  41992. class StereoscopicUniversalCamera extends UniversalCamera {
  41993. /**
  41994. * Creates a new StereoscopicUniversalCamera
  41995. * @param name defines camera name
  41996. * @param position defines initial position
  41997. * @param interaxialDistance defines distance between each color axis
  41998. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41999. * @param scene defines the hosting scene
  42000. */
  42001. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42002. /**
  42003. * Gets camera class name
  42004. * @returns StereoscopicUniversalCamera
  42005. */
  42006. getClassName(): string;
  42007. }
  42008. }
  42009. declare module BABYLON {
  42010. /**
  42011. * WebXR Camera which holds the views for the xrSession
  42012. * @see https://doc.babylonjs.com/how_to/webxr
  42013. */
  42014. class WebXRCamera extends FreeCamera {
  42015. private static _TmpMatrix;
  42016. /**
  42017. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42018. * @param name the name of the camera
  42019. * @param scene the scene to add the camera to
  42020. */
  42021. constructor(name: string, scene: BABYLON.Scene);
  42022. private _updateNumberOfRigCameras;
  42023. /** @hidden */
  42024. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42025. /**
  42026. * Updates the cameras position from the current pose information of the XR session
  42027. * @param xrSessionManager the session containing pose information
  42028. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42029. */
  42030. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42031. }
  42032. }
  42033. declare module BABYLON {
  42034. /**
  42035. * Options to create the webXR UI
  42036. */
  42037. class WebXREnterExitUIOptions {
  42038. /**
  42039. * Context to enter xr with
  42040. */
  42041. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  42042. /**
  42043. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42044. */
  42045. customButtons?: Array<{
  42046. element: HTMLElement;
  42047. initializationOptions: XRSessionCreationOptions;
  42048. }>;
  42049. }
  42050. /**
  42051. * UI to allow the user to enter/exit XR mode
  42052. */
  42053. class WebXREnterExitUI implements IDisposable {
  42054. private scene;
  42055. private _overlay;
  42056. private _buttons;
  42057. /**
  42058. * Creates UI to allow the user to enter/exit XR mode
  42059. * @param scene the scene to add the ui to
  42060. * @param helper the xr experience helper to enter/exit xr with
  42061. * @param options options to configure the UI
  42062. * @returns the created ui
  42063. */
  42064. static CreateAsync(scene: BABYLON.Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<void>;
  42065. private constructor();
  42066. /**
  42067. * Disposes of the object
  42068. */
  42069. dispose(): void;
  42070. }
  42071. }
  42072. declare module BABYLON {
  42073. /**
  42074. * States of the webXR experience
  42075. */
  42076. enum WebXRState {
  42077. /**
  42078. * Transitioning to being in XR mode
  42079. */
  42080. ENTERING_XR = 0,
  42081. /**
  42082. * Transitioning to non XR mode
  42083. */
  42084. EXITING_XR = 1,
  42085. /**
  42086. * In XR mode and presenting
  42087. */
  42088. IN_XR = 2,
  42089. /**
  42090. * Not entered XR mode
  42091. */
  42092. NOT_IN_XR = 3
  42093. }
  42094. /**
  42095. * Helper class used to enable XR
  42096. * @see https://doc.babylonjs.com/how_to/webxr
  42097. */
  42098. class WebXRExperienceHelper implements IDisposable {
  42099. private scene;
  42100. /**
  42101. * 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
  42102. */
  42103. container: AbstractMesh;
  42104. /**
  42105. * Camera used to render xr content
  42106. */
  42107. camera: WebXRCamera;
  42108. /**
  42109. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42110. */
  42111. state: WebXRState;
  42112. private _setState;
  42113. /**
  42114. * Fires when the state of the experience helper has changed
  42115. */
  42116. onStateChangedObservable: Observable<WebXRState>;
  42117. private _sessionManager;
  42118. private _nonVRCamera;
  42119. private _originalSceneAutoClear;
  42120. private _supported;
  42121. /**
  42122. * Creates the experience helper
  42123. * @param scene the scene to attach the experience helper to
  42124. * @returns a promise for the experience helper
  42125. */
  42126. static CreateAsync(scene: BABYLON.Scene): Promise<WebXRExperienceHelper>;
  42127. /**
  42128. * Creates a WebXRExperienceHelper
  42129. * @param scene The scene the helper should be created in
  42130. */
  42131. private constructor();
  42132. /**
  42133. * Exits XR mode and returns the scene to its original state
  42134. * @returns promise that resolves after xr mode has exited
  42135. */
  42136. exitXR(): Promise<void>;
  42137. /**
  42138. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42139. * @param sessionCreationOptions options for the XR session
  42140. * @param frameOfReference frame of reference of the XR session
  42141. * @returns promise that resolves after xr mode has entered
  42142. */
  42143. enterXR(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  42144. /**
  42145. * Checks if the creation options are supported by the xr session
  42146. * @param options creation options
  42147. * @returns true if supported
  42148. */
  42149. supportsSession(options: XRSessionCreationOptions): Promise<boolean>;
  42150. /**
  42151. * Disposes of the experience helper
  42152. */
  42153. dispose(): void;
  42154. }
  42155. }
  42156. declare module BABYLON {
  42157. /**
  42158. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42159. */
  42160. class WebXRManagedOutputCanvas implements IDisposable {
  42161. private _canvas;
  42162. /**
  42163. * xrpresent context of the canvas which can be used to display/mirror xr content
  42164. */
  42165. canvasContext: Nullable<WebGLRenderingContext>;
  42166. /**
  42167. * Initializes the canvas to be added/removed upon entering/exiting xr
  42168. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42169. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42170. */
  42171. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42172. /**
  42173. * Disposes of the object
  42174. */
  42175. dispose(): void;
  42176. private _setManagedOutputCanvas;
  42177. private _addCanvas;
  42178. private _removeCanvas;
  42179. }
  42180. }
  42181. declare module BABYLON {
  42182. /**
  42183. * Manages an XRSession
  42184. * @see https://doc.babylonjs.com/how_to/webxr
  42185. */
  42186. class WebXRSessionManager implements IDisposable {
  42187. private scene;
  42188. /**
  42189. * Fires every time a new xrFrame arrives which can be used to update the camera
  42190. */
  42191. onXRFrameObservable: Observable<any>;
  42192. /**
  42193. * Fires when the xr session is ended either by the device or manually done
  42194. */
  42195. onXRSessionEnded: Observable<any>;
  42196. /** @hidden */
  42197. _xrSession: XRSession;
  42198. /** @hidden */
  42199. _frameOfReference: XRFrameOfReference;
  42200. /** @hidden */
  42201. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42202. /** @hidden */
  42203. _currentXRFrame: Nullable<XRFrame>;
  42204. private _xrNavigator;
  42205. private _xrDevice;
  42206. private _tmpMatrix;
  42207. /**
  42208. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42209. * @param scene The scene which the session should be created for
  42210. */
  42211. constructor(scene: BABYLON.Scene);
  42212. /**
  42213. * Initializes the manager
  42214. * After initialization enterXR can be called to start an XR session
  42215. * @returns Promise which resolves after it is initialized
  42216. */
  42217. initialize(): Promise<void>;
  42218. /**
  42219. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  42220. * @param sessionCreationOptions xr options to create the session with
  42221. * @param frameOfReferenceType option to configure how the xr pose is expressed
  42222. * @returns Promise which resolves after it enters XR
  42223. */
  42224. enterXR(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  42225. /**
  42226. * Stops the xrSession and restores the renderloop
  42227. * @returns Promise which resolves after it exits XR
  42228. */
  42229. exitXR(): Promise<void>;
  42230. /**
  42231. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  42232. * @param ray ray to cast into the environment
  42233. * @returns Promise which resolves with a collision point in the environment if it exists
  42234. */
  42235. environmentPointHitTest(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  42236. /**
  42237. * Checks if a session would be supported for the creation options specified
  42238. * @param options creation options to check if they are supported
  42239. * @returns true if supported
  42240. */
  42241. supportsSession(options: XRSessionCreationOptions): Promise<boolean>;
  42242. /**
  42243. * @hidden
  42244. * Converts the render layer of xrSession to a render target
  42245. * @param session session to create render target for
  42246. * @param scene scene the new render target should be created for
  42247. */
  42248. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: BABYLON.Scene): RenderTargetTexture;
  42249. /**
  42250. * Disposes of the session manager
  42251. */
  42252. dispose(): void;
  42253. }
  42254. }
  42255. declare module BABYLON {
  42256. /**
  42257. * This represents all the required metrics to create a VR camera.
  42258. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42259. */
  42260. class VRCameraMetrics {
  42261. /**
  42262. * Define the horizontal resolution off the screen.
  42263. */
  42264. hResolution: number;
  42265. /**
  42266. * Define the vertical resolution off the screen.
  42267. */
  42268. vResolution: number;
  42269. /**
  42270. * Define the horizontal screen size.
  42271. */
  42272. hScreenSize: number;
  42273. /**
  42274. * Define the vertical screen size.
  42275. */
  42276. vScreenSize: number;
  42277. /**
  42278. * Define the vertical screen center position.
  42279. */
  42280. vScreenCenter: number;
  42281. /**
  42282. * Define the distance of the eyes to the screen.
  42283. */
  42284. eyeToScreenDistance: number;
  42285. /**
  42286. * Define the distance between both lenses
  42287. */
  42288. lensSeparationDistance: number;
  42289. /**
  42290. * Define the distance between both viewer's eyes.
  42291. */
  42292. interpupillaryDistance: number;
  42293. /**
  42294. * Define the distortion factor of the VR postprocess.
  42295. * Please, touch with care.
  42296. */
  42297. distortionK: number[];
  42298. /**
  42299. * Define the chromatic aberration correction factors for the VR post process.
  42300. */
  42301. chromaAbCorrection: number[];
  42302. /**
  42303. * Define the scale factor of the post process.
  42304. * The smaller the better but the slower.
  42305. */
  42306. postProcessScaleFactor: number;
  42307. /**
  42308. * Define an offset for the lens center.
  42309. */
  42310. lensCenterOffset: number;
  42311. /**
  42312. * Define if the current vr camera should compensate the distortion of the lense or not.
  42313. */
  42314. compensateDistortion: boolean;
  42315. /**
  42316. * Gets the rendering aspect ratio based on the provided resolutions.
  42317. */
  42318. readonly aspectRatio: number;
  42319. /**
  42320. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42321. */
  42322. readonly aspectRatioFov: number;
  42323. /**
  42324. * @hidden
  42325. */
  42326. readonly leftHMatrix: Matrix;
  42327. /**
  42328. * @hidden
  42329. */
  42330. readonly rightHMatrix: Matrix;
  42331. /**
  42332. * @hidden
  42333. */
  42334. readonly leftPreViewMatrix: Matrix;
  42335. /**
  42336. * @hidden
  42337. */
  42338. readonly rightPreViewMatrix: Matrix;
  42339. /**
  42340. * Get the default VRMetrics based on the most generic setup.
  42341. * @returns the default vr metrics
  42342. */
  42343. static GetDefault(): VRCameraMetrics;
  42344. }
  42345. }
  42346. declare module BABYLON {
  42347. /**
  42348. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42349. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42350. */
  42351. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42352. /**
  42353. * Creates a new VRDeviceOrientationArcRotateCamera
  42354. * @param name defines camera name
  42355. * @param alpha defines the camera rotation along the logitudinal axis
  42356. * @param beta defines the camera rotation along the latitudinal axis
  42357. * @param radius defines the camera distance from its target
  42358. * @param target defines the camera target
  42359. * @param scene defines the scene the camera belongs to
  42360. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42361. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42362. */
  42363. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42364. /**
  42365. * Gets camera class name
  42366. * @returns VRDeviceOrientationArcRotateCamera
  42367. */
  42368. getClassName(): string;
  42369. }
  42370. }
  42371. declare module BABYLON {
  42372. /**
  42373. * Camera used to simulate VR rendering (based on FreeCamera)
  42374. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42375. */
  42376. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42377. /**
  42378. * Creates a new VRDeviceOrientationFreeCamera
  42379. * @param name defines camera name
  42380. * @param position defines the start position of the camera
  42381. * @param scene defines the scene the camera belongs to
  42382. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42383. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42384. */
  42385. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42386. /**
  42387. * Gets camera class name
  42388. * @returns VRDeviceOrientationFreeCamera
  42389. */
  42390. getClassName(): string;
  42391. }
  42392. }
  42393. declare module BABYLON {
  42394. /**
  42395. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42396. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42397. */
  42398. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42399. /**
  42400. * Creates a new VRDeviceOrientationGamepadCamera
  42401. * @param name defines camera name
  42402. * @param position defines the start position of the camera
  42403. * @param scene defines the scene the camera belongs to
  42404. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42405. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42406. */
  42407. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42408. /**
  42409. * Gets camera class name
  42410. * @returns VRDeviceOrientationGamepadCamera
  42411. */
  42412. getClassName(): string;
  42413. }
  42414. }
  42415. declare module BABYLON {
  42416. /**
  42417. * Options to modify the vr teleportation behavior.
  42418. */
  42419. interface VRTeleportationOptions {
  42420. /**
  42421. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42422. */
  42423. floorMeshName?: string;
  42424. /**
  42425. * A list of meshes to be used as the teleportation floor. (default: empty)
  42426. */
  42427. floorMeshes?: Mesh[];
  42428. }
  42429. /**
  42430. * Options to modify the vr experience helper's behavior.
  42431. */
  42432. interface VRExperienceHelperOptions extends WebVROptions {
  42433. /**
  42434. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42435. */
  42436. createDeviceOrientationCamera?: boolean;
  42437. /**
  42438. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42439. */
  42440. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42441. /**
  42442. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42443. */
  42444. laserToggle?: boolean;
  42445. /**
  42446. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42447. */
  42448. floorMeshes?: Mesh[];
  42449. }
  42450. /**
  42451. * Helps to quickly add VR support to an existing scene.
  42452. * See http://doc.babylonjs.com/how_to/webvr_helper
  42453. */
  42454. class VRExperienceHelper {
  42455. /** Options to modify the vr experience helper's behavior. */
  42456. webVROptions: VRExperienceHelperOptions;
  42457. private _scene;
  42458. private _position;
  42459. private _btnVR;
  42460. private _btnVRDisplayed;
  42461. private _webVRsupported;
  42462. private _webVRready;
  42463. private _webVRrequesting;
  42464. private _webVRpresenting;
  42465. private _hasEnteredVR;
  42466. private _fullscreenVRpresenting;
  42467. private _canvas;
  42468. private _webVRCamera;
  42469. private _vrDeviceOrientationCamera;
  42470. private _deviceOrientationCamera;
  42471. private _existingCamera;
  42472. private _onKeyDown;
  42473. private _onVrDisplayPresentChange;
  42474. private _onVRDisplayChanged;
  42475. private _onVRRequestPresentStart;
  42476. private _onVRRequestPresentComplete;
  42477. /**
  42478. * Observable raised when entering VR.
  42479. */
  42480. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42481. /**
  42482. * Observable raised when exiting VR.
  42483. */
  42484. onExitingVRObservable: Observable<VRExperienceHelper>;
  42485. /**
  42486. * Observable raised when controller mesh is loaded.
  42487. */
  42488. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42489. /** Return this.onEnteringVRObservable
  42490. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42491. */
  42492. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42493. /** Return this.onExitingVRObservable
  42494. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42495. */
  42496. readonly onExitingVR: Observable<VRExperienceHelper>;
  42497. /** Return this.onControllerMeshLoadedObservable
  42498. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42499. */
  42500. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42501. private _rayLength;
  42502. private _useCustomVRButton;
  42503. private _teleportationRequested;
  42504. private _teleportActive;
  42505. private _floorMeshName;
  42506. private _floorMeshesCollection;
  42507. private _rotationAllowed;
  42508. private _teleportBackwardsVector;
  42509. private _teleportationTarget;
  42510. private _isDefaultTeleportationTarget;
  42511. private _postProcessMove;
  42512. private _teleportationFillColor;
  42513. private _teleportationBorderColor;
  42514. private _rotationAngle;
  42515. private _haloCenter;
  42516. private _cameraGazer;
  42517. private _padSensibilityUp;
  42518. private _padSensibilityDown;
  42519. private _leftController;
  42520. private _rightController;
  42521. /**
  42522. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42523. */
  42524. onNewMeshSelected: Observable<AbstractMesh>;
  42525. /**
  42526. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42527. */
  42528. onNewMeshPicked: Observable<PickingInfo>;
  42529. private _circleEase;
  42530. /**
  42531. * Observable raised before camera teleportation
  42532. */
  42533. onBeforeCameraTeleport: Observable<Vector3>;
  42534. /**
  42535. * Observable raised after camera teleportation
  42536. */
  42537. onAfterCameraTeleport: Observable<Vector3>;
  42538. /**
  42539. * Observable raised when current selected mesh gets unselected
  42540. */
  42541. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42542. private _raySelectionPredicate;
  42543. /**
  42544. * To be optionaly changed by user to define custom ray selection
  42545. */
  42546. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42547. /**
  42548. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42549. */
  42550. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42551. /**
  42552. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42553. */
  42554. teleportationEnabled: boolean;
  42555. private _defaultHeight;
  42556. private _teleportationInitialized;
  42557. private _interactionsEnabled;
  42558. private _interactionsRequested;
  42559. private _displayGaze;
  42560. private _displayLaserPointer;
  42561. /**
  42562. * The mesh used to display where the user is going to teleport.
  42563. */
  42564. /**
  42565. * Sets the mesh to be used to display where the user is going to teleport.
  42566. */
  42567. teleportationTarget: Mesh;
  42568. /**
  42569. * 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
  42570. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42571. * See http://doc.babylonjs.com/resources/baking_transformations
  42572. */
  42573. gazeTrackerMesh: Mesh;
  42574. /**
  42575. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42576. */
  42577. updateGazeTrackerScale: boolean;
  42578. /**
  42579. * The gaze tracking mesh corresponding to the left controller
  42580. */
  42581. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42582. /**
  42583. * The gaze tracking mesh corresponding to the right controller
  42584. */
  42585. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42586. /**
  42587. * If the ray of the gaze should be displayed.
  42588. */
  42589. /**
  42590. * Sets if the ray of the gaze should be displayed.
  42591. */
  42592. displayGaze: boolean;
  42593. /**
  42594. * If the ray of the LaserPointer should be displayed.
  42595. */
  42596. /**
  42597. * Sets if the ray of the LaserPointer should be displayed.
  42598. */
  42599. displayLaserPointer: boolean;
  42600. /**
  42601. * The deviceOrientationCamera used as the camera when not in VR.
  42602. */
  42603. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42604. /**
  42605. * Based on the current WebVR support, returns the current VR camera used.
  42606. */
  42607. readonly currentVRCamera: Nullable<Camera>;
  42608. /**
  42609. * The webVRCamera which is used when in VR.
  42610. */
  42611. readonly webVRCamera: WebVRFreeCamera;
  42612. /**
  42613. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42614. */
  42615. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42616. private readonly _teleportationRequestInitiated;
  42617. /**
  42618. * Instantiates a VRExperienceHelper.
  42619. * Helps to quickly add VR support to an existing scene.
  42620. * @param scene The scene the VRExperienceHelper belongs to.
  42621. * @param webVROptions Options to modify the vr experience helper's behavior.
  42622. */
  42623. constructor(scene: Scene,
  42624. /** Options to modify the vr experience helper's behavior. */
  42625. webVROptions?: VRExperienceHelperOptions);
  42626. private _onDefaultMeshLoaded;
  42627. private _onResize;
  42628. private _onFullscreenChange;
  42629. /**
  42630. * Gets a value indicating if we are currently in VR mode.
  42631. */
  42632. readonly isInVRMode: boolean;
  42633. private onVrDisplayPresentChange;
  42634. private onVRDisplayChanged;
  42635. private moveButtonToBottomRight;
  42636. private displayVRButton;
  42637. private updateButtonVisibility;
  42638. /**
  42639. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42640. * Otherwise, will use the fullscreen API.
  42641. */
  42642. enterVR(): void;
  42643. /**
  42644. * Attempt to exit VR, or fullscreen.
  42645. */
  42646. exitVR(): void;
  42647. /**
  42648. * The position of the vr experience helper.
  42649. */
  42650. /**
  42651. * Sets the position of the vr experience helper.
  42652. */
  42653. position: Vector3;
  42654. /**
  42655. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42656. */
  42657. enableInteractions(): void;
  42658. private readonly _noControllerIsActive;
  42659. private beforeRender;
  42660. private _isTeleportationFloor;
  42661. /**
  42662. * Adds a floor mesh to be used for teleportation.
  42663. * @param floorMesh the mesh to be used for teleportation.
  42664. */
  42665. addFloorMesh(floorMesh: Mesh): void;
  42666. /**
  42667. * Removes a floor mesh from being used for teleportation.
  42668. * @param floorMesh the mesh to be removed.
  42669. */
  42670. removeFloorMesh(floorMesh: Mesh): void;
  42671. /**
  42672. * Enables interactions and teleportation using the VR controllers and gaze.
  42673. * @param vrTeleportationOptions options to modify teleportation behavior.
  42674. */
  42675. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42676. private _onNewGamepadConnected;
  42677. private _tryEnableInteractionOnController;
  42678. private _onNewGamepadDisconnected;
  42679. private _enableInteractionOnController;
  42680. private _checkTeleportWithRay;
  42681. private _checkRotate;
  42682. private _checkTeleportBackwards;
  42683. private _enableTeleportationOnController;
  42684. private _createTeleportationCircles;
  42685. private _displayTeleportationTarget;
  42686. private _hideTeleportationTarget;
  42687. private _rotateCamera;
  42688. private _moveTeleportationSelectorTo;
  42689. private _workingVector;
  42690. private _workingQuaternion;
  42691. private _workingMatrix;
  42692. /**
  42693. * Teleports the users feet to the desired location
  42694. * @param location The location where the user's feet should be placed
  42695. */
  42696. teleportCamera(location: Vector3): void;
  42697. private _convertNormalToDirectionOfRay;
  42698. private _castRayAndSelectObject;
  42699. private _notifySelectedMeshUnselected;
  42700. /**
  42701. * Sets the color of the laser ray from the vr controllers.
  42702. * @param color new color for the ray.
  42703. */
  42704. changeLaserColor(color: Color3): void;
  42705. /**
  42706. * Sets the color of the ray from the vr headsets gaze.
  42707. * @param color new color for the ray.
  42708. */
  42709. changeGazeColor(color: Color3): void;
  42710. /**
  42711. * Exits VR and disposes of the vr experience helper
  42712. */
  42713. dispose(): void;
  42714. /**
  42715. * Gets the name of the VRExperienceHelper class
  42716. * @returns "VRExperienceHelper"
  42717. */
  42718. getClassName(): string;
  42719. }
  42720. }
  42721. declare module BABYLON {
  42722. /**
  42723. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  42724. * IMPORTANT!! The data is right-hand data.
  42725. * @export
  42726. * @interface DevicePose
  42727. */
  42728. interface DevicePose {
  42729. /**
  42730. * The position of the device, values in array are [x,y,z].
  42731. */
  42732. readonly position: Nullable<Float32Array>;
  42733. /**
  42734. * The linearVelocity of the device, values in array are [x,y,z].
  42735. */
  42736. readonly linearVelocity: Nullable<Float32Array>;
  42737. /**
  42738. * The linearAcceleration of the device, values in array are [x,y,z].
  42739. */
  42740. readonly linearAcceleration: Nullable<Float32Array>;
  42741. /**
  42742. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  42743. */
  42744. readonly orientation: Nullable<Float32Array>;
  42745. /**
  42746. * The angularVelocity of the device, values in array are [x,y,z].
  42747. */
  42748. readonly angularVelocity: Nullable<Float32Array>;
  42749. /**
  42750. * The angularAcceleration of the device, values in array are [x,y,z].
  42751. */
  42752. readonly angularAcceleration: Nullable<Float32Array>;
  42753. }
  42754. /**
  42755. * Interface representing a pose controlled object in Babylon.
  42756. * A pose controlled object has both regular pose values as well as pose values
  42757. * from an external device such as a VR head mounted display
  42758. */
  42759. interface PoseControlled {
  42760. /**
  42761. * The position of the object in babylon space.
  42762. */
  42763. position: Vector3;
  42764. /**
  42765. * The rotation quaternion of the object in babylon space.
  42766. */
  42767. rotationQuaternion: Quaternion;
  42768. /**
  42769. * The position of the device in babylon space.
  42770. */
  42771. devicePosition?: Vector3;
  42772. /**
  42773. * The rotation quaternion of the device in babylon space.
  42774. */
  42775. deviceRotationQuaternion: Quaternion;
  42776. /**
  42777. * The raw pose coming from the device.
  42778. */
  42779. rawPose: Nullable<DevicePose>;
  42780. /**
  42781. * The scale of the device to be used when translating from device space to babylon space.
  42782. */
  42783. deviceScaleFactor: number;
  42784. /**
  42785. * Updates the poseControlled values based on the input device pose.
  42786. * @param poseData the pose data to update the object with
  42787. */
  42788. updateFromDevice(poseData: DevicePose): void;
  42789. }
  42790. /**
  42791. * Set of options to customize the webVRCamera
  42792. */
  42793. interface WebVROptions {
  42794. /**
  42795. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  42796. */
  42797. trackPosition?: boolean;
  42798. /**
  42799. * Sets the scale of the vrDevice in babylon space. (default: 1)
  42800. */
  42801. positionScale?: number;
  42802. /**
  42803. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  42804. */
  42805. displayName?: string;
  42806. /**
  42807. * Should the native controller meshes be initialized. (default: true)
  42808. */
  42809. controllerMeshes?: boolean;
  42810. /**
  42811. * Creating a default HemiLight only on controllers. (default: true)
  42812. */
  42813. defaultLightingOnControllers?: boolean;
  42814. /**
  42815. * If you don't want to use the default VR button of the helper. (default: false)
  42816. */
  42817. useCustomVRButton?: boolean;
  42818. /**
  42819. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  42820. */
  42821. customVRButton?: HTMLButtonElement;
  42822. /**
  42823. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  42824. */
  42825. rayLength?: number;
  42826. /**
  42827. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  42828. */
  42829. defaultHeight?: number;
  42830. }
  42831. /**
  42832. * This represents a WebVR camera.
  42833. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  42834. * @example http://doc.babylonjs.com/how_to/webvr_camera
  42835. */
  42836. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  42837. private webVROptions;
  42838. /**
  42839. * @hidden
  42840. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  42841. */
  42842. _vrDevice: any;
  42843. /**
  42844. * The rawPose of the vrDevice.
  42845. */
  42846. rawPose: Nullable<DevicePose>;
  42847. private _onVREnabled;
  42848. private _specsVersion;
  42849. private _attached;
  42850. private _frameData;
  42851. protected _descendants: Array<Node>;
  42852. private _deviceRoomPosition;
  42853. /** @hidden */
  42854. _deviceRoomRotationQuaternion: Quaternion;
  42855. private _standingMatrix;
  42856. /**
  42857. * Represents device position in babylon space.
  42858. */
  42859. devicePosition: Vector3;
  42860. /**
  42861. * Represents device rotation in babylon space.
  42862. */
  42863. deviceRotationQuaternion: Quaternion;
  42864. /**
  42865. * The scale of the device to be used when translating from device space to babylon space.
  42866. */
  42867. deviceScaleFactor: number;
  42868. private _deviceToWorld;
  42869. private _worldToDevice;
  42870. /**
  42871. * References to the webVR controllers for the vrDevice.
  42872. */
  42873. controllers: Array<WebVRController>;
  42874. /**
  42875. * Emits an event when a controller is attached.
  42876. */
  42877. onControllersAttachedObservable: Observable<WebVRController[]>;
  42878. /**
  42879. * Emits an event when a controller's mesh has been loaded;
  42880. */
  42881. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42882. /**
  42883. * Emits an event when the HMD's pose has been updated.
  42884. */
  42885. onPoseUpdatedFromDeviceObservable: Observable<any>;
  42886. private _poseSet;
  42887. /**
  42888. * If the rig cameras be used as parent instead of this camera.
  42889. */
  42890. rigParenting: boolean;
  42891. private _lightOnControllers;
  42892. private _defaultHeight?;
  42893. /**
  42894. * Instantiates a WebVRFreeCamera.
  42895. * @param name The name of the WebVRFreeCamera
  42896. * @param position The starting anchor position for the camera
  42897. * @param scene The scene the camera belongs to
  42898. * @param webVROptions a set of customizable options for the webVRCamera
  42899. */
  42900. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  42901. /**
  42902. * Gets the device distance from the ground in meters.
  42903. * @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.
  42904. */
  42905. deviceDistanceToRoomGround(): number;
  42906. /**
  42907. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42908. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  42909. */
  42910. useStandingMatrix(callback?: (bool: boolean) => void): void;
  42911. /**
  42912. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42913. * @returns A promise with a boolean set to if the standing matrix is supported.
  42914. */
  42915. useStandingMatrixAsync(): Promise<boolean>;
  42916. /**
  42917. * Disposes the camera
  42918. */
  42919. dispose(): void;
  42920. /**
  42921. * Gets a vrController by name.
  42922. * @param name The name of the controller to retreive
  42923. * @returns the controller matching the name specified or null if not found
  42924. */
  42925. getControllerByName(name: string): Nullable<WebVRController>;
  42926. private _leftController;
  42927. /**
  42928. * The controller corrisponding to the users left hand.
  42929. */
  42930. readonly leftController: Nullable<WebVRController>;
  42931. private _rightController;
  42932. /**
  42933. * The controller corrisponding to the users right hand.
  42934. */
  42935. readonly rightController: Nullable<WebVRController>;
  42936. /**
  42937. * Casts a ray forward from the vrCamera's gaze.
  42938. * @param length Length of the ray (default: 100)
  42939. * @returns the ray corrisponding to the gaze
  42940. */
  42941. getForwardRay(length?: number): Ray;
  42942. /**
  42943. * @hidden
  42944. * Updates the camera based on device's frame data
  42945. */
  42946. _checkInputs(): void;
  42947. /**
  42948. * Updates the poseControlled values based on the input device pose.
  42949. * @param poseData Pose coming from the device
  42950. */
  42951. updateFromDevice(poseData: DevicePose): void;
  42952. private _htmlElementAttached;
  42953. private _detachIfAttached;
  42954. /**
  42955. * WebVR's attach control will start broadcasting frames to the device.
  42956. * Note that in certain browsers (chrome for example) this function must be called
  42957. * within a user-interaction callback. Example:
  42958. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  42959. *
  42960. * @param element html element to attach the vrDevice to
  42961. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  42962. */
  42963. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42964. /**
  42965. * Detaches the camera from the html element and disables VR
  42966. *
  42967. * @param element html element to detach from
  42968. */
  42969. detachControl(element: HTMLElement): void;
  42970. /**
  42971. * @returns the name of this class
  42972. */
  42973. getClassName(): string;
  42974. /**
  42975. * Calls resetPose on the vrDisplay
  42976. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  42977. */
  42978. resetToCurrentRotation(): void;
  42979. /**
  42980. * @hidden
  42981. * Updates the rig cameras (left and right eye)
  42982. */
  42983. _updateRigCameras(): void;
  42984. private _workingVector;
  42985. private _oneVector;
  42986. private _workingMatrix;
  42987. private updateCacheCalled;
  42988. private _correctPositionIfNotTrackPosition;
  42989. /**
  42990. * @hidden
  42991. * Updates the cached values of the camera
  42992. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  42993. */
  42994. _updateCache(ignoreParentClass?: boolean): void;
  42995. /**
  42996. * @hidden
  42997. * Get current device position in babylon world
  42998. */
  42999. _computeDevicePosition(): void;
  43000. /**
  43001. * Updates the current device position and rotation in the babylon world
  43002. */
  43003. update(): void;
  43004. /**
  43005. * @hidden
  43006. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  43007. * @returns an identity matrix
  43008. */
  43009. _getViewMatrix(): Matrix;
  43010. private _tmpMatrix;
  43011. /**
  43012. * This function is called by the two RIG cameras.
  43013. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  43014. */
  43015. protected _getWebVRViewMatrix(): Matrix;
  43016. protected _getWebVRProjectionMatrix(): Matrix;
  43017. private _onGamepadConnectedObserver;
  43018. private _onGamepadDisconnectedObserver;
  43019. private _updateCacheWhenTrackingDisabledObserver;
  43020. /**
  43021. * Initializes the controllers and their meshes
  43022. */
  43023. initControllers(): void;
  43024. }
  43025. }
  43026. declare module BABYLON {
  43027. /** @hidden */
  43028. class _OcclusionDataStorage {
  43029. /** @hidden */
  43030. occlusionInternalRetryCounter: number;
  43031. /** @hidden */
  43032. isOcclusionQueryInProgress: boolean;
  43033. /** @hidden */
  43034. isOccluded: boolean;
  43035. /** @hidden */
  43036. occlusionRetryCount: number;
  43037. /** @hidden */
  43038. occlusionType: number;
  43039. /** @hidden */
  43040. occlusionQueryAlgorithmType: number;
  43041. }
  43042. interface Engine {
  43043. /**
  43044. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43045. * @return the new query
  43046. */
  43047. createQuery(): WebGLQuery;
  43048. /**
  43049. * Delete and release a webGL query
  43050. * @param query defines the query to delete
  43051. * @return the current engine
  43052. */
  43053. deleteQuery(query: WebGLQuery): Engine;
  43054. /**
  43055. * Check if a given query has resolved and got its value
  43056. * @param query defines the query to check
  43057. * @returns true if the query got its value
  43058. */
  43059. isQueryResultAvailable(query: WebGLQuery): boolean;
  43060. /**
  43061. * Gets the value of a given query
  43062. * @param query defines the query to check
  43063. * @returns the value of the query
  43064. */
  43065. getQueryResult(query: WebGLQuery): number;
  43066. /**
  43067. * Initiates an occlusion query
  43068. * @param algorithmType defines the algorithm to use
  43069. * @param query defines the query to use
  43070. * @returns the current engine
  43071. * @see http://doc.babylonjs.com/features/occlusionquery
  43072. */
  43073. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43074. /**
  43075. * Ends an occlusion query
  43076. * @see http://doc.babylonjs.com/features/occlusionquery
  43077. * @param algorithmType defines the algorithm to use
  43078. * @returns the current engine
  43079. */
  43080. endOcclusionQuery(algorithmType: number): Engine;
  43081. /**
  43082. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43083. * Please note that only one query can be issued at a time
  43084. * @returns a time token used to track the time span
  43085. */
  43086. startTimeQuery(): Nullable<_TimeToken>;
  43087. /**
  43088. * Ends a time query
  43089. * @param token defines the token used to measure the time span
  43090. * @returns the time spent (in ns)
  43091. */
  43092. endTimeQuery(token: _TimeToken): int;
  43093. /** @hidden */
  43094. _currentNonTimestampToken: Nullable<_TimeToken>;
  43095. /** @hidden */
  43096. _createTimeQuery(): WebGLQuery;
  43097. /** @hidden */
  43098. _deleteTimeQuery(query: WebGLQuery): void;
  43099. /** @hidden */
  43100. _getGlAlgorithmType(algorithmType: number): number;
  43101. /** @hidden */
  43102. _getTimeQueryResult(query: WebGLQuery): any;
  43103. /** @hidden */
  43104. _getTimeQueryAvailability(query: WebGLQuery): any;
  43105. }
  43106. interface AbstractMesh {
  43107. /**
  43108. * Backing filed
  43109. * @hidden
  43110. */
  43111. __occlusionDataStorage: _OcclusionDataStorage;
  43112. /**
  43113. * Access property
  43114. * @hidden
  43115. */
  43116. _occlusionDataStorage: _OcclusionDataStorage;
  43117. /**
  43118. * 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.
  43119. * The default value is -1 which means don't break the query and wait till the result
  43120. * @see http://doc.babylonjs.com/features/occlusionquery
  43121. */
  43122. occlusionRetryCount: number;
  43123. /**
  43124. * 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:
  43125. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43126. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43127. * * 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.
  43128. * @see http://doc.babylonjs.com/features/occlusionquery
  43129. */
  43130. occlusionType: number;
  43131. /**
  43132. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43133. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43134. * * 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.
  43135. * @see http://doc.babylonjs.com/features/occlusionquery
  43136. */
  43137. occlusionQueryAlgorithmType: number;
  43138. /**
  43139. * 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
  43140. * @see http://doc.babylonjs.com/features/occlusionquery
  43141. */
  43142. isOccluded: boolean;
  43143. /**
  43144. * Flag to check the progress status of the query
  43145. * @see http://doc.babylonjs.com/features/occlusionquery
  43146. */
  43147. isOcclusionQueryInProgress: boolean;
  43148. }
  43149. }
  43150. declare module BABYLON {
  43151. interface Engine {
  43152. /**
  43153. * Creates a webGL transform feedback object
  43154. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43155. * @returns the webGL transform feedback object
  43156. */
  43157. createTransformFeedback(): WebGLTransformFeedback;
  43158. /**
  43159. * Delete a webGL transform feedback object
  43160. * @param value defines the webGL transform feedback object to delete
  43161. */
  43162. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43163. /**
  43164. * Bind a webGL transform feedback object to the webgl context
  43165. * @param value defines the webGL transform feedback object to bind
  43166. */
  43167. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43168. /**
  43169. * Begins a transform feedback operation
  43170. * @param usePoints defines if points or triangles must be used
  43171. */
  43172. beginTransformFeedback(usePoints: boolean): void;
  43173. /**
  43174. * Ends a transform feedback operation
  43175. */
  43176. endTransformFeedback(): void;
  43177. /**
  43178. * Specify the varyings to use with transform feedback
  43179. * @param program defines the associated webGL program
  43180. * @param value defines the list of strings representing the varying names
  43181. */
  43182. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43183. /**
  43184. * Bind a webGL buffer for a transform feedback operation
  43185. * @param value defines the webGL buffer to bind
  43186. */
  43187. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43188. }
  43189. }
  43190. declare module BABYLON {
  43191. /**
  43192. * Google Daydream controller
  43193. */
  43194. class DaydreamController extends WebVRController {
  43195. /**
  43196. * Base Url for the controller model.
  43197. */
  43198. static MODEL_BASE_URL: string;
  43199. /**
  43200. * File name for the controller model.
  43201. */
  43202. static MODEL_FILENAME: string;
  43203. /**
  43204. * Gamepad Id prefix used to identify Daydream Controller.
  43205. */
  43206. static readonly GAMEPAD_ID_PREFIX: string;
  43207. /**
  43208. * Creates a new DaydreamController from a gamepad
  43209. * @param vrGamepad the gamepad that the controller should be created from
  43210. */
  43211. constructor(vrGamepad: any);
  43212. /**
  43213. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43214. * @param scene scene in which to add meshes
  43215. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43216. */
  43217. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43218. /**
  43219. * Called once for each button that changed state since the last frame
  43220. * @param buttonIdx Which button index changed
  43221. * @param state New state of the button
  43222. * @param changes Which properties on the state changed since last frame
  43223. */
  43224. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43225. }
  43226. }
  43227. declare module BABYLON {
  43228. /**
  43229. * Gear VR Controller
  43230. */
  43231. class GearVRController extends WebVRController {
  43232. /**
  43233. * Base Url for the controller model.
  43234. */
  43235. static MODEL_BASE_URL: string;
  43236. /**
  43237. * File name for the controller model.
  43238. */
  43239. static MODEL_FILENAME: string;
  43240. /**
  43241. * Gamepad Id prefix used to identify this controller.
  43242. */
  43243. static readonly GAMEPAD_ID_PREFIX: string;
  43244. private readonly _buttonIndexToObservableNameMap;
  43245. /**
  43246. * Creates a new GearVRController from a gamepad
  43247. * @param vrGamepad the gamepad that the controller should be created from
  43248. */
  43249. constructor(vrGamepad: any);
  43250. /**
  43251. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43252. * @param scene scene in which to add meshes
  43253. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43254. */
  43255. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43256. /**
  43257. * Called once for each button that changed state since the last frame
  43258. * @param buttonIdx Which button index changed
  43259. * @param state New state of the button
  43260. * @param changes Which properties on the state changed since last frame
  43261. */
  43262. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43263. }
  43264. }
  43265. declare module BABYLON {
  43266. /**
  43267. * Generic Controller
  43268. */
  43269. class GenericController extends WebVRController {
  43270. /**
  43271. * Base Url for the controller model.
  43272. */
  43273. static readonly MODEL_BASE_URL: string;
  43274. /**
  43275. * File name for the controller model.
  43276. */
  43277. static readonly MODEL_FILENAME: string;
  43278. /**
  43279. * Creates a new GenericController from a gamepad
  43280. * @param vrGamepad the gamepad that the controller should be created from
  43281. */
  43282. constructor(vrGamepad: any);
  43283. /**
  43284. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43285. * @param scene scene in which to add meshes
  43286. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43287. */
  43288. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43289. /**
  43290. * Called once for each button that changed state since the last frame
  43291. * @param buttonIdx Which button index changed
  43292. * @param state New state of the button
  43293. * @param changes Which properties on the state changed since last frame
  43294. */
  43295. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43296. }
  43297. }
  43298. declare module BABYLON {
  43299. /**
  43300. * Oculus Touch Controller
  43301. */
  43302. class OculusTouchController extends WebVRController {
  43303. /**
  43304. * Base Url for the controller model.
  43305. */
  43306. static MODEL_BASE_URL: string;
  43307. /**
  43308. * File name for the left controller model.
  43309. */
  43310. static MODEL_LEFT_FILENAME: string;
  43311. /**
  43312. * File name for the right controller model.
  43313. */
  43314. static MODEL_RIGHT_FILENAME: string;
  43315. /**
  43316. * Fired when the secondary trigger on this controller is modified
  43317. */
  43318. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43319. /**
  43320. * Fired when the thumb rest on this controller is modified
  43321. */
  43322. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43323. /**
  43324. * Creates a new OculusTouchController from a gamepad
  43325. * @param vrGamepad the gamepad that the controller should be created from
  43326. */
  43327. constructor(vrGamepad: any);
  43328. /**
  43329. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43330. * @param scene scene in which to add meshes
  43331. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43332. */
  43333. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43334. /**
  43335. * Fired when the A button on this controller is modified
  43336. */
  43337. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43338. /**
  43339. * Fired when the B button on this controller is modified
  43340. */
  43341. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43342. /**
  43343. * Fired when the X button on this controller is modified
  43344. */
  43345. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43346. /**
  43347. * Fired when the Y button on this controller is modified
  43348. */
  43349. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43350. /**
  43351. * Called once for each button that changed state since the last frame
  43352. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43353. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43354. * 2) secondary trigger (same)
  43355. * 3) A (right) X (left), touch, pressed = value
  43356. * 4) B / Y
  43357. * 5) thumb rest
  43358. * @param buttonIdx Which button index changed
  43359. * @param state New state of the button
  43360. * @param changes Which properties on the state changed since last frame
  43361. */
  43362. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43363. }
  43364. }
  43365. declare module BABYLON {
  43366. /**
  43367. * Defines the types of pose enabled controllers that are supported
  43368. */
  43369. enum PoseEnabledControllerType {
  43370. /**
  43371. * HTC Vive
  43372. */
  43373. VIVE = 0,
  43374. /**
  43375. * Oculus Rift
  43376. */
  43377. OCULUS = 1,
  43378. /**
  43379. * Windows mixed reality
  43380. */
  43381. WINDOWS = 2,
  43382. /**
  43383. * Samsung gear VR
  43384. */
  43385. GEAR_VR = 3,
  43386. /**
  43387. * Google Daydream
  43388. */
  43389. DAYDREAM = 4,
  43390. /**
  43391. * Generic
  43392. */
  43393. GENERIC = 5
  43394. }
  43395. /**
  43396. * Defines the MutableGamepadButton interface for the state of a gamepad button
  43397. */
  43398. interface MutableGamepadButton {
  43399. /**
  43400. * Value of the button/trigger
  43401. */
  43402. value: number;
  43403. /**
  43404. * If the button/trigger is currently touched
  43405. */
  43406. touched: boolean;
  43407. /**
  43408. * If the button/trigger is currently pressed
  43409. */
  43410. pressed: boolean;
  43411. }
  43412. /**
  43413. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  43414. * @hidden
  43415. */
  43416. interface ExtendedGamepadButton extends GamepadButton {
  43417. /**
  43418. * If the button/trigger is currently pressed
  43419. */
  43420. readonly pressed: boolean;
  43421. /**
  43422. * If the button/trigger is currently touched
  43423. */
  43424. readonly touched: boolean;
  43425. /**
  43426. * Value of the button/trigger
  43427. */
  43428. readonly value: number;
  43429. }
  43430. /**
  43431. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43432. */
  43433. class PoseEnabledControllerHelper {
  43434. /**
  43435. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43436. * @param vrGamepad the gamepad to initialized
  43437. * @returns a vr controller of the type the gamepad identified as
  43438. */
  43439. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  43440. }
  43441. /**
  43442. * Defines the PoseEnabledController object that contains state of a vr capable controller
  43443. */
  43444. class PoseEnabledController extends Gamepad implements PoseControlled {
  43445. private _deviceRoomPosition;
  43446. private _deviceRoomRotationQuaternion;
  43447. /**
  43448. * The device position in babylon space
  43449. */
  43450. devicePosition: Vector3;
  43451. /**
  43452. * The device rotation in babylon space
  43453. */
  43454. deviceRotationQuaternion: Quaternion;
  43455. /**
  43456. * The scale factor of the device in babylon space
  43457. */
  43458. deviceScaleFactor: number;
  43459. /**
  43460. * (Likely devicePosition should be used instead) The device position in its room space
  43461. */
  43462. position: Vector3;
  43463. /**
  43464. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  43465. */
  43466. rotationQuaternion: Quaternion;
  43467. /**
  43468. * The type of controller (Eg. Windows mixed reality)
  43469. */
  43470. controllerType: PoseEnabledControllerType;
  43471. protected _calculatedPosition: Vector3;
  43472. private _calculatedRotation;
  43473. /**
  43474. * The raw pose from the device
  43475. */
  43476. rawPose: DevicePose;
  43477. private _trackPosition;
  43478. private _maxRotationDistFromHeadset;
  43479. private _draggedRoomRotation;
  43480. /**
  43481. * @hidden
  43482. */
  43483. _disableTrackPosition(fixedPosition: Vector3): void;
  43484. /**
  43485. * Internal, the mesh attached to the controller
  43486. * @hidden
  43487. */
  43488. _mesh: Nullable<AbstractMesh>;
  43489. private _poseControlledCamera;
  43490. private _leftHandSystemQuaternion;
  43491. /**
  43492. * Internal, matrix used to convert room space to babylon space
  43493. * @hidden
  43494. */
  43495. _deviceToWorld: Matrix;
  43496. /**
  43497. * Node to be used when casting a ray from the controller
  43498. * @hidden
  43499. */
  43500. _pointingPoseNode: Nullable<AbstractMesh>;
  43501. /**
  43502. * Name of the child mesh that can be used to cast a ray from the controller
  43503. */
  43504. static readonly POINTING_POSE: string;
  43505. /**
  43506. * Creates a new PoseEnabledController from a gamepad
  43507. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  43508. */
  43509. constructor(browserGamepad: any);
  43510. private _workingMatrix;
  43511. /**
  43512. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  43513. */
  43514. update(): void;
  43515. /**
  43516. * Updates only the pose device and mesh without doing any button event checking
  43517. */
  43518. protected _updatePoseAndMesh(): void;
  43519. /**
  43520. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  43521. * @param poseData raw pose fromthe device
  43522. */
  43523. updateFromDevice(poseData: DevicePose): void;
  43524. /**
  43525. * @hidden
  43526. */
  43527. _meshAttachedObservable: Observable<AbstractMesh>;
  43528. /**
  43529. * Attaches a mesh to the controller
  43530. * @param mesh the mesh to be attached
  43531. */
  43532. attachToMesh(mesh: AbstractMesh): void;
  43533. /**
  43534. * Attaches the controllers mesh to a camera
  43535. * @param camera the camera the mesh should be attached to
  43536. */
  43537. attachToPoseControlledCamera(camera: TargetCamera): void;
  43538. /**
  43539. * Disposes of the controller
  43540. */
  43541. dispose(): void;
  43542. /**
  43543. * The mesh that is attached to the controller
  43544. */
  43545. readonly mesh: Nullable<AbstractMesh>;
  43546. /**
  43547. * Gets the ray of the controller in the direction the controller is pointing
  43548. * @param length the length the resulting ray should be
  43549. * @returns a ray in the direction the controller is pointing
  43550. */
  43551. getForwardRay(length?: number): Ray;
  43552. }
  43553. }
  43554. declare module BABYLON {
  43555. /**
  43556. * Vive Controller
  43557. */
  43558. class ViveController extends WebVRController {
  43559. /**
  43560. * Base Url for the controller model.
  43561. */
  43562. static MODEL_BASE_URL: string;
  43563. /**
  43564. * File name for the controller model.
  43565. */
  43566. static MODEL_FILENAME: string;
  43567. /**
  43568. * Creates a new ViveController from a gamepad
  43569. * @param vrGamepad the gamepad that the controller should be created from
  43570. */
  43571. constructor(vrGamepad: any);
  43572. /**
  43573. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43574. * @param scene scene in which to add meshes
  43575. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43576. */
  43577. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43578. /**
  43579. * Fired when the left button on this controller is modified
  43580. */
  43581. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43582. /**
  43583. * Fired when the right button on this controller is modified
  43584. */
  43585. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43586. /**
  43587. * Fired when the menu button on this controller is modified
  43588. */
  43589. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43590. /**
  43591. * Called once for each button that changed state since the last frame
  43592. * Vive mapping:
  43593. * 0: touchpad
  43594. * 1: trigger
  43595. * 2: left AND right buttons
  43596. * 3: menu button
  43597. * @param buttonIdx Which button index changed
  43598. * @param state New state of the button
  43599. * @param changes Which properties on the state changed since last frame
  43600. */
  43601. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43602. }
  43603. }
  43604. declare module BABYLON {
  43605. /**
  43606. * Defines the WebVRController object that represents controllers tracked in 3D space
  43607. */
  43608. abstract class WebVRController extends PoseEnabledController {
  43609. /**
  43610. * Internal, the default controller model for the controller
  43611. */
  43612. protected _defaultModel: AbstractMesh;
  43613. /**
  43614. * Fired when the trigger state has changed
  43615. */
  43616. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43617. /**
  43618. * Fired when the main button state has changed
  43619. */
  43620. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43621. /**
  43622. * Fired when the secondary button state has changed
  43623. */
  43624. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43625. /**
  43626. * Fired when the pad state has changed
  43627. */
  43628. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  43629. /**
  43630. * Fired when controllers stick values have changed
  43631. */
  43632. onPadValuesChangedObservable: Observable<StickValues>;
  43633. /**
  43634. * Array of button availible on the controller
  43635. */
  43636. protected _buttons: Array<MutableGamepadButton>;
  43637. private _onButtonStateChange;
  43638. /**
  43639. * Fired when a controller button's state has changed
  43640. * @param callback the callback containing the button that was modified
  43641. */
  43642. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  43643. /**
  43644. * X and Y axis corrisponding to the controllers joystick
  43645. */
  43646. pad: StickValues;
  43647. /**
  43648. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  43649. */
  43650. hand: string;
  43651. /**
  43652. * The default controller model for the controller
  43653. */
  43654. readonly defaultModel: AbstractMesh;
  43655. /**
  43656. * Creates a new WebVRController from a gamepad
  43657. * @param vrGamepad the gamepad that the WebVRController should be created from
  43658. */
  43659. constructor(vrGamepad: any);
  43660. /**
  43661. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  43662. */
  43663. update(): void;
  43664. /**
  43665. * Function to be called when a button is modified
  43666. */
  43667. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43668. /**
  43669. * Loads a mesh and attaches it to the controller
  43670. * @param scene the scene the mesh should be added to
  43671. * @param meshLoaded callback for when the mesh has been loaded
  43672. */
  43673. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43674. private _setButtonValue;
  43675. private _changes;
  43676. private _checkChanges;
  43677. /**
  43678. * Disposes of th webVRCOntroller
  43679. */
  43680. dispose(): void;
  43681. }
  43682. }
  43683. declare module BABYLON {
  43684. /**
  43685. * Defines the WindowsMotionController object that the state of the windows motion controller
  43686. */
  43687. class WindowsMotionController extends WebVRController {
  43688. /**
  43689. * The base url used to load the left and right controller models
  43690. */
  43691. static MODEL_BASE_URL: string;
  43692. /**
  43693. * The name of the left controller model file
  43694. */
  43695. static MODEL_LEFT_FILENAME: string;
  43696. /**
  43697. * The name of the right controller model file
  43698. */
  43699. static MODEL_RIGHT_FILENAME: string;
  43700. /**
  43701. * The controller name prefix for this controller type
  43702. */
  43703. static readonly GAMEPAD_ID_PREFIX: string;
  43704. /**
  43705. * The controller id pattern for this controller type
  43706. */
  43707. private static readonly GAMEPAD_ID_PATTERN;
  43708. private _loadedMeshInfo;
  43709. private readonly _mapping;
  43710. /**
  43711. * Fired when the trackpad on this controller is clicked
  43712. */
  43713. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43714. /**
  43715. * Fired when the trackpad on this controller is modified
  43716. */
  43717. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43718. /**
  43719. * The current x and y values of this controller's trackpad
  43720. */
  43721. trackpad: StickValues;
  43722. /**
  43723. * Creates a new WindowsMotionController from a gamepad
  43724. * @param vrGamepad the gamepad that the controller should be created from
  43725. */
  43726. constructor(vrGamepad: any);
  43727. /**
  43728. * Fired when the trigger on this controller is modified
  43729. */
  43730. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43731. /**
  43732. * Fired when the menu button on this controller is modified
  43733. */
  43734. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43735. /**
  43736. * Fired when the grip button on this controller is modified
  43737. */
  43738. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43739. /**
  43740. * Fired when the thumbstick button on this controller is modified
  43741. */
  43742. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43743. /**
  43744. * Fired when the touchpad button on this controller is modified
  43745. */
  43746. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43747. /**
  43748. * Fired when the touchpad values on this controller are modified
  43749. */
  43750. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43751. private _updateTrackpad;
  43752. /**
  43753. * Called once per frame by the engine.
  43754. */
  43755. update(): void;
  43756. /**
  43757. * Called once for each button that changed state since the last frame
  43758. * @param buttonIdx Which button index changed
  43759. * @param state New state of the button
  43760. * @param changes Which properties on the state changed since last frame
  43761. */
  43762. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43763. /**
  43764. * Moves the buttons on the controller mesh based on their current state
  43765. * @param buttonName the name of the button to move
  43766. * @param buttonValue the value of the button which determines the buttons new position
  43767. */
  43768. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43769. /**
  43770. * Moves the axis on the controller mesh based on its current state
  43771. * @param axis the index of the axis
  43772. * @param axisValue the value of the axis which determines the meshes new position
  43773. * @hidden
  43774. */
  43775. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43776. /**
  43777. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43778. * @param scene scene in which to add meshes
  43779. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43780. */
  43781. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43782. /**
  43783. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43784. * can be transformed by button presses and axes values, based on this._mapping.
  43785. *
  43786. * @param scene scene in which the meshes exist
  43787. * @param meshes list of meshes that make up the controller model to process
  43788. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43789. */
  43790. private processModel;
  43791. private createMeshInfo;
  43792. /**
  43793. * Gets the ray of the controller in the direction the controller is pointing
  43794. * @param length the length the resulting ray should be
  43795. * @returns a ray in the direction the controller is pointing
  43796. */
  43797. getForwardRay(length?: number): Ray;
  43798. /**
  43799. * Disposes of the controller
  43800. */
  43801. dispose(): void;
  43802. }
  43803. }
  43804. declare module BABYLON {
  43805. /**
  43806. * Interface to implement to create a shadow generator compatible with BJS.
  43807. */
  43808. interface IShadowGenerator {
  43809. /**
  43810. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  43811. * @returns The render target texture if present otherwise, null
  43812. */
  43813. getShadowMap(): Nullable<RenderTargetTexture>;
  43814. /**
  43815. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  43816. * @returns The render target texture if the shadow map is present otherwise, null
  43817. */
  43818. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  43819. /**
  43820. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  43821. * @param subMesh The submesh we want to render in the shadow map
  43822. * @param useInstances Defines wether will draw in the map using instances
  43823. * @returns true if ready otherwise, false
  43824. */
  43825. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43826. /**
  43827. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  43828. * @param defines Defines of the material we want to update
  43829. * @param lightIndex Index of the light in the enabled light list of the material
  43830. */
  43831. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  43832. /**
  43833. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  43834. * defined in the generator but impacting the effect).
  43835. * It implies the unifroms available on the materials are the standard BJS ones.
  43836. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  43837. * @param effect The effect we are binfing the information for
  43838. */
  43839. bindShadowLight(lightIndex: string, effect: Effect): void;
  43840. /**
  43841. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  43842. * (eq to shadow prjection matrix * light transform matrix)
  43843. * @returns The transform matrix used to create the shadow map
  43844. */
  43845. getTransformMatrix(): Matrix;
  43846. /**
  43847. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  43848. * Cube and 2D textures for instance.
  43849. */
  43850. recreateShadowMap(): void;
  43851. /**
  43852. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43853. * @param onCompiled Callback triggered at the and of the effects compilation
  43854. * @param options Sets of optional options forcing the compilation with different modes
  43855. */
  43856. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  43857. useInstances: boolean;
  43858. }>): void;
  43859. /**
  43860. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43861. * @param options Sets of optional options forcing the compilation with different modes
  43862. * @returns A promise that resolves when the compilation completes
  43863. */
  43864. forceCompilationAsync(options?: Partial<{
  43865. useInstances: boolean;
  43866. }>): Promise<void>;
  43867. /**
  43868. * Serializes the shadow generator setup to a json object.
  43869. * @returns The serialized JSON object
  43870. */
  43871. serialize(): any;
  43872. /**
  43873. * Disposes the Shadow map and related Textures and effects.
  43874. */
  43875. dispose(): void;
  43876. }
  43877. /**
  43878. * Default implementation IShadowGenerator.
  43879. * This is the main object responsible of generating shadows in the framework.
  43880. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  43881. */
  43882. class ShadowGenerator implements IShadowGenerator {
  43883. /**
  43884. * Shadow generator mode None: no filtering applied.
  43885. */
  43886. static readonly FILTER_NONE: number;
  43887. /**
  43888. * Shadow generator mode ESM: Exponential Shadow Mapping.
  43889. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43890. */
  43891. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  43892. /**
  43893. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  43894. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  43895. */
  43896. static readonly FILTER_POISSONSAMPLING: number;
  43897. /**
  43898. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  43899. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43900. */
  43901. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  43902. /**
  43903. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  43904. * edge artifacts on steep falloff.
  43905. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43906. */
  43907. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  43908. /**
  43909. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  43910. * edge artifacts on steep falloff.
  43911. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43912. */
  43913. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  43914. /**
  43915. * Shadow generator mode PCF: Percentage Closer Filtering
  43916. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  43917. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  43918. */
  43919. static readonly FILTER_PCF: number;
  43920. /**
  43921. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  43922. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  43923. * Contact Hardening
  43924. */
  43925. static readonly FILTER_PCSS: number;
  43926. /**
  43927. * Reserved for PCF and PCSS
  43928. * Highest Quality.
  43929. *
  43930. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  43931. *
  43932. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  43933. */
  43934. static readonly QUALITY_HIGH: number;
  43935. /**
  43936. * Reserved for PCF and PCSS
  43937. * Good tradeoff for quality/perf cross devices
  43938. *
  43939. * Execute PCF on a 3*3 kernel.
  43940. *
  43941. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  43942. */
  43943. static readonly QUALITY_MEDIUM: number;
  43944. /**
  43945. * Reserved for PCF and PCSS
  43946. * The lowest quality but the fastest.
  43947. *
  43948. * Execute PCF on a 1*1 kernel.
  43949. *
  43950. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  43951. */
  43952. static readonly QUALITY_LOW: number;
  43953. private _bias;
  43954. /**
  43955. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  43956. */
  43957. /**
  43958. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  43959. */
  43960. bias: number;
  43961. private _normalBias;
  43962. /**
  43963. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  43964. */
  43965. /**
  43966. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  43967. */
  43968. normalBias: number;
  43969. private _blurBoxOffset;
  43970. /**
  43971. * Gets the blur box offset: offset applied during the blur pass.
  43972. * Only usefull if useKernelBlur = false
  43973. */
  43974. /**
  43975. * Sets the blur box offset: offset applied during the blur pass.
  43976. * Only usefull if useKernelBlur = false
  43977. */
  43978. blurBoxOffset: number;
  43979. private _blurScale;
  43980. /**
  43981. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  43982. * 2 means half of the size.
  43983. */
  43984. /**
  43985. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  43986. * 2 means half of the size.
  43987. */
  43988. blurScale: number;
  43989. private _blurKernel;
  43990. /**
  43991. * Gets the blur kernel: kernel size of the blur pass.
  43992. * Only usefull if useKernelBlur = true
  43993. */
  43994. /**
  43995. * Sets the blur kernel: kernel size of the blur pass.
  43996. * Only usefull if useKernelBlur = true
  43997. */
  43998. blurKernel: number;
  43999. private _useKernelBlur;
  44000. /**
  44001. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44002. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  44003. */
  44004. /**
  44005. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44006. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  44007. */
  44008. useKernelBlur: boolean;
  44009. private _depthScale;
  44010. /**
  44011. * Gets the depth scale used in ESM mode.
  44012. */
  44013. /**
  44014. * Sets the depth scale used in ESM mode.
  44015. * This can override the scale stored on the light.
  44016. */
  44017. depthScale: number;
  44018. private _filter;
  44019. /**
  44020. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44021. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44022. */
  44023. /**
  44024. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44025. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44026. */
  44027. filter: number;
  44028. /**
  44029. * Gets if the current filter is set to Poisson Sampling.
  44030. */
  44031. /**
  44032. * Sets the current filter to Poisson Sampling.
  44033. */
  44034. usePoissonSampling: boolean;
  44035. /**
  44036. * Gets if the current filter is set to VSM.
  44037. * DEPRECATED. Should use useExponentialShadowMap instead.
  44038. */
  44039. /**
  44040. * Sets the current filter is to VSM.
  44041. * DEPRECATED. Should use useExponentialShadowMap instead.
  44042. */
  44043. useVarianceShadowMap: boolean;
  44044. /**
  44045. * Gets if the current filter is set to blurred VSM.
  44046. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  44047. */
  44048. /**
  44049. * Sets the current filter is to blurred VSM.
  44050. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  44051. */
  44052. useBlurVarianceShadowMap: boolean;
  44053. /**
  44054. * Gets if the current filter is set to ESM.
  44055. */
  44056. /**
  44057. * Sets the current filter is to ESM.
  44058. */
  44059. useExponentialShadowMap: boolean;
  44060. /**
  44061. * Gets if the current filter is set to filtered ESM.
  44062. */
  44063. /**
  44064. * Gets if the current filter is set to filtered ESM.
  44065. */
  44066. useBlurExponentialShadowMap: boolean;
  44067. /**
  44068. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44069. * exponential to prevent steep falloff artifacts).
  44070. */
  44071. /**
  44072. * Sets the current filter to "close ESM" (using the inverse of the
  44073. * exponential to prevent steep falloff artifacts).
  44074. */
  44075. useCloseExponentialShadowMap: boolean;
  44076. /**
  44077. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44078. * exponential to prevent steep falloff artifacts).
  44079. */
  44080. /**
  44081. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44082. * exponential to prevent steep falloff artifacts).
  44083. */
  44084. useBlurCloseExponentialShadowMap: boolean;
  44085. /**
  44086. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44087. */
  44088. /**
  44089. * Sets the current filter to "PCF" (percentage closer filtering).
  44090. */
  44091. usePercentageCloserFiltering: boolean;
  44092. private _filteringQuality;
  44093. /**
  44094. * Gets the PCF or PCSS Quality.
  44095. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44096. */
  44097. /**
  44098. * Sets the PCF or PCSS Quality.
  44099. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44100. */
  44101. filteringQuality: number;
  44102. /**
  44103. * Gets if the current filter is set to "PCSS" (contact hardening).
  44104. */
  44105. /**
  44106. * Sets the current filter to "PCSS" (contact hardening).
  44107. */
  44108. useContactHardeningShadow: boolean;
  44109. private _contactHardeningLightSizeUVRatio;
  44110. /**
  44111. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44112. * Using a ratio helps keeping shape stability independently of the map size.
  44113. *
  44114. * It does not account for the light projection as it was having too much
  44115. * instability during the light setup or during light position changes.
  44116. *
  44117. * Only valid if useContactHardeningShadow is true.
  44118. */
  44119. /**
  44120. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44121. * Using a ratio helps keeping shape stability independently of the map size.
  44122. *
  44123. * It does not account for the light projection as it was having too much
  44124. * instability during the light setup or during light position changes.
  44125. *
  44126. * Only valid if useContactHardeningShadow is true.
  44127. */
  44128. contactHardeningLightSizeUVRatio: number;
  44129. private _darkness;
  44130. /**
  44131. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44132. * 0 means strongest and 1 would means no shadow.
  44133. * @returns the darkness.
  44134. */
  44135. getDarkness(): number;
  44136. /**
  44137. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44138. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44139. * @returns the shadow generator allowing fluent coding.
  44140. */
  44141. setDarkness(darkness: number): ShadowGenerator;
  44142. private _transparencyShadow;
  44143. /**
  44144. * Sets the ability to have transparent shadow (boolean).
  44145. * @param transparent True if transparent else False
  44146. * @returns the shadow generator allowing fluent coding
  44147. */
  44148. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  44149. private _shadowMap;
  44150. private _shadowMap2;
  44151. /**
  44152. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44153. * @returns The render target texture if present otherwise, null
  44154. */
  44155. getShadowMap(): Nullable<RenderTargetTexture>;
  44156. /**
  44157. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44158. * @returns The render target texture if the shadow map is present otherwise, null
  44159. */
  44160. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44161. /**
  44162. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44163. * @param mesh Mesh to add
  44164. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44165. * @returns the Shadow Generator itself
  44166. */
  44167. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44168. /**
  44169. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44170. * @param mesh Mesh to remove
  44171. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44172. * @returns the Shadow Generator itself
  44173. */
  44174. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44175. /**
  44176. * Controls the extent to which the shadows fade out at the edge of the frustum
  44177. * Used only by directionals and spots
  44178. */
  44179. frustumEdgeFalloff: number;
  44180. private _light;
  44181. /**
  44182. * Returns the associated light object.
  44183. * @returns the light generating the shadow
  44184. */
  44185. getLight(): IShadowLight;
  44186. /**
  44187. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44188. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44189. * It might on the other hand introduce peter panning.
  44190. */
  44191. forceBackFacesOnly: boolean;
  44192. private _scene;
  44193. private _lightDirection;
  44194. private _effect;
  44195. private _viewMatrix;
  44196. private _projectionMatrix;
  44197. private _transformMatrix;
  44198. private _cachedPosition;
  44199. private _cachedDirection;
  44200. private _cachedDefines;
  44201. private _currentRenderID;
  44202. private _boxBlurPostprocess;
  44203. private _kernelBlurXPostprocess;
  44204. private _kernelBlurYPostprocess;
  44205. private _blurPostProcesses;
  44206. private _mapSize;
  44207. private _currentFaceIndex;
  44208. private _currentFaceIndexCache;
  44209. private _textureType;
  44210. private _defaultTextureMatrix;
  44211. /**
  44212. * Creates a ShadowGenerator object.
  44213. * A ShadowGenerator is the required tool to use the shadows.
  44214. * Each light casting shadows needs to use its own ShadowGenerator.
  44215. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  44216. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44217. * @param light The light object generating the shadows.
  44218. * @param useFullFloatFirst 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.
  44219. */
  44220. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  44221. private _initializeGenerator;
  44222. private _initializeShadowMap;
  44223. private _initializeBlurRTTAndPostProcesses;
  44224. private _renderForShadowMap;
  44225. private _renderSubMeshForShadowMap;
  44226. private _applyFilterValues;
  44227. /**
  44228. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44229. * @param onCompiled Callback triggered at the and of the effects compilation
  44230. * @param options Sets of optional options forcing the compilation with different modes
  44231. */
  44232. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44233. useInstances: boolean;
  44234. }>): void;
  44235. /**
  44236. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44237. * @param options Sets of optional options forcing the compilation with different modes
  44238. * @returns A promise that resolves when the compilation completes
  44239. */
  44240. forceCompilationAsync(options?: Partial<{
  44241. useInstances: boolean;
  44242. }>): Promise<void>;
  44243. /**
  44244. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44245. * @param subMesh The submesh we want to render in the shadow map
  44246. * @param useInstances Defines wether will draw in the map using instances
  44247. * @returns true if ready otherwise, false
  44248. */
  44249. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44250. /**
  44251. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44252. * @param defines Defines of the material we want to update
  44253. * @param lightIndex Index of the light in the enabled light list of the material
  44254. */
  44255. prepareDefines(defines: any, lightIndex: number): void;
  44256. /**
  44257. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44258. * defined in the generator but impacting the effect).
  44259. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44260. * @param effect The effect we are binfing the information for
  44261. */
  44262. bindShadowLight(lightIndex: string, effect: Effect): void;
  44263. /**
  44264. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44265. * (eq to shadow prjection matrix * light transform matrix)
  44266. * @returns The transform matrix used to create the shadow map
  44267. */
  44268. getTransformMatrix(): Matrix;
  44269. /**
  44270. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44271. * Cube and 2D textures for instance.
  44272. */
  44273. recreateShadowMap(): void;
  44274. private _disposeBlurPostProcesses;
  44275. private _disposeRTTandPostProcesses;
  44276. /**
  44277. * Disposes the ShadowGenerator.
  44278. * Returns nothing.
  44279. */
  44280. dispose(): void;
  44281. /**
  44282. * Serializes the shadow generator setup to a json object.
  44283. * @returns The serialized JSON object
  44284. */
  44285. serialize(): any;
  44286. /**
  44287. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44288. * @param parsedShadowGenerator The JSON object to parse
  44289. * @param scene The scene to create the shadow map for
  44290. * @returns The parsed shadow generator
  44291. */
  44292. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  44293. }
  44294. }
  44295. declare module BABYLON {
  44296. /**
  44297. * Defines the shadow generator component responsible to manage any shadow generators
  44298. * in a given scene.
  44299. */
  44300. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44301. /**
  44302. * The component name helpfull to identify the component in the list of scene components.
  44303. */
  44304. readonly name: string;
  44305. /**
  44306. * The scene the component belongs to.
  44307. */
  44308. scene: Scene;
  44309. /**
  44310. * Creates a new instance of the component for the given scene
  44311. * @param scene Defines the scene to register the component in
  44312. */
  44313. constructor(scene: Scene);
  44314. /**
  44315. * Registers the component in a given scene
  44316. */
  44317. register(): void;
  44318. /**
  44319. * Rebuilds the elements related to this component in case of
  44320. * context lost for instance.
  44321. */
  44322. rebuild(): void;
  44323. /**
  44324. * Serializes the component data to the specified json object
  44325. * @param serializationObject The object to serialize to
  44326. */
  44327. serialize(serializationObject: any): void;
  44328. /**
  44329. * Adds all the element from the container to the scene
  44330. * @param container the container holding the elements
  44331. */
  44332. addFromContainer(container: AbstractScene): void;
  44333. /**
  44334. * Removes all the elements in the container from the scene
  44335. * @param container contains the elements to remove
  44336. */
  44337. removeFromContainer(container: AbstractScene): void;
  44338. /**
  44339. * Rebuilds the elements related to this component in case of
  44340. * context lost for instance.
  44341. */
  44342. dispose(): void;
  44343. private _gatherRenderTargets;
  44344. }
  44345. }
  44346. declare module BABYLON {
  44347. }
  44348. declare module BABYLON {
  44349. /**
  44350. * Background material used to create an efficient environement around your scene.
  44351. */
  44352. class BackgroundMaterial extends PushMaterial {
  44353. /**
  44354. * Standard reflectance value at parallel view angle.
  44355. */
  44356. static StandardReflectance0: number;
  44357. /**
  44358. * Standard reflectance value at grazing angle.
  44359. */
  44360. static StandardReflectance90: number;
  44361. protected _primaryColor: Color3;
  44362. /**
  44363. * Key light Color (multiply against the environement texture)
  44364. */
  44365. primaryColor: Color3;
  44366. protected __perceptualColor: Nullable<Color3>;
  44367. /**
  44368. * Experimental Internal Use Only.
  44369. *
  44370. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44371. * This acts as a helper to set the primary color to a more "human friendly" value.
  44372. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44373. * output color as close as possible from the chosen value.
  44374. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44375. * part of lighting setup.)
  44376. */
  44377. _perceptualColor: Nullable<Color3>;
  44378. protected _primaryColorShadowLevel: float;
  44379. /**
  44380. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44381. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44382. */
  44383. primaryColorShadowLevel: float;
  44384. protected _primaryColorHighlightLevel: float;
  44385. /**
  44386. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44387. * The primary color is used at the level chosen to define what the white area would look.
  44388. */
  44389. primaryColorHighlightLevel: float;
  44390. protected _reflectionTexture: Nullable<BaseTexture>;
  44391. /**
  44392. * Reflection Texture used in the material.
  44393. * Should be author in a specific way for the best result (refer to the documentation).
  44394. */
  44395. reflectionTexture: Nullable<BaseTexture>;
  44396. protected _reflectionBlur: float;
  44397. /**
  44398. * Reflection Texture level of blur.
  44399. *
  44400. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44401. * texture twice.
  44402. */
  44403. reflectionBlur: float;
  44404. protected _diffuseTexture: Nullable<BaseTexture>;
  44405. /**
  44406. * Diffuse Texture used in the material.
  44407. * Should be author in a specific way for the best result (refer to the documentation).
  44408. */
  44409. diffuseTexture: Nullable<BaseTexture>;
  44410. protected _shadowLights: Nullable<IShadowLight[]>;
  44411. /**
  44412. * Specify the list of lights casting shadow on the material.
  44413. * All scene shadow lights will be included if null.
  44414. */
  44415. shadowLights: Nullable<IShadowLight[]>;
  44416. protected _shadowLevel: float;
  44417. /**
  44418. * Helps adjusting the shadow to a softer level if required.
  44419. * 0 means black shadows and 1 means no shadows.
  44420. */
  44421. shadowLevel: float;
  44422. protected _sceneCenter: Vector3;
  44423. /**
  44424. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44425. * It is usually zero but might be interesting to modify according to your setup.
  44426. */
  44427. sceneCenter: Vector3;
  44428. protected _opacityFresnel: boolean;
  44429. /**
  44430. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44431. * This helps ensuring a nice transition when the camera goes under the ground.
  44432. */
  44433. opacityFresnel: boolean;
  44434. protected _reflectionFresnel: boolean;
  44435. /**
  44436. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44437. * This helps adding a mirror texture on the ground.
  44438. */
  44439. reflectionFresnel: boolean;
  44440. protected _reflectionFalloffDistance: number;
  44441. /**
  44442. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44443. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44444. */
  44445. reflectionFalloffDistance: number;
  44446. protected _reflectionAmount: number;
  44447. /**
  44448. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44449. */
  44450. reflectionAmount: number;
  44451. protected _reflectionReflectance0: number;
  44452. /**
  44453. * This specifies the weight of the reflection at grazing angle.
  44454. */
  44455. reflectionReflectance0: number;
  44456. protected _reflectionReflectance90: number;
  44457. /**
  44458. * This specifies the weight of the reflection at a perpendicular point of view.
  44459. */
  44460. reflectionReflectance90: number;
  44461. /**
  44462. * Sets the reflection reflectance fresnel values according to the default standard
  44463. * empirically know to work well :-)
  44464. */
  44465. reflectionStandardFresnelWeight: number;
  44466. protected _useRGBColor: boolean;
  44467. /**
  44468. * Helps to directly use the maps channels instead of their level.
  44469. */
  44470. useRGBColor: boolean;
  44471. protected _enableNoise: boolean;
  44472. /**
  44473. * This helps reducing the banding effect that could occur on the background.
  44474. */
  44475. enableNoise: boolean;
  44476. /**
  44477. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44478. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44479. * Recommended to be keep at 1.0 except for special cases.
  44480. */
  44481. fovMultiplier: number;
  44482. private _fovMultiplier;
  44483. /**
  44484. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44485. */
  44486. useEquirectangularFOV: boolean;
  44487. private _maxSimultaneousLights;
  44488. /**
  44489. * Number of Simultaneous lights allowed on the material.
  44490. */
  44491. maxSimultaneousLights: int;
  44492. /**
  44493. * Default configuration related to image processing available in the Background Material.
  44494. */
  44495. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44496. /**
  44497. * Keep track of the image processing observer to allow dispose and replace.
  44498. */
  44499. private _imageProcessingObserver;
  44500. /**
  44501. * Attaches a new image processing configuration to the PBR Material.
  44502. * @param configuration (if null the scene configuration will be use)
  44503. */
  44504. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44505. /**
  44506. * Gets the image processing configuration used either in this material.
  44507. */
  44508. /**
  44509. * Sets the Default image processing configuration used either in the this material.
  44510. *
  44511. * If sets to null, the scene one is in use.
  44512. */
  44513. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44514. /**
  44515. * Gets wether the color curves effect is enabled.
  44516. */
  44517. /**
  44518. * Sets wether the color curves effect is enabled.
  44519. */
  44520. cameraColorCurvesEnabled: boolean;
  44521. /**
  44522. * Gets wether the color grading effect is enabled.
  44523. */
  44524. /**
  44525. * Gets wether the color grading effect is enabled.
  44526. */
  44527. cameraColorGradingEnabled: boolean;
  44528. /**
  44529. * Gets wether tonemapping is enabled or not.
  44530. */
  44531. /**
  44532. * Sets wether tonemapping is enabled or not
  44533. */
  44534. cameraToneMappingEnabled: boolean;
  44535. /**
  44536. * The camera exposure used on this material.
  44537. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44538. * This corresponds to a photographic exposure.
  44539. */
  44540. /**
  44541. * The camera exposure used on this material.
  44542. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44543. * This corresponds to a photographic exposure.
  44544. */
  44545. cameraExposure: float;
  44546. /**
  44547. * Gets The camera contrast used on this material.
  44548. */
  44549. /**
  44550. * Sets The camera contrast used on this material.
  44551. */
  44552. cameraContrast: float;
  44553. /**
  44554. * Gets the Color Grading 2D Lookup Texture.
  44555. */
  44556. /**
  44557. * Sets the Color Grading 2D Lookup Texture.
  44558. */
  44559. cameraColorGradingTexture: Nullable<BaseTexture>;
  44560. /**
  44561. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44562. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44563. * 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;
  44564. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44565. */
  44566. /**
  44567. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44568. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44569. * 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;
  44570. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44571. */
  44572. cameraColorCurves: Nullable<ColorCurves>;
  44573. /**
  44574. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44575. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44576. */
  44577. switchToBGR: boolean;
  44578. private _renderTargets;
  44579. private _reflectionControls;
  44580. private _white;
  44581. private _primaryShadowColor;
  44582. private _primaryHighlightColor;
  44583. /**
  44584. * Instantiates a Background Material in the given scene
  44585. * @param name The friendly name of the material
  44586. * @param scene The scene to add the material to
  44587. */
  44588. constructor(name: string, scene: Scene);
  44589. /**
  44590. * Gets a boolean indicating that current material needs to register RTT
  44591. */
  44592. readonly hasRenderTargetTextures: boolean;
  44593. /**
  44594. * The entire material has been created in order to prevent overdraw.
  44595. * @returns false
  44596. */
  44597. needAlphaTesting(): boolean;
  44598. /**
  44599. * The entire material has been created in order to prevent overdraw.
  44600. * @returns true if blending is enable
  44601. */
  44602. needAlphaBlending(): boolean;
  44603. /**
  44604. * Checks wether the material is ready to be rendered for a given mesh.
  44605. * @param mesh The mesh to render
  44606. * @param subMesh The submesh to check against
  44607. * @param useInstances Specify wether or not the material is used with instances
  44608. * @returns true if all the dependencies are ready (Textures, Effects...)
  44609. */
  44610. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44611. /**
  44612. * Compute the primary color according to the chosen perceptual color.
  44613. */
  44614. private _computePrimaryColorFromPerceptualColor;
  44615. /**
  44616. * Compute the highlights and shadow colors according to their chosen levels.
  44617. */
  44618. private _computePrimaryColors;
  44619. /**
  44620. * Build the uniform buffer used in the material.
  44621. */
  44622. buildUniformLayout(): void;
  44623. /**
  44624. * Unbind the material.
  44625. */
  44626. unbind(): void;
  44627. /**
  44628. * Bind only the world matrix to the material.
  44629. * @param world The world matrix to bind.
  44630. */
  44631. bindOnlyWorldMatrix(world: Matrix): void;
  44632. /**
  44633. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44634. * @param world The world matrix to bind.
  44635. * @param subMesh The submesh to bind for.
  44636. */
  44637. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44638. /**
  44639. * Dispose the material.
  44640. * @param forceDisposeEffect Force disposal of the associated effect.
  44641. * @param forceDisposeTextures Force disposal of the associated textures.
  44642. */
  44643. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44644. /**
  44645. * Clones the material.
  44646. * @param name The cloned name.
  44647. * @returns The cloned material.
  44648. */
  44649. clone(name: string): BackgroundMaterial;
  44650. /**
  44651. * Serializes the current material to its JSON representation.
  44652. * @returns The JSON representation.
  44653. */
  44654. serialize(): any;
  44655. /**
  44656. * Gets the class name of the material
  44657. * @returns "BackgroundMaterial"
  44658. */
  44659. getClassName(): string;
  44660. /**
  44661. * Parse a JSON input to create back a background material.
  44662. * @param source The JSON data to parse
  44663. * @param scene The scene to create the parsed material in
  44664. * @param rootUrl The root url of the assets the material depends upon
  44665. * @returns the instantiated BackgroundMaterial.
  44666. */
  44667. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44668. }
  44669. }
  44670. declare module BABYLON {
  44671. /**
  44672. * The Physically based material base class of BJS.
  44673. *
  44674. * This offers the main features of a standard PBR material.
  44675. * For more information, please refer to the documentation :
  44676. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44677. */
  44678. abstract class PBRBaseMaterial extends PushMaterial {
  44679. /**
  44680. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44681. */
  44682. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44683. /**
  44684. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44685. * to enhance interoperability with other engines.
  44686. */
  44687. static readonly LIGHTFALLOFF_GLTF: number;
  44688. /**
  44689. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44690. * to enhance interoperability with other materials.
  44691. */
  44692. static readonly LIGHTFALLOFF_STANDARD: number;
  44693. /**
  44694. * Intensity of the direct lights e.g. the four lights available in your scene.
  44695. * This impacts both the direct diffuse and specular highlights.
  44696. */
  44697. protected _directIntensity: number;
  44698. /**
  44699. * Intensity of the emissive part of the material.
  44700. * This helps controlling the emissive effect without modifying the emissive color.
  44701. */
  44702. protected _emissiveIntensity: number;
  44703. /**
  44704. * Intensity of the environment e.g. how much the environment will light the object
  44705. * either through harmonics for rough material or through the refelction for shiny ones.
  44706. */
  44707. protected _environmentIntensity: number;
  44708. /**
  44709. * This is a special control allowing the reduction of the specular highlights coming from the
  44710. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44711. */
  44712. protected _specularIntensity: number;
  44713. /**
  44714. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44715. */
  44716. private _lightingInfos;
  44717. /**
  44718. * Debug Control allowing disabling the bump map on this material.
  44719. */
  44720. protected _disableBumpMap: boolean;
  44721. /**
  44722. * AKA Diffuse Texture in standard nomenclature.
  44723. */
  44724. protected _albedoTexture: BaseTexture;
  44725. /**
  44726. * AKA Occlusion Texture in other nomenclature.
  44727. */
  44728. protected _ambientTexture: BaseTexture;
  44729. /**
  44730. * AKA Occlusion Texture Intensity in other nomenclature.
  44731. */
  44732. protected _ambientTextureStrength: number;
  44733. /**
  44734. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44735. * 1 means it completely occludes it
  44736. * 0 mean it has no impact
  44737. */
  44738. protected _ambientTextureImpactOnAnalyticalLights: number;
  44739. /**
  44740. * Stores the alpha values in a texture.
  44741. */
  44742. protected _opacityTexture: BaseTexture;
  44743. /**
  44744. * Stores the reflection values in a texture.
  44745. */
  44746. protected _reflectionTexture: BaseTexture;
  44747. /**
  44748. * Stores the refraction values in a texture.
  44749. */
  44750. protected _refractionTexture: BaseTexture;
  44751. /**
  44752. * Stores the emissive values in a texture.
  44753. */
  44754. protected _emissiveTexture: BaseTexture;
  44755. /**
  44756. * AKA Specular texture in other nomenclature.
  44757. */
  44758. protected _reflectivityTexture: BaseTexture;
  44759. /**
  44760. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44761. */
  44762. protected _metallicTexture: BaseTexture;
  44763. /**
  44764. * Specifies the metallic scalar of the metallic/roughness workflow.
  44765. * Can also be used to scale the metalness values of the metallic texture.
  44766. */
  44767. protected _metallic: Nullable<number>;
  44768. /**
  44769. * Specifies the roughness scalar of the metallic/roughness workflow.
  44770. * Can also be used to scale the roughness values of the metallic texture.
  44771. */
  44772. protected _roughness: Nullable<number>;
  44773. /**
  44774. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44775. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44776. */
  44777. protected _microSurfaceTexture: BaseTexture;
  44778. /**
  44779. * Stores surface normal data used to displace a mesh in a texture.
  44780. */
  44781. protected _bumpTexture: BaseTexture;
  44782. /**
  44783. * Stores the pre-calculated light information of a mesh in a texture.
  44784. */
  44785. protected _lightmapTexture: BaseTexture;
  44786. /**
  44787. * The color of a material in ambient lighting.
  44788. */
  44789. protected _ambientColor: Color3;
  44790. /**
  44791. * AKA Diffuse Color in other nomenclature.
  44792. */
  44793. protected _albedoColor: Color3;
  44794. /**
  44795. * AKA Specular Color in other nomenclature.
  44796. */
  44797. protected _reflectivityColor: Color3;
  44798. /**
  44799. * The color applied when light is reflected from a material.
  44800. */
  44801. protected _reflectionColor: Color3;
  44802. /**
  44803. * The color applied when light is emitted from a material.
  44804. */
  44805. protected _emissiveColor: Color3;
  44806. /**
  44807. * AKA Glossiness in other nomenclature.
  44808. */
  44809. protected _microSurface: number;
  44810. /**
  44811. * source material index of refraction (IOR)' / 'destination material IOR.
  44812. */
  44813. protected _indexOfRefraction: number;
  44814. /**
  44815. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  44816. */
  44817. protected _invertRefractionY: boolean;
  44818. /**
  44819. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44820. * Materials half opaque for instance using refraction could benefit from this control.
  44821. */
  44822. protected _linkRefractionWithTransparency: boolean;
  44823. /**
  44824. * Specifies that the material will use the light map as a show map.
  44825. */
  44826. protected _useLightmapAsShadowmap: boolean;
  44827. /**
  44828. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44829. * makes the reflect vector face the model (under horizon).
  44830. */
  44831. protected _useHorizonOcclusion: boolean;
  44832. /**
  44833. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44834. * too much the area relying on ambient texture to define their ambient occlusion.
  44835. */
  44836. protected _useRadianceOcclusion: boolean;
  44837. /**
  44838. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44839. */
  44840. protected _useAlphaFromAlbedoTexture: boolean;
  44841. /**
  44842. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44843. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44844. */
  44845. protected _useSpecularOverAlpha: boolean;
  44846. /**
  44847. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44848. */
  44849. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44850. /**
  44851. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44852. */
  44853. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44854. /**
  44855. * Specifies if the metallic texture contains the roughness information in its green channel.
  44856. */
  44857. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44858. /**
  44859. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44860. */
  44861. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44862. /**
  44863. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44864. */
  44865. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44866. /**
  44867. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44868. */
  44869. protected _useAmbientInGrayScale: boolean;
  44870. /**
  44871. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44872. * The material will try to infer what glossiness each pixel should be.
  44873. */
  44874. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44875. /**
  44876. * Defines the falloff type used in this material.
  44877. * It by default is Physical.
  44878. */
  44879. protected _lightFalloff: number;
  44880. /**
  44881. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44882. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44883. */
  44884. protected _useRadianceOverAlpha: boolean;
  44885. /**
  44886. * Allows using an object space normal map (instead of tangent space).
  44887. */
  44888. protected _useObjectSpaceNormalMap: boolean;
  44889. /**
  44890. * Allows using the bump map in parallax mode.
  44891. */
  44892. protected _useParallax: boolean;
  44893. /**
  44894. * Allows using the bump map in parallax occlusion mode.
  44895. */
  44896. protected _useParallaxOcclusion: boolean;
  44897. /**
  44898. * Controls the scale bias of the parallax mode.
  44899. */
  44900. protected _parallaxScaleBias: number;
  44901. /**
  44902. * If sets to true, disables all the lights affecting the material.
  44903. */
  44904. protected _disableLighting: boolean;
  44905. /**
  44906. * Number of Simultaneous lights allowed on the material.
  44907. */
  44908. protected _maxSimultaneousLights: number;
  44909. /**
  44910. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44911. */
  44912. protected _invertNormalMapX: boolean;
  44913. /**
  44914. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44915. */
  44916. protected _invertNormalMapY: boolean;
  44917. /**
  44918. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44919. */
  44920. protected _twoSidedLighting: boolean;
  44921. /**
  44922. * Defines the alpha limits in alpha test mode.
  44923. */
  44924. protected _alphaCutOff: number;
  44925. /**
  44926. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44927. */
  44928. protected _forceAlphaTest: boolean;
  44929. /**
  44930. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44931. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44932. */
  44933. protected _useAlphaFresnel: boolean;
  44934. /**
  44935. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44936. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44937. */
  44938. protected _useLinearAlphaFresnel: boolean;
  44939. /**
  44940. * The transparency mode of the material.
  44941. */
  44942. protected _transparencyMode: Nullable<number>;
  44943. /**
  44944. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44945. * from cos thetav and roughness:
  44946. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44947. */
  44948. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44949. /**
  44950. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44951. */
  44952. protected _forceIrradianceInFragment: boolean;
  44953. /**
  44954. * Force normal to face away from face.
  44955. */
  44956. protected _forceNormalForward: boolean;
  44957. /**
  44958. * Enables specular anti aliasing in the PBR shader.
  44959. * It will both interacts on the Geometry for analytical and IBL lighting.
  44960. * It also prefilter the roughness map based on the bump values.
  44961. */
  44962. protected _enableSpecularAntiAliasing: boolean;
  44963. /**
  44964. * Default configuration related to image processing available in the PBR Material.
  44965. */
  44966. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44967. /**
  44968. * Keep track of the image processing observer to allow dispose and replace.
  44969. */
  44970. private _imageProcessingObserver;
  44971. /**
  44972. * Attaches a new image processing configuration to the PBR Material.
  44973. * @param configuration
  44974. */
  44975. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44976. /**
  44977. * Stores the available render targets.
  44978. */
  44979. private _renderTargets;
  44980. /**
  44981. * Sets the global ambient color for the material used in lighting calculations.
  44982. */
  44983. private _globalAmbientColor;
  44984. /**
  44985. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44986. */
  44987. private _useLogarithmicDepth;
  44988. /**
  44989. * If set to true, no lighting calculations will be applied.
  44990. */
  44991. private _unlit;
  44992. /**
  44993. * Instantiates a new PBRMaterial instance.
  44994. *
  44995. * @param name The material name
  44996. * @param scene The scene the material will be use in.
  44997. */
  44998. constructor(name: string, scene: Scene);
  44999. /**
  45000. * Gets a boolean indicating that current material needs to register RTT
  45001. */
  45002. readonly hasRenderTargetTextures: boolean;
  45003. /**
  45004. * Gets the name of the material class.
  45005. */
  45006. getClassName(): string;
  45007. /**
  45008. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45009. */
  45010. /**
  45011. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45012. */
  45013. useLogarithmicDepth: boolean;
  45014. /**
  45015. * Gets the current transparency mode.
  45016. */
  45017. /**
  45018. * Sets the transparency mode of the material.
  45019. *
  45020. * | Value | Type | Description |
  45021. * | ----- | ----------------------------------- | ----------- |
  45022. * | 0 | OPAQUE | |
  45023. * | 1 | ALPHATEST | |
  45024. * | 2 | ALPHABLEND | |
  45025. * | 3 | ALPHATESTANDBLEND | |
  45026. *
  45027. */
  45028. transparencyMode: Nullable<number>;
  45029. /**
  45030. * Returns true if alpha blending should be disabled.
  45031. */
  45032. private readonly _disableAlphaBlending;
  45033. /**
  45034. * Specifies whether or not this material should be rendered in alpha blend mode.
  45035. */
  45036. needAlphaBlending(): boolean;
  45037. /**
  45038. * Specifies if the mesh will require alpha blending.
  45039. * @param mesh - BJS mesh.
  45040. */
  45041. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45042. /**
  45043. * Specifies whether or not this material should be rendered in alpha test mode.
  45044. */
  45045. needAlphaTesting(): boolean;
  45046. /**
  45047. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45048. */
  45049. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45050. /**
  45051. * Gets the texture used for the alpha test.
  45052. */
  45053. getAlphaTestTexture(): BaseTexture;
  45054. /**
  45055. * Stores the reflectivity values based on metallic roughness workflow.
  45056. */
  45057. private static _scaledReflectivity;
  45058. /**
  45059. * Specifies that the submesh is ready to be used.
  45060. * @param mesh - BJS mesh.
  45061. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45062. * @param useInstances - Specifies that instances should be used.
  45063. * @returns - boolean indicating that the submesh is ready or not.
  45064. */
  45065. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45066. /**
  45067. * Specifies if the material uses metallic roughness workflow.
  45068. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45069. */
  45070. isMetallicWorkflow(): boolean;
  45071. private _prepareEffect;
  45072. private _prepareDefines;
  45073. /**
  45074. * Force shader compilation
  45075. */
  45076. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45077. clipPlane: boolean;
  45078. }>): void;
  45079. /**
  45080. * Initializes the uniform buffer layout for the shader.
  45081. */
  45082. buildUniformLayout(): void;
  45083. /**
  45084. * Unbinds the textures.
  45085. */
  45086. unbind(): void;
  45087. /**
  45088. * Binds the submesh data.
  45089. * @param world - The world matrix.
  45090. * @param mesh - The BJS mesh.
  45091. * @param subMesh - A submesh of the BJS mesh.
  45092. */
  45093. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45094. /**
  45095. * Returns the animatable textures.
  45096. * @returns - Array of animatable textures.
  45097. */
  45098. getAnimatables(): IAnimatable[];
  45099. /**
  45100. * Returns the texture used for reflections.
  45101. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45102. */
  45103. private _getReflectionTexture;
  45104. /**
  45105. * Returns the texture used for refraction or null if none is used.
  45106. * @returns - Refection texture if present. If no refraction texture and refraction
  45107. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45108. */
  45109. private _getRefractionTexture;
  45110. /**
  45111. * Disposes the resources of the material.
  45112. * @param forceDisposeEffect - Forces the disposal of effects.
  45113. * @param forceDisposeTextures - Forces the disposal of all textures.
  45114. */
  45115. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45116. }
  45117. }
  45118. declare module BABYLON {
  45119. /**
  45120. * The Physically based simple base material of BJS.
  45121. *
  45122. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45123. * It is used as the base class for both the specGloss and metalRough conventions.
  45124. */
  45125. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45126. /**
  45127. * Number of Simultaneous lights allowed on the material.
  45128. */
  45129. maxSimultaneousLights: number;
  45130. /**
  45131. * If sets to true, disables all the lights affecting the material.
  45132. */
  45133. disableLighting: boolean;
  45134. /**
  45135. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45136. */
  45137. environmentTexture: BaseTexture;
  45138. /**
  45139. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45140. */
  45141. invertNormalMapX: boolean;
  45142. /**
  45143. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45144. */
  45145. invertNormalMapY: boolean;
  45146. /**
  45147. * Normal map used in the model.
  45148. */
  45149. normalTexture: BaseTexture;
  45150. /**
  45151. * Emissivie color used to self-illuminate the model.
  45152. */
  45153. emissiveColor: Color3;
  45154. /**
  45155. * Emissivie texture used to self-illuminate the model.
  45156. */
  45157. emissiveTexture: BaseTexture;
  45158. /**
  45159. * Occlusion Channel Strenght.
  45160. */
  45161. occlusionStrength: number;
  45162. /**
  45163. * Occlusion Texture of the material (adding extra occlusion effects).
  45164. */
  45165. occlusionTexture: BaseTexture;
  45166. /**
  45167. * Defines the alpha limits in alpha test mode.
  45168. */
  45169. alphaCutOff: number;
  45170. /**
  45171. * Gets the current double sided mode.
  45172. */
  45173. /**
  45174. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45175. */
  45176. doubleSided: boolean;
  45177. /**
  45178. * Stores the pre-calculated light information of a mesh in a texture.
  45179. */
  45180. lightmapTexture: BaseTexture;
  45181. /**
  45182. * If true, the light map contains occlusion information instead of lighting info.
  45183. */
  45184. useLightmapAsShadowmap: boolean;
  45185. /**
  45186. * Return the active textures of the material.
  45187. */
  45188. getActiveTextures(): BaseTexture[];
  45189. hasTexture(texture: BaseTexture): boolean;
  45190. /**
  45191. * Instantiates a new PBRMaterial instance.
  45192. *
  45193. * @param name The material name
  45194. * @param scene The scene the material will be use in.
  45195. */
  45196. constructor(name: string, scene: Scene);
  45197. getClassName(): string;
  45198. }
  45199. }
  45200. declare module BABYLON {
  45201. /**
  45202. * The Physically based material of BJS.
  45203. *
  45204. * This offers the main features of a standard PBR material.
  45205. * For more information, please refer to the documentation :
  45206. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45207. */
  45208. class PBRMaterial extends PBRBaseMaterial {
  45209. /**
  45210. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45211. */
  45212. static readonly PBRMATERIAL_OPAQUE: number;
  45213. /**
  45214. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45215. */
  45216. static readonly PBRMATERIAL_ALPHATEST: number;
  45217. /**
  45218. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45219. */
  45220. static readonly PBRMATERIAL_ALPHABLEND: number;
  45221. /**
  45222. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45223. * They are also discarded below the alpha cutoff threshold to improve performances.
  45224. */
  45225. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45226. /**
  45227. * Defines the default value of how much AO map is occluding the analytical lights
  45228. * (point spot...).
  45229. */
  45230. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45231. /**
  45232. * Intensity of the direct lights e.g. the four lights available in your scene.
  45233. * This impacts both the direct diffuse and specular highlights.
  45234. */
  45235. directIntensity: number;
  45236. /**
  45237. * Intensity of the emissive part of the material.
  45238. * This helps controlling the emissive effect without modifying the emissive color.
  45239. */
  45240. emissiveIntensity: number;
  45241. /**
  45242. * Intensity of the environment e.g. how much the environment will light the object
  45243. * either through harmonics for rough material or through the refelction for shiny ones.
  45244. */
  45245. environmentIntensity: number;
  45246. /**
  45247. * This is a special control allowing the reduction of the specular highlights coming from the
  45248. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45249. */
  45250. specularIntensity: number;
  45251. /**
  45252. * Debug Control allowing disabling the bump map on this material.
  45253. */
  45254. disableBumpMap: boolean;
  45255. /**
  45256. * AKA Diffuse Texture in standard nomenclature.
  45257. */
  45258. albedoTexture: BaseTexture;
  45259. /**
  45260. * AKA Occlusion Texture in other nomenclature.
  45261. */
  45262. ambientTexture: BaseTexture;
  45263. /**
  45264. * AKA Occlusion Texture Intensity in other nomenclature.
  45265. */
  45266. ambientTextureStrength: number;
  45267. /**
  45268. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45269. * 1 means it completely occludes it
  45270. * 0 mean it has no impact
  45271. */
  45272. ambientTextureImpactOnAnalyticalLights: number;
  45273. /**
  45274. * Stores the alpha values in a texture.
  45275. */
  45276. opacityTexture: BaseTexture;
  45277. /**
  45278. * Stores the reflection values in a texture.
  45279. */
  45280. reflectionTexture: Nullable<BaseTexture>;
  45281. /**
  45282. * Stores the emissive values in a texture.
  45283. */
  45284. emissiveTexture: BaseTexture;
  45285. /**
  45286. * AKA Specular texture in other nomenclature.
  45287. */
  45288. reflectivityTexture: BaseTexture;
  45289. /**
  45290. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45291. */
  45292. metallicTexture: BaseTexture;
  45293. /**
  45294. * Specifies the metallic scalar of the metallic/roughness workflow.
  45295. * Can also be used to scale the metalness values of the metallic texture.
  45296. */
  45297. metallic: Nullable<number>;
  45298. /**
  45299. * Specifies the roughness scalar of the metallic/roughness workflow.
  45300. * Can also be used to scale the roughness values of the metallic texture.
  45301. */
  45302. roughness: Nullable<number>;
  45303. /**
  45304. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45305. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45306. */
  45307. microSurfaceTexture: BaseTexture;
  45308. /**
  45309. * Stores surface normal data used to displace a mesh in a texture.
  45310. */
  45311. bumpTexture: BaseTexture;
  45312. /**
  45313. * Stores the pre-calculated light information of a mesh in a texture.
  45314. */
  45315. lightmapTexture: BaseTexture;
  45316. /**
  45317. * Stores the refracted light information in a texture.
  45318. */
  45319. refractionTexture: BaseTexture;
  45320. /**
  45321. * The color of a material in ambient lighting.
  45322. */
  45323. ambientColor: Color3;
  45324. /**
  45325. * AKA Diffuse Color in other nomenclature.
  45326. */
  45327. albedoColor: Color3;
  45328. /**
  45329. * AKA Specular Color in other nomenclature.
  45330. */
  45331. reflectivityColor: Color3;
  45332. /**
  45333. * The color reflected from the material.
  45334. */
  45335. reflectionColor: Color3;
  45336. /**
  45337. * The color emitted from the material.
  45338. */
  45339. emissiveColor: Color3;
  45340. /**
  45341. * AKA Glossiness in other nomenclature.
  45342. */
  45343. microSurface: number;
  45344. /**
  45345. * source material index of refraction (IOR)' / 'destination material IOR.
  45346. */
  45347. indexOfRefraction: number;
  45348. /**
  45349. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  45350. */
  45351. invertRefractionY: boolean;
  45352. /**
  45353. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45354. * Materials half opaque for instance using refraction could benefit from this control.
  45355. */
  45356. linkRefractionWithTransparency: boolean;
  45357. /**
  45358. * If true, the light map contains occlusion information instead of lighting info.
  45359. */
  45360. useLightmapAsShadowmap: boolean;
  45361. /**
  45362. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45363. */
  45364. useAlphaFromAlbedoTexture: boolean;
  45365. /**
  45366. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45367. */
  45368. forceAlphaTest: boolean;
  45369. /**
  45370. * Defines the alpha limits in alpha test mode.
  45371. */
  45372. alphaCutOff: number;
  45373. /**
  45374. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45375. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45376. */
  45377. useSpecularOverAlpha: boolean;
  45378. /**
  45379. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45380. */
  45381. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45382. /**
  45383. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45384. */
  45385. useRoughnessFromMetallicTextureAlpha: boolean;
  45386. /**
  45387. * Specifies if the metallic texture contains the roughness information in its green channel.
  45388. */
  45389. useRoughnessFromMetallicTextureGreen: boolean;
  45390. /**
  45391. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45392. */
  45393. useMetallnessFromMetallicTextureBlue: boolean;
  45394. /**
  45395. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45396. */
  45397. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45398. /**
  45399. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45400. */
  45401. useAmbientInGrayScale: boolean;
  45402. /**
  45403. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45404. * The material will try to infer what glossiness each pixel should be.
  45405. */
  45406. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45407. /**
  45408. * BJS is using an harcoded light falloff based on a manually sets up range.
  45409. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45410. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45411. */
  45412. /**
  45413. * BJS is using an harcoded light falloff based on a manually sets up range.
  45414. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45415. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45416. */
  45417. usePhysicalLightFalloff: boolean;
  45418. /**
  45419. * In order to support the falloff compatibility with gltf, a special mode has been added
  45420. * to reproduce the gltf light falloff.
  45421. */
  45422. /**
  45423. * In order to support the falloff compatibility with gltf, a special mode has been added
  45424. * to reproduce the gltf light falloff.
  45425. */
  45426. useGLTFLightFalloff: boolean;
  45427. /**
  45428. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45429. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45430. */
  45431. useRadianceOverAlpha: boolean;
  45432. /**
  45433. * Allows using an object space normal map (instead of tangent space).
  45434. */
  45435. useObjectSpaceNormalMap: boolean;
  45436. /**
  45437. * Allows using the bump map in parallax mode.
  45438. */
  45439. useParallax: boolean;
  45440. /**
  45441. * Allows using the bump map in parallax occlusion mode.
  45442. */
  45443. useParallaxOcclusion: boolean;
  45444. /**
  45445. * Controls the scale bias of the parallax mode.
  45446. */
  45447. parallaxScaleBias: number;
  45448. /**
  45449. * If sets to true, disables all the lights affecting the material.
  45450. */
  45451. disableLighting: boolean;
  45452. /**
  45453. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45454. */
  45455. forceIrradianceInFragment: boolean;
  45456. /**
  45457. * Number of Simultaneous lights allowed on the material.
  45458. */
  45459. maxSimultaneousLights: number;
  45460. /**
  45461. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45462. */
  45463. invertNormalMapX: boolean;
  45464. /**
  45465. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45466. */
  45467. invertNormalMapY: boolean;
  45468. /**
  45469. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45470. */
  45471. twoSidedLighting: boolean;
  45472. /**
  45473. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45474. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45475. */
  45476. useAlphaFresnel: boolean;
  45477. /**
  45478. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45479. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45480. */
  45481. useLinearAlphaFresnel: boolean;
  45482. /**
  45483. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45484. * And/Or occlude the blended part.
  45485. */
  45486. environmentBRDFTexture: Nullable<BaseTexture>;
  45487. /**
  45488. * Force normal to face away from face.
  45489. */
  45490. forceNormalForward: boolean;
  45491. /**
  45492. * Enables specular anti aliasing in the PBR shader.
  45493. * It will both interacts on the Geometry for analytical and IBL lighting.
  45494. * It also prefilter the roughness map based on the bump values.
  45495. */
  45496. enableSpecularAntiAliasing: boolean;
  45497. /**
  45498. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45499. * makes the reflect vector face the model (under horizon).
  45500. */
  45501. useHorizonOcclusion: boolean;
  45502. /**
  45503. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45504. * too much the area relying on ambient texture to define their ambient occlusion.
  45505. */
  45506. useRadianceOcclusion: boolean;
  45507. /**
  45508. * If set to true, no lighting calculations will be applied.
  45509. */
  45510. unlit: boolean;
  45511. /**
  45512. * Gets the image processing configuration used either in this material.
  45513. */
  45514. /**
  45515. * Sets the Default image processing configuration used either in the this material.
  45516. *
  45517. * If sets to null, the scene one is in use.
  45518. */
  45519. imageProcessingConfiguration: ImageProcessingConfiguration;
  45520. /**
  45521. * Gets wether the color curves effect is enabled.
  45522. */
  45523. /**
  45524. * Sets wether the color curves effect is enabled.
  45525. */
  45526. cameraColorCurvesEnabled: boolean;
  45527. /**
  45528. * Gets wether the color grading effect is enabled.
  45529. */
  45530. /**
  45531. * Gets wether the color grading effect is enabled.
  45532. */
  45533. cameraColorGradingEnabled: boolean;
  45534. /**
  45535. * Gets wether tonemapping is enabled or not.
  45536. */
  45537. /**
  45538. * Sets wether tonemapping is enabled or not
  45539. */
  45540. cameraToneMappingEnabled: boolean;
  45541. /**
  45542. * The camera exposure used on this material.
  45543. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45544. * This corresponds to a photographic exposure.
  45545. */
  45546. /**
  45547. * The camera exposure used on this material.
  45548. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45549. * This corresponds to a photographic exposure.
  45550. */
  45551. cameraExposure: number;
  45552. /**
  45553. * Gets The camera contrast used on this material.
  45554. */
  45555. /**
  45556. * Sets The camera contrast used on this material.
  45557. */
  45558. cameraContrast: number;
  45559. /**
  45560. * Gets the Color Grading 2D Lookup Texture.
  45561. */
  45562. /**
  45563. * Sets the Color Grading 2D Lookup Texture.
  45564. */
  45565. cameraColorGradingTexture: Nullable<BaseTexture>;
  45566. /**
  45567. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45568. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45569. * 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;
  45570. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45571. */
  45572. /**
  45573. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45574. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45575. * 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;
  45576. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45577. */
  45578. cameraColorCurves: Nullable<ColorCurves>;
  45579. /**
  45580. * Instantiates a new PBRMaterial instance.
  45581. *
  45582. * @param name The material name
  45583. * @param scene The scene the material will be use in.
  45584. */
  45585. constructor(name: string, scene: Scene);
  45586. /**
  45587. * Returns the name of this material class.
  45588. */
  45589. getClassName(): string;
  45590. /**
  45591. * Returns an array of the actively used textures.
  45592. * @returns - Array of BaseTextures
  45593. */
  45594. getActiveTextures(): BaseTexture[];
  45595. /**
  45596. * Checks to see if a texture is used in the material.
  45597. * @param texture - Base texture to use.
  45598. * @returns - Boolean specifying if a texture is used in the material.
  45599. */
  45600. hasTexture(texture: BaseTexture): boolean;
  45601. /**
  45602. * Makes a duplicate of the current material.
  45603. * @param name - name to use for the new material.
  45604. */
  45605. clone(name: string): PBRMaterial;
  45606. /**
  45607. * Serializes this PBR Material.
  45608. * @returns - An object with the serialized material.
  45609. */
  45610. serialize(): any;
  45611. /**
  45612. * Parses a PBR Material from a serialized object.
  45613. * @param source - Serialized object.
  45614. * @param scene - BJS scene instance.
  45615. * @param rootUrl - url for the scene object
  45616. * @returns - PBRMaterial
  45617. */
  45618. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45619. }
  45620. }
  45621. declare module BABYLON {
  45622. /**
  45623. * The PBR material of BJS following the metal roughness convention.
  45624. *
  45625. * This fits to the PBR convention in the GLTF definition:
  45626. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  45627. */
  45628. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  45629. /**
  45630. * The base color has two different interpretations depending on the value of metalness.
  45631. * When the material is a metal, the base color is the specific measured reflectance value
  45632. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  45633. * of the material.
  45634. */
  45635. baseColor: Color3;
  45636. /**
  45637. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  45638. * well as opacity information in the alpha channel.
  45639. */
  45640. baseTexture: BaseTexture;
  45641. /**
  45642. * Specifies the metallic scalar value of the material.
  45643. * Can also be used to scale the metalness values of the metallic texture.
  45644. */
  45645. metallic: number;
  45646. /**
  45647. * Specifies the roughness scalar value of the material.
  45648. * Can also be used to scale the roughness values of the metallic texture.
  45649. */
  45650. roughness: number;
  45651. /**
  45652. * Texture containing both the metallic value in the B channel and the
  45653. * roughness value in the G channel to keep better precision.
  45654. */
  45655. metallicRoughnessTexture: BaseTexture;
  45656. /**
  45657. * Instantiates a new PBRMetalRoughnessMaterial instance.
  45658. *
  45659. * @param name The material name
  45660. * @param scene The scene the material will be use in.
  45661. */
  45662. constructor(name: string, scene: Scene);
  45663. /**
  45664. * Return the currrent class name of the material.
  45665. */
  45666. getClassName(): string;
  45667. /**
  45668. * Return the active textures of the material.
  45669. */
  45670. getActiveTextures(): BaseTexture[];
  45671. /**
  45672. * Checks to see if a texture is used in the material.
  45673. * @param texture - Base texture to use.
  45674. * @returns - Boolean specifying if a texture is used in the material.
  45675. */
  45676. hasTexture(texture: BaseTexture): boolean;
  45677. /**
  45678. * Makes a duplicate of the current material.
  45679. * @param name - name to use for the new material.
  45680. */
  45681. clone(name: string): PBRMetallicRoughnessMaterial;
  45682. /**
  45683. * Serialize the material to a parsable JSON object.
  45684. */
  45685. serialize(): any;
  45686. /**
  45687. * Parses a JSON object correponding to the serialize function.
  45688. */
  45689. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  45690. }
  45691. }
  45692. declare module BABYLON {
  45693. /**
  45694. * The PBR material of BJS following the specular glossiness convention.
  45695. *
  45696. * This fits to the PBR convention in the GLTF definition:
  45697. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  45698. */
  45699. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  45700. /**
  45701. * Specifies the diffuse color of the material.
  45702. */
  45703. diffuseColor: Color3;
  45704. /**
  45705. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  45706. * channel.
  45707. */
  45708. diffuseTexture: BaseTexture;
  45709. /**
  45710. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  45711. */
  45712. specularColor: Color3;
  45713. /**
  45714. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  45715. */
  45716. glossiness: number;
  45717. /**
  45718. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  45719. */
  45720. specularGlossinessTexture: BaseTexture;
  45721. /**
  45722. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  45723. *
  45724. * @param name The material name
  45725. * @param scene The scene the material will be use in.
  45726. */
  45727. constructor(name: string, scene: Scene);
  45728. /**
  45729. * Return the currrent class name of the material.
  45730. */
  45731. getClassName(): string;
  45732. /**
  45733. * Return the active textures of the material.
  45734. */
  45735. getActiveTextures(): BaseTexture[];
  45736. /**
  45737. * Checks to see if a texture is used in the material.
  45738. * @param texture - Base texture to use.
  45739. * @returns - Boolean specifying if a texture is used in the material.
  45740. */
  45741. hasTexture(texture: BaseTexture): boolean;
  45742. /**
  45743. * Makes a duplicate of the current material.
  45744. * @param name - name to use for the new material.
  45745. */
  45746. clone(name: string): PBRSpecularGlossinessMaterial;
  45747. /**
  45748. * Serialize the material to a parsable JSON object.
  45749. */
  45750. serialize(): any;
  45751. /**
  45752. * Parses a JSON object correponding to the serialize function.
  45753. */
  45754. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  45755. }
  45756. }
  45757. declare module BABYLON {
  45758. /**
  45759. * Base class of all the textures in babylon.
  45760. * It groups all the common properties the materials, post process, lights... might need
  45761. * in order to make a correct use of the texture.
  45762. */
  45763. class BaseTexture {
  45764. /**
  45765. * Default anisotropic filtering level for the application.
  45766. * It is set to 4 as a good tradeoff between perf and quality.
  45767. */
  45768. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  45769. /**
  45770. * Define the name of the texture.
  45771. */
  45772. name: string;
  45773. private _hasAlpha;
  45774. /**
  45775. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  45776. */
  45777. hasAlpha: boolean;
  45778. /**
  45779. * Defines if the alpha value should be determined via the rgb values.
  45780. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  45781. */
  45782. getAlphaFromRGB: boolean;
  45783. /**
  45784. * Intensity or strength of the texture.
  45785. * It is commonly used by materials to fine tune the intensity of the texture
  45786. */
  45787. level: number;
  45788. /**
  45789. * Define the UV chanel to use starting from 0 and defaulting to 0.
  45790. * This is part of the texture as textures usually maps to one uv set.
  45791. */
  45792. coordinatesIndex: number;
  45793. private _coordinatesMode;
  45794. /**
  45795. * How a texture is mapped.
  45796. *
  45797. * | Value | Type | Description |
  45798. * | ----- | ----------------------------------- | ----------- |
  45799. * | 0 | EXPLICIT_MODE | |
  45800. * | 1 | SPHERICAL_MODE | |
  45801. * | 2 | PLANAR_MODE | |
  45802. * | 3 | CUBIC_MODE | |
  45803. * | 4 | PROJECTION_MODE | |
  45804. * | 5 | SKYBOX_MODE | |
  45805. * | 6 | INVCUBIC_MODE | |
  45806. * | 7 | EQUIRECTANGULAR_MODE | |
  45807. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  45808. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  45809. */
  45810. coordinatesMode: number;
  45811. /**
  45812. * | Value | Type | Description |
  45813. * | ----- | ------------------ | ----------- |
  45814. * | 0 | CLAMP_ADDRESSMODE | |
  45815. * | 1 | WRAP_ADDRESSMODE | |
  45816. * | 2 | MIRROR_ADDRESSMODE | |
  45817. */
  45818. wrapU: number;
  45819. /**
  45820. * | Value | Type | Description |
  45821. * | ----- | ------------------ | ----------- |
  45822. * | 0 | CLAMP_ADDRESSMODE | |
  45823. * | 1 | WRAP_ADDRESSMODE | |
  45824. * | 2 | MIRROR_ADDRESSMODE | |
  45825. */
  45826. wrapV: number;
  45827. /**
  45828. * | Value | Type | Description |
  45829. * | ----- | ------------------ | ----------- |
  45830. * | 0 | CLAMP_ADDRESSMODE | |
  45831. * | 1 | WRAP_ADDRESSMODE | |
  45832. * | 2 | MIRROR_ADDRESSMODE | |
  45833. */
  45834. wrapR: number;
  45835. /**
  45836. * With compliant hardware and browser (supporting anisotropic filtering)
  45837. * this defines the level of anisotropic filtering in the texture.
  45838. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  45839. */
  45840. anisotropicFilteringLevel: number;
  45841. /**
  45842. * Define if the texture is a cube texture or if false a 2d texture.
  45843. */
  45844. isCube: boolean;
  45845. /**
  45846. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  45847. */
  45848. is3D: boolean;
  45849. /**
  45850. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  45851. * HDR texture are usually stored in linear space.
  45852. * This only impacts the PBR and Background materials
  45853. */
  45854. gammaSpace: boolean;
  45855. /**
  45856. * Gets whether or not the texture contains RGBD data.
  45857. */
  45858. readonly isRGBD: boolean;
  45859. /**
  45860. * Is Z inverted in the texture (useful in a cube texture).
  45861. */
  45862. invertZ: boolean;
  45863. /**
  45864. * @hidden
  45865. */
  45866. lodLevelInAlpha: boolean;
  45867. /**
  45868. * With prefiltered texture, defined the offset used during the prefiltering steps.
  45869. */
  45870. lodGenerationOffset: number;
  45871. /**
  45872. * With prefiltered texture, defined the scale used during the prefiltering steps.
  45873. */
  45874. lodGenerationScale: number;
  45875. /**
  45876. * Define if the texture is a render target.
  45877. */
  45878. isRenderTarget: boolean;
  45879. /**
  45880. * Define the unique id of the texture in the scene.
  45881. */
  45882. readonly uid: string;
  45883. /**
  45884. * Return a string representation of the texture.
  45885. * @returns the texture as a string
  45886. */
  45887. toString(): string;
  45888. /**
  45889. * Get the class name of the texture.
  45890. * @returns "BaseTexture"
  45891. */
  45892. getClassName(): string;
  45893. /**
  45894. * Define the list of animation attached to the texture.
  45895. */
  45896. animations: Animation[];
  45897. /**
  45898. * An event triggered when the texture is disposed.
  45899. */
  45900. onDisposeObservable: Observable<BaseTexture>;
  45901. private _onDisposeObserver;
  45902. /**
  45903. * Callback triggered when the texture has been disposed.
  45904. * Kept for back compatibility, you can use the onDisposeObservable instead.
  45905. */
  45906. onDispose: () => void;
  45907. /**
  45908. * Define the current state of the loading sequence when in delayed load mode.
  45909. */
  45910. delayLoadState: number;
  45911. private _scene;
  45912. /** @hidden */
  45913. _texture: Nullable<InternalTexture>;
  45914. private _uid;
  45915. /**
  45916. * Define if the texture is preventinga material to render or not.
  45917. * If not and the texture is not ready, the engine will use a default black texture instead.
  45918. */
  45919. readonly isBlocking: boolean;
  45920. /**
  45921. * Instantiates a new BaseTexture.
  45922. * Base class of all the textures in babylon.
  45923. * It groups all the common properties the materials, post process, lights... might need
  45924. * in order to make a correct use of the texture.
  45925. * @param scene Define the scene the texture blongs to
  45926. */
  45927. constructor(scene: Nullable<Scene>);
  45928. /**
  45929. * Get the scene the texture belongs to.
  45930. * @returns the scene or null if undefined
  45931. */
  45932. getScene(): Nullable<Scene>;
  45933. /**
  45934. * Get the texture transform matrix used to offset tile the texture for istance.
  45935. * @returns the transformation matrix
  45936. */
  45937. getTextureMatrix(): Matrix;
  45938. /**
  45939. * Get the texture reflection matrix used to rotate/transform the reflection.
  45940. * @returns the reflection matrix
  45941. */
  45942. getReflectionTextureMatrix(): Matrix;
  45943. /**
  45944. * Get the underlying lower level texture from Babylon.
  45945. * @returns the insternal texture
  45946. */
  45947. getInternalTexture(): Nullable<InternalTexture>;
  45948. /**
  45949. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  45950. * @returns true if ready or not blocking
  45951. */
  45952. isReadyOrNotBlocking(): boolean;
  45953. /**
  45954. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  45955. * @returns true if fully ready
  45956. */
  45957. isReady(): boolean;
  45958. private _cachedSize;
  45959. /**
  45960. * Get the size of the texture.
  45961. * @returns the texture size.
  45962. */
  45963. getSize(): ISize;
  45964. /**
  45965. * Get the base size of the texture.
  45966. * It can be different from the size if the texture has been resized for POT for instance
  45967. * @returns the base size
  45968. */
  45969. getBaseSize(): ISize;
  45970. /**
  45971. * Scales the texture if is `canRescale()`
  45972. * @param ratio the resize factor we want to use to rescale
  45973. */
  45974. scale(ratio: number): void;
  45975. /**
  45976. * Get if the texture can rescale.
  45977. */
  45978. readonly canRescale: boolean;
  45979. /** @hidden */
  45980. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  45981. /** @hidden */
  45982. _rebuild(): void;
  45983. /**
  45984. * Triggers the load sequence in delayed load mode.
  45985. */
  45986. delayLoad(): void;
  45987. /**
  45988. * Clones the texture.
  45989. * @returns the cloned texture
  45990. */
  45991. clone(): Nullable<BaseTexture>;
  45992. /**
  45993. * Get the texture underlying type (INT, FLOAT...)
  45994. */
  45995. readonly textureType: number;
  45996. /**
  45997. * Get the texture underlying format (RGB, RGBA...)
  45998. */
  45999. readonly textureFormat: number;
  46000. /**
  46001. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  46002. * This will returns an RGBA array buffer containing either in values (0-255) or
  46003. * float values (0-1) depending of the underlying buffer type.
  46004. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  46005. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  46006. * @param buffer defines a user defined buffer to fill with data (can be null)
  46007. * @returns The Array buffer containing the pixels data.
  46008. */
  46009. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  46010. /**
  46011. * Release and destroy the underlying lower level texture aka internalTexture.
  46012. */
  46013. releaseInternalTexture(): void;
  46014. /**
  46015. * Get the polynomial representation of the texture data.
  46016. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46017. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46018. */
  46019. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46020. /** @hidden */
  46021. readonly _lodTextureHigh: Nullable<BaseTexture>;
  46022. /** @hidden */
  46023. readonly _lodTextureMid: Nullable<BaseTexture>;
  46024. /** @hidden */
  46025. readonly _lodTextureLow: Nullable<BaseTexture>;
  46026. /**
  46027. * Dispose the texture and release its associated resources.
  46028. */
  46029. dispose(): void;
  46030. /**
  46031. * Serialize the texture into a JSON representation that can be parsed later on.
  46032. * @returns the JSON representation of the texture
  46033. */
  46034. serialize(): any;
  46035. /**
  46036. * Helper function to be called back once a list of texture contains only ready textures.
  46037. * @param textures Define the list of textures to wait for
  46038. * @param callback Define the callback triggered once the entire list will be ready
  46039. */
  46040. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  46041. }
  46042. }
  46043. declare module BABYLON {
  46044. /**
  46045. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46046. * It can help converting any input color in a desired output one. This can then be used to create effects
  46047. * from sepia, black and white to sixties or futuristic rendering...
  46048. *
  46049. * The only supported format is currently 3dl.
  46050. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46051. */
  46052. class ColorGradingTexture extends BaseTexture {
  46053. /**
  46054. * The current texture matrix. (will always be identity in color grading texture)
  46055. */
  46056. private _textureMatrix;
  46057. /**
  46058. * The texture URL.
  46059. */
  46060. url: string;
  46061. /**
  46062. * Empty line regex stored for GC.
  46063. */
  46064. private static _noneEmptyLineRegex;
  46065. private _engine;
  46066. /**
  46067. * Instantiates a ColorGradingTexture from the following parameters.
  46068. *
  46069. * @param url The location of the color gradind data (currently only supporting 3dl)
  46070. * @param scene The scene the texture will be used in
  46071. */
  46072. constructor(url: string, scene: Scene);
  46073. /**
  46074. * Returns the texture matrix used in most of the material.
  46075. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46076. */
  46077. getTextureMatrix(): Matrix;
  46078. /**
  46079. * Occurs when the file being loaded is a .3dl LUT file.
  46080. */
  46081. private load3dlTexture;
  46082. /**
  46083. * Starts the loading process of the texture.
  46084. */
  46085. private loadTexture;
  46086. /**
  46087. * Clones the color gradind texture.
  46088. */
  46089. clone(): ColorGradingTexture;
  46090. /**
  46091. * Called during delayed load for textures.
  46092. */
  46093. delayLoad(): void;
  46094. /**
  46095. * Parses a color grading texture serialized by Babylon.
  46096. * @param parsedTexture The texture information being parsedTexture
  46097. * @param scene The scene to load the texture in
  46098. * @param rootUrl The root url of the data assets to load
  46099. * @return A color gradind texture
  46100. */
  46101. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  46102. /**
  46103. * Serializes the LUT texture to json format.
  46104. */
  46105. serialize(): any;
  46106. }
  46107. }
  46108. declare module BABYLON {
  46109. /**
  46110. * Class for creating a cube texture
  46111. */
  46112. class CubeTexture extends BaseTexture {
  46113. /**
  46114. * The url of the texture
  46115. */
  46116. url: string;
  46117. /**
  46118. * Gets or sets the center of the bounding box associated with the cube texture.
  46119. * It must define where the camera used to render the texture was set
  46120. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46121. */
  46122. boundingBoxPosition: Vector3;
  46123. private _boundingBoxSize;
  46124. /**
  46125. * Gets or sets the size of the bounding box associated with the cube texture
  46126. * When defined, the cubemap will switch to local mode
  46127. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46128. * @example https://www.babylonjs-playground.com/#RNASML
  46129. */
  46130. /**
  46131. * Returns the bounding box size
  46132. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46133. */
  46134. boundingBoxSize: Vector3;
  46135. protected _rotationY: number;
  46136. /**
  46137. * Sets texture matrix rotation angle around Y axis in radians.
  46138. */
  46139. /**
  46140. * Gets texture matrix rotation angle around Y axis radians.
  46141. */
  46142. rotationY: number;
  46143. private _noMipmap;
  46144. private _files;
  46145. private _extensions;
  46146. private _textureMatrix;
  46147. private _format;
  46148. private _createPolynomials;
  46149. /** @hidden */
  46150. readonly _prefiltered: boolean;
  46151. /**
  46152. * Creates a cube texture from an array of image urls
  46153. * @param files defines an array of image urls
  46154. * @param scene defines the hosting scene
  46155. * @param noMipmap specifies if mip maps are not used
  46156. * @returns a cube texture
  46157. */
  46158. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  46159. /**
  46160. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  46161. * @param url defines the url of the prefiltered texture
  46162. * @param scene defines the scene the texture is attached to
  46163. * @param forcedExtension defines the extension of the file if different from the url
  46164. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46165. * @return the prefiltered texture
  46166. */
  46167. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  46168. /**
  46169. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  46170. * as prefiltered data.
  46171. * @param rootUrl defines the url of the texture or the root name of the six images
  46172. * @param scene defines the scene the texture is attached to
  46173. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  46174. * @param noMipmap defines if mipmaps should be created or not
  46175. * @param files defines the six files to load for the different faces
  46176. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  46177. * @param onError defines a callback triggered in case of error during load
  46178. * @param format defines the internal format to use for the texture once loaded
  46179. * @param prefiltered defines whether or not the texture is created from prefiltered data
  46180. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  46181. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46182. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46183. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46184. * @return the cube texture
  46185. */
  46186. 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);
  46187. /**
  46188. * Delays loading of the cube texture
  46189. */
  46190. delayLoad(): void;
  46191. /**
  46192. * Returns the reflection texture matrix
  46193. * @returns the reflection texture matrix
  46194. */
  46195. getReflectionTextureMatrix(): Matrix;
  46196. /**
  46197. * Sets the reflection texture matrix
  46198. * @param value Reflection texture matrix
  46199. */
  46200. setReflectionTextureMatrix(value: Matrix): void;
  46201. /**
  46202. * Parses text to create a cube texture
  46203. * @param parsedTexture define the serialized text to read from
  46204. * @param scene defines the hosting scene
  46205. * @param rootUrl defines the root url of the cube texture
  46206. * @returns a cube texture
  46207. */
  46208. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  46209. /**
  46210. * Makes a clone, or deep copy, of the cube texture
  46211. * @returns a new cube texture
  46212. */
  46213. clone(): CubeTexture;
  46214. }
  46215. }
  46216. declare module BABYLON {
  46217. /**
  46218. * A class extending Texture allowing drawing on a texture
  46219. * @see http://doc.babylonjs.com/how_to/dynamictexture
  46220. */
  46221. class DynamicTexture extends Texture {
  46222. private _generateMipMaps;
  46223. private _canvas;
  46224. private _context;
  46225. private _engine;
  46226. /**
  46227. * Creates a DynamicTexture
  46228. * @param name defines the name of the texture
  46229. * @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
  46230. * @param scene defines the scene where you want the texture
  46231. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46232. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46233. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  46234. */
  46235. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46236. /**
  46237. * Gets the current state of canRescale
  46238. */
  46239. readonly canRescale: boolean;
  46240. private _recreate;
  46241. /**
  46242. * Scales the texture
  46243. * @param ratio the scale factor to apply to both width and height
  46244. */
  46245. scale(ratio: number): void;
  46246. /**
  46247. * Resizes the texture
  46248. * @param width the new width
  46249. * @param height the new height
  46250. */
  46251. scaleTo(width: number, height: number): void;
  46252. /**
  46253. * Gets the context of the canvas used by the texture
  46254. * @returns the canvas context of the dynamic texture
  46255. */
  46256. getContext(): CanvasRenderingContext2D;
  46257. /**
  46258. * Clears the texture
  46259. */
  46260. clear(): void;
  46261. /**
  46262. * Updates the texture
  46263. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46264. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46265. */
  46266. update(invertY?: boolean, premulAlpha?: boolean): void;
  46267. /**
  46268. * Draws text onto the texture
  46269. * @param text defines the text to be drawn
  46270. * @param x defines the placement of the text from the left
  46271. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46272. * @param font defines the font to be used with font-style, font-size, font-name
  46273. * @param color defines the color used for the text
  46274. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46275. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46276. * @param update defines whether texture is immediately update (default is true)
  46277. */
  46278. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  46279. /**
  46280. * Clones the texture
  46281. * @returns the clone of the texture.
  46282. */
  46283. clone(): DynamicTexture;
  46284. /**
  46285. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46286. * @returns a serialized dynamic texture object
  46287. */
  46288. serialize(): any;
  46289. /** @hidden */
  46290. _rebuild(): void;
  46291. }
  46292. }
  46293. declare module BABYLON {
  46294. /**
  46295. * This represents a texture coming from an HDR input.
  46296. *
  46297. * The only supported format is currently panorama picture stored in RGBE format.
  46298. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46299. */
  46300. class HDRCubeTexture extends BaseTexture {
  46301. private static _facesMapping;
  46302. private _generateHarmonics;
  46303. private _noMipmap;
  46304. private _textureMatrix;
  46305. private _size;
  46306. private _onLoad;
  46307. private _onError;
  46308. /**
  46309. * The texture URL.
  46310. */
  46311. url: string;
  46312. /**
  46313. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46314. */
  46315. coordinatesMode: number;
  46316. protected _isBlocking: boolean;
  46317. /**
  46318. * Sets wether or not the texture is blocking during loading.
  46319. */
  46320. /**
  46321. * Gets wether or not the texture is blocking during loading.
  46322. */
  46323. isBlocking: boolean;
  46324. protected _rotationY: number;
  46325. /**
  46326. * Sets texture matrix rotation angle around Y axis in radians.
  46327. */
  46328. /**
  46329. * Gets texture matrix rotation angle around Y axis radians.
  46330. */
  46331. rotationY: number;
  46332. /**
  46333. * Gets or sets the center of the bounding box associated with the cube texture
  46334. * It must define where the camera used to render the texture was set
  46335. */
  46336. boundingBoxPosition: Vector3;
  46337. private _boundingBoxSize;
  46338. /**
  46339. * Gets or sets the size of the bounding box associated with the cube texture
  46340. * When defined, the cubemap will switch to local mode
  46341. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46342. * @example https://www.babylonjs-playground.com/#RNASML
  46343. */
  46344. boundingBoxSize: Vector3;
  46345. /**
  46346. * Instantiates an HDRTexture from the following parameters.
  46347. *
  46348. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  46349. * @param scene The scene the texture will be used in
  46350. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  46351. * @param noMipmap Forces to not generate the mipmap if true
  46352. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  46353. * @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)
  46354. * @param reserved Reserved flag for internal use.
  46355. */
  46356. 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>);
  46357. /**
  46358. * Occurs when the file is raw .hdr file.
  46359. */
  46360. private loadTexture;
  46361. clone(): HDRCubeTexture;
  46362. delayLoad(): void;
  46363. /**
  46364. * Get the texture reflection matrix used to rotate/transform the reflection.
  46365. * @returns the reflection matrix
  46366. */
  46367. getReflectionTextureMatrix(): Matrix;
  46368. /**
  46369. * Set the texture reflection matrix used to rotate/transform the reflection.
  46370. * @param value Define the reflection matrix to set
  46371. */
  46372. setReflectionTextureMatrix(value: Matrix): void;
  46373. /**
  46374. * Parses a JSON representation of an HDR Texture in order to create the texture
  46375. * @param parsedTexture Define the JSON representation
  46376. * @param scene Define the scene the texture should be created in
  46377. * @param rootUrl Define the root url in case we need to load relative dependencies
  46378. * @returns the newly created texture after parsing
  46379. */
  46380. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  46381. serialize(): any;
  46382. }
  46383. }
  46384. declare module BABYLON {
  46385. /**
  46386. * Class used to store data associated with WebGL texture data for the engine
  46387. * This class should not be used directly
  46388. */
  46389. class InternalTexture implements IInternalTextureTracker {
  46390. /**
  46391. * The source of the texture data is unknown
  46392. */
  46393. static DATASOURCE_UNKNOWN: number;
  46394. /**
  46395. * Texture data comes from an URL
  46396. */
  46397. static DATASOURCE_URL: number;
  46398. /**
  46399. * Texture data is only used for temporary storage
  46400. */
  46401. static DATASOURCE_TEMP: number;
  46402. /**
  46403. * Texture data comes from raw data (ArrayBuffer)
  46404. */
  46405. static DATASOURCE_RAW: number;
  46406. /**
  46407. * Texture content is dynamic (video or dynamic texture)
  46408. */
  46409. static DATASOURCE_DYNAMIC: number;
  46410. /**
  46411. * Texture content is generated by rendering to it
  46412. */
  46413. static DATASOURCE_RENDERTARGET: number;
  46414. /**
  46415. * Texture content is part of a multi render target process
  46416. */
  46417. static DATASOURCE_MULTIRENDERTARGET: number;
  46418. /**
  46419. * Texture data comes from a cube data file
  46420. */
  46421. static DATASOURCE_CUBE: number;
  46422. /**
  46423. * Texture data comes from a raw cube data
  46424. */
  46425. static DATASOURCE_CUBERAW: number;
  46426. /**
  46427. * Texture data come from a prefiltered cube data file
  46428. */
  46429. static DATASOURCE_CUBEPREFILTERED: number;
  46430. /**
  46431. * Texture content is raw 3D data
  46432. */
  46433. static DATASOURCE_RAW3D: number;
  46434. /**
  46435. * Texture content is a depth texture
  46436. */
  46437. static DATASOURCE_DEPTHTEXTURE: number;
  46438. /**
  46439. * Texture data comes from a raw cube data encoded with RGBD
  46440. */
  46441. static DATASOURCE_CUBERAW_RGBD: number;
  46442. /**
  46443. * Defines if the texture is ready
  46444. */
  46445. isReady: boolean;
  46446. /**
  46447. * Defines if the texture is a cube texture
  46448. */
  46449. isCube: boolean;
  46450. /**
  46451. * Defines if the texture contains 3D data
  46452. */
  46453. is3D: boolean;
  46454. /**
  46455. * Gets the URL used to load this texture
  46456. */
  46457. url: string;
  46458. /**
  46459. * Gets the sampling mode of the texture
  46460. */
  46461. samplingMode: number;
  46462. /**
  46463. * Gets a boolean indicating if the texture needs mipmaps generation
  46464. */
  46465. generateMipMaps: boolean;
  46466. /**
  46467. * Gets the number of samples used by the texture (WebGL2+ only)
  46468. */
  46469. samples: number;
  46470. /**
  46471. * Gets the type of the texture (int, float...)
  46472. */
  46473. type: number;
  46474. /**
  46475. * Gets the format of the texture (RGB, RGBA...)
  46476. */
  46477. format: number;
  46478. /**
  46479. * Observable called when the texture is loaded
  46480. */
  46481. onLoadedObservable: Observable<InternalTexture>;
  46482. /**
  46483. * Gets the width of the texture
  46484. */
  46485. width: number;
  46486. /**
  46487. * Gets the height of the texture
  46488. */
  46489. height: number;
  46490. /**
  46491. * Gets the depth of the texture
  46492. */
  46493. depth: number;
  46494. /**
  46495. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  46496. */
  46497. baseWidth: number;
  46498. /**
  46499. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  46500. */
  46501. baseHeight: number;
  46502. /**
  46503. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  46504. */
  46505. baseDepth: number;
  46506. /**
  46507. * Gets a boolean indicating if the texture is inverted on Y axis
  46508. */
  46509. invertY: boolean;
  46510. /**
  46511. * Gets or set the previous tracker in the list
  46512. */
  46513. previous: Nullable<IInternalTextureTracker>;
  46514. /**
  46515. * Gets or set the next tracker in the list
  46516. */
  46517. next: Nullable<IInternalTextureTracker>;
  46518. /** @hidden */
  46519. _initialSlot: number;
  46520. /** @hidden */
  46521. _designatedSlot: number;
  46522. /** @hidden */
  46523. _dataSource: number;
  46524. /** @hidden */
  46525. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  46526. /** @hidden */
  46527. _bufferView: Nullable<ArrayBufferView>;
  46528. /** @hidden */
  46529. _bufferViewArray: Nullable<ArrayBufferView[]>;
  46530. /** @hidden */
  46531. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  46532. /** @hidden */
  46533. _size: number;
  46534. /** @hidden */
  46535. _extension: string;
  46536. /** @hidden */
  46537. _files: Nullable<string[]>;
  46538. /** @hidden */
  46539. _workingCanvas: HTMLCanvasElement;
  46540. /** @hidden */
  46541. _workingContext: CanvasRenderingContext2D;
  46542. /** @hidden */
  46543. _framebuffer: Nullable<WebGLFramebuffer>;
  46544. /** @hidden */
  46545. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  46546. /** @hidden */
  46547. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  46548. /** @hidden */
  46549. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  46550. /** @hidden */
  46551. _attachments: Nullable<number[]>;
  46552. /** @hidden */
  46553. _cachedCoordinatesMode: Nullable<number>;
  46554. /** @hidden */
  46555. _cachedWrapU: Nullable<number>;
  46556. /** @hidden */
  46557. _cachedWrapV: Nullable<number>;
  46558. /** @hidden */
  46559. _cachedWrapR: Nullable<number>;
  46560. /** @hidden */
  46561. _cachedAnisotropicFilteringLevel: Nullable<number>;
  46562. /** @hidden */
  46563. _isDisabled: boolean;
  46564. /** @hidden */
  46565. _compression: Nullable<string>;
  46566. /** @hidden */
  46567. _generateStencilBuffer: boolean;
  46568. /** @hidden */
  46569. _generateDepthBuffer: boolean;
  46570. /** @hidden */
  46571. _comparisonFunction: number;
  46572. /** @hidden */
  46573. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  46574. /** @hidden */
  46575. _lodGenerationScale: number;
  46576. /** @hidden */
  46577. _lodGenerationOffset: number;
  46578. /** @hidden */
  46579. _lodTextureHigh: BaseTexture;
  46580. /** @hidden */
  46581. _lodTextureMid: BaseTexture;
  46582. /** @hidden */
  46583. _lodTextureLow: BaseTexture;
  46584. /** @hidden */
  46585. _isRGBD: boolean;
  46586. /** @hidden */
  46587. _webGLTexture: Nullable<WebGLTexture>;
  46588. /** @hidden */
  46589. _references: number;
  46590. private _engine;
  46591. /**
  46592. * Gets the Engine the texture belongs to.
  46593. * @returns The babylon engine
  46594. */
  46595. getEngine(): Engine;
  46596. /**
  46597. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  46598. */
  46599. readonly dataSource: number;
  46600. /**
  46601. * Creates a new InternalTexture
  46602. * @param engine defines the engine to use
  46603. * @param dataSource defines the type of data that will be used
  46604. * @param delayAllocation if the texture allocation should be delayed (default: false)
  46605. */
  46606. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  46607. /**
  46608. * Increments the number of references (ie. the number of Texture that point to it)
  46609. */
  46610. incrementReferences(): void;
  46611. /**
  46612. * Change the size of the texture (not the size of the content)
  46613. * @param width defines the new width
  46614. * @param height defines the new height
  46615. * @param depth defines the new depth (1 by default)
  46616. */
  46617. updateSize(width: int, height: int, depth?: int): void;
  46618. /** @hidden */
  46619. _rebuild(): void;
  46620. /** @hidden */
  46621. _swapAndDie(target: InternalTexture): void;
  46622. /**
  46623. * Dispose the current allocated resources
  46624. */
  46625. dispose(): void;
  46626. }
  46627. }
  46628. declare module BABYLON {
  46629. /**
  46630. * This represents the required contract to create a new type of texture loader.
  46631. */
  46632. interface IInternalTextureLoader {
  46633. /**
  46634. * Defines wether the loader supports cascade loading the different faces.
  46635. */
  46636. supportCascades: boolean;
  46637. /**
  46638. * This returns if the loader support the current file information.
  46639. * @param extension defines the file extension of the file being loaded
  46640. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46641. * @param fallback defines the fallback internal texture if any
  46642. * @param isBase64 defines whether the texture is encoded as a base64
  46643. * @param isBuffer defines whether the texture data are stored as a buffer
  46644. * @returns true if the loader can load the specified file
  46645. */
  46646. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46647. /**
  46648. * Transform the url before loading if required.
  46649. * @param rootUrl the url of the texture
  46650. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46651. * @returns the transformed texture
  46652. */
  46653. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46654. /**
  46655. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46656. * @param rootUrl the url of the texture
  46657. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46658. * @returns the fallback texture
  46659. */
  46660. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46661. /**
  46662. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46663. * @param data contains the texture data
  46664. * @param texture defines the BabylonJS internal texture
  46665. * @param createPolynomials will be true if polynomials have been requested
  46666. * @param onLoad defines the callback to trigger once the texture is ready
  46667. * @param onError defines the callback to trigger in case of error
  46668. */
  46669. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46670. /**
  46671. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46672. * @param data contains the texture data
  46673. * @param texture defines the BabylonJS internal texture
  46674. * @param callback defines the method to call once ready to upload
  46675. */
  46676. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46677. }
  46678. }
  46679. declare module BABYLON {
  46680. /**
  46681. * Internal interface used to track InternalTexture already bound to the GL context
  46682. */
  46683. interface IInternalTextureTracker {
  46684. /**
  46685. * Gets or set the previous tracker in the list
  46686. */
  46687. previous: Nullable<IInternalTextureTracker>;
  46688. /**
  46689. * Gets or set the next tracker in the list
  46690. */
  46691. next: Nullable<IInternalTextureTracker>;
  46692. }
  46693. /**
  46694. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  46695. */
  46696. class DummyInternalTextureTracker {
  46697. /**
  46698. * Gets or set the previous tracker in the list
  46699. */
  46700. previous: Nullable<IInternalTextureTracker>;
  46701. /**
  46702. * Gets or set the next tracker in the list
  46703. */
  46704. next: Nullable<IInternalTextureTracker>;
  46705. }
  46706. }
  46707. declare module BABYLON {
  46708. /**
  46709. * Mirror texture can be used to simulate the view from a mirror in a scene.
  46710. * It will dynamically be rendered every frame to adapt to the camera point of view.
  46711. * You can then easily use it as a reflectionTexture on a flat surface.
  46712. * In case the surface is not a plane, please consider relying on reflection probes.
  46713. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46714. */
  46715. class MirrorTexture extends RenderTargetTexture {
  46716. private scene;
  46717. /**
  46718. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  46719. * It is possible to directly set the mirrorPlane by directly using a BABYLON.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.
  46720. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46721. */
  46722. mirrorPlane: Plane;
  46723. /**
  46724. * Define the blur ratio used to blur the reflection if needed.
  46725. */
  46726. blurRatio: number;
  46727. /**
  46728. * Define the adaptive blur kernel used to blur the reflection if needed.
  46729. * This will autocompute the closest best match for the `blurKernel`
  46730. */
  46731. adaptiveBlurKernel: number;
  46732. /**
  46733. * Define the blur kernel used to blur the reflection if needed.
  46734. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46735. */
  46736. blurKernel: number;
  46737. /**
  46738. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  46739. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46740. */
  46741. blurKernelX: number;
  46742. /**
  46743. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  46744. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46745. */
  46746. blurKernelY: number;
  46747. private _autoComputeBlurKernel;
  46748. protected _onRatioRescale(): void;
  46749. private _updateGammaSpace;
  46750. private _imageProcessingConfigChangeObserver;
  46751. private _transformMatrix;
  46752. private _mirrorMatrix;
  46753. private _savedViewMatrix;
  46754. private _blurX;
  46755. private _blurY;
  46756. private _adaptiveBlurKernel;
  46757. private _blurKernelX;
  46758. private _blurKernelY;
  46759. private _blurRatio;
  46760. /**
  46761. * Instantiates a Mirror Texture.
  46762. * Mirror texture can be used to simulate the view from a mirror in a scene.
  46763. * It will dynamically be rendered every frame to adapt to the camera point of view.
  46764. * You can then easily use it as a reflectionTexture on a flat surface.
  46765. * In case the surface is not a plane, please consider relying on reflection probes.
  46766. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46767. * @param name
  46768. * @param size
  46769. * @param scene
  46770. * @param generateMipMaps
  46771. * @param type
  46772. * @param samplingMode
  46773. * @param generateDepthBuffer
  46774. */
  46775. constructor(name: string, size: number | {
  46776. width: number;
  46777. height: number;
  46778. } | {
  46779. ratio: number;
  46780. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  46781. private _preparePostProcesses;
  46782. /**
  46783. * Clone the mirror texture.
  46784. * @returns the cloned texture
  46785. */
  46786. clone(): MirrorTexture;
  46787. /**
  46788. * Serialize the texture to a JSON representation you could use in Parse later on
  46789. * @returns the serialized JSON representation
  46790. */
  46791. serialize(): any;
  46792. /**
  46793. * Dispose the texture and release its associated resources.
  46794. */
  46795. dispose(): void;
  46796. }
  46797. }
  46798. declare module BABYLON {
  46799. /**
  46800. * Creation options of the multi render target texture.
  46801. */
  46802. interface IMultiRenderTargetOptions {
  46803. /**
  46804. * Define if the texture needs to create mip maps after render.
  46805. */
  46806. generateMipMaps?: boolean;
  46807. /**
  46808. * Define the types of all the draw buffers we want to create
  46809. */
  46810. types?: number[];
  46811. /**
  46812. * Define the sampling modes of all the draw buffers we want to create
  46813. */
  46814. samplingModes?: number[];
  46815. /**
  46816. * Define if a depth buffer is required
  46817. */
  46818. generateDepthBuffer?: boolean;
  46819. /**
  46820. * Define if a stencil buffer is required
  46821. */
  46822. generateStencilBuffer?: boolean;
  46823. /**
  46824. * Define if a depth texture is required instead of a depth buffer
  46825. */
  46826. generateDepthTexture?: boolean;
  46827. /**
  46828. * Define the number of desired draw buffers
  46829. */
  46830. textureCount?: number;
  46831. /**
  46832. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46833. */
  46834. doNotChangeAspectRatio?: boolean;
  46835. /**
  46836. * Define the default type of the buffers we are creating
  46837. */
  46838. defaultType?: number;
  46839. }
  46840. /**
  46841. * A multi render target, like a render target provides the ability to render to a texture.
  46842. * Unlike the render target, it can render to several draw buffers in one draw.
  46843. * This is specially interesting in deferred rendering or for any effects requiring more than
  46844. * just one color from a single pass.
  46845. */
  46846. class MultiRenderTarget extends RenderTargetTexture {
  46847. private _internalTextures;
  46848. private _textures;
  46849. private _multiRenderTargetOptions;
  46850. /**
  46851. * Get if draw buffers are currently supported by the used hardware and browser.
  46852. */
  46853. readonly isSupported: boolean;
  46854. /**
  46855. * Get the list of textures generated by the multi render target.
  46856. */
  46857. readonly textures: Texture[];
  46858. /**
  46859. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46860. */
  46861. readonly depthTexture: Texture;
  46862. /**
  46863. * Set the wrapping mode on U of all the textures we are rendering to.
  46864. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46865. */
  46866. wrapU: number;
  46867. /**
  46868. * Set the wrapping mode on V of all the textures we are rendering to.
  46869. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46870. */
  46871. wrapV: number;
  46872. /**
  46873. * Instantiate a new multi render target texture.
  46874. * A multi render target, like a render target provides the ability to render to a texture.
  46875. * Unlike the render target, it can render to several draw buffers in one draw.
  46876. * This is specially interesting in deferred rendering or for any effects requiring more than
  46877. * just one color from a single pass.
  46878. * @param name Define the name of the texture
  46879. * @param size Define the size of the buffers to render to
  46880. * @param count Define the number of target we are rendering into
  46881. * @param scene Define the scene the texture belongs to
  46882. * @param options Define the options used to create the multi render target
  46883. */
  46884. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46885. /** @hidden */
  46886. _rebuild(): void;
  46887. private _createInternalTextures;
  46888. private _createTextures;
  46889. /**
  46890. * Define the number of samples used if MSAA is enabled.
  46891. */
  46892. samples: number;
  46893. /**
  46894. * Resize all the textures in the multi render target.
  46895. * Be carrefull as it will recreate all the data in the new texture.
  46896. * @param size Define the new size
  46897. */
  46898. resize(size: any): void;
  46899. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46900. /**
  46901. * Dispose the render targets and their associated resources
  46902. */
  46903. dispose(): void;
  46904. /**
  46905. * Release all the underlying texture used as draw buffers.
  46906. */
  46907. releaseInternalTextures(): void;
  46908. }
  46909. }
  46910. declare module BABYLON {
  46911. /**
  46912. * Raw cube texture where the raw buffers are passed in
  46913. */
  46914. class RawCubeTexture extends CubeTexture {
  46915. /**
  46916. * Creates a cube texture where the raw buffers are passed in.
  46917. * @param scene defines the scene the texture is attached to
  46918. * @param data defines the array of data to use to create each face
  46919. * @param size defines the size of the textures
  46920. * @param format defines the format of the data
  46921. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  46922. * @param generateMipMaps defines if the engine should generate the mip levels
  46923. * @param invertY defines if data must be stored with Y axis inverted
  46924. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  46925. * @param compression defines the compression used (null by default)
  46926. */
  46927. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  46928. /**
  46929. * Updates the raw cube texture.
  46930. * @param data defines the data to store
  46931. * @param format defines the data format
  46932. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46933. * @param invertY defines if data must be stored with Y axis inverted
  46934. * @param compression defines the compression used (null by default)
  46935. * @param level defines which level of the texture to update
  46936. */
  46937. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  46938. /**
  46939. * Updates a raw cube texture with RGBD encoded data.
  46940. * @param data defines the array of data [mipmap][face] to use to create each face
  46941. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  46942. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46943. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46944. * @returns a promsie that resolves when the operation is complete
  46945. */
  46946. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  46947. /**
  46948. * Clones the raw cube texture.
  46949. * @return a new cube texture
  46950. */
  46951. clone(): CubeTexture;
  46952. /** @hidden */
  46953. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46954. }
  46955. }
  46956. declare module BABYLON {
  46957. /**
  46958. * Raw texture can help creating a texture directly from an array of data.
  46959. * This can be super useful if you either get the data from an uncompressed source or
  46960. * if you wish to create your texture pixel by pixel.
  46961. */
  46962. class RawTexture extends Texture {
  46963. /**
  46964. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  46965. */
  46966. format: number;
  46967. private _engine;
  46968. /**
  46969. * Instantiates a new RawTexture.
  46970. * Raw texture can help creating a texture directly from an array of data.
  46971. * This can be super useful if you either get the data from an uncompressed source or
  46972. * if you wish to create your texture pixel by pixel.
  46973. * @param data define the array of data to use to create the texture
  46974. * @param width define the width of the texture
  46975. * @param height define the height of the texture
  46976. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  46977. * @param scene define the scene the texture belongs to
  46978. * @param generateMipMaps define whether mip maps should be generated or not
  46979. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46980. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46981. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46982. */
  46983. constructor(data: ArrayBufferView, width: number, height: number,
  46984. /**
  46985. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  46986. */
  46987. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  46988. /**
  46989. * Updates the texture underlying data.
  46990. * @param data Define the new data of the texture
  46991. */
  46992. update(data: ArrayBufferView): void;
  46993. /**
  46994. * Creates a luminance texture from some data.
  46995. * @param data Define the texture data
  46996. * @param width Define the width of the texture
  46997. * @param height Define the height of the texture
  46998. * @param scene Define the scene the texture belongs to
  46999. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47000. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47001. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47002. * @returns the luminance texture
  47003. */
  47004. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47005. /**
  47006. * Creates a luminance alpha texture from some data.
  47007. * @param data Define the texture data
  47008. * @param width Define the width of the texture
  47009. * @param height Define the height of the texture
  47010. * @param scene Define the scene the texture belongs to
  47011. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47012. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47013. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47014. * @returns the luminance alpha texture
  47015. */
  47016. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47017. /**
  47018. * Creates an alpha texture from some data.
  47019. * @param data Define the texture data
  47020. * @param width Define the width of the texture
  47021. * @param height Define the height of the texture
  47022. * @param scene Define the scene the texture belongs to
  47023. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47024. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47025. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47026. * @returns the alpha texture
  47027. */
  47028. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47029. /**
  47030. * Creates a RGB texture from some data.
  47031. * @param data Define the texture data
  47032. * @param width Define the width of the texture
  47033. * @param height Define the height of the texture
  47034. * @param scene Define the scene the texture belongs to
  47035. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47036. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47037. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47038. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47039. * @returns the RGB alpha texture
  47040. */
  47041. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47042. /**
  47043. * Creates a RGBA texture from some data.
  47044. * @param data Define the texture data
  47045. * @param width Define the width of the texture
  47046. * @param height Define the height of the texture
  47047. * @param scene Define the scene the texture belongs to
  47048. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47049. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47050. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47051. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47052. * @returns the RGBA texture
  47053. */
  47054. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47055. /**
  47056. * Creates a R texture from some data.
  47057. * @param data Define the texture data
  47058. * @param width Define the width of the texture
  47059. * @param height Define the height of the texture
  47060. * @param scene Define the scene the texture belongs to
  47061. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47062. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47063. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47064. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47065. * @returns the R texture
  47066. */
  47067. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47068. }
  47069. }
  47070. declare module BABYLON {
  47071. /**
  47072. * Class used to store 3D textures containing user data
  47073. */
  47074. class RawTexture3D extends Texture {
  47075. /** Gets or sets the texture format to use */
  47076. format: number;
  47077. private _engine;
  47078. /**
  47079. * Create a new RawTexture3D
  47080. * @param data defines the data of the texture
  47081. * @param width defines the width of the texture
  47082. * @param height defines the height of the texture
  47083. * @param depth defines the depth of the texture
  47084. * @param format defines the texture format to use
  47085. * @param scene defines the hosting scene
  47086. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47087. * @param invertY defines if texture must be stored with Y axis inverted
  47088. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  47089. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47090. */
  47091. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47092. /** Gets or sets the texture format to use */
  47093. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47094. /**
  47095. * Update the texture with new data
  47096. * @param data defines the data to store in the texture
  47097. */
  47098. update(data: ArrayBufferView): void;
  47099. }
  47100. }
  47101. declare module BABYLON {
  47102. /**
  47103. * Creates a refraction texture used by refraction channel of the standard material.
  47104. * It is like a mirror but to see through a material.
  47105. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47106. */
  47107. class RefractionTexture extends RenderTargetTexture {
  47108. /**
  47109. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47110. * It is possible to directly set the refractionPlane by directly using a BABYLON.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.
  47111. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47112. */
  47113. refractionPlane: Plane;
  47114. /**
  47115. * Define how deep under the surface we should see.
  47116. */
  47117. depth: number;
  47118. /**
  47119. * Creates a refraction texture used by refraction channel of the standard material.
  47120. * It is like a mirror but to see through a material.
  47121. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47122. * @param name Define the texture name
  47123. * @param size Define the size of the underlying texture
  47124. * @param scene Define the scene the refraction belongs to
  47125. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47126. */
  47127. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47128. /**
  47129. * Clone the refraction texture.
  47130. * @returns the cloned texture
  47131. */
  47132. clone(): RefractionTexture;
  47133. /**
  47134. * Serialize the texture to a JSON representation you could use in Parse later on
  47135. * @returns the serialized JSON representation
  47136. */
  47137. serialize(): any;
  47138. }
  47139. }
  47140. declare module BABYLON {
  47141. /**
  47142. * This Helps creating a texture that will be created from a camera in your scene.
  47143. * It is basically a dynamic texture that could be used to create special effects for instance.
  47144. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  47145. */
  47146. class RenderTargetTexture extends Texture {
  47147. isCube: boolean;
  47148. /**
  47149. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  47150. */
  47151. static readonly REFRESHRATE_RENDER_ONCE: number;
  47152. /**
  47153. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  47154. */
  47155. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  47156. /**
  47157. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  47158. * the central point of your effect and can save a lot of performances.
  47159. */
  47160. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  47161. /**
  47162. * Use this predicate to dynamically define the list of mesh you want to render.
  47163. * If set, the renderList property will be overwritten.
  47164. */
  47165. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  47166. private _renderList;
  47167. /**
  47168. * Use this list to define the list of mesh you want to render.
  47169. */
  47170. renderList: Nullable<Array<AbstractMesh>>;
  47171. private _hookArray;
  47172. /**
  47173. * Define if particles should be rendered in your texture.
  47174. */
  47175. renderParticles: boolean;
  47176. /**
  47177. * Define if sprites should be rendered in your texture.
  47178. */
  47179. renderSprites: boolean;
  47180. /**
  47181. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  47182. */
  47183. coordinatesMode: number;
  47184. /**
  47185. * Define the camera used to render the texture.
  47186. */
  47187. activeCamera: Nullable<Camera>;
  47188. /**
  47189. * Override the render function of the texture with your own one.
  47190. */
  47191. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  47192. /**
  47193. * Define if camera post processes should be use while rendering the texture.
  47194. */
  47195. useCameraPostProcesses: boolean;
  47196. /**
  47197. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  47198. */
  47199. ignoreCameraViewport: boolean;
  47200. private _postProcessManager;
  47201. private _postProcesses;
  47202. private _resizeObserver;
  47203. /**
  47204. * An event triggered when the texture is unbind.
  47205. */
  47206. onBeforeBindObservable: Observable<RenderTargetTexture>;
  47207. /**
  47208. * An event triggered when the texture is unbind.
  47209. */
  47210. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  47211. private _onAfterUnbindObserver;
  47212. /**
  47213. * Set a after unbind callback in the texture.
  47214. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  47215. */
  47216. onAfterUnbind: () => void;
  47217. /**
  47218. * An event triggered before rendering the texture
  47219. */
  47220. onBeforeRenderObservable: Observable<number>;
  47221. private _onBeforeRenderObserver;
  47222. /**
  47223. * Set a before render callback in the texture.
  47224. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  47225. */
  47226. onBeforeRender: (faceIndex: number) => void;
  47227. /**
  47228. * An event triggered after rendering the texture
  47229. */
  47230. onAfterRenderObservable: Observable<number>;
  47231. private _onAfterRenderObserver;
  47232. /**
  47233. * Set a after render callback in the texture.
  47234. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  47235. */
  47236. onAfterRender: (faceIndex: number) => void;
  47237. /**
  47238. * An event triggered after the texture clear
  47239. */
  47240. onClearObservable: Observable<Engine>;
  47241. private _onClearObserver;
  47242. /**
  47243. * Set a clear callback in the texture.
  47244. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  47245. */
  47246. onClear: (Engine: Engine) => void;
  47247. /**
  47248. * Define the clear color of the Render Target if it should be different from the scene.
  47249. */
  47250. clearColor: Color4;
  47251. protected _size: number | {
  47252. width: number;
  47253. height: number;
  47254. };
  47255. protected _initialSizeParameter: number | {
  47256. width: number;
  47257. height: number;
  47258. } | {
  47259. ratio: number;
  47260. };
  47261. protected _sizeRatio: Nullable<number>;
  47262. /** @hidden */
  47263. _generateMipMaps: boolean;
  47264. protected _renderingManager: RenderingManager;
  47265. /** @hidden */
  47266. _waitingRenderList: string[];
  47267. protected _doNotChangeAspectRatio: boolean;
  47268. protected _currentRefreshId: number;
  47269. protected _refreshRate: number;
  47270. protected _textureMatrix: Matrix;
  47271. protected _samples: number;
  47272. protected _renderTargetOptions: RenderTargetCreationOptions;
  47273. /**
  47274. * Gets render target creation options that were used.
  47275. */
  47276. readonly renderTargetOptions: RenderTargetCreationOptions;
  47277. protected _engine: Engine;
  47278. protected _onRatioRescale(): void;
  47279. /**
  47280. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  47281. * It must define where the camera used to render the texture is set
  47282. */
  47283. boundingBoxPosition: Vector3;
  47284. private _boundingBoxSize;
  47285. /**
  47286. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  47287. * When defined, the cubemap will switch to local mode
  47288. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47289. * @example https://www.babylonjs-playground.com/#RNASML
  47290. */
  47291. boundingBoxSize: Vector3;
  47292. /**
  47293. * In case the RTT has been created with a depth texture, get the associated
  47294. * depth texture.
  47295. * Otherwise, return null.
  47296. */
  47297. depthStencilTexture: Nullable<InternalTexture>;
  47298. /**
  47299. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  47300. * or used a shadow, depth texture...
  47301. * @param name The friendly name of the texture
  47302. * @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)
  47303. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  47304. * @param generateMipMaps True if mip maps need to be generated after render.
  47305. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  47306. * @param type The type of the buffer in the RTT (int, half float, float...)
  47307. * @param isCube True if a cube texture needs to be created
  47308. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  47309. * @param generateDepthBuffer True to generate a depth buffer
  47310. * @param generateStencilBuffer True to generate a stencil buffer
  47311. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  47312. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  47313. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47314. */
  47315. constructor(name: string, size: number | {
  47316. width: number;
  47317. height: number;
  47318. } | {
  47319. ratio: number;
  47320. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  47321. /**
  47322. * Creates a depth stencil texture.
  47323. * This is only available in WebGL 2 or with the depth texture extension available.
  47324. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  47325. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  47326. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  47327. */
  47328. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  47329. private _processSizeParameter;
  47330. /**
  47331. * Define the number of samples to use in case of MSAA.
  47332. * It defaults to one meaning no MSAA has been enabled.
  47333. */
  47334. samples: number;
  47335. /**
  47336. * Resets the refresh counter of the texture and start bak from scratch.
  47337. * Could be usefull to regenerate the texture if it is setup to render only once.
  47338. */
  47339. resetRefreshCounter(): void;
  47340. /**
  47341. * Define the refresh rate of the texture or the rendering frequency.
  47342. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  47343. */
  47344. refreshRate: number;
  47345. /**
  47346. * Adds a post process to the render target rendering passes.
  47347. * @param postProcess define the post process to add
  47348. */
  47349. addPostProcess(postProcess: PostProcess): void;
  47350. /**
  47351. * Clear all the post processes attached to the render target
  47352. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  47353. */
  47354. clearPostProcesses(dispose?: boolean): void;
  47355. /**
  47356. * Remove one of the post process from the list of attached post processes to the texture
  47357. * @param postProcess define the post process to remove from the list
  47358. */
  47359. removePostProcess(postProcess: PostProcess): void;
  47360. /** @hidden */
  47361. _shouldRender(): boolean;
  47362. /**
  47363. * Gets the actual render size of the texture.
  47364. * @returns the width of the render size
  47365. */
  47366. getRenderSize(): number;
  47367. /**
  47368. * Gets the actual render width of the texture.
  47369. * @returns the width of the render size
  47370. */
  47371. getRenderWidth(): number;
  47372. /**
  47373. * Gets the actual render height of the texture.
  47374. * @returns the height of the render size
  47375. */
  47376. getRenderHeight(): number;
  47377. /**
  47378. * Get if the texture can be rescaled or not.
  47379. */
  47380. readonly canRescale: boolean;
  47381. /**
  47382. * Resize the texture using a ratio.
  47383. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  47384. */
  47385. scale(ratio: number): void;
  47386. /**
  47387. * Get the texture reflection matrix used to rotate/transform the reflection.
  47388. * @returns the reflection matrix
  47389. */
  47390. getReflectionTextureMatrix(): Matrix;
  47391. /**
  47392. * Resize the texture to a new desired size.
  47393. * Be carrefull as it will recreate all the data in the new texture.
  47394. * @param size Define the new size. It can be:
  47395. * - a number for squared texture,
  47396. * - an object containing { width: number, height: number }
  47397. * - or an object containing a ratio { ratio: number }
  47398. */
  47399. resize(size: number | {
  47400. width: number;
  47401. height: number;
  47402. } | {
  47403. ratio: number;
  47404. }): void;
  47405. /**
  47406. * Renders all the objects from the render list into the texture.
  47407. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  47408. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  47409. */
  47410. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  47411. private _bestReflectionRenderTargetDimension;
  47412. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47413. private renderToTarget;
  47414. /**
  47415. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47416. * This allowed control for front to back rendering or reversly depending of the special needs.
  47417. *
  47418. * @param renderingGroupId The rendering group id corresponding to its index
  47419. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47420. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47421. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47422. */
  47423. 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;
  47424. /**
  47425. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47426. *
  47427. * @param renderingGroupId The rendering group id corresponding to its index
  47428. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47429. */
  47430. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47431. /**
  47432. * Clones the texture.
  47433. * @returns the cloned texture
  47434. */
  47435. clone(): RenderTargetTexture;
  47436. /**
  47437. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  47438. * @returns The JSON representation of the texture
  47439. */
  47440. serialize(): any;
  47441. /**
  47442. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  47443. */
  47444. disposeFramebufferObjects(): void;
  47445. /**
  47446. * Dispose the texture and release its associated resources.
  47447. */
  47448. dispose(): void;
  47449. /** @hidden */
  47450. _rebuild(): void;
  47451. /**
  47452. * Clear the info related to rendering groups preventing retention point in material dispose.
  47453. */
  47454. freeRenderingGroups(): void;
  47455. }
  47456. }
  47457. declare module BABYLON {
  47458. /**
  47459. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  47460. * @see http://doc.babylonjs.com/babylon101/materials#texture
  47461. */
  47462. class Texture extends BaseTexture {
  47463. /** nearest is mag = nearest and min = nearest and mip = linear */
  47464. static readonly NEAREST_SAMPLINGMODE: number;
  47465. /** nearest is mag = nearest and min = nearest and mip = linear */
  47466. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  47467. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47468. static readonly BILINEAR_SAMPLINGMODE: number;
  47469. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47470. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  47471. /** Trilinear is mag = linear and min = linear and mip = linear */
  47472. static readonly TRILINEAR_SAMPLINGMODE: number;
  47473. /** Trilinear is mag = linear and min = linear and mip = linear */
  47474. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  47475. /** mag = nearest and min = nearest and mip = nearest */
  47476. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  47477. /** mag = nearest and min = linear and mip = nearest */
  47478. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  47479. /** mag = nearest and min = linear and mip = linear */
  47480. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  47481. /** mag = nearest and min = linear and mip = none */
  47482. static readonly NEAREST_LINEAR: number;
  47483. /** mag = nearest and min = nearest and mip = none */
  47484. static readonly NEAREST_NEAREST: number;
  47485. /** mag = linear and min = nearest and mip = nearest */
  47486. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  47487. /** mag = linear and min = nearest and mip = linear */
  47488. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  47489. /** mag = linear and min = linear and mip = none */
  47490. static readonly LINEAR_LINEAR: number;
  47491. /** mag = linear and min = nearest and mip = none */
  47492. static readonly LINEAR_NEAREST: number;
  47493. /** Explicit coordinates mode */
  47494. static readonly EXPLICIT_MODE: number;
  47495. /** Spherical coordinates mode */
  47496. static readonly SPHERICAL_MODE: number;
  47497. /** Planar coordinates mode */
  47498. static readonly PLANAR_MODE: number;
  47499. /** Cubic coordinates mode */
  47500. static readonly CUBIC_MODE: number;
  47501. /** Projection coordinates mode */
  47502. static readonly PROJECTION_MODE: number;
  47503. /** Inverse Cubic coordinates mode */
  47504. static readonly SKYBOX_MODE: number;
  47505. /** Inverse Cubic coordinates mode */
  47506. static readonly INVCUBIC_MODE: number;
  47507. /** Equirectangular coordinates mode */
  47508. static readonly EQUIRECTANGULAR_MODE: number;
  47509. /** Equirectangular Fixed coordinates mode */
  47510. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  47511. /** Equirectangular Fixed Mirrored coordinates mode */
  47512. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  47513. /** Texture is not repeating outside of 0..1 UVs */
  47514. static readonly CLAMP_ADDRESSMODE: number;
  47515. /** Texture is repeating outside of 0..1 UVs */
  47516. static readonly WRAP_ADDRESSMODE: number;
  47517. /** Texture is repeating and mirrored */
  47518. static readonly MIRROR_ADDRESSMODE: number;
  47519. /**
  47520. * 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
  47521. */
  47522. static UseSerializedUrlIfAny: boolean;
  47523. /**
  47524. * Define the url of the texture.
  47525. */
  47526. url: Nullable<string>;
  47527. /**
  47528. * Define an offset on the texture to offset the u coordinates of the UVs
  47529. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  47530. */
  47531. uOffset: number;
  47532. /**
  47533. * Define an offset on the texture to offset the v coordinates of the UVs
  47534. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  47535. */
  47536. vOffset: number;
  47537. /**
  47538. * Define an offset on the texture to scale the u coordinates of the UVs
  47539. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  47540. */
  47541. uScale: number;
  47542. /**
  47543. * Define an offset on the texture to scale the v coordinates of the UVs
  47544. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  47545. */
  47546. vScale: number;
  47547. /**
  47548. * Define an offset on the texture to rotate around the u coordinates of the UVs
  47549. * @see http://doc.babylonjs.com/how_to/more_materials
  47550. */
  47551. uAng: number;
  47552. /**
  47553. * Define an offset on the texture to rotate around the v coordinates of the UVs
  47554. * @see http://doc.babylonjs.com/how_to/more_materials
  47555. */
  47556. vAng: number;
  47557. /**
  47558. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  47559. * @see http://doc.babylonjs.com/how_to/more_materials
  47560. */
  47561. wAng: number;
  47562. /**
  47563. * Defines the center of rotation (U)
  47564. */
  47565. uRotationCenter: number;
  47566. /**
  47567. * Defines the center of rotation (V)
  47568. */
  47569. vRotationCenter: number;
  47570. /**
  47571. * Defines the center of rotation (W)
  47572. */
  47573. wRotationCenter: number;
  47574. /**
  47575. * Are mip maps generated for this texture or not.
  47576. */
  47577. readonly noMipmap: boolean;
  47578. private _noMipmap;
  47579. /** @hidden */
  47580. _invertY: boolean;
  47581. private _rowGenerationMatrix;
  47582. private _cachedTextureMatrix;
  47583. private _projectionModeMatrix;
  47584. private _t0;
  47585. private _t1;
  47586. private _t2;
  47587. private _cachedUOffset;
  47588. private _cachedVOffset;
  47589. private _cachedUScale;
  47590. private _cachedVScale;
  47591. private _cachedUAng;
  47592. private _cachedVAng;
  47593. private _cachedWAng;
  47594. private _cachedProjectionMatrixId;
  47595. private _cachedCoordinatesMode;
  47596. /** @hidden */
  47597. _samplingMode: number;
  47598. /** @hidden */
  47599. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47600. private _deleteBuffer;
  47601. protected _format: Nullable<number>;
  47602. private _delayedOnLoad;
  47603. private _delayedOnError;
  47604. /**
  47605. * Observable triggered once the texture has been loaded.
  47606. */
  47607. onLoadObservable: Observable<Texture>;
  47608. protected _isBlocking: boolean;
  47609. /**
  47610. * Is the texture preventing material to render while loading.
  47611. * If false, a default texture will be used instead of the loading one during the preparation step.
  47612. */
  47613. isBlocking: boolean;
  47614. /**
  47615. * Get the current sampling mode associated with the texture.
  47616. */
  47617. readonly samplingMode: number;
  47618. /**
  47619. * Instantiates a new texture.
  47620. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  47621. * @see http://doc.babylonjs.com/babylon101/materials#texture
  47622. * @param url define the url of the picture to load as a texture
  47623. * @param scene define the scene the texture will belong to
  47624. * @param noMipmap define if the texture will require mip maps or not
  47625. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47626. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47627. * @param onLoad define a callback triggered when the texture has been loaded
  47628. * @param onError define a callback triggered when an error occurred during the loading session
  47629. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  47630. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  47631. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47632. */
  47633. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  47634. /**
  47635. * Update the url (and optional buffer) of this texture if url was null during construction.
  47636. * @param url the url of the texture
  47637. * @param buffer the buffer of the texture (defaults to null)
  47638. */
  47639. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  47640. /**
  47641. * Finish the loading sequence of a texture flagged as delayed load.
  47642. * @hidden
  47643. */
  47644. delayLoad(): void;
  47645. /**
  47646. * Update the sampling mode of the texture.
  47647. * Default is Trilinear mode.
  47648. *
  47649. * | Value | Type | Description |
  47650. * | ----- | ------------------ | ----------- |
  47651. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  47652. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  47653. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  47654. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  47655. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  47656. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  47657. * | 7 | NEAREST_LINEAR | |
  47658. * | 8 | NEAREST_NEAREST | |
  47659. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  47660. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  47661. * | 11 | LINEAR_LINEAR | |
  47662. * | 12 | LINEAR_NEAREST | |
  47663. *
  47664. * > _mag_: magnification filter (close to the viewer)
  47665. * > _min_: minification filter (far from the viewer)
  47666. * > _mip_: filter used between mip map levels
  47667. *@param samplingMode Define the new sampling mode of the texture
  47668. */
  47669. updateSamplingMode(samplingMode: number): void;
  47670. private _prepareRowForTextureGeneration;
  47671. /**
  47672. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  47673. * @returns the transform matrix of the texture.
  47674. */
  47675. getTextureMatrix(): Matrix;
  47676. /**
  47677. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  47678. * @returns The reflection texture transform
  47679. */
  47680. getReflectionTextureMatrix(): Matrix;
  47681. /**
  47682. * Clones the texture.
  47683. * @returns the cloned texture
  47684. */
  47685. clone(): Texture;
  47686. /**
  47687. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  47688. * @returns The JSON representation of the texture
  47689. */
  47690. serialize(): any;
  47691. /**
  47692. * Get the current class name of the texture usefull for serialization or dynamic coding.
  47693. * @returns "Texture"
  47694. */
  47695. getClassName(): string;
  47696. /**
  47697. * Dispose the texture and release its associated resources.
  47698. */
  47699. dispose(): void;
  47700. /**
  47701. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  47702. * @param parsedTexture Define the JSON representation of the texture
  47703. * @param scene Define the scene the parsed texture should be instantiated in
  47704. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47705. * @returns The parsed texture if successful
  47706. */
  47707. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  47708. /**
  47709. * Creates a texture from its base 64 representation.
  47710. * @param data Define the base64 payload without the data: prefix
  47711. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  47712. * @param scene Define the scene the texture should belong to
  47713. * @param noMipmap Forces the texture to not create mip map information if true
  47714. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47715. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47716. * @param onLoad define a callback triggered when the texture has been loaded
  47717. * @param onError define a callback triggered when an error occurred during the loading session
  47718. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47719. * @returns the created texture
  47720. */
  47721. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  47722. /**
  47723. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  47724. * @param data Define the base64 payload without the data: prefix
  47725. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  47726. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  47727. * @param scene Define the scene the texture should belong to
  47728. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  47729. * @param noMipmap Forces the texture to not create mip map information if true
  47730. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47731. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47732. * @param onLoad define a callback triggered when the texture has been loaded
  47733. * @param onError define a callback triggered when an error occurred during the loading session
  47734. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47735. * @returns the created texture
  47736. */
  47737. 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;
  47738. }
  47739. }
  47740. declare module BABYLON {
  47741. /**
  47742. * Settings for finer control over video usage
  47743. */
  47744. interface VideoTextureSettings {
  47745. /**
  47746. * Applies `autoplay` to video, if specified
  47747. */
  47748. autoPlay?: boolean;
  47749. /**
  47750. * Applies `loop` to video, if specified
  47751. */
  47752. loop?: boolean;
  47753. /**
  47754. * Automatically updates internal texture from video at every frame in the render loop
  47755. */
  47756. autoUpdateTexture: boolean;
  47757. /**
  47758. * Image src displayed during the video loading or until the user interacts with the video.
  47759. */
  47760. poster?: string;
  47761. }
  47762. /**
  47763. * If you want to display a video in your scene, this is the special texture for that.
  47764. * This special texture works similar to other textures, with the exception of a few parameters.
  47765. * @see https://doc.babylonjs.com/how_to/video_texture
  47766. */
  47767. class VideoTexture extends Texture {
  47768. /**
  47769. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  47770. */
  47771. readonly autoUpdateTexture: boolean;
  47772. /**
  47773. * The video instance used by the texture internally
  47774. */
  47775. readonly video: HTMLVideoElement;
  47776. private _onUserActionRequestedObservable;
  47777. /**
  47778. * Event triggerd when a dom action is required by the user to play the video.
  47779. * This happens due to recent changes in browser policies preventing video to auto start.
  47780. */
  47781. readonly onUserActionRequestedObservable: Observable<Texture>;
  47782. private _generateMipMaps;
  47783. private _engine;
  47784. private _stillImageCaptured;
  47785. private _poster;
  47786. /**
  47787. * Creates a video texture.
  47788. * If you want to display a video in your scene, this is the special texture for that.
  47789. * This special texture works similar to other textures, with the exception of a few parameters.
  47790. * @see https://doc.babylonjs.com/how_to/video_texture
  47791. * @param name optional name, will detect from video source, if not defined
  47792. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  47793. * @param scene is obviously the current scene.
  47794. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  47795. * @param invertY is false by default but can be used to invert video on Y axis
  47796. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  47797. * @param settings allows finer control over video usage
  47798. */
  47799. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  47800. private _getName;
  47801. private _getVideo;
  47802. private _createInternalTexture;
  47803. private reset;
  47804. /**
  47805. * @hidden Internal method to initiate `update`.
  47806. */
  47807. _rebuild(): void;
  47808. /**
  47809. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  47810. */
  47811. update(): void;
  47812. /**
  47813. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  47814. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  47815. */
  47816. updateTexture(isVisible: boolean): void;
  47817. protected _updateInternalTexture: (e?: Event | undefined) => void;
  47818. /**
  47819. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  47820. * @param url New url.
  47821. */
  47822. updateURL(url: string): void;
  47823. /**
  47824. * Dispose the texture and release its associated resources.
  47825. */
  47826. dispose(): void;
  47827. /**
  47828. * Creates a video texture straight from your WebCam video feed.
  47829. * @param scene Define the scene the texture should be created in
  47830. * @param onReady Define a callback to triggered once the texture will be ready
  47831. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  47832. */
  47833. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  47834. minWidth: number;
  47835. maxWidth: number;
  47836. minHeight: number;
  47837. maxHeight: number;
  47838. deviceId: string;
  47839. }): void;
  47840. }
  47841. }
  47842. declare var DracoDecoderModule: any;
  47843. declare var WebAssembly: any;
  47844. declare module BABYLON {
  47845. /**
  47846. * Configuration for Draco compression
  47847. */
  47848. interface IDracoCompressionConfiguration {
  47849. /**
  47850. * Configuration for the decoder.
  47851. */
  47852. decoder?: {
  47853. /**
  47854. * The url to the WebAssembly module.
  47855. */
  47856. wasmUrl?: string;
  47857. /**
  47858. * The url to the WebAssembly binary.
  47859. */
  47860. wasmBinaryUrl?: string;
  47861. /**
  47862. * The url to the fallback JavaScript module.
  47863. */
  47864. fallbackUrl?: string;
  47865. };
  47866. }
  47867. /**
  47868. * Draco compression (https://google.github.io/draco/)
  47869. *
  47870. * This class wraps the Draco module.
  47871. *
  47872. * **Encoder**
  47873. *
  47874. * The encoder is not currently implemented.
  47875. *
  47876. * **Decoder**
  47877. *
  47878. * 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.
  47879. *
  47880. * To update the configuration, use the following code:
  47881. * ```javascript
  47882. * BABYLON.DracoCompression.Configuration = {
  47883. * decoder: {
  47884. * wasmUrl: "<url to the WebAssembly library>",
  47885. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  47886. * fallbackUrl: "<url to the fallback JavaScript library>",
  47887. * }
  47888. * };
  47889. * ```
  47890. *
  47891. * 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.
  47892. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  47893. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  47894. *
  47895. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  47896. * ```javascript
  47897. * var dracoCompression = new BABYLON.DracoCompression();
  47898. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  47899. * [BABYLON.VertexBuffer.PositionKind]: 0
  47900. * });
  47901. * ```
  47902. *
  47903. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  47904. */
  47905. class DracoCompression implements IDisposable {
  47906. private static _DecoderModulePromise;
  47907. /**
  47908. * The configuration. Defaults to the following urls:
  47909. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  47910. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  47911. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  47912. */
  47913. static Configuration: IDracoCompressionConfiguration;
  47914. /**
  47915. * Returns true if the decoder is available.
  47916. */
  47917. static readonly DecoderAvailable: boolean;
  47918. /**
  47919. * Constructor
  47920. */
  47921. constructor();
  47922. /**
  47923. * Stop all async operations and release resources.
  47924. */
  47925. dispose(): void;
  47926. /**
  47927. * Decode Draco compressed mesh data to vertex data.
  47928. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  47929. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  47930. * @returns A promise that resolves with the decoded vertex data
  47931. */
  47932. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  47933. [kind: string]: number;
  47934. }): Promise<VertexData>;
  47935. private static _GetDecoderModule;
  47936. private static _LoadScriptAsync;
  47937. private static _LoadFileAsync;
  47938. }
  47939. }
  47940. declare module BABYLON {
  47941. /** @hidden */
  47942. class CannonJSPlugin implements IPhysicsEnginePlugin {
  47943. private _useDeltaForWorldStep;
  47944. world: any;
  47945. name: string;
  47946. private _physicsMaterials;
  47947. private _fixedTimeStep;
  47948. BJSCANNON: any;
  47949. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  47950. setGravity(gravity: Vector3): void;
  47951. setTimeStep(timeStep: number): void;
  47952. getTimeStep(): number;
  47953. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47954. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47955. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47956. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47957. private _processChildMeshes;
  47958. removePhysicsBody(impostor: PhysicsImpostor): void;
  47959. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47960. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47961. private _addMaterial;
  47962. private _checkWithEpsilon;
  47963. private _createShape;
  47964. private _createHeightmap;
  47965. private _minus90X;
  47966. private _plus90X;
  47967. private _tmpPosition;
  47968. private _tmpDeltaPosition;
  47969. private _tmpUnityRotation;
  47970. private _updatePhysicsBodyTransformation;
  47971. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47972. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47973. isSupported(): boolean;
  47974. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47975. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47976. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47977. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47978. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47979. getBodyMass(impostor: PhysicsImpostor): number;
  47980. getBodyFriction(impostor: PhysicsImpostor): number;
  47981. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47982. getBodyRestitution(impostor: PhysicsImpostor): number;
  47983. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47984. sleepBody(impostor: PhysicsImpostor): void;
  47985. wakeUpBody(impostor: PhysicsImpostor): void;
  47986. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47987. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47988. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47989. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47990. getRadius(impostor: PhysicsImpostor): number;
  47991. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47992. dispose(): void;
  47993. private _extendNamespace;
  47994. }
  47995. }
  47996. declare module BABYLON {
  47997. /** @hidden */
  47998. class OimoJSPlugin implements IPhysicsEnginePlugin {
  47999. world: any;
  48000. name: string;
  48001. BJSOIMO: any;
  48002. constructor(iterations?: number);
  48003. setGravity(gravity: Vector3): void;
  48004. setTimeStep(timeStep: number): void;
  48005. getTimeStep(): number;
  48006. private _tmpImpostorsArray;
  48007. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48008. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48009. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48010. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48011. private _tmpPositionVector;
  48012. removePhysicsBody(impostor: PhysicsImpostor): void;
  48013. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48014. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48015. isSupported(): boolean;
  48016. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48017. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48018. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48019. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48020. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48021. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48022. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48023. getBodyMass(impostor: PhysicsImpostor): number;
  48024. getBodyFriction(impostor: PhysicsImpostor): number;
  48025. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48026. getBodyRestitution(impostor: PhysicsImpostor): number;
  48027. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48028. sleepBody(impostor: PhysicsImpostor): void;
  48029. wakeUpBody(impostor: PhysicsImpostor): void;
  48030. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48031. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  48032. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48033. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48034. getRadius(impostor: PhysicsImpostor): number;
  48035. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48036. dispose(): void;
  48037. }
  48038. }
  48039. declare module BABYLON {
  48040. /**
  48041. * Particle emitter emitting particles from the inside of a box.
  48042. * It emits the particles randomly between 2 given directions.
  48043. */
  48044. class BoxParticleEmitter implements IParticleEmitterType {
  48045. /**
  48046. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48047. */
  48048. direction1: Vector3;
  48049. /**
  48050. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48051. */
  48052. direction2: Vector3;
  48053. /**
  48054. * 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.
  48055. */
  48056. minEmitBox: Vector3;
  48057. /**
  48058. * 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.
  48059. */
  48060. maxEmitBox: Vector3;
  48061. /**
  48062. * Creates a new instance BoxParticleEmitter
  48063. */
  48064. constructor();
  48065. /**
  48066. * Called by the particle System when the direction is computed for the created particle.
  48067. * @param worldMatrix is the world matrix of the particle system
  48068. * @param directionToUpdate is the direction vector to update with the result
  48069. * @param particle is the particle we are computed the direction for
  48070. */
  48071. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48072. /**
  48073. * Called by the particle System when the position is computed for the created particle.
  48074. * @param worldMatrix is the world matrix of the particle system
  48075. * @param positionToUpdate is the position vector to update with the result
  48076. * @param particle is the particle we are computed the position for
  48077. */
  48078. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48079. /**
  48080. * Clones the current emitter and returns a copy of it
  48081. * @returns the new emitter
  48082. */
  48083. clone(): BoxParticleEmitter;
  48084. /**
  48085. * Called by the GPUParticleSystem to setup the update shader
  48086. * @param effect defines the update shader
  48087. */
  48088. applyToShader(effect: Effect): void;
  48089. /**
  48090. * Returns a string to use to update the GPU particles update shader
  48091. * @returns a string containng the defines string
  48092. */
  48093. getEffectDefines(): string;
  48094. /**
  48095. * Returns the string "BoxParticleEmitter"
  48096. * @returns a string containing the class name
  48097. */
  48098. getClassName(): string;
  48099. /**
  48100. * Serializes the particle system to a JSON object.
  48101. * @returns the JSON object
  48102. */
  48103. serialize(): any;
  48104. /**
  48105. * Parse properties from a JSON object
  48106. * @param serializationObject defines the JSON object
  48107. */
  48108. parse(serializationObject: any): void;
  48109. }
  48110. }
  48111. declare module BABYLON {
  48112. /**
  48113. * Particle emitter emitting particles from the inside of a cone.
  48114. * It emits the particles alongside the cone volume from the base to the particle.
  48115. * The emission direction might be randomized.
  48116. */
  48117. class ConeParticleEmitter implements IParticleEmitterType {
  48118. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48119. directionRandomizer: number;
  48120. private _radius;
  48121. private _angle;
  48122. private _height;
  48123. /**
  48124. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  48125. */
  48126. radiusRange: number;
  48127. /**
  48128. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  48129. */
  48130. heightRange: number;
  48131. /**
  48132. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  48133. */
  48134. emitFromSpawnPointOnly: boolean;
  48135. /**
  48136. * Gets or sets the radius of the emission cone
  48137. */
  48138. radius: number;
  48139. /**
  48140. * Gets or sets the angle of the emission cone
  48141. */
  48142. angle: number;
  48143. private _buildHeight;
  48144. /**
  48145. * Creates a new instance ConeParticleEmitter
  48146. * @param radius the radius of the emission cone (1 by default)
  48147. * @param angles the cone base angle (PI by default)
  48148. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  48149. */
  48150. constructor(radius?: number, angle?: number,
  48151. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48152. directionRandomizer?: number);
  48153. /**
  48154. * Called by the particle System when the direction is computed for the created particle.
  48155. * @param worldMatrix is the world matrix of the particle system
  48156. * @param directionToUpdate is the direction vector to update with the result
  48157. * @param particle is the particle we are computed the direction for
  48158. */
  48159. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48160. /**
  48161. * Called by the particle System when the position is computed for the created particle.
  48162. * @param worldMatrix is the world matrix of the particle system
  48163. * @param positionToUpdate is the position vector to update with the result
  48164. * @param particle is the particle we are computed the position for
  48165. */
  48166. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48167. /**
  48168. * Clones the current emitter and returns a copy of it
  48169. * @returns the new emitter
  48170. */
  48171. clone(): ConeParticleEmitter;
  48172. /**
  48173. * Called by the GPUParticleSystem to setup the update shader
  48174. * @param effect defines the update shader
  48175. */
  48176. applyToShader(effect: Effect): void;
  48177. /**
  48178. * Returns a string to use to update the GPU particles update shader
  48179. * @returns a string containng the defines string
  48180. */
  48181. getEffectDefines(): string;
  48182. /**
  48183. * Returns the string "ConeParticleEmitter"
  48184. * @returns a string containing the class name
  48185. */
  48186. getClassName(): string;
  48187. /**
  48188. * Serializes the particle system to a JSON object.
  48189. * @returns the JSON object
  48190. */
  48191. serialize(): any;
  48192. /**
  48193. * Parse properties from a JSON object
  48194. * @param serializationObject defines the JSON object
  48195. */
  48196. parse(serializationObject: any): void;
  48197. }
  48198. }
  48199. declare module BABYLON {
  48200. /**
  48201. * Particle emitter emitting particles from the inside of a cylinder.
  48202. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  48203. */
  48204. class CylinderParticleEmitter implements IParticleEmitterType {
  48205. /**
  48206. * The radius of the emission cylinder.
  48207. */
  48208. radius: number;
  48209. /**
  48210. * The height of the emission cylinder.
  48211. */
  48212. height: number;
  48213. /**
  48214. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48215. */
  48216. radiusRange: number;
  48217. /**
  48218. * How much to randomize the particle direction [0-1].
  48219. */
  48220. directionRandomizer: number;
  48221. /**
  48222. * Creates a new instance CylinderParticleEmitter
  48223. * @param radius the radius of the emission cylinder (1 by default)
  48224. * @param height the height of the emission cylinder (1 by default)
  48225. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48226. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48227. */
  48228. constructor(
  48229. /**
  48230. * The radius of the emission cylinder.
  48231. */
  48232. radius?: number,
  48233. /**
  48234. * The height of the emission cylinder.
  48235. */
  48236. height?: number,
  48237. /**
  48238. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48239. */
  48240. radiusRange?: number,
  48241. /**
  48242. * How much to randomize the particle direction [0-1].
  48243. */
  48244. directionRandomizer?: number);
  48245. /**
  48246. * Called by the particle System when the direction is computed for the created particle.
  48247. * @param worldMatrix is the world matrix of the particle system
  48248. * @param directionToUpdate is the direction vector to update with the result
  48249. * @param particle is the particle we are computed the direction for
  48250. */
  48251. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48252. /**
  48253. * Called by the particle System when the position is computed for the created particle.
  48254. * @param worldMatrix is the world matrix of the particle system
  48255. * @param positionToUpdate is the position vector to update with the result
  48256. * @param particle is the particle we are computed the position for
  48257. */
  48258. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48259. /**
  48260. * Clones the current emitter and returns a copy of it
  48261. * @returns the new emitter
  48262. */
  48263. clone(): CylinderParticleEmitter;
  48264. /**
  48265. * Called by the GPUParticleSystem to setup the update shader
  48266. * @param effect defines the update shader
  48267. */
  48268. applyToShader(effect: Effect): void;
  48269. /**
  48270. * Returns a string to use to update the GPU particles update shader
  48271. * @returns a string containng the defines string
  48272. */
  48273. getEffectDefines(): string;
  48274. /**
  48275. * Returns the string "CylinderParticleEmitter"
  48276. * @returns a string containing the class name
  48277. */
  48278. getClassName(): string;
  48279. /**
  48280. * Serializes the particle system to a JSON object.
  48281. * @returns the JSON object
  48282. */
  48283. serialize(): any;
  48284. /**
  48285. * Parse properties from a JSON object
  48286. * @param serializationObject defines the JSON object
  48287. */
  48288. parse(serializationObject: any): void;
  48289. }
  48290. /**
  48291. * Particle emitter emitting particles from the inside of a cylinder.
  48292. * It emits the particles randomly between two vectors.
  48293. */
  48294. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  48295. /**
  48296. * The min limit of the emission direction.
  48297. */
  48298. direction1: Vector3;
  48299. /**
  48300. * The max limit of the emission direction.
  48301. */
  48302. direction2: Vector3;
  48303. /**
  48304. * Creates a new instance CylinderDirectedParticleEmitter
  48305. * @param radius the radius of the emission cylinder (1 by default)
  48306. * @param height the height of the emission cylinder (1 by default)
  48307. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48308. * @param direction1 the min limit of the emission direction (up vector by default)
  48309. * @param direction2 the max limit of the emission direction (up vector by default)
  48310. */
  48311. constructor(radius?: number, height?: number, radiusRange?: number,
  48312. /**
  48313. * The min limit of the emission direction.
  48314. */
  48315. direction1?: Vector3,
  48316. /**
  48317. * The max limit of the emission direction.
  48318. */
  48319. direction2?: Vector3);
  48320. /**
  48321. * Called by the particle System when the direction is computed for the created particle.
  48322. * @param worldMatrix is the world matrix of the particle system
  48323. * @param directionToUpdate is the direction vector to update with the result
  48324. * @param particle is the particle we are computed the direction for
  48325. */
  48326. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48327. /**
  48328. * Clones the current emitter and returns a copy of it
  48329. * @returns the new emitter
  48330. */
  48331. clone(): CylinderDirectedParticleEmitter;
  48332. /**
  48333. * Called by the GPUParticleSystem to setup the update shader
  48334. * @param effect defines the update shader
  48335. */
  48336. applyToShader(effect: Effect): void;
  48337. /**
  48338. * Returns a string to use to update the GPU particles update shader
  48339. * @returns a string containng the defines string
  48340. */
  48341. getEffectDefines(): string;
  48342. /**
  48343. * Returns the string "CylinderDirectedParticleEmitter"
  48344. * @returns a string containing the class name
  48345. */
  48346. getClassName(): string;
  48347. /**
  48348. * Serializes the particle system to a JSON object.
  48349. * @returns the JSON object
  48350. */
  48351. serialize(): any;
  48352. /**
  48353. * Parse properties from a JSON object
  48354. * @param serializationObject defines the JSON object
  48355. */
  48356. parse(serializationObject: any): void;
  48357. }
  48358. }
  48359. declare module BABYLON {
  48360. /**
  48361. * Particle emitter emitting particles from the inside of a hemisphere.
  48362. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  48363. */
  48364. class HemisphericParticleEmitter implements IParticleEmitterType {
  48365. /**
  48366. * The radius of the emission hemisphere.
  48367. */
  48368. radius: number;
  48369. /**
  48370. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48371. */
  48372. radiusRange: number;
  48373. /**
  48374. * How much to randomize the particle direction [0-1].
  48375. */
  48376. directionRandomizer: number;
  48377. /**
  48378. * Creates a new instance HemisphericParticleEmitter
  48379. * @param radius the radius of the emission hemisphere (1 by default)
  48380. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48381. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48382. */
  48383. constructor(
  48384. /**
  48385. * The radius of the emission hemisphere.
  48386. */
  48387. radius?: number,
  48388. /**
  48389. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48390. */
  48391. radiusRange?: number,
  48392. /**
  48393. * How much to randomize the particle direction [0-1].
  48394. */
  48395. directionRandomizer?: number);
  48396. /**
  48397. * Called by the particle System when the direction is computed for the created particle.
  48398. * @param worldMatrix is the world matrix of the particle system
  48399. * @param directionToUpdate is the direction vector to update with the result
  48400. * @param particle is the particle we are computed the direction for
  48401. */
  48402. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48403. /**
  48404. * Called by the particle System when the position is computed for the created particle.
  48405. * @param worldMatrix is the world matrix of the particle system
  48406. * @param positionToUpdate is the position vector to update with the result
  48407. * @param particle is the particle we are computed the position for
  48408. */
  48409. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48410. /**
  48411. * Clones the current emitter and returns a copy of it
  48412. * @returns the new emitter
  48413. */
  48414. clone(): HemisphericParticleEmitter;
  48415. /**
  48416. * Called by the GPUParticleSystem to setup the update shader
  48417. * @param effect defines the update shader
  48418. */
  48419. applyToShader(effect: Effect): void;
  48420. /**
  48421. * Returns a string to use to update the GPU particles update shader
  48422. * @returns a string containng the defines string
  48423. */
  48424. getEffectDefines(): string;
  48425. /**
  48426. * Returns the string "HemisphericParticleEmitter"
  48427. * @returns a string containing the class name
  48428. */
  48429. getClassName(): string;
  48430. /**
  48431. * Serializes the particle system to a JSON object.
  48432. * @returns the JSON object
  48433. */
  48434. serialize(): any;
  48435. /**
  48436. * Parse properties from a JSON object
  48437. * @param serializationObject defines the JSON object
  48438. */
  48439. parse(serializationObject: any): void;
  48440. }
  48441. }
  48442. declare module BABYLON {
  48443. /**
  48444. * Particle emitter represents a volume emitting particles.
  48445. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  48446. */
  48447. interface IParticleEmitterType {
  48448. /**
  48449. * Called by the particle System when the direction is computed for the created particle.
  48450. * @param worldMatrix is the world matrix of the particle system
  48451. * @param directionToUpdate is the direction vector to update with the result
  48452. * @param particle is the particle we are computed the direction for
  48453. */
  48454. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48455. /**
  48456. * Called by the particle System when the position is computed for the created particle.
  48457. * @param worldMatrix is the world matrix of the particle system
  48458. * @param positionToUpdate is the position vector to update with the result
  48459. * @param particle is the particle we are computed the position for
  48460. */
  48461. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48462. /**
  48463. * Clones the current emitter and returns a copy of it
  48464. * @returns the new emitter
  48465. */
  48466. clone(): IParticleEmitterType;
  48467. /**
  48468. * Called by the GPUParticleSystem to setup the update shader
  48469. * @param effect defines the update shader
  48470. */
  48471. applyToShader(effect: Effect): void;
  48472. /**
  48473. * Returns a string to use to update the GPU particles update shader
  48474. * @returns the effect defines string
  48475. */
  48476. getEffectDefines(): string;
  48477. /**
  48478. * Returns a string representing the class name
  48479. * @returns a string containing the class name
  48480. */
  48481. getClassName(): string;
  48482. /**
  48483. * Serializes the particle system to a JSON object.
  48484. * @returns the JSON object
  48485. */
  48486. serialize(): any;
  48487. /**
  48488. * Parse properties from a JSON object
  48489. * @param serializationObject defines the JSON object
  48490. */
  48491. parse(serializationObject: any): void;
  48492. }
  48493. }
  48494. declare module BABYLON {
  48495. /**
  48496. * Particle emitter emitting particles from a point.
  48497. * It emits the particles randomly between 2 given directions.
  48498. */
  48499. class PointParticleEmitter implements IParticleEmitterType {
  48500. /**
  48501. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48502. */
  48503. direction1: Vector3;
  48504. /**
  48505. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48506. */
  48507. direction2: Vector3;
  48508. /**
  48509. * Creates a new instance PointParticleEmitter
  48510. */
  48511. constructor();
  48512. /**
  48513. * Called by the particle System when the direction is computed for the created particle.
  48514. * @param worldMatrix is the world matrix of the particle system
  48515. * @param directionToUpdate is the direction vector to update with the result
  48516. * @param particle is the particle we are computed the direction for
  48517. */
  48518. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48519. /**
  48520. * Called by the particle System when the position is computed for the created particle.
  48521. * @param worldMatrix is the world matrix of the particle system
  48522. * @param positionToUpdate is the position vector to update with the result
  48523. * @param particle is the particle we are computed the position for
  48524. */
  48525. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48526. /**
  48527. * Clones the current emitter and returns a copy of it
  48528. * @returns the new emitter
  48529. */
  48530. clone(): PointParticleEmitter;
  48531. /**
  48532. * Called by the GPUParticleSystem to setup the update shader
  48533. * @param effect defines the update shader
  48534. */
  48535. applyToShader(effect: Effect): void;
  48536. /**
  48537. * Returns a string to use to update the GPU particles update shader
  48538. * @returns a string containng the defines string
  48539. */
  48540. getEffectDefines(): string;
  48541. /**
  48542. * Returns the string "PointParticleEmitter"
  48543. * @returns a string containing the class name
  48544. */
  48545. getClassName(): string;
  48546. /**
  48547. * Serializes the particle system to a JSON object.
  48548. * @returns the JSON object
  48549. */
  48550. serialize(): any;
  48551. /**
  48552. * Parse properties from a JSON object
  48553. * @param serializationObject defines the JSON object
  48554. */
  48555. parse(serializationObject: any): void;
  48556. }
  48557. }
  48558. declare module BABYLON {
  48559. /**
  48560. * Particle emitter emitting particles from the inside of a sphere.
  48561. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  48562. */
  48563. class SphereParticleEmitter implements IParticleEmitterType {
  48564. /**
  48565. * The radius of the emission sphere.
  48566. */
  48567. radius: number;
  48568. /**
  48569. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48570. */
  48571. radiusRange: number;
  48572. /**
  48573. * How much to randomize the particle direction [0-1].
  48574. */
  48575. directionRandomizer: number;
  48576. /**
  48577. * Creates a new instance SphereParticleEmitter
  48578. * @param radius the radius of the emission sphere (1 by default)
  48579. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48580. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48581. */
  48582. constructor(
  48583. /**
  48584. * The radius of the emission sphere.
  48585. */
  48586. radius?: number,
  48587. /**
  48588. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48589. */
  48590. radiusRange?: number,
  48591. /**
  48592. * How much to randomize the particle direction [0-1].
  48593. */
  48594. directionRandomizer?: number);
  48595. /**
  48596. * Called by the particle System when the direction is computed for the created particle.
  48597. * @param worldMatrix is the world matrix of the particle system
  48598. * @param directionToUpdate is the direction vector to update with the result
  48599. * @param particle is the particle we are computed the direction for
  48600. */
  48601. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48602. /**
  48603. * Called by the particle System when the position is computed for the created particle.
  48604. * @param worldMatrix is the world matrix of the particle system
  48605. * @param positionToUpdate is the position vector to update with the result
  48606. * @param particle is the particle we are computed the position for
  48607. */
  48608. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48609. /**
  48610. * Clones the current emitter and returns a copy of it
  48611. * @returns the new emitter
  48612. */
  48613. clone(): SphereParticleEmitter;
  48614. /**
  48615. * Called by the GPUParticleSystem to setup the update shader
  48616. * @param effect defines the update shader
  48617. */
  48618. applyToShader(effect: Effect): void;
  48619. /**
  48620. * Returns a string to use to update the GPU particles update shader
  48621. * @returns a string containng the defines string
  48622. */
  48623. getEffectDefines(): string;
  48624. /**
  48625. * Returns the string "SphereParticleEmitter"
  48626. * @returns a string containing the class name
  48627. */
  48628. getClassName(): string;
  48629. /**
  48630. * Serializes the particle system to a JSON object.
  48631. * @returns the JSON object
  48632. */
  48633. serialize(): any;
  48634. /**
  48635. * Parse properties from a JSON object
  48636. * @param serializationObject defines the JSON object
  48637. */
  48638. parse(serializationObject: any): void;
  48639. }
  48640. /**
  48641. * Particle emitter emitting particles from the inside of a sphere.
  48642. * It emits the particles randomly between two vectors.
  48643. */
  48644. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  48645. /**
  48646. * The min limit of the emission direction.
  48647. */
  48648. direction1: Vector3;
  48649. /**
  48650. * The max limit of the emission direction.
  48651. */
  48652. direction2: Vector3;
  48653. /**
  48654. * Creates a new instance SphereDirectedParticleEmitter
  48655. * @param radius the radius of the emission sphere (1 by default)
  48656. * @param direction1 the min limit of the emission direction (up vector by default)
  48657. * @param direction2 the max limit of the emission direction (up vector by default)
  48658. */
  48659. constructor(radius?: number,
  48660. /**
  48661. * The min limit of the emission direction.
  48662. */
  48663. direction1?: Vector3,
  48664. /**
  48665. * The max limit of the emission direction.
  48666. */
  48667. direction2?: Vector3);
  48668. /**
  48669. * Called by the particle System when the direction is computed for the created particle.
  48670. * @param worldMatrix is the world matrix of the particle system
  48671. * @param directionToUpdate is the direction vector to update with the result
  48672. * @param particle is the particle we are computed the direction for
  48673. */
  48674. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48675. /**
  48676. * Clones the current emitter and returns a copy of it
  48677. * @returns the new emitter
  48678. */
  48679. clone(): SphereDirectedParticleEmitter;
  48680. /**
  48681. * Called by the GPUParticleSystem to setup the update shader
  48682. * @param effect defines the update shader
  48683. */
  48684. applyToShader(effect: Effect): void;
  48685. /**
  48686. * Returns a string to use to update the GPU particles update shader
  48687. * @returns a string containng the defines string
  48688. */
  48689. getEffectDefines(): string;
  48690. /**
  48691. * Returns the string "SphereDirectedParticleEmitter"
  48692. * @returns a string containing the class name
  48693. */
  48694. getClassName(): string;
  48695. /**
  48696. * Serializes the particle system to a JSON object.
  48697. * @returns the JSON object
  48698. */
  48699. serialize(): any;
  48700. /**
  48701. * Parse properties from a JSON object
  48702. * @param serializationObject defines the JSON object
  48703. */
  48704. parse(serializationObject: any): void;
  48705. }
  48706. }
  48707. declare module BABYLON {
  48708. /**
  48709. * This represents a set of one or more post processes in Babylon.
  48710. * A post process can be used to apply a shader to a texture after it is rendered.
  48711. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48712. */
  48713. class PostProcessRenderEffect {
  48714. private _postProcesses;
  48715. private _getPostProcesses;
  48716. private _singleInstance;
  48717. private _cameras;
  48718. private _indicesForCamera;
  48719. /**
  48720. * Name of the effect
  48721. * @hidden
  48722. */
  48723. _name: string;
  48724. /**
  48725. * Instantiates a post process render effect.
  48726. * A post process can be used to apply a shader to a texture after it is rendered.
  48727. * @param engine The engine the effect is tied to
  48728. * @param name The name of the effect
  48729. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  48730. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  48731. */
  48732. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  48733. /**
  48734. * Checks if all the post processes in the effect are supported.
  48735. */
  48736. readonly isSupported: boolean;
  48737. /**
  48738. * Updates the current state of the effect
  48739. * @hidden
  48740. */
  48741. _update(): void;
  48742. /**
  48743. * Attaches the effect on cameras
  48744. * @param cameras The camera to attach to.
  48745. * @hidden
  48746. */
  48747. _attachCameras(cameras: Camera): void;
  48748. /**
  48749. * Attaches the effect on cameras
  48750. * @param cameras The camera to attach to.
  48751. * @hidden
  48752. */
  48753. _attachCameras(cameras: Camera[]): void;
  48754. /**
  48755. * Detatches the effect on cameras
  48756. * @param cameras The camera to detatch from.
  48757. * @hidden
  48758. */
  48759. _detachCameras(cameras: Camera): void;
  48760. /**
  48761. * Detatches the effect on cameras
  48762. * @param cameras The camera to detatch from.
  48763. * @hidden
  48764. */
  48765. _detachCameras(cameras: Camera[]): void;
  48766. /**
  48767. * Enables the effect on given cameras
  48768. * @param cameras The camera to enable.
  48769. * @hidden
  48770. */
  48771. _enable(cameras: Camera): void;
  48772. /**
  48773. * Enables the effect on given cameras
  48774. * @param cameras The camera to enable.
  48775. * @hidden
  48776. */
  48777. _enable(cameras: Nullable<Camera[]>): void;
  48778. /**
  48779. * Disables the effect on the given cameras
  48780. * @param cameras The camera to disable.
  48781. * @hidden
  48782. */
  48783. _disable(cameras: Camera): void;
  48784. /**
  48785. * Disables the effect on the given cameras
  48786. * @param cameras The camera to disable.
  48787. * @hidden
  48788. */
  48789. _disable(cameras: Nullable<Camera[]>): void;
  48790. /**
  48791. * Gets a list of the post processes contained in the effect.
  48792. * @param camera The camera to get the post processes on.
  48793. * @returns The list of the post processes in the effect.
  48794. */
  48795. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  48796. }
  48797. }
  48798. declare module BABYLON {
  48799. /**
  48800. * PostProcessRenderPipeline
  48801. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48802. */
  48803. class PostProcessRenderPipeline {
  48804. private engine;
  48805. private _renderEffects;
  48806. private _renderEffectsForIsolatedPass;
  48807. /**
  48808. * @hidden
  48809. */
  48810. protected _cameras: Camera[];
  48811. /** @hidden */
  48812. _name: string;
  48813. /**
  48814. * Initializes a PostProcessRenderPipeline
  48815. * @param engine engine to add the pipeline to
  48816. * @param name name of the pipeline
  48817. */
  48818. constructor(engine: Engine, name: string);
  48819. /**
  48820. * "PostProcessRenderPipeline"
  48821. * @returns "PostProcessRenderPipeline"
  48822. */
  48823. getClassName(): string;
  48824. /**
  48825. * If all the render effects in the pipeline are support
  48826. */
  48827. readonly isSupported: boolean;
  48828. /**
  48829. * Adds an effect to the pipeline
  48830. * @param renderEffect the effect to add
  48831. */
  48832. addEffect(renderEffect: PostProcessRenderEffect): void;
  48833. /** @hidden */
  48834. _rebuild(): void;
  48835. /** @hidden */
  48836. _enableEffect(renderEffectName: string, cameras: Camera): void;
  48837. /** @hidden */
  48838. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  48839. /** @hidden */
  48840. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  48841. /** @hidden */
  48842. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  48843. /** @hidden */
  48844. _attachCameras(cameras: Camera, unique: boolean): void;
  48845. /** @hidden */
  48846. _attachCameras(cameras: Camera[], unique: boolean): void;
  48847. /** @hidden */
  48848. _detachCameras(cameras: Camera): void;
  48849. /** @hidden */
  48850. _detachCameras(cameras: Nullable<Camera[]>): void;
  48851. /** @hidden */
  48852. _update(): void;
  48853. /** @hidden */
  48854. _reset(): void;
  48855. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  48856. /**
  48857. * Disposes of the pipeline
  48858. */
  48859. dispose(): void;
  48860. }
  48861. }
  48862. declare module BABYLON {
  48863. /**
  48864. * PostProcessRenderPipelineManager class
  48865. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48866. */
  48867. class PostProcessRenderPipelineManager {
  48868. private _renderPipelines;
  48869. /**
  48870. * Initializes a PostProcessRenderPipelineManager
  48871. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48872. */
  48873. constructor();
  48874. /**
  48875. * Adds a pipeline to the manager
  48876. * @param renderPipeline The pipeline to add
  48877. */
  48878. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  48879. /**
  48880. * Attaches a camera to the pipeline
  48881. * @param renderPipelineName The name of the pipeline to attach to
  48882. * @param cameras the camera to attach
  48883. * @param unique if the camera can be attached multiple times to the pipeline
  48884. */
  48885. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  48886. /**
  48887. * Detaches a camera from the pipeline
  48888. * @param renderPipelineName The name of the pipeline to detach from
  48889. * @param cameras the camera to detach
  48890. */
  48891. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  48892. /**
  48893. * Enables an effect by name on a pipeline
  48894. * @param renderPipelineName the name of the pipeline to enable the effect in
  48895. * @param renderEffectName the name of the effect to enable
  48896. * @param cameras the cameras that the effect should be enabled on
  48897. */
  48898. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  48899. /**
  48900. * Disables an effect by name on a pipeline
  48901. * @param renderPipelineName the name of the pipeline to disable the effect in
  48902. * @param renderEffectName the name of the effect to disable
  48903. * @param cameras the cameras that the effect should be disabled on
  48904. */
  48905. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  48906. /**
  48907. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  48908. */
  48909. update(): void;
  48910. /** @hidden */
  48911. _rebuild(): void;
  48912. /**
  48913. * Disposes of the manager and pipelines
  48914. */
  48915. dispose(): void;
  48916. }
  48917. }
  48918. declare module BABYLON {
  48919. interface Scene {
  48920. /** @hidden (Backing field) */
  48921. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  48922. /**
  48923. * Gets the postprocess render pipeline manager
  48924. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48925. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  48926. */
  48927. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  48928. }
  48929. /**
  48930. * Defines the Render Pipeline scene component responsible to rendering pipelines
  48931. */
  48932. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  48933. /**
  48934. * The component name helpfull to identify the component in the list of scene components.
  48935. */
  48936. readonly name: string;
  48937. /**
  48938. * The scene the component belongs to.
  48939. */
  48940. scene: Scene;
  48941. /**
  48942. * Creates a new instance of the component for the given scene
  48943. * @param scene Defines the scene to register the component in
  48944. */
  48945. constructor(scene: Scene);
  48946. /**
  48947. * Registers the component in a given scene
  48948. */
  48949. register(): void;
  48950. /**
  48951. * Rebuilds the elements related to this component in case of
  48952. * context lost for instance.
  48953. */
  48954. rebuild(): void;
  48955. /**
  48956. * Disposes the component and the associated ressources
  48957. */
  48958. dispose(): void;
  48959. private _gatherRenderTargets;
  48960. }
  48961. }
  48962. declare module BABYLON {
  48963. /**
  48964. * Helper class dealing with the extraction of spherical polynomial dataArray
  48965. * from a cube map.
  48966. */
  48967. class CubeMapToSphericalPolynomialTools {
  48968. private static FileFaces;
  48969. /**
  48970. * Converts a texture to the according Spherical Polynomial data.
  48971. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48972. *
  48973. * @param texture The texture to extract the information from.
  48974. * @return The Spherical Polynomial data.
  48975. */
  48976. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48977. /**
  48978. * Converts a cubemap to the according Spherical Polynomial data.
  48979. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48980. *
  48981. * @param cubeInfo The Cube map to extract the information from.
  48982. * @return The Spherical Polynomial data.
  48983. */
  48984. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48985. }
  48986. }
  48987. declare module BABYLON {
  48988. /**
  48989. * Header information of HDR texture files.
  48990. */
  48991. interface HDRInfo {
  48992. /**
  48993. * The height of the texture in pixels.
  48994. */
  48995. height: number;
  48996. /**
  48997. * The width of the texture in pixels.
  48998. */
  48999. width: number;
  49000. /**
  49001. * The index of the beginning of the data in the binary file.
  49002. */
  49003. dataPosition: number;
  49004. }
  49005. /**
  49006. * This groups tools to convert HDR texture to native colors array.
  49007. */
  49008. class HDRTools {
  49009. private static Ldexp;
  49010. private static Rgbe2float;
  49011. private static readStringLine;
  49012. /**
  49013. * Reads header information from an RGBE texture stored in a native array.
  49014. * More information on this format are available here:
  49015. * https://en.wikipedia.org/wiki/RGBE_image_format
  49016. *
  49017. * @param uint8array The binary file stored in native array.
  49018. * @return The header information.
  49019. */
  49020. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49021. /**
  49022. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49023. * This RGBE texture needs to store the information as a panorama.
  49024. *
  49025. * More information on this format are available here:
  49026. * https://en.wikipedia.org/wiki/RGBE_image_format
  49027. *
  49028. * @param buffer The binary file stored in an array buffer.
  49029. * @param size The expected size of the extracted cubemap.
  49030. * @return The Cube Map information.
  49031. */
  49032. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49033. /**
  49034. * Returns the pixels data extracted from an RGBE texture.
  49035. * This pixels will be stored left to right up to down in the R G B order in one array.
  49036. *
  49037. * More information on this format are available here:
  49038. * https://en.wikipedia.org/wiki/RGBE_image_format
  49039. *
  49040. * @param uint8array The binary file stored in an array buffer.
  49041. * @param hdrInfo The header information of the file.
  49042. * @return The pixels data in RGB right to left up to down order.
  49043. */
  49044. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49045. private static RGBE_ReadPixels_RLE;
  49046. }
  49047. }
  49048. declare module BABYLON {
  49049. /**
  49050. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49051. */
  49052. interface CubeMapInfo {
  49053. /**
  49054. * The pixel array for the front face.
  49055. * This is stored in format, left to right, up to down format.
  49056. */
  49057. front: Nullable<ArrayBufferView>;
  49058. /**
  49059. * The pixel array for the back face.
  49060. * This is stored in format, left to right, up to down format.
  49061. */
  49062. back: Nullable<ArrayBufferView>;
  49063. /**
  49064. * The pixel array for the left face.
  49065. * This is stored in format, left to right, up to down format.
  49066. */
  49067. left: Nullable<ArrayBufferView>;
  49068. /**
  49069. * The pixel array for the right face.
  49070. * This is stored in format, left to right, up to down format.
  49071. */
  49072. right: Nullable<ArrayBufferView>;
  49073. /**
  49074. * The pixel array for the up face.
  49075. * This is stored in format, left to right, up to down format.
  49076. */
  49077. up: Nullable<ArrayBufferView>;
  49078. /**
  49079. * The pixel array for the down face.
  49080. * This is stored in format, left to right, up to down format.
  49081. */
  49082. down: Nullable<ArrayBufferView>;
  49083. /**
  49084. * The size of the cubemap stored.
  49085. *
  49086. * Each faces will be size * size pixels.
  49087. */
  49088. size: number;
  49089. /**
  49090. * The format of the texture.
  49091. *
  49092. * RGBA, RGB.
  49093. */
  49094. format: number;
  49095. /**
  49096. * The type of the texture data.
  49097. *
  49098. * UNSIGNED_INT, FLOAT.
  49099. */
  49100. type: number;
  49101. /**
  49102. * Specifies whether the texture is in gamma space.
  49103. */
  49104. gammaSpace: boolean;
  49105. }
  49106. /**
  49107. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  49108. */
  49109. class PanoramaToCubeMapTools {
  49110. private static FACE_FRONT;
  49111. private static FACE_BACK;
  49112. private static FACE_RIGHT;
  49113. private static FACE_LEFT;
  49114. private static FACE_DOWN;
  49115. private static FACE_UP;
  49116. /**
  49117. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49118. *
  49119. * @param float32Array The source data.
  49120. * @param inputWidth The width of the input panorama.
  49121. * @param inputHeight The height of the input panorama.
  49122. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49123. * @return The cubemap data
  49124. */
  49125. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49126. private static CreateCubemapTexture;
  49127. private static CalcProjectionSpherical;
  49128. }
  49129. }
  49130. declare module BABYLON {
  49131. }
  49132. declare module BABYLON {
  49133. }
  49134. declare module BABYLON {
  49135. }
  49136. declare module BABYLON {
  49137. }
  49138. declare module BABYLON {
  49139. /**
  49140. * 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.
  49141. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49142. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49143. */
  49144. class CustomProceduralTexture extends ProceduralTexture {
  49145. private _animate;
  49146. private _time;
  49147. private _config;
  49148. private _texturePath;
  49149. /**
  49150. * Instantiates a new Custom Procedural Texture.
  49151. * 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.
  49152. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49153. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49154. * @param name Define the name of the texture
  49155. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49156. * @param size Define the size of the texture to create
  49157. * @param scene Define the scene the texture belongs to
  49158. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49159. * @param generateMipMaps Define if the texture should creates mip maps or not
  49160. */
  49161. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49162. private _loadJson;
  49163. /**
  49164. * Is the texture ready to be used ? (rendered at least once)
  49165. * @returns true if ready, otherwise, false.
  49166. */
  49167. isReady(): boolean;
  49168. /**
  49169. * Render the texture to its associated render target.
  49170. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49171. */
  49172. render(useCameraPostProcess?: boolean): void;
  49173. /**
  49174. * Update the list of dependant textures samplers in the shader.
  49175. */
  49176. updateTextures(): void;
  49177. /**
  49178. * Update the uniform values of the procedural texture in the shader.
  49179. */
  49180. updateShaderUniforms(): void;
  49181. /**
  49182. * Define if the texture animates or not.
  49183. */
  49184. animate: boolean;
  49185. }
  49186. }
  49187. declare module BABYLON {
  49188. /**
  49189. * Class used to generate noise procedural textures
  49190. */
  49191. class NoiseProceduralTexture extends ProceduralTexture {
  49192. private _time;
  49193. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49194. brightness: number;
  49195. /** Defines the number of octaves to process */
  49196. octaves: number;
  49197. /** Defines the level of persistence (0.8 by default) */
  49198. persistence: number;
  49199. /** Gets or sets animation speed factor (default is 1) */
  49200. animationSpeedFactor: number;
  49201. /**
  49202. * Creates a new NoiseProceduralTexture
  49203. * @param name defines the name fo the texture
  49204. * @param size defines the size of the texture (default is 256)
  49205. * @param scene defines the hosting scene
  49206. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49207. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49208. */
  49209. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49210. private _updateShaderUniforms;
  49211. protected _getDefines(): string;
  49212. /** Generate the current state of the procedural texture */
  49213. render(useCameraPostProcess?: boolean): void;
  49214. /**
  49215. * Serializes this noise procedural texture
  49216. * @returns a serialized noise procedural texture object
  49217. */
  49218. serialize(): any;
  49219. /**
  49220. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49221. * @param parsedTexture defines parsed texture data
  49222. * @param scene defines the current scene
  49223. * @param rootUrl defines the root URL containing noise procedural texture information
  49224. * @returns a parsed NoiseProceduralTexture
  49225. */
  49226. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  49227. }
  49228. }
  49229. declare module BABYLON {
  49230. /**
  49231. * 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.
  49232. * This is the base class of any Procedural texture and contains most of the shareable code.
  49233. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49234. */
  49235. class ProceduralTexture extends Texture {
  49236. isCube: boolean;
  49237. /**
  49238. * Define if the texture is enabled or not (disabled texture will not render)
  49239. */
  49240. isEnabled: boolean;
  49241. /**
  49242. * Define if the texture must be cleared before rendering (default is true)
  49243. */
  49244. autoClear: boolean;
  49245. /**
  49246. * Callback called when the texture is generated
  49247. */
  49248. onGenerated: () => void;
  49249. /**
  49250. * Event raised when the texture is generated
  49251. */
  49252. onGeneratedObservable: Observable<ProceduralTexture>;
  49253. /** @hidden */
  49254. _generateMipMaps: boolean;
  49255. /** @hidden **/
  49256. _effect: Effect;
  49257. /** @hidden */
  49258. _textures: {
  49259. [key: string]: Texture;
  49260. };
  49261. private _size;
  49262. private _currentRefreshId;
  49263. private _refreshRate;
  49264. private _vertexBuffers;
  49265. private _indexBuffer;
  49266. private _uniforms;
  49267. private _samplers;
  49268. private _fragment;
  49269. private _floats;
  49270. private _ints;
  49271. private _floatsArrays;
  49272. private _colors3;
  49273. private _colors4;
  49274. private _vectors2;
  49275. private _vectors3;
  49276. private _matrices;
  49277. private _fallbackTexture;
  49278. private _fallbackTextureUsed;
  49279. private _engine;
  49280. private _cachedDefines;
  49281. private _contentUpdateId;
  49282. private _contentData;
  49283. /**
  49284. * Instantiates a new procedural texture.
  49285. * 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.
  49286. * This is the base class of any Procedural texture and contains most of the shareable code.
  49287. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49288. * @param name Define the name of the texture
  49289. * @param size Define the size of the texture to create
  49290. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  49291. * @param scene Define the scene the texture belongs to
  49292. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49293. * @param generateMipMaps Define if the texture should creates mip maps or not
  49294. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  49295. */
  49296. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  49297. /**
  49298. * The effect that is created when initializing the post process.
  49299. * @returns The created effect corrisponding the the postprocess.
  49300. */
  49301. getEffect(): Effect;
  49302. /**
  49303. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  49304. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  49305. */
  49306. getContent(): Nullable<ArrayBufferView>;
  49307. private _createIndexBuffer;
  49308. /** @hidden */
  49309. _rebuild(): void;
  49310. /**
  49311. * Resets the texture in order to recreate its associated resources.
  49312. * This can be called in case of context loss
  49313. */
  49314. reset(): void;
  49315. protected _getDefines(): string;
  49316. /**
  49317. * Is the texture ready to be used ? (rendered at least once)
  49318. * @returns true if ready, otherwise, false.
  49319. */
  49320. isReady(): boolean;
  49321. /**
  49322. * Resets the refresh counter of the texture and start bak from scratch.
  49323. * Could be usefull to regenerate the texture if it is setup to render only once.
  49324. */
  49325. resetRefreshCounter(): void;
  49326. /**
  49327. * Set the fragment shader to use in order to render the texture.
  49328. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  49329. */
  49330. setFragment(fragment: any): void;
  49331. /**
  49332. * Define the refresh rate of the texture or the rendering frequency.
  49333. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  49334. */
  49335. refreshRate: number;
  49336. /** @hidden */
  49337. _shouldRender(): boolean;
  49338. /**
  49339. * Get the size the texture is rendering at.
  49340. * @returns the size (texture is always squared)
  49341. */
  49342. getRenderSize(): number;
  49343. /**
  49344. * Resize the texture to new value.
  49345. * @param size Define the new size the texture should have
  49346. * @param generateMipMaps Define whether the new texture should create mip maps
  49347. */
  49348. resize(size: number, generateMipMaps: boolean): void;
  49349. private _checkUniform;
  49350. /**
  49351. * Set a texture in the shader program used to render.
  49352. * @param name Define the name of the uniform samplers as defined in the shader
  49353. * @param texture Define the texture to bind to this sampler
  49354. * @return the texture itself allowing "fluent" like uniform updates
  49355. */
  49356. setTexture(name: string, texture: Texture): ProceduralTexture;
  49357. /**
  49358. * Set a float in the shader.
  49359. * @param name Define the name of the uniform as defined in the shader
  49360. * @param value Define the value to give to the uniform
  49361. * @return the texture itself allowing "fluent" like uniform updates
  49362. */
  49363. setFloat(name: string, value: number): ProceduralTexture;
  49364. /**
  49365. * Set a int in the shader.
  49366. * @param name Define the name of the uniform as defined in the shader
  49367. * @param value Define the value to give to the uniform
  49368. * @return the texture itself allowing "fluent" like uniform updates
  49369. */
  49370. setInt(name: string, value: number): ProceduralTexture;
  49371. /**
  49372. * Set an array of floats in the shader.
  49373. * @param name Define the name of the uniform as defined in the shader
  49374. * @param value Define the value to give to the uniform
  49375. * @return the texture itself allowing "fluent" like uniform updates
  49376. */
  49377. setFloats(name: string, value: number[]): ProceduralTexture;
  49378. /**
  49379. * Set a vec3 in the shader from a Color3.
  49380. * @param name Define the name of the uniform as defined in the shader
  49381. * @param value Define the value to give to the uniform
  49382. * @return the texture itself allowing "fluent" like uniform updates
  49383. */
  49384. setColor3(name: string, value: Color3): ProceduralTexture;
  49385. /**
  49386. * Set a vec4 in the shader from a Color4.
  49387. * @param name Define the name of the uniform as defined in the shader
  49388. * @param value Define the value to give to the uniform
  49389. * @return the texture itself allowing "fluent" like uniform updates
  49390. */
  49391. setColor4(name: string, value: Color4): ProceduralTexture;
  49392. /**
  49393. * Set a vec2 in the shader from a Vector2.
  49394. * @param name Define the name of the uniform as defined in the shader
  49395. * @param value Define the value to give to the uniform
  49396. * @return the texture itself allowing "fluent" like uniform updates
  49397. */
  49398. setVector2(name: string, value: Vector2): ProceduralTexture;
  49399. /**
  49400. * Set a vec3 in the shader from a Vector3.
  49401. * @param name Define the name of the uniform as defined in the shader
  49402. * @param value Define the value to give to the uniform
  49403. * @return the texture itself allowing "fluent" like uniform updates
  49404. */
  49405. setVector3(name: string, value: Vector3): ProceduralTexture;
  49406. /**
  49407. * Set a mat4 in the shader from a MAtrix.
  49408. * @param name Define the name of the uniform as defined in the shader
  49409. * @param value Define the value to give to the uniform
  49410. * @return the texture itself allowing "fluent" like uniform updates
  49411. */
  49412. setMatrix(name: string, value: Matrix): ProceduralTexture;
  49413. /**
  49414. * Render the texture to its associated render target.
  49415. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49416. */
  49417. render(useCameraPostProcess?: boolean): void;
  49418. /**
  49419. * Clone the texture.
  49420. * @returns the cloned texture
  49421. */
  49422. clone(): ProceduralTexture;
  49423. /**
  49424. * Dispose the texture and release its asoociated resources.
  49425. */
  49426. dispose(): void;
  49427. }
  49428. }
  49429. declare module BABYLON {
  49430. interface AbstractScene {
  49431. /**
  49432. * The list of procedural textures added to the scene
  49433. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49434. */
  49435. proceduralTextures: Array<ProceduralTexture>;
  49436. }
  49437. /**
  49438. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  49439. * in a given scene.
  49440. */
  49441. class ProceduralTextureSceneComponent implements ISceneComponent {
  49442. /**
  49443. * The component name helpfull to identify the component in the list of scene components.
  49444. */
  49445. readonly name: string;
  49446. /**
  49447. * The scene the component belongs to.
  49448. */
  49449. scene: Scene;
  49450. /**
  49451. * Creates a new instance of the component for the given scene
  49452. * @param scene Defines the scene to register the component in
  49453. */
  49454. constructor(scene: Scene);
  49455. /**
  49456. * Registers the component in a given scene
  49457. */
  49458. register(): void;
  49459. /**
  49460. * Rebuilds the elements related to this component in case of
  49461. * context lost for instance.
  49462. */
  49463. rebuild(): void;
  49464. /**
  49465. * Disposes the component and the associated ressources.
  49466. */
  49467. dispose(): void;
  49468. private _beforeClear;
  49469. }
  49470. }
  49471. declare module BABYLON {
  49472. /**
  49473. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  49474. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49475. */
  49476. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49477. private _scene;
  49478. private _camerasToBeAttached;
  49479. /**
  49480. * ID of the sharpen post process,
  49481. */
  49482. private readonly SharpenPostProcessId;
  49483. /**
  49484. * @ignore
  49485. * ID of the image processing post process;
  49486. */
  49487. readonly ImageProcessingPostProcessId: string;
  49488. /**
  49489. * @ignore
  49490. * ID of the Fast Approximate Anti-Aliasing post process;
  49491. */
  49492. readonly FxaaPostProcessId: string;
  49493. /**
  49494. * ID of the chromatic aberration post process,
  49495. */
  49496. private readonly ChromaticAberrationPostProcessId;
  49497. /**
  49498. * ID of the grain post process
  49499. */
  49500. private readonly GrainPostProcessId;
  49501. /**
  49502. * Sharpen post process which will apply a sharpen convolution to enhance edges
  49503. */
  49504. sharpen: SharpenPostProcess;
  49505. private _sharpenEffect;
  49506. private bloom;
  49507. /**
  49508. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  49509. */
  49510. depthOfField: DepthOfFieldEffect;
  49511. /**
  49512. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  49513. */
  49514. fxaa: FxaaPostProcess;
  49515. /**
  49516. * Image post processing pass used to perform operations such as tone mapping or color grading.
  49517. */
  49518. imageProcessing: ImageProcessingPostProcess;
  49519. /**
  49520. * Chromatic aberration post process which will shift rgb colors in the image
  49521. */
  49522. chromaticAberration: ChromaticAberrationPostProcess;
  49523. private _chromaticAberrationEffect;
  49524. /**
  49525. * Grain post process which add noise to the image
  49526. */
  49527. grain: GrainPostProcess;
  49528. private _grainEffect;
  49529. /**
  49530. * Glow post process which adds a glow to emmisive areas of the image
  49531. */
  49532. private _glowLayer;
  49533. /**
  49534. * Animations which can be used to tweak settings over a period of time
  49535. */
  49536. animations: Animation[];
  49537. private _imageProcessingConfigurationObserver;
  49538. private _sharpenEnabled;
  49539. private _bloomEnabled;
  49540. private _depthOfFieldEnabled;
  49541. private _depthOfFieldBlurLevel;
  49542. private _fxaaEnabled;
  49543. private _imageProcessingEnabled;
  49544. private _defaultPipelineTextureType;
  49545. private _bloomScale;
  49546. private _chromaticAberrationEnabled;
  49547. private _grainEnabled;
  49548. private _buildAllowed;
  49549. /**
  49550. * Enable or disable the sharpen process from the pipeline
  49551. */
  49552. sharpenEnabled: boolean;
  49553. private _resizeObserver;
  49554. private _hardwareScaleLevel;
  49555. private _bloomKernel;
  49556. /**
  49557. * Specifies the size of the bloom blur kernel, relative to the final output size
  49558. */
  49559. bloomKernel: number;
  49560. /**
  49561. * Specifies the weight of the bloom in the final rendering
  49562. */
  49563. private _bloomWeight;
  49564. /**
  49565. * Specifies the luma threshold for the area that will be blurred by the bloom
  49566. */
  49567. private _bloomThreshold;
  49568. private _hdr;
  49569. /**
  49570. * The strength of the bloom.
  49571. */
  49572. bloomWeight: number;
  49573. /**
  49574. * The strength of the bloom.
  49575. */
  49576. bloomThreshold: number;
  49577. /**
  49578. * The scale of the bloom, lower value will provide better performance.
  49579. */
  49580. bloomScale: number;
  49581. /**
  49582. * Enable or disable the bloom from the pipeline
  49583. */
  49584. bloomEnabled: boolean;
  49585. private _rebuildBloom;
  49586. /**
  49587. * If the depth of field is enabled.
  49588. */
  49589. depthOfFieldEnabled: boolean;
  49590. /**
  49591. * Blur level of the depth of field effect. (Higher blur will effect performance)
  49592. */
  49593. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  49594. /**
  49595. * If the anti aliasing is enabled.
  49596. */
  49597. fxaaEnabled: boolean;
  49598. private _samples;
  49599. /**
  49600. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  49601. */
  49602. samples: number;
  49603. /**
  49604. * If image processing is enabled.
  49605. */
  49606. imageProcessingEnabled: boolean;
  49607. /**
  49608. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  49609. */
  49610. glowLayerEnabled: boolean;
  49611. /**
  49612. * Enable or disable the chromaticAberration process from the pipeline
  49613. */
  49614. chromaticAberrationEnabled: boolean;
  49615. /**
  49616. * Enable or disable the grain process from the pipeline
  49617. */
  49618. grainEnabled: boolean;
  49619. /**
  49620. * @constructor
  49621. * @param name - The rendering pipeline name (default: "")
  49622. * @param hdr - If high dynamic range textures should be used (default: true)
  49623. * @param scene - The scene linked to this pipeline (default: the last created scene)
  49624. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  49625. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  49626. */
  49627. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  49628. /**
  49629. * Force the compilation of the entire pipeline.
  49630. */
  49631. prepare(): void;
  49632. private _hasCleared;
  49633. private _prevPostProcess;
  49634. private _prevPrevPostProcess;
  49635. private _setAutoClearAndTextureSharing;
  49636. private _depthOfFieldSceneObserver;
  49637. private _buildPipeline;
  49638. private _disposePostProcesses;
  49639. /**
  49640. * Adds a camera to the pipeline
  49641. * @param camera the camera to be added
  49642. */
  49643. addCamera(camera: Camera): void;
  49644. /**
  49645. * Removes a camera from the pipeline
  49646. * @param camera the camera to remove
  49647. */
  49648. removeCamera(camera: Camera): void;
  49649. /**
  49650. * Dispose of the pipeline and stop all post processes
  49651. */
  49652. dispose(): void;
  49653. /**
  49654. * Serialize the rendering pipeline (Used when exporting)
  49655. * @returns the serialized object
  49656. */
  49657. serialize(): any;
  49658. /**
  49659. * Parse the serialized pipeline
  49660. * @param source Source pipeline.
  49661. * @param scene The scene to load the pipeline to.
  49662. * @param rootUrl The URL of the serialized pipeline.
  49663. * @returns An instantiated pipeline from the serialized object.
  49664. */
  49665. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  49666. }
  49667. }
  49668. declare module BABYLON {
  49669. /**
  49670. * BABYLON.JS Chromatic Aberration GLSL Shader
  49671. * Author: Olivier Guyot
  49672. * Separates very slightly R, G and B colors on the edges of the screen
  49673. * Inspired by Francois Tarlier & Martins Upitis
  49674. */
  49675. class LensRenderingPipeline extends PostProcessRenderPipeline {
  49676. /**
  49677. * @ignore
  49678. * The chromatic aberration PostProcess id in the pipeline
  49679. */
  49680. LensChromaticAberrationEffect: string;
  49681. /**
  49682. * @ignore
  49683. * The highlights enhancing PostProcess id in the pipeline
  49684. */
  49685. HighlightsEnhancingEffect: string;
  49686. /**
  49687. * @ignore
  49688. * The depth-of-field PostProcess id in the pipeline
  49689. */
  49690. LensDepthOfFieldEffect: string;
  49691. private _scene;
  49692. private _depthTexture;
  49693. private _grainTexture;
  49694. private _chromaticAberrationPostProcess;
  49695. private _highlightsPostProcess;
  49696. private _depthOfFieldPostProcess;
  49697. private _edgeBlur;
  49698. private _grainAmount;
  49699. private _chromaticAberration;
  49700. private _distortion;
  49701. private _highlightsGain;
  49702. private _highlightsThreshold;
  49703. private _dofDistance;
  49704. private _dofAperture;
  49705. private _dofDarken;
  49706. private _dofPentagon;
  49707. private _blurNoise;
  49708. /**
  49709. * @constructor
  49710. *
  49711. * Effect parameters are as follow:
  49712. * {
  49713. * chromatic_aberration: number; // from 0 to x (1 for realism)
  49714. * edge_blur: number; // from 0 to x (1 for realism)
  49715. * distortion: number; // from 0 to x (1 for realism)
  49716. * grain_amount: number; // from 0 to 1
  49717. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  49718. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  49719. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  49720. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  49721. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  49722. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  49723. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  49724. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  49725. * }
  49726. * Note: if an effect parameter is unset, effect is disabled
  49727. *
  49728. * @param name The rendering pipeline name
  49729. * @param parameters - An object containing all parameters (see above)
  49730. * @param scene The scene linked to this pipeline
  49731. * @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)
  49732. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49733. */
  49734. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  49735. /**
  49736. * Sets the amount of blur at the edges
  49737. * @param amount blur amount
  49738. */
  49739. setEdgeBlur(amount: number): void;
  49740. /**
  49741. * Sets edge blur to 0
  49742. */
  49743. disableEdgeBlur(): void;
  49744. /**
  49745. * Sets the amout of grain
  49746. * @param amount Amount of grain
  49747. */
  49748. setGrainAmount(amount: number): void;
  49749. /**
  49750. * Set grain amount to 0
  49751. */
  49752. disableGrain(): void;
  49753. /**
  49754. * Sets the chromatic aberration amount
  49755. * @param amount amount of chromatic aberration
  49756. */
  49757. setChromaticAberration(amount: number): void;
  49758. /**
  49759. * Sets chromatic aberration amount to 0
  49760. */
  49761. disableChromaticAberration(): void;
  49762. /**
  49763. * Sets the EdgeDistortion amount
  49764. * @param amount amount of EdgeDistortion
  49765. */
  49766. setEdgeDistortion(amount: number): void;
  49767. /**
  49768. * Sets edge distortion to 0
  49769. */
  49770. disableEdgeDistortion(): void;
  49771. /**
  49772. * Sets the FocusDistance amount
  49773. * @param amount amount of FocusDistance
  49774. */
  49775. setFocusDistance(amount: number): void;
  49776. /**
  49777. * Disables depth of field
  49778. */
  49779. disableDepthOfField(): void;
  49780. /**
  49781. * Sets the Aperture amount
  49782. * @param amount amount of Aperture
  49783. */
  49784. setAperture(amount: number): void;
  49785. /**
  49786. * Sets the DarkenOutOfFocus amount
  49787. * @param amount amount of DarkenOutOfFocus
  49788. */
  49789. setDarkenOutOfFocus(amount: number): void;
  49790. /**
  49791. * Creates a pentagon bokeh effect
  49792. */
  49793. enablePentagonBokeh(): void;
  49794. /**
  49795. * Disables the pentagon bokeh effect
  49796. */
  49797. disablePentagonBokeh(): void;
  49798. /**
  49799. * Enables noise blur
  49800. */
  49801. enableNoiseBlur(): void;
  49802. /**
  49803. * Disables noise blur
  49804. */
  49805. disableNoiseBlur(): void;
  49806. /**
  49807. * Sets the HighlightsGain amount
  49808. * @param amount amount of HighlightsGain
  49809. */
  49810. setHighlightsGain(amount: number): void;
  49811. /**
  49812. * Sets the HighlightsThreshold amount
  49813. * @param amount amount of HighlightsThreshold
  49814. */
  49815. setHighlightsThreshold(amount: number): void;
  49816. /**
  49817. * Disables highlights
  49818. */
  49819. disableHighlights(): void;
  49820. /**
  49821. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  49822. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  49823. */
  49824. dispose(disableDepthRender?: boolean): void;
  49825. private _createChromaticAberrationPostProcess;
  49826. private _createHighlightsPostProcess;
  49827. private _createDepthOfFieldPostProcess;
  49828. private _createGrainTexture;
  49829. }
  49830. }
  49831. declare module BABYLON {
  49832. /**
  49833. * Render pipeline to produce ssao effect
  49834. */
  49835. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  49836. /**
  49837. * @ignore
  49838. * The PassPostProcess id in the pipeline that contains the original scene color
  49839. */
  49840. SSAOOriginalSceneColorEffect: string;
  49841. /**
  49842. * @ignore
  49843. * The SSAO PostProcess id in the pipeline
  49844. */
  49845. SSAORenderEffect: string;
  49846. /**
  49847. * @ignore
  49848. * The horizontal blur PostProcess id in the pipeline
  49849. */
  49850. SSAOBlurHRenderEffect: string;
  49851. /**
  49852. * @ignore
  49853. * The vertical blur PostProcess id in the pipeline
  49854. */
  49855. SSAOBlurVRenderEffect: string;
  49856. /**
  49857. * @ignore
  49858. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  49859. */
  49860. SSAOCombineRenderEffect: string;
  49861. /**
  49862. * The output strength of the SSAO post-process. Default value is 1.0.
  49863. */
  49864. totalStrength: number;
  49865. /**
  49866. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  49867. */
  49868. maxZ: number;
  49869. /**
  49870. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  49871. */
  49872. minZAspect: number;
  49873. private _samples;
  49874. /**
  49875. * Number of samples used for the SSAO calculations. Default value is 8
  49876. */
  49877. samples: number;
  49878. private _textureSamples;
  49879. /**
  49880. * Number of samples to use for antialiasing
  49881. */
  49882. textureSamples: number;
  49883. /**
  49884. * Ratio object used for SSAO ratio and blur ratio
  49885. */
  49886. private _ratio;
  49887. /**
  49888. * Dynamically generated sphere sampler.
  49889. */
  49890. private _sampleSphere;
  49891. /**
  49892. * Blur filter offsets
  49893. */
  49894. private _samplerOffsets;
  49895. private _expensiveBlur;
  49896. /**
  49897. * If bilateral blur should be used
  49898. */
  49899. expensiveBlur: boolean;
  49900. /**
  49901. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  49902. */
  49903. radius: number;
  49904. /**
  49905. * The base color of the SSAO post-process
  49906. * The final result is "base + ssao" between [0, 1]
  49907. */
  49908. base: number;
  49909. /**
  49910. * Support test.
  49911. */
  49912. static readonly IsSupported: boolean;
  49913. private _scene;
  49914. private _depthTexture;
  49915. private _normalTexture;
  49916. private _randomTexture;
  49917. private _originalColorPostProcess;
  49918. private _ssaoPostProcess;
  49919. private _blurHPostProcess;
  49920. private _blurVPostProcess;
  49921. private _ssaoCombinePostProcess;
  49922. private _firstUpdate;
  49923. /**
  49924. * @constructor
  49925. * @param name The rendering pipeline name
  49926. * @param scene The scene linked to this pipeline
  49927. * @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 }
  49928. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49929. */
  49930. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  49931. /**
  49932. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  49933. */
  49934. dispose(disableGeometryBufferRenderer?: boolean): void;
  49935. private _createBlurPostProcess;
  49936. /** @hidden */
  49937. _rebuild(): void;
  49938. private _bits;
  49939. private _radicalInverse_VdC;
  49940. private _hammersley;
  49941. private _hemisphereSample_uniform;
  49942. private _generateHemisphere;
  49943. private _createSSAOPostProcess;
  49944. private _createSSAOCombinePostProcess;
  49945. private _createRandomTexture;
  49946. /**
  49947. * Serialize the rendering pipeline (Used when exporting)
  49948. * @returns the serialized object
  49949. */
  49950. serialize(): any;
  49951. /**
  49952. * Parse the serialized pipeline
  49953. * @param source Source pipeline.
  49954. * @param scene The scene to load the pipeline to.
  49955. * @param rootUrl The URL of the serialized pipeline.
  49956. * @returns An instantiated pipeline from the serialized object.
  49957. */
  49958. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  49959. }
  49960. }
  49961. declare module BABYLON {
  49962. /**
  49963. * Render pipeline to produce ssao effect
  49964. */
  49965. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  49966. /**
  49967. * @ignore
  49968. * The PassPostProcess id in the pipeline that contains the original scene color
  49969. */
  49970. SSAOOriginalSceneColorEffect: string;
  49971. /**
  49972. * @ignore
  49973. * The SSAO PostProcess id in the pipeline
  49974. */
  49975. SSAORenderEffect: string;
  49976. /**
  49977. * @ignore
  49978. * The horizontal blur PostProcess id in the pipeline
  49979. */
  49980. SSAOBlurHRenderEffect: string;
  49981. /**
  49982. * @ignore
  49983. * The vertical blur PostProcess id in the pipeline
  49984. */
  49985. SSAOBlurVRenderEffect: string;
  49986. /**
  49987. * @ignore
  49988. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  49989. */
  49990. SSAOCombineRenderEffect: string;
  49991. /**
  49992. * The output strength of the SSAO post-process. Default value is 1.0.
  49993. */
  49994. totalStrength: number;
  49995. /**
  49996. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  49997. */
  49998. radius: number;
  49999. /**
  50000. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50001. * Must not be equal to fallOff and superior to fallOff.
  50002. * Default value is 0.975
  50003. */
  50004. area: number;
  50005. /**
  50006. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50007. * Must not be equal to area and inferior to area.
  50008. * Default value is 0.0
  50009. */
  50010. fallOff: number;
  50011. /**
  50012. * The base color of the SSAO post-process
  50013. * The final result is "base + ssao" between [0, 1]
  50014. */
  50015. base: number;
  50016. private _scene;
  50017. private _depthTexture;
  50018. private _randomTexture;
  50019. private _originalColorPostProcess;
  50020. private _ssaoPostProcess;
  50021. private _blurHPostProcess;
  50022. private _blurVPostProcess;
  50023. private _ssaoCombinePostProcess;
  50024. private _firstUpdate;
  50025. /**
  50026. * @constructor
  50027. * @param name - The rendering pipeline name
  50028. * @param scene - The scene linked to this pipeline
  50029. * @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 }
  50030. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50031. */
  50032. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50033. /**
  50034. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50035. */
  50036. dispose(disableDepthRender?: boolean): void;
  50037. private _createBlurPostProcess;
  50038. /** @hidden */
  50039. _rebuild(): void;
  50040. private _createSSAOPostProcess;
  50041. private _createSSAOCombinePostProcess;
  50042. private _createRandomTexture;
  50043. }
  50044. }
  50045. declare module BABYLON {
  50046. /**
  50047. * Standard rendering pipeline
  50048. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50049. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  50050. */
  50051. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50052. /**
  50053. * Public members
  50054. */
  50055. /**
  50056. * Post-process which contains the original scene color before the pipeline applies all the effects
  50057. */
  50058. originalPostProcess: Nullable<PostProcess>;
  50059. /**
  50060. * Post-process used to down scale an image x4
  50061. */
  50062. downSampleX4PostProcess: Nullable<PostProcess>;
  50063. /**
  50064. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  50065. */
  50066. brightPassPostProcess: Nullable<PostProcess>;
  50067. /**
  50068. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  50069. */
  50070. blurHPostProcesses: PostProcess[];
  50071. /**
  50072. * Post-process array storing all the vertical blur post-processes used by the pipeline
  50073. */
  50074. blurVPostProcesses: PostProcess[];
  50075. /**
  50076. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  50077. */
  50078. textureAdderPostProcess: Nullable<PostProcess>;
  50079. /**
  50080. * Post-process used to create volumetric lighting effect
  50081. */
  50082. volumetricLightPostProcess: Nullable<PostProcess>;
  50083. /**
  50084. * Post-process used to smooth the previous volumetric light post-process on the X axis
  50085. */
  50086. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  50087. /**
  50088. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  50089. */
  50090. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  50091. /**
  50092. * Post-process used to merge the volumetric light effect and the real scene color
  50093. */
  50094. volumetricLightMergePostProces: Nullable<PostProcess>;
  50095. /**
  50096. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  50097. */
  50098. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  50099. /**
  50100. * Base post-process used to calculate the average luminance of the final image for HDR
  50101. */
  50102. luminancePostProcess: Nullable<PostProcess>;
  50103. /**
  50104. * Post-processes used to create down sample post-processes in order to get
  50105. * the average luminance of the final image for HDR
  50106. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  50107. */
  50108. luminanceDownSamplePostProcesses: PostProcess[];
  50109. /**
  50110. * Post-process used to create a HDR effect (light adaptation)
  50111. */
  50112. hdrPostProcess: Nullable<PostProcess>;
  50113. /**
  50114. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  50115. */
  50116. textureAdderFinalPostProcess: Nullable<PostProcess>;
  50117. /**
  50118. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  50119. */
  50120. lensFlareFinalPostProcess: Nullable<PostProcess>;
  50121. /**
  50122. * Post-process used to merge the final HDR post-process and the real scene color
  50123. */
  50124. hdrFinalPostProcess: Nullable<PostProcess>;
  50125. /**
  50126. * Post-process used to create a lens flare effect
  50127. */
  50128. lensFlarePostProcess: Nullable<PostProcess>;
  50129. /**
  50130. * Post-process that merges the result of the lens flare post-process and the real scene color
  50131. */
  50132. lensFlareComposePostProcess: Nullable<PostProcess>;
  50133. /**
  50134. * Post-process used to create a motion blur effect
  50135. */
  50136. motionBlurPostProcess: Nullable<PostProcess>;
  50137. /**
  50138. * Post-process used to create a depth of field effect
  50139. */
  50140. depthOfFieldPostProcess: Nullable<PostProcess>;
  50141. /**
  50142. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50143. */
  50144. fxaaPostProcess: Nullable<FxaaPostProcess>;
  50145. /**
  50146. * Represents the brightness threshold in order to configure the illuminated surfaces
  50147. */
  50148. brightThreshold: number;
  50149. /**
  50150. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  50151. */
  50152. blurWidth: number;
  50153. /**
  50154. * Sets if the blur for highlighted surfaces must be only horizontal
  50155. */
  50156. horizontalBlur: boolean;
  50157. /**
  50158. * Sets the overall exposure used by the pipeline
  50159. */
  50160. exposure: number;
  50161. /**
  50162. * Texture used typically to simulate "dirty" on camera lens
  50163. */
  50164. lensTexture: Nullable<Texture>;
  50165. /**
  50166. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  50167. */
  50168. volumetricLightCoefficient: number;
  50169. /**
  50170. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  50171. */
  50172. volumetricLightPower: number;
  50173. /**
  50174. * Used the set the blur intensity to smooth the volumetric lights
  50175. */
  50176. volumetricLightBlurScale: number;
  50177. /**
  50178. * Light (spot or directional) used to generate the volumetric lights rays
  50179. * The source light must have a shadow generate so the pipeline can get its
  50180. * depth map
  50181. */
  50182. sourceLight: Nullable<SpotLight | DirectionalLight>;
  50183. /**
  50184. * For eye adaptation, represents the minimum luminance the eye can see
  50185. */
  50186. hdrMinimumLuminance: number;
  50187. /**
  50188. * For eye adaptation, represents the decrease luminance speed
  50189. */
  50190. hdrDecreaseRate: number;
  50191. /**
  50192. * For eye adaptation, represents the increase luminance speed
  50193. */
  50194. hdrIncreaseRate: number;
  50195. /**
  50196. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  50197. */
  50198. lensColorTexture: Nullable<Texture>;
  50199. /**
  50200. * The overall strengh for the lens flare effect
  50201. */
  50202. lensFlareStrength: number;
  50203. /**
  50204. * Dispersion coefficient for lens flare ghosts
  50205. */
  50206. lensFlareGhostDispersal: number;
  50207. /**
  50208. * Main lens flare halo width
  50209. */
  50210. lensFlareHaloWidth: number;
  50211. /**
  50212. * Based on the lens distortion effect, defines how much the lens flare result
  50213. * is distorted
  50214. */
  50215. lensFlareDistortionStrength: number;
  50216. /**
  50217. * Lens star texture must be used to simulate rays on the flares and is available
  50218. * in the documentation
  50219. */
  50220. lensStarTexture: Nullable<Texture>;
  50221. /**
  50222. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  50223. * flare effect by taking account of the dirt texture
  50224. */
  50225. lensFlareDirtTexture: Nullable<Texture>;
  50226. /**
  50227. * Represents the focal length for the depth of field effect
  50228. */
  50229. depthOfFieldDistance: number;
  50230. /**
  50231. * Represents the blur intensity for the blurred part of the depth of field effect
  50232. */
  50233. depthOfFieldBlurWidth: number;
  50234. /**
  50235. * For motion blur, defines how much the image is blurred by the movement
  50236. */
  50237. motionStrength: number;
  50238. /**
  50239. * List of animations for the pipeline (IAnimatable implementation)
  50240. */
  50241. animations: Animation[];
  50242. /**
  50243. * Private members
  50244. */
  50245. private _scene;
  50246. private _currentDepthOfFieldSource;
  50247. private _basePostProcess;
  50248. private _hdrCurrentLuminance;
  50249. private _floatTextureType;
  50250. private _ratio;
  50251. private _bloomEnabled;
  50252. private _depthOfFieldEnabled;
  50253. private _vlsEnabled;
  50254. private _lensFlareEnabled;
  50255. private _hdrEnabled;
  50256. private _motionBlurEnabled;
  50257. private _fxaaEnabled;
  50258. private _motionBlurSamples;
  50259. private _volumetricLightStepsCount;
  50260. private _samples;
  50261. /**
  50262. * @ignore
  50263. * Specifies if the bloom pipeline is enabled
  50264. */
  50265. BloomEnabled: boolean;
  50266. /**
  50267. * @ignore
  50268. * Specifies if the depth of field pipeline is enabed
  50269. */
  50270. DepthOfFieldEnabled: boolean;
  50271. /**
  50272. * @ignore
  50273. * Specifies if the lens flare pipeline is enabed
  50274. */
  50275. LensFlareEnabled: boolean;
  50276. /**
  50277. * @ignore
  50278. * Specifies if the HDR pipeline is enabled
  50279. */
  50280. HDREnabled: boolean;
  50281. /**
  50282. * @ignore
  50283. * Specifies if the volumetric lights scattering effect is enabled
  50284. */
  50285. VLSEnabled: boolean;
  50286. /**
  50287. * @ignore
  50288. * Specifies if the motion blur effect is enabled
  50289. */
  50290. MotionBlurEnabled: boolean;
  50291. /**
  50292. * Specifies if anti-aliasing is enabled
  50293. */
  50294. fxaaEnabled: boolean;
  50295. /**
  50296. * Specifies the number of steps used to calculate the volumetric lights
  50297. * Typically in interval [50, 200]
  50298. */
  50299. volumetricLightStepsCount: number;
  50300. /**
  50301. * Specifies the number of samples used for the motion blur effect
  50302. * Typically in interval [16, 64]
  50303. */
  50304. motionBlurSamples: number;
  50305. /**
  50306. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50307. */
  50308. samples: number;
  50309. /**
  50310. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50311. * @constructor
  50312. * @param name The rendering pipeline name
  50313. * @param scene The scene linked to this pipeline
  50314. * @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)
  50315. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  50316. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50317. */
  50318. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  50319. private _buildPipeline;
  50320. private _createDownSampleX4PostProcess;
  50321. private _createBrightPassPostProcess;
  50322. private _createBlurPostProcesses;
  50323. private _createTextureAdderPostProcess;
  50324. private _createVolumetricLightPostProcess;
  50325. private _createLuminancePostProcesses;
  50326. private _createHdrPostProcess;
  50327. private _createLensFlarePostProcess;
  50328. private _createDepthOfFieldPostProcess;
  50329. private _createMotionBlurPostProcess;
  50330. private _getDepthTexture;
  50331. private _disposePostProcesses;
  50332. /**
  50333. * Dispose of the pipeline and stop all post processes
  50334. */
  50335. dispose(): void;
  50336. /**
  50337. * Serialize the rendering pipeline (Used when exporting)
  50338. * @returns the serialized object
  50339. */
  50340. serialize(): any;
  50341. /**
  50342. * Parse the serialized pipeline
  50343. * @param source Source pipeline.
  50344. * @param scene The scene to load the pipeline to.
  50345. * @param rootUrl The URL of the serialized pipeline.
  50346. * @returns An instantiated pipeline from the serialized object.
  50347. */
  50348. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  50349. /**
  50350. * Luminance steps
  50351. */
  50352. static LuminanceSteps: number;
  50353. }
  50354. }